From 90ac242072dc68ad454aaaa228868b0f1c8e10f9 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 13 Aug 2016 00:03:43 +0930 Subject: [PATCH] Correct .dynsym sh_info bfd/ * elf-bfd.h (struct elf_link_hash_table): Add local_dynsymcount. * elflink.c (_bfd_elf_link_renumber_dynsyms): Set local_dynsymcount. (bfd_elf_final_link): Set .dynsym sh_info from local_dynsymcount. ld/ * testsuite/ld-tic6x/shlib-1.rd: Correct expected .dynsym sh_info. * testsuite/ld-tic6x/shlib-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. --- bfd/ChangeLog | 6 ++++++ bfd/elf-bfd.h | 1 + bfd/elflink.c | 14 +++++--------- ld/ChangeLog | 16 ++++++++++++++++ ld/testsuite/ld-tic6x/shlib-1.rd | 2 +- ld/testsuite/ld-tic6x/shlib-1b.rd | 2 +- ld/testsuite/ld-tic6x/shlib-1r.rd | 2 +- ld/testsuite/ld-tic6x/shlib-1rb.rd | 2 +- ld/testsuite/ld-tic6x/shlib-app-1.rd | 2 +- ld/testsuite/ld-tic6x/shlib-app-1b.rd | 2 +- ld/testsuite/ld-tic6x/shlib-app-1r.rd | 2 +- ld/testsuite/ld-tic6x/shlib-app-1rb.rd | 2 +- ld/testsuite/ld-tic6x/shlib-noindex.rd | 2 +- ld/testsuite/ld-tic6x/static-app-1.rd | 2 +- ld/testsuite/ld-tic6x/static-app-1b.rd | 2 +- ld/testsuite/ld-tic6x/static-app-1r.rd | 2 +- ld/testsuite/ld-tic6x/static-app-1rb.rd | 2 +- 17 files changed, 41 insertions(+), 22 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 94c1fcb8c27..7326ecd4a95 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2016-08-12 Alan Modra + + * elf-bfd.h (struct elf_link_hash_table): Add local_dynsymcount. + * elflink.c (_bfd_elf_link_renumber_dynsyms): Set local_dynsymcount. + (bfd_elf_final_link): Set .dynsym sh_info from local_dynsymcount. + 2016-08-11 Alan Modra * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Don't exit with diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index bb3371fec88..424ea30ea46 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -524,6 +524,7 @@ struct elf_link_hash_table /* The number of symbols found in the link which is intended for the mandatory DT_SYMTAB tag (.dynsym section) in .dynamic section. */ bfd_size_type dynsymcount; + bfd_size_type local_dynsymcount; /* The string table of dynamic symbols, which becomes the .dynstr section. */ diff --git a/bfd/elflink.c b/bfd/elflink.c index 5bc57408e47..9e9a33cb352 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -904,6 +904,7 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, for (p = elf_hash_table (info)->dynlocal; p ; p = p->next) p->dynindx = ++dynsymcount; } + elf_hash_table (info)->local_dynsymcount = dynsymcount; elf_link_hash_traverse (elf_hash_table (info), elf_link_renumber_hash_table_dynsyms, @@ -11781,7 +11782,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) { Elf_Internal_Sym sym; bfd_byte *dynsym = elf_hash_table (info)->dynsym->contents; - long last_local = 0; + + o = elf_hash_table (info)->dynsym->output_section; + elf_section_data (o)->this_hdr.sh_info + = elf_hash_table (info)->local_dynsymcount + 1; /* Write out the section symbols for the output sections. */ if (bfd_link_pic (info) @@ -11811,8 +11815,6 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) return FALSE; sym.st_value = s->vma; dest = dynsym + dynindx * bed->s->sizeof_sym; - if (last_local < dynindx) - last_local = dynindx; bed->s->swap_symbol_out (abfd, &sym, dest, 0); } } @@ -11845,16 +11847,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) + e->isym.st_value); } - if (last_local < e->dynindx) - last_local = e->dynindx; - dest = dynsym + e->dynindx * bed->s->sizeof_sym; bed->s->swap_symbol_out (abfd, &sym, dest, 0); } } - - elf_section_data (elf_hash_table (info)->dynsym->output_section)->this_hdr.sh_info = - last_local + 1; } /* We get the global symbols from the hash table. */ diff --git a/ld/ChangeLog b/ld/ChangeLog index 6c70b54b131..7fa2283b533 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,19 @@ +2016-08-12 Alan Modra + + * testsuite/ld-tic6x/shlib-1.rd: Correct expected .dynsym sh_info. + * testsuite/ld-tic6x/shlib-1b.rd: Likewise. + * testsuite/ld-tic6x/shlib-1r.rd: Likewise. + * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. + * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. + * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. + * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. + * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. + * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. + * testsuite/ld-tic6x/static-app-1.rd: Likewise. + * testsuite/ld-tic6x/static-app-1b.rd: Likewise. + * testsuite/ld-tic6x/static-app-1r.rd: Likewise. + * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. + 2016-08-12 Alan Modra * testsuite/ld-undefined/weak-fundef.s: New. diff --git a/ld/testsuite/ld-tic6x/shlib-1.rd b/ld/testsuite/ld-tic6x/shlib-1.rd index 4b6e0263275..a07ddca4939 100644 --- a/ld/testsuite/ld-tic6x/shlib-1.rd +++ b/ld/testsuite/ld-tic6x/shlib-1.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 000048 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 00008118 001118 000025 00 A 0 0 1 \[ 4\] \.rela\.got RELA 00008140 001140 000024 0c AI 2 10 4 \[ 5\] \.rela\.neardata RELA 00008164 001164 000018 0c AI 2 11 4 diff --git a/ld/testsuite/ld-tic6x/shlib-1b.rd b/ld/testsuite/ld-tic6x/shlib-1b.rd index 4b6e0263275..a07ddca4939 100644 --- a/ld/testsuite/ld-tic6x/shlib-1b.rd +++ b/ld/testsuite/ld-tic6x/shlib-1b.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 000048 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 00008118 001118 000025 00 A 0 0 1 \[ 4\] \.rela\.got RELA 00008140 001140 000024 0c AI 2 10 4 \[ 5\] \.rela\.neardata RELA 00008164 001164 000018 0c AI 2 11 4 diff --git a/ld/testsuite/ld-tic6x/shlib-1r.rd b/ld/testsuite/ld-tic6x/shlib-1r.rd index 4b6e0263275..a07ddca4939 100644 --- a/ld/testsuite/ld-tic6x/shlib-1r.rd +++ b/ld/testsuite/ld-tic6x/shlib-1r.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 000048 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 00008118 001118 000025 00 A 0 0 1 \[ 4\] \.rela\.got RELA 00008140 001140 000024 0c AI 2 10 4 \[ 5\] \.rela\.neardata RELA 00008164 001164 000018 0c AI 2 11 4 diff --git a/ld/testsuite/ld-tic6x/shlib-1rb.rd b/ld/testsuite/ld-tic6x/shlib-1rb.rd index 4b6e0263275..a07ddca4939 100644 --- a/ld/testsuite/ld-tic6x/shlib-1rb.rd +++ b/ld/testsuite/ld-tic6x/shlib-1rb.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 000048 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 00008118 001118 000025 00 A 0 0 1 \[ 4\] \.rela\.got RELA 00008140 001140 000024 0c AI 2 10 4 \[ 5\] \.rela\.neardata RELA 00008164 001164 000018 0c AI 2 11 4 diff --git a/ld/testsuite/ld-tic6x/shlib-app-1.rd b/ld/testsuite/ld-tic6x/shlib-app-1.rd index 35cc92fa575..f0e67c9216a 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 000044 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 00008044 001044 0000c0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 00008044 001044 0000c0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 00008104 001104 000035 00 A 0 0 1 \[ 4\] \.rela\.got RELA 0000813c 00113c 000018 0c AI 2 11 4 \[ 5\] \.rela\.neardata RELA 00008154 001154 000018 0c AI 2 12 4 diff --git a/ld/testsuite/ld-tic6x/shlib-app-1b.rd b/ld/testsuite/ld-tic6x/shlib-app-1b.rd index a16c4fae29a..19a73710c91 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1b.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1b.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 000044 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 00008044 001044 0000c0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 00008044 001044 0000c0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 00008104 001104 000036 00 A 0 0 1 \[ 4\] \.rela\.got RELA 0000813c 00113c 000018 0c AI 2 11 4 \[ 5\] \.rela\.neardata RELA 00008154 001154 000018 0c AI 2 12 4 diff --git a/ld/testsuite/ld-tic6x/shlib-app-1r.rd b/ld/testsuite/ld-tic6x/shlib-app-1r.rd index d12ee1ced3b..f4fcf6b1a46 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1r.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1r.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 00003c 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 000080dc 0010dc 000030 00 A 0 0 1 \[ 4\] \.rela\.got RELA 0000810c 00110c 000018 0c AI 2 10 4 \[ 5\] \.rela\.bss RELA 00008124 001124 00000c 0c AI 2 12 4 diff --git a/ld/testsuite/ld-tic6x/shlib-app-1rb.rd b/ld/testsuite/ld-tic6x/shlib-app-1rb.rd index 6026e2ab7bd..3b7b6a99152 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1rb.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1rb.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 00003c 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 000080dc 0010dc 000031 00 A 0 0 1 \[ 4\] \.rela\.got RELA 00008110 001110 000018 0c AI 2 10 4 \[ 5\] \.rela\.bss RELA 00008128 001128 00000c 0c AI 2 12 4 diff --git a/ld/testsuite/ld-tic6x/shlib-noindex.rd b/ld/testsuite/ld-tic6x/shlib-noindex.rd index 3d9a724f193..fa031309fbc 100644 --- a/ld/testsuite/ld-tic6x/shlib-noindex.rd +++ b/ld/testsuite/ld-tic6x/shlib-noindex.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 000048 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 6 4 + \[ 2\] \.dynsym DYNSYM 00008048 001048 0000d0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 00008118 001118 000025 00 A 0 0 1 \[ 4\] \.rela\.text RELA 00008140 001140 00000c 0c AI 2 10 4 \[ 5\] \.rela\.got RELA 0000814c 00114c 000024 0c AI 2 11 4 diff --git a/ld/testsuite/ld-tic6x/static-app-1.rd b/ld/testsuite/ld-tic6x/static-app-1.rd index 1efa574a0b2..c1bfc2fc336 100644 --- a/ld/testsuite/ld-tic6x/static-app-1.rd +++ b/ld/testsuite/ld-tic6x/static-app-1.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 00003c 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 5 4 + \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 000080dc 0010dc 00001d 00 A 0 0 1 \[ 4\] \.rela\.got RELA 000080fc 0010fc 000024 0c AI 2 8 4 \[ 5\] \.rela\.neardata RELA 00008120 001120 000030 0c AI 2 9 4 diff --git a/ld/testsuite/ld-tic6x/static-app-1b.rd b/ld/testsuite/ld-tic6x/static-app-1b.rd index 1efa574a0b2..c1bfc2fc336 100644 --- a/ld/testsuite/ld-tic6x/static-app-1b.rd +++ b/ld/testsuite/ld-tic6x/static-app-1b.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 00003c 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 5 4 + \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 000080dc 0010dc 00001d 00 A 0 0 1 \[ 4\] \.rela\.got RELA 000080fc 0010fc 000024 0c AI 2 8 4 \[ 5\] \.rela\.neardata RELA 00008120 001120 000030 0c AI 2 9 4 diff --git a/ld/testsuite/ld-tic6x/static-app-1r.rd b/ld/testsuite/ld-tic6x/static-app-1r.rd index 4ee2c85ae90..af8341ed37e 100644 --- a/ld/testsuite/ld-tic6x/static-app-1r.rd +++ b/ld/testsuite/ld-tic6x/static-app-1r.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 00003c 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 5 4 + \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 000080dc 0010dc 00001d 00 A 0 0 1 \[ 4\] \.rela\.got RELA 000080fc 0010fc 000024 0c AI 2 8 4 \[ 5\] \.rela\.neardata RELA 00008120 001120 000018 0c AI 2 9 4 diff --git a/ld/testsuite/ld-tic6x/static-app-1rb.rd b/ld/testsuite/ld-tic6x/static-app-1rb.rd index 4ee2c85ae90..af8341ed37e 100644 --- a/ld/testsuite/ld-tic6x/static-app-1rb.rd +++ b/ld/testsuite/ld-tic6x/static-app-1rb.rd @@ -4,7 +4,7 @@ Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 \[ 1\] \.hash HASH 00008000 001000 00003c 04 A 2 0 4 - \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 5 4 + \[ 2\] \.dynsym DYNSYM 0000803c 00103c 0000a0 10 A 3 7 4 \[ 3\] \.dynstr STRTAB 000080dc 0010dc 00001d 00 A 0 0 1 \[ 4\] \.rela\.got RELA 000080fc 0010fc 000024 0c AI 2 8 4 \[ 5\] \.rela\.neardata RELA 00008120 001120 000018 0c AI 2 9 4 -- 2.30.2