Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: bfd/elf32-lm32.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bfd/elf32-iq2000.c ('k') | bfd/elf32-m32c.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Lattice Mico32-specific support for 32-bit ELF 1 /* Lattice Mico32-specific support for 32-bit ELF
2 Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 2 Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
3 Contributed by Jon Beniston <jon@beniston.com> 3 Contributed by Jon Beniston <jon@beniston.com>
4 4
5 This file is part of BFD, the Binary File Descriptor library. 5 This file is part of BFD, the Binary File Descriptor library.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or 9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */ 20 MA 02110-1301, USA. */
21 21
22 #include "sysdep.h"
22 #include "bfd.h" 23 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libbfd.h" 24 #include "libbfd.h"
25 #include "elf-bfd.h" 25 #include "elf-bfd.h"
26 #include "elf/lm32.h" 26 #include "elf/lm32.h"
27 27
28 #define DEFAULT_STACK_SIZE 0x20000 28 #define DEFAULT_STACK_SIZE 0x20000
29 29
30 #define PLT_ENTRY_SIZE 20 30 #define PLT_ENTRY_SIZE 20
31 31
32 #define PLT0_ENTRY_WORD0 0 32 #define PLT0_ENTRY_WORD0 0
33 #define PLT0_ENTRY_WORD1 0 33 #define PLT0_ENTRY_WORD1 0
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up 210 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
211 shortcuts to them in our hash table. */ 211 shortcuts to them in our hash table. */
212 212
213 static bfd_boolean 213 static bfd_boolean
214 create_got_section (bfd *dynobj, struct bfd_link_info *info) 214 create_got_section (bfd *dynobj, struct bfd_link_info *info)
215 { 215 {
216 struct elf_lm32_link_hash_table *htab; 216 struct elf_lm32_link_hash_table *htab;
217 asection *s; 217 asection *s;
218 218
219 /* This function may be called more than once. */ 219 /* This function may be called more than once. */
220 s = bfd_get_section_by_name (dynobj, ".got"); 220 s = bfd_get_linker_section (dynobj, ".got");
221 if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0) 221 if (s != NULL)
222 return TRUE; 222 return TRUE;
223 223
224 htab = lm32_elf_hash_table (info); 224 htab = lm32_elf_hash_table (info);
225 if (htab == NULL) 225 if (htab == NULL)
226 return FALSE; 226 return FALSE;
227 227
228 if (! _bfd_elf_create_got_section (dynobj, info)) 228 if (! _bfd_elf_create_got_section (dynobj, info))
229 return FALSE; 229 return FALSE;
230 230
231 htab->sgot = bfd_get_section_by_name (dynobj, ".got"); 231 htab->sgot = bfd_get_linker_section (dynobj, ".got");
232 htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); 232 htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
233 htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); 233 htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
234 if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot) 234 if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
235 abort (); 235 abort ();
236 236
237 return TRUE; 237 return TRUE;
238 } 238 }
239 239
240 /* Create .rofixup sections in DYNOBJ, and set up 240 /* Create .rofixup sections in DYNOBJ, and set up
241 shortcuts to them in our hash table. */ 241 shortcuts to them in our hash table. */
242 242
243 static bfd_boolean 243 static bfd_boolean
244 create_rofixup_section (bfd *dynobj, struct bfd_link_info *info) 244 create_rofixup_section (bfd *dynobj, struct bfd_link_info *info)
245 { 245 {
246 struct elf_lm32_link_hash_table *htab; 246 struct elf_lm32_link_hash_table *htab;
247 htab = lm32_elf_hash_table (info); 247 htab = lm32_elf_hash_table (info);
248 248
249 if (htab == NULL) 249 if (htab == NULL)
250 return FALSE; 250 return FALSE;
251 251
252 /* Fixup section for R_LM32_32 relocs. */ 252 /* Fixup section for R_LM32_32 relocs. */
253 lm32fdpic_fixup32_section (info) = bfd_make_section_with_flags (dynobj, 253 lm32fdpic_fixup32_section (info)
254 ".rofixup", 254 = bfd_make_section_anyway_with_flags (dynobj,
255 » » » » (SEC_ALLOC 255 » » » » » ".rofixup",
256 | SEC_LOAD 256 » » » » » (SEC_ALLOC
257 | SEC_HAS_CON TENTS 257 » » » » » | SEC_LOAD
258 | SEC_IN_MEMO RY 258 » » » » » | SEC_HAS_CONTENTS
259 » | SEC_LINKER_ CREATED 259 » » » » » | SEC_IN_MEMORY
260 | SEC_READONL Y)); 260 » » » » » | SEC_LINKER_CREATED
261 » » » » » | SEC_READONLY));
261 if (lm32fdpic_fixup32_section (info) == NULL 262 if (lm32fdpic_fixup32_section (info) == NULL
262 || ! bfd_set_section_alignment (dynobj, lm32fdpic_fixup32_section (info), 2)) 263 || ! bfd_set_section_alignment (dynobj,
264 » » » » lm32fdpic_fixup32_section (info), 2))
263 return FALSE; 265 return FALSE;
264 266
265 return TRUE; 267 return TRUE;
266 } 268 }
267 269
268 static reloc_howto_type lm32_elf_howto_table [] = 270 static reloc_howto_type lm32_elf_howto_table [] =
269 { 271 {
270 /* This reloc does nothing. */ 272 /* This reloc does nothing. */
271 HOWTO (R_LM32_NONE, /* type */ 273 HOWTO (R_LM32_NONE, /* type */
272 0, /* rightshift */ 274 0, /* rightshift */
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 bfd_boolean unresolved_reloc; 888 bfd_boolean unresolved_reloc;
887 bfd_boolean warned; 889 bfd_boolean warned;
888 890
889 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, 891 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
890 r_symndx, symtab_hdr, sym_hashes, 892 r_symndx, symtab_hdr, sym_hashes,
891 h, sec, relocation, 893 h, sec, relocation,
892 unresolved_reloc, warned); 894 unresolved_reloc, warned);
893 name = h->root.root.string; 895 name = h->root.root.string;
894 } 896 }
895 897
896 if (sec != NULL && elf_discarded_section (sec)) 898 if (sec != NULL && discarded_section (sec))
897 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, 899 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
898 » » » » » rel, relend, howto, contents); 900 » » » » » rel, 1, relend, howto, 0, contents);
899 901
900 if (info->relocatable) 902 if (info->relocatable)
901 { 903 {
902 /* This is a relocatable link. We don't have to change 904 /* This is a relocatable link. We don't have to change
903 anything, unless the reloc is against a section symbol, 905 anything, unless the reloc is against a section symbol,
904 in which case we have to adjust according to where the 906 in which case we have to adjust according to where the
905 section symbol winds up in the output section. */ 907 section symbol winds up in the output section. */
906 if (sym == NULL || ELF_ST_TYPE (sym->st_info) != STT_SECTION) 908 if (sym == NULL || ELF_ST_TYPE (sym->st_info) != STT_SECTION)
907 continue; 909 continue;
908 910
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 + off); 1026 + off);
1025 } 1027 }
1026 1028
1027 if (info->shared) 1029 if (info->shared)
1028 { 1030 {
1029 asection *srelgot; 1031 asection *srelgot;
1030 Elf_Internal_Rela outrel; 1032 Elf_Internal_Rela outrel;
1031 1033
1032 /* We need to generate a R_LM32_RELATIVE reloc 1034 /* We need to generate a R_LM32_RELATIVE reloc
1033 for the dynamic linker. */ 1035 for the dynamic linker. */
1034 srelgot = bfd_get_section_by_name (dynobj, ".rela.got" ); 1036 srelgot = bfd_get_linker_section (dynobj,
1037 » » » » » » » ".rela.got");
1035 BFD_ASSERT (srelgot != NULL); 1038 BFD_ASSERT (srelgot != NULL);
1036 1039
1037 outrel.r_offset = (sgot->output_section->vma 1040 outrel.r_offset = (sgot->output_section->vma
1038 + sgot->output_offset 1041 + sgot->output_offset
1039 + off); 1042 + off);
1040 outrel.r_info = ELF32_R_INFO (0, R_LM32_RELATIVE); 1043 outrel.r_info = ELF32_R_INFO (0, R_LM32_RELATIVE);
1041 outrel.r_addend = relocation; 1044 outrel.r_addend = relocation;
1042 loc = srelgot->contents; 1045 loc = srelgot->contents;
1043 loc += srelgot->reloc_count * sizeof (Elf32_External_R ela); 1046 loc += srelgot->reloc_count * sizeof (Elf32_External_R ela);
1044 bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc); 1047 bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 case R_LM32_32: 1342 case R_LM32_32:
1340 /* FDPIC requires a GOT if there is a .rofixup section 1343 /* FDPIC requires a GOT if there is a .rofixup section
1341 (Normal ELF doesn't). */ 1344 (Normal ELF doesn't). */
1342 if (dynobj == NULL) 1345 if (dynobj == NULL)
1343 htab->root.dynobj = dynobj = abfd; 1346 htab->root.dynobj = dynobj = abfd;
1344 if (! create_got_section (dynobj, info)) 1347 if (! create_got_section (dynobj, info))
1345 return FALSE; 1348 return FALSE;
1346 /* Create .rofixup section */ 1349 /* Create .rofixup section */
1347 if (htab->sfixup32 == NULL) 1350 if (htab->sfixup32 == NULL)
1348 { 1351 {
1349 if (! create_rofixup_section (abfd, info)) 1352 if (! create_rofixup_section (dynobj, info))
1350 return FALSE; 1353 return FALSE;
1351 } 1354 }
1352 break; 1355 break;
1353 case R_LM32_16_GOT: 1356 case R_LM32_16_GOT:
1354 case R_LM32_GOTOFF_HI16: 1357 case R_LM32_GOTOFF_HI16:
1355 case R_LM32_GOTOFF_LO16: 1358 case R_LM32_GOTOFF_LO16:
1356 /* Create .rofixup section. */ 1359 /* Create .rofixup section. */
1357 if (htab->sfixup32 == NULL) 1360 if (htab->sfixup32 == NULL)
1358 { 1361 {
1359 if (! create_rofixup_section (abfd, info)) 1362 » » if (dynobj == NULL)
1363 » » htab->root.dynobj = dynobj = abfd;
1364 if (! create_rofixup_section (dynobj, info))
1360 return FALSE; 1365 return FALSE;
1361 } 1366 }
1362 break; 1367 break;
1363 } 1368 }
1364 } 1369 }
1365 1370
1366 switch (r_type) 1371 switch (r_type)
1367 { 1372 {
1368 case R_LM32_16_GOT: 1373 case R_LM32_16_GOT:
1369 if (h != NULL) 1374 if (h != NULL)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 asection *sdyn; 1425 asection *sdyn;
1421 asection *sgot; 1426 asection *sgot;
1422 1427
1423 htab = lm32_elf_hash_table (info); 1428 htab = lm32_elf_hash_table (info);
1424 if (htab == NULL) 1429 if (htab == NULL)
1425 return FALSE; 1430 return FALSE;
1426 1431
1427 dynobj = htab->root.dynobj; 1432 dynobj = htab->root.dynobj;
1428 1433
1429 sgot = htab->sgotplt; 1434 sgot = htab->sgotplt;
1430 sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); 1435 sdyn = bfd_get_linker_section (dynobj, ".dynamic");
1431 1436
1432 if (htab->root.dynamic_sections_created) 1437 if (htab->root.dynamic_sections_created)
1433 { 1438 {
1434 asection *splt; 1439 asection *splt;
1435 Elf32_External_Dyn *dyncon, *dynconend; 1440 Elf32_External_Dyn *dyncon, *dynconend;
1436 1441
1437 BFD_ASSERT (sgot != NULL && sdyn != NULL); 1442 BFD_ASSERT (sgot != NULL && sdyn != NULL);
1438 1443
1439 dyncon = (Elf32_External_Dyn *) sdyn->contents; 1444 dyncon = (Elf32_External_Dyn *) sdyn->contents;
1440 dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); 1445 dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 if (h->needs_copy) 1723 if (h->needs_copy)
1719 { 1724 {
1720 asection *s; 1725 asection *s;
1721 Elf_Internal_Rela rela; 1726 Elf_Internal_Rela rela;
1722 1727
1723 /* This symbols needs a copy reloc. Set it up. */ 1728 /* This symbols needs a copy reloc. Set it up. */
1724 BFD_ASSERT (h->dynindx != -1 1729 BFD_ASSERT (h->dynindx != -1
1725 && (h->root.type == bfd_link_hash_defined 1730 && (h->root.type == bfd_link_hash_defined
1726 || h->root.type == bfd_link_hash_defweak)); 1731 || h->root.type == bfd_link_hash_defweak));
1727 1732
1728 s = bfd_get_section_by_name (h->root.u.def.section->owner, 1733 s = bfd_get_linker_section (htab->root.dynobj, ".rela.bss");
1729 ".rela.bss");
1730 BFD_ASSERT (s != NULL); 1734 BFD_ASSERT (s != NULL);
1731 1735
1732 rela.r_offset = (h->root.u.def.value 1736 rela.r_offset = (h->root.u.def.value
1733 + h->root.u.def.section->output_section->vma 1737 + h->root.u.def.section->output_section->vma
1734 + h->root.u.def.section->output_offset); 1738 + h->root.u.def.section->output_offset);
1735 rela.r_info = ELF32_R_INFO (h->dynindx, R_LM32_COPY); 1739 rela.r_info = ELF32_R_INFO (h->dynindx, R_LM32_COPY);
1736 rela.r_addend = 0; 1740 rela.r_addend = 0;
1737 loc = s->contents; 1741 loc = s->contents;
1738 loc += s->reloc_count * sizeof (Elf32_External_Rela); 1742 loc += s->reloc_count * sizeof (Elf32_External_Rela);
1739 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); 1743 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 1860
1857 /* If we didn't find any dynamic relocs in sections which needs the 1861 /* If we didn't find any dynamic relocs in sections which needs the
1858 copy reloc, then we'll be keeping the dynamic relocs and avoiding 1862 copy reloc, then we'll be keeping the dynamic relocs and avoiding
1859 the copy reloc. */ 1863 the copy reloc. */
1860 if (p == NULL) 1864 if (p == NULL)
1861 { 1865 {
1862 h->non_got_ref = 0; 1866 h->non_got_ref = 0;
1863 return TRUE; 1867 return TRUE;
1864 } 1868 }
1865 1869
1866 if (h->size == 0)
1867 {
1868 (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
1869 h->root.root.string);
1870 return TRUE;
1871 }
1872
1873 /* We must allocate the symbol in our .dynbss section, which will 1870 /* We must allocate the symbol in our .dynbss section, which will
1874 become part of the .bss section of the executable. There will be 1871 become part of the .bss section of the executable. There will be
1875 an entry for this symbol in the .dynsym section. The dynamic 1872 an entry for this symbol in the .dynsym section. The dynamic
1876 object will contain position independent code, so all references 1873 object will contain position independent code, so all references
1877 from the dynamic object to this symbol will go through the global 1874 from the dynamic object to this symbol will go through the global
1878 offset table. The dynamic linker will use the .dynsym entry to 1875 offset table. The dynamic linker will use the .dynsym entry to
1879 determine the address it must put in the global offset table, so 1876 determine the address it must put in the global offset table, so
1880 both the dynamic object and the regular object will refer to the 1877 both the dynamic object and the regular object will refer to the
1881 same memory location for the variable. */ 1878 same memory location for the variable. */
1882 1879
1883 htab = lm32_elf_hash_table (info); 1880 htab = lm32_elf_hash_table (info);
1884 if (htab == NULL) 1881 if (htab == NULL)
1885 return FALSE; 1882 return FALSE;
1886 1883
1887 s = htab->sdynbss; 1884 s = htab->sdynbss;
1888 BFD_ASSERT (s != NULL); 1885 BFD_ASSERT (s != NULL);
1889 1886
1890 /* We must generate a R_LM32_COPY reloc to tell the dynamic linker 1887 /* We must generate a R_LM32_COPY reloc to tell the dynamic linker
1891 to copy the initial value out of the dynamic object and into the 1888 to copy the initial value out of the dynamic object and into the
1892 runtime process image. We need to remember the offset into the 1889 runtime process image. We need to remember the offset into the
1893 .rela.bss section we are going to use. */ 1890 .rela.bss section we are going to use. */
1894 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) 1891 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
1895 { 1892 {
1896 asection *srel; 1893 asection *srel;
1897 1894
1898 srel = htab->srelbss; 1895 srel = htab->srelbss;
1899 BFD_ASSERT (srel != NULL); 1896 BFD_ASSERT (srel != NULL);
1900 srel->size += sizeof (Elf32_External_Rela); 1897 srel->size += sizeof (Elf32_External_Rela);
1901 h->needs_copy = 1; 1898 h->needs_copy = 1;
1902 } 1899 }
1903 1900
1904 return _bfd_elf_adjust_dynamic_copy (h, s); 1901 return _bfd_elf_adjust_dynamic_copy (h, s);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 return FALSE; 2136 return FALSE;
2140 2137
2141 dynobj = htab->root.dynobj; 2138 dynobj = htab->root.dynobj;
2142 BFD_ASSERT (dynobj != NULL); 2139 BFD_ASSERT (dynobj != NULL);
2143 2140
2144 if (htab->root.dynamic_sections_created) 2141 if (htab->root.dynamic_sections_created)
2145 { 2142 {
2146 /* Set the contents of the .interp section to the interpreter. */ 2143 /* Set the contents of the .interp section to the interpreter. */
2147 if (info->executable) 2144 if (info->executable)
2148 { 2145 {
2149 » s = bfd_get_section_by_name (dynobj, ".interp"); 2146 » s = bfd_get_linker_section (dynobj, ".interp");
2150 BFD_ASSERT (s != NULL); 2147 BFD_ASSERT (s != NULL);
2151 s->size = sizeof ELF_DYNAMIC_INTERPRETER; 2148 s->size = sizeof ELF_DYNAMIC_INTERPRETER;
2152 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; 2149 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
2153 } 2150 }
2154 } 2151 }
2155 2152
2156 /* Set up .got offsets for local syms, and space for local dynamic 2153 /* Set up .got offsets for local syms, and space for local dynamic
2157 relocs. */ 2154 relocs. */
2158 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) 2155 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
2159 { 2156 {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 { 2362 {
2366 h = sym_hashes[r_symndx - symtab_hdr->sh_info]; 2363 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
2367 while (h->root.type == bfd_link_hash_indirect 2364 while (h->root.type == bfd_link_hash_indirect
2368 || h->root.type == bfd_link_hash_warning) 2365 || h->root.type == bfd_link_hash_warning)
2369 h = (struct elf_link_hash_entry *) h->root.u.i.l ink; 2366 h = (struct elf_link_hash_entry *) h->root.u.i.l ink;
2370 } 2367 }
2371 2368
2372 /* Don't generate entries for weak symbols. */ 2369 /* Don't generate entries for weak symbols. */
2373 if (!h || (h && h->root.type != bfd_link_hash_undefwea k)) 2370 if (!h || (h && h->root.type != bfd_link_hash_undefwea k))
2374 { 2371 {
2375 if (!elf_discarded_section (s) && !((bfd_get_secti on_flags (ibfd, s) & SEC_ALLOC) == 0)) 2372 if (!discarded_section (s) && !((bfd_get_section_f lags (ibfd, s) & SEC_ALLOC) == 0))
2376 { 2373 {
2377 switch (ELF32_R_TYPE (internal_relocs->r_info) ) 2374 switch (ELF32_R_TYPE (internal_relocs->r_info) )
2378 { 2375 {
2379 case R_LM32_32: 2376 case R_LM32_32:
2380 r32_count++; 2377 r32_count++;
2381 break; 2378 break;
2382 case R_LM32_16_GOT: 2379 case R_LM32_16_GOT:
2383 rgot_count++; 2380 rgot_count++;
2384 break; 2381 break;
2385 } 2382 }
2386 } 2383 }
2387 } 2384 }
2388 else 2385 else
2389 { 2386 {
2390 struct weak_symbol_list *current, *new_entry; 2387 struct weak_symbol_list *current, *new_entry;
2391 /* Is this symbol already in the list? */ 2388 /* Is this symbol already in the list? */
2392 for (current = list_start; current; current = curr ent->next) 2389 for (current = list_start; current; current = curr ent->next)
2393 { 2390 {
2394 if (!strcmp (current->name, h->root.root.strin g)) 2391 if (!strcmp (current->name, h->root.root.strin g))
2395 break; 2392 break;
2396 } 2393 }
2397 if (!current && !elf_discarded_section (s) && (bfd _get_section_flags (ibfd, s) & SEC_ALLOC)) 2394 if (!current && !discarded_section (s) && (bfd_get _section_flags (ibfd, s) & SEC_ALLOC))
2398 { 2395 {
2399 /* Will this have an entry in the GOT. */ 2396 /* Will this have an entry in the GOT. */
2400 if (ELF32_R_TYPE (internal_relocs->r_info) == R_LM32_16_GOT) 2397 if (ELF32_R_TYPE (internal_relocs->r_info) == R_LM32_16_GOT)
2401 { 2398 {
2402 /* Create a new entry. */ 2399 /* Create a new entry. */
2403 new_entry = malloc (sizeof (struct weak_sy mbol_list)); 2400 new_entry = malloc (sizeof (struct weak_sy mbol_list));
2404 if (!new_entry) 2401 if (!new_entry)
2405 return FALSE; 2402 return FALSE;
2406 new_entry->name = h->root.root.string; 2403 new_entry->name = h->root.root.string;
2407 new_entry->next = NULL; 2404 new_entry->next = NULL;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 2480 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
2484 | SEC_LINKER_CREATED); 2481 | SEC_LINKER_CREATED);
2485 2482
2486 pltflags = flags; 2483 pltflags = flags;
2487 pltflags |= SEC_CODE; 2484 pltflags |= SEC_CODE;
2488 if (bed->plt_not_loaded) 2485 if (bed->plt_not_loaded)
2489 pltflags &= ~ (SEC_LOAD | SEC_HAS_CONTENTS); 2486 pltflags &= ~ (SEC_LOAD | SEC_HAS_CONTENTS);
2490 if (bed->plt_readonly) 2487 if (bed->plt_readonly)
2491 pltflags |= SEC_READONLY; 2488 pltflags |= SEC_READONLY;
2492 2489
2493 s = bfd_make_section_with_flags (abfd, ".plt", pltflags); 2490 s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
2494 htab->splt = s; 2491 htab->splt = s;
2495 if (s == NULL 2492 if (s == NULL
2496 || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) 2493 || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
2497 return FALSE; 2494 return FALSE;
2498 2495
2499 if (bed->want_plt_sym) 2496 if (bed->want_plt_sym)
2500 { 2497 {
2501 /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the 2498 /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
2502 .plt section. */ 2499 .plt section. */
2503 struct bfd_link_hash_entry *bh = NULL; 2500 struct bfd_link_hash_entry *bh = NULL;
2504 struct elf_link_hash_entry *h; 2501 struct elf_link_hash_entry *h;
2505 2502
2506 if (! (_bfd_generic_link_add_one_symbol 2503 if (! (_bfd_generic_link_add_one_symbol
2507 (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 2504 (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
2508 (bfd_vma) 0, NULL, FALSE, 2505 (bfd_vma) 0, NULL, FALSE,
2509 get_elf_backend_data (abfd)->collect, &bh))) 2506 get_elf_backend_data (abfd)->collect, &bh)))
2510 return FALSE; 2507 return FALSE;
2511 h = (struct elf_link_hash_entry *) bh; 2508 h = (struct elf_link_hash_entry *) bh;
2512 h->def_regular = 1; 2509 h->def_regular = 1;
2513 h->type = STT_OBJECT; 2510 h->type = STT_OBJECT;
2514 htab->root.hplt = h; 2511 htab->root.hplt = h;
2515 2512
2516 if (info->shared 2513 if (info->shared
2517 && ! bfd_elf_link_record_dynamic_symbol (info, h)) 2514 && ! bfd_elf_link_record_dynamic_symbol (info, h))
2518 return FALSE; 2515 return FALSE;
2519 } 2516 }
2520 2517
2521 s = bfd_make_section_with_flags (abfd, 2518 s = bfd_make_section_anyway_with_flags (abfd,
2522 » » » » bed->default_use_rela_p ? ".rela.plt" : ".rel .plt", 2519 » » » » » bed->default_use_rela_p
2523 » » » » flags | SEC_READONLY); 2520 » » » » » ? ".rela.plt" : ".rel.plt",
2521 » » » » » flags | SEC_READONLY);
2524 htab->srelplt = s; 2522 htab->srelplt = s;
2525 if (s == NULL 2523 if (s == NULL
2526 || ! bfd_set_section_alignment (abfd, s, ptralign)) 2524 || ! bfd_set_section_alignment (abfd, s, ptralign))
2527 return FALSE; 2525 return FALSE;
2528 2526
2529 if (htab->sgot == NULL 2527 if (htab->sgot == NULL
2530 && ! create_got_section (abfd, info)) 2528 && ! create_got_section (abfd, info))
2531 return FALSE; 2529 return FALSE;
2532 2530
2533 {
2534 const char *secname;
2535 char *relname;
2536 flagword secflags;
2537 asection *sec;
2538
2539 for (sec = abfd->sections; sec; sec = sec->next)
2540 {
2541 secflags = bfd_get_section_flags (abfd, sec);
2542 if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
2543 || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
2544 continue;
2545 secname = bfd_get_section_name (abfd, sec);
2546 relname = bfd_malloc ((bfd_size_type) strlen (secname) + 6);
2547 strcpy (relname, ".rela");
2548 strcat (relname, secname);
2549 if (bfd_get_section_by_name (abfd, secname))
2550 continue;
2551 s = bfd_make_section_with_flags (abfd, relname,
2552 flags | SEC_READONLY);
2553 if (s == NULL
2554 || ! bfd_set_section_alignment (abfd, s, ptralign))
2555 return FALSE;
2556 }
2557 }
2558
2559 if (bed->want_dynbss) 2531 if (bed->want_dynbss)
2560 { 2532 {
2561 /* The .dynbss section is a place to put symbols which are defined 2533 /* The .dynbss section is a place to put symbols which are defined
2562 by dynamic objects, are referenced by regular objects, and are 2534 by dynamic objects, are referenced by regular objects, and are
2563 not functions. We must allocate space for them in the process 2535 not functions. We must allocate space for them in the process
2564 image and use a R_*_COPY reloc to tell the dynamic linker to 2536 image and use a R_*_COPY reloc to tell the dynamic linker to
2565 initialize them at run time. The linker script puts the .dynbss 2537 initialize them at run time. The linker script puts the .dynbss
2566 section into the .bss section of the final image. */ 2538 section into the .bss section of the final image. */
2567 s = bfd_make_section_with_flags (abfd, ".dynbss", 2539 s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
2568 » » » » SEC_ALLOC | SEC_LINKER_CREATED); 2540 » » » » » SEC_ALLOC | SEC_LINKER_CREATED);
2569 htab->sdynbss = s; 2541 htab->sdynbss = s;
2570 if (s == NULL) 2542 if (s == NULL)
2571 return FALSE; 2543 return FALSE;
2572 /* The .rel[a].bss section holds copy relocs. This section is not 2544 /* The .rel[a].bss section holds copy relocs. This section is not
2573 normally needed. We need to create it here, though, so that the 2545 normally needed. We need to create it here, though, so that the
2574 linker will map it to an output section. We can't just create it 2546 linker will map it to an output section. We can't just create it
2575 only if we need it, because we will not know whether we need it 2547 only if we need it, because we will not know whether we need it
2576 until we have seen all the input files, and the first time the 2548 until we have seen all the input files, and the first time the
2577 main linker code calls BFD after examining all the input files 2549 main linker code calls BFD after examining all the input files
2578 (size_dynamic_sections) the input sections have already been 2550 (size_dynamic_sections) the input sections have already been
2579 mapped to the output sections. If the section turns out not to 2551 mapped to the output sections. If the section turns out not to
2580 be needed, we can discard it later. We will never need this 2552 be needed, we can discard it later. We will never need this
2581 section when generating a shared object, since they do not use 2553 section when generating a shared object, since they do not use
2582 copy relocs. */ 2554 copy relocs. */
2583 if (! info->shared) 2555 if (! info->shared)
2584 { 2556 {
2585 s = bfd_make_section_with_flags (abfd, 2557 s = bfd_make_section_anyway_with_flags (abfd,
2586 » » » » » (bed->default_use_rela_p 2558 » » » » » » (bed->default_use_rela_p
2587 » » » » » ? ".rela.bss" : ".rel.bss"), 2559 » » » » » » ? ".rela.bss" : ".rel.bss"),
2588 » » » » » flags | SEC_READONLY); 2560 » » » » » » flags | SEC_READONLY);
2589 htab->srelbss = s; 2561 htab->srelbss = s;
2590 if (s == NULL 2562 if (s == NULL
2591 || ! bfd_set_section_alignment (abfd, s, ptralign)) 2563 || ! bfd_set_section_alignment (abfd, s, ptralign))
2592 return FALSE; 2564 return FALSE;
2593 } 2565 }
2594 } 2566 }
2595 2567
2596 return TRUE; 2568 return TRUE;
2597 } 2569 }
2598 2570
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 #undef elf_backend_always_size_sections 2859 #undef elf_backend_always_size_sections
2888 #define elf_backend_always_size_sections lm32_elf_always_size_sections 2860 #define elf_backend_always_size_sections lm32_elf_always_size_sections
2889 #undef elf_backend_modify_segment_map 2861 #undef elf_backend_modify_segment_map
2890 #define elf_backend_modify_segment_map lm32_elf_modify_segment_map 2862 #define elf_backend_modify_segment_map lm32_elf_modify_segment_map
2891 #undef elf_backend_modify_program_headers 2863 #undef elf_backend_modify_program_headers
2892 #define elf_backend_modify_program_headers lm32_elf_modify_program_headers 2864 #define elf_backend_modify_program_headers lm32_elf_modify_program_headers
2893 #undef bfd_elf32_bfd_copy_private_bfd_data 2865 #undef bfd_elf32_bfd_copy_private_bfd_data
2894 #define bfd_elf32_bfd_copy_private_bfd_data lm32_elf_fdpic_copy_private_bfd_ data 2866 #define bfd_elf32_bfd_copy_private_bfd_data lm32_elf_fdpic_copy_private_bfd_ data
2895 2867
2896 #include "elf32-target.h" 2868 #include "elf32-target.h"
OLDNEW
« no previous file with comments | « bfd/elf32-iq2000.c ('k') | bfd/elf32-m32c.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698