diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2018-05-03 17:17:46 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@mips.com> | 2018-05-03 17:17:46 +0100 |
commit | 3be08ea4728b56d35e136af4e6fd3086ade17764 (patch) | |
tree | 0982e7e0d5c68f187b90bc0967cf7402793f6eb6 /bfd | |
parent | bd732259bd3bec9494a2f1f39f74255dd4a9be85 (diff) | |
download | gdb-3be08ea4728b56d35e136af4e6fd3086ade17764.zip gdb-3be08ea4728b56d35e136af4e6fd3086ade17764.tar.gz gdb-3be08ea4728b56d35e136af4e6fd3086ade17764.tar.bz2 |
BFD: Prevent writing the MIPS _gp_disp symbol into symbol tables
The _gp_disp is a magic symbol, always implicitly defined by the linker.
It does not make a sense to write it into symbol tables for output files.
Moreover, now if the linker gets a version script, the _gp_disp symbol
gets zero version definition index. The zero index means[1]:
"The symbol is local, not available outside the object."
But the _gp_disp symbol has GLOBAL binding. That confuses some tools
like for example the LLD linker when they get such files as inputs.
This patch fixes the problem - it prevents writing the _gp_disp symbol
in regular and dynamic symbol tables.
This was tested by running LD test suite on a mipsel-linux board.
References:
[1] "Linux Standard Base Specification", Section "10.7.2 Symbol
Version Table", p. 32
2018-05-03 Simon Atanasyan <simon@atanasyan.com>
bfd/
* elf32-mips.c: (elf32_mips_fixup_symbol): New function.
(elf_backend_fixup_symbol): New macro.
* elfxx-mips.c: (mips_elf_output_extsym): Discard _gp_disp
handling.
(_bfd_mips_elf_finish_dynamic_symbol): Likewise.
ld/
* testsuite/ld-mips-elf/gp-disp-sym.d: New test.
* testsuite/ld-mips-elf/gp-disp-sym.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
* testsuite/ld-mips-elf/mips16-pic-2.ad: Update for _gp_disp
symbol removal.
* testsuite/ld-mips-elf/mips16-pic-2.nd: Likewise.
* testsuite/ld-mips-elf/pic-and-nonpic-3a.dd: Likewise.
* testsuite/ld-mips-elf/tlslib-o32-hidden.got: Likewise.
* testsuite/ld-mips-elf/tlslib-o32-ver.got: Likewise.
* testsuite/ld-mips-elf/tlslib-o32.got: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 8 | ||||
-rw-r--r-- | bfd/elf32-mips.c | 12 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 12 |
3 files changed, 20 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 11baf5d..94f28b1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2018-05-03 Simon Atanasyan <simon@atanasyan.com> + + * elf32-mips.c: (elf32_mips_fixup_symbol): New function. + (elf_backend_fixup_symbol): New macro. + * elfxx-mips.c: (mips_elf_output_extsym): Discard _gp_disp + handling. + (_bfd_mips_elf_finish_dynamic_symbol): Likewise. + 2018-04-30 Francois H. Theron <francois.theron@netronome.com> * Makefile.am: Added NFP files to build. diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 87147b5..23a5712 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -2420,6 +2420,17 @@ elf32_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, } } } + +/* Remove the magic _gp_disp symbol from the symbol tables. */ + +static bfd_boolean +elf32_mips_fixup_symbol (struct bfd_link_info *info, + struct elf_link_hash_entry *h) +{ + if (strcmp (h->root.root.string, "_gp_disp") == 0) + _bfd_elf_link_hash_hide_symbol (info, h, TRUE); + return TRUE; +} /* Depending on the target vector we generate some version of Irix executables or "normal" MIPS ELF ABI executables. */ @@ -2523,6 +2534,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = { #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook #define elf_backend_copy_indirect_symbol \ _bfd_mips_elf_copy_indirect_symbol +#define elf_backend_fixup_symbol elf32_mips_fixup_symbol #define elf_backend_grok_prstatus elf32_mips_grok_prstatus #define elf_backend_grok_psinfo elf32_mips_grok_psinfo #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index ce64581..e349e8a 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -2903,12 +2903,6 @@ mips_elf_output_extsym (struct mips_elf_link_hash_entry *h, void *data) h->esym.asym.value = mips_elf_hash_table (einfo->info)->procedure_count; } - else if (strcmp (name, "_gp_disp") == 0 && ! NEWABI_P (einfo->abfd)) - { - h->esym.asym.sc = scAbs; - h->esym.asym.st = stLabel; - h->esym.asym.value = elf_gp (einfo->abfd); - } else h->esym.asym.sc = scUndefined; } @@ -10976,12 +10970,6 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd, sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION); sym->st_value = 1; } - else if (strcmp (name, "_gp_disp") == 0 && ! NEWABI_P (output_bfd)) - { - sym->st_shndx = SHN_ABS; - sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION); - sym->st_value = elf_gp (output_bfd); - } else if (SGI_COMPAT (output_bfd)) { if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0 |