GNU Binutils with patches for OS216
Revisión | e17b0c351f0b22fb42edf34e5a6e486d72e9ee05 (tree) |
---|---|
Tiempo | 2017-02-03 07:38:23 |
Autor | Maciej W. Rozycki <macro@imgt...> |
Commiter | Maciej W. Rozycki |
MIPS/BFD: Respect the ELF gABI dynamic symbol table sort requirement
Ensure all local symbols precede external symbols in the dynamic symbol
table.
No local symbols are expected to make it to the dynamic symbol table
except for section symbols already taken care of, so this is really a
safeguard only against a potential BFD bug otherwise not so harmful,
which may become a grave one due to a symbol table sorting requirement
violation (see PR ld/20828 for an example). This means however that no
test suite coverage is possible for this change as code introduced here
is not normally expected to trigger.
Logically split then the part of the dynamic symbol table which is not
global offset table mapped, into a local area at the beginning and an
external area following. By the time mips_elf_sort_hash_table' is
called we have the number of local dynamic symbol table entries (section
and non-section) already counted in local_dynsymcount', so use it to
offset the external area from the beginning.
bfd/
* elfxx-mips.c (mips_elf_hash_sort_data): Add
max_local_dynindx'.
(mips_elf_sort_hash_table): Handle it.
(mips_elf_sort_hash_table_f) <GGA_NONE>: For forced local
symbols bump up max_local_dynindx' rather than
max_non_got_dynindx'.
@@ -1,5 +1,14 @@ | ||
1 | 1 | 2017-02-02 Maciej W. Rozycki <macro@imgtec.com> |
2 | 2 | |
3 | + * elfxx-mips.c (mips_elf_hash_sort_data): Add | |
4 | + `max_local_dynindx'. | |
5 | + (mips_elf_sort_hash_table): Handle it. | |
6 | + (mips_elf_sort_hash_table_f) <GGA_NONE>: For forced local | |
7 | + symbols bump up `max_local_dynindx' rather than | |
8 | + `max_non_got_dynindx'. | |
9 | + | |
10 | +2017-02-02 Maciej W. Rozycki <macro@imgtec.com> | |
11 | + | |
3 | 12 | * elfxx-mips.c (mips_elf_hash_sort_data): Convert the |
4 | 13 | `min_got_dynindx', `max_unref_got_dynindx' and |
5 | 14 | `max_non_got_dynindx' members to the `bfd_size_type' data type. |
@@ -315,7 +315,10 @@ struct mips_elf_hash_sort_data | ||
315 | 315 | with a GOT entry that is not referenced (e.g., a dynamic symbol |
316 | 316 | with dynamic relocations pointing to it from non-primary GOTs). */ |
317 | 317 | bfd_size_type max_unref_got_dynindx; |
318 | - /* The greatest dynamic symbol table index not corresponding to a | |
318 | + /* The greatest dynamic symbol table index corresponding to a local | |
319 | + symbol. */ | |
320 | + bfd_size_type max_local_dynindx; | |
321 | + /* The greatest dynamic symbol table index corresponding to an external | |
319 | 322 | symbol without a GOT entry. */ |
320 | 323 | bfd_size_type max_non_got_dynindx; |
321 | 324 | }; |
@@ -3846,11 +3849,15 @@ mips_elf_sort_hash_table (bfd *abfd, struct bfd_link_info *info) | ||
3846 | 3849 | hsd.max_unref_got_dynindx |
3847 | 3850 | = hsd.min_got_dynindx |
3848 | 3851 | = (htab->root.dynsymcount - g->reloc_only_gotno); |
3849 | - hsd.max_non_got_dynindx = count_section_dynsyms (abfd, info) + 1; | |
3852 | + /* Add 1 to local symbol indices to account for the mandatory NULL entry | |
3853 | + at the head of the table; see `_bfd_elf_link_renumber_dynsyms'. */ | |
3854 | + hsd.max_local_dynindx = count_section_dynsyms (abfd, info) + 1; | |
3855 | + hsd.max_non_got_dynindx = htab->root.local_dynsymcount + 1; | |
3850 | 3856 | mips_elf_link_hash_traverse (htab, mips_elf_sort_hash_table_f, &hsd); |
3851 | 3857 | |
3852 | 3858 | /* There should have been enough room in the symbol table to |
3853 | 3859 | accommodate both the GOT and non-GOT symbols. */ |
3860 | + BFD_ASSERT (hsd.max_local_dynindx <= htab->root.local_dynsymcount + 1); | |
3854 | 3861 | BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx); |
3855 | 3862 | BFD_ASSERT (hsd.max_unref_got_dynindx == htab->root.dynsymcount); |
3856 | 3863 | BFD_ASSERT (htab->root.dynsymcount - hsd.min_got_dynindx == g->global_gotno); |
@@ -3879,7 +3886,10 @@ mips_elf_sort_hash_table_f (struct mips_elf_link_hash_entry *h, void *data) | ||
3879 | 3886 | switch (h->global_got_area) |
3880 | 3887 | { |
3881 | 3888 | case GGA_NONE: |
3882 | - h->root.dynindx = hsd->max_non_got_dynindx++; | |
3889 | + if (h->root.forced_local) | |
3890 | + h->root.dynindx = hsd->max_local_dynindx++; | |
3891 | + else | |
3892 | + h->root.dynindx = hsd->max_non_got_dynindx++; | |
3883 | 3893 | break; |
3884 | 3894 | |
3885 | 3895 | case GGA_NORMAL: |