diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-06-04 05:58:34 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-06-04 05:58:47 -0700 |
commit | c4b126b87a6cd842e567136b07ac1adca98c660f (patch) | |
tree | d2fc43aad5eabf1e5389b8136c98d2042ec52225 /bfd/elf32-vax.c | |
parent | 1cf67587a0980e5fee20cad75f2c1fe01af6e808 (diff) | |
download | gdb-c4b126b87a6cd842e567136b07ac1adca98c660f.zip gdb-c4b126b87a6cd842e567136b07ac1adca98c660f.tar.gz gdb-c4b126b87a6cd842e567136b07ac1adca98c660f.tar.bz2 |
ELF: Don't check relocations in non-loaded, non-alloced sections
Don't do anything special with non-loaded, non-alloced sections.
In particular, any relocs in such sections should not affect GOT
and PLT reference counting (ie. we don't allow them to create GOT
or PLT entries), there's no possibility or desire to optimize TLS
relocs, and there's not much point in propagating relocs to shared
libs that the dynamic linker won't relocate.
Since check_relocs is no longer called on non-loaded, non-alloced
sections, remove SEC_ALLOC check. Resolve relocation in debug section
against symbol defined in shared library to 0.
bfd/
PR ld/26080
* elf-m10300.c (mn10300_elf_relocate_section): Resolve relocation
in debug section against symbol defined in shared library to 0.
* elf32-i386.c (elf_i386_check_relocs): Remove SEC_ALLOC check.
* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-nds32.c (nds32_elf_check_relocs): Likewise.
* elf32-nios2.c (nios2_elf32_check_relocs): Likewise.
* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.
* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Set non_got_ref for non-GOT
reference.
(elf_vax_adjust_dynamic_symbol): Generate a copy reloc only if
there is non-GOT reference.
* elflink.c (_bfd_elf_link_check_relocs): Skip non-loaded,
non-alloced sections.
ld/
PR ld/26080
* testsuite/ld-elf/comm-data.exp: Remove copy_reloc.
* testsuite/ld-elf/comm-data2r.rd: Removed.
* testsuite/ld-elf/comm-data2r.sd: Likewise.
* testsuite/ld-elf/comm-data2r.xd: Likewise.
Diffstat (limited to 'bfd/elf32-vax.c')
-rw-r--r-- | bfd/elf32-vax.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index fa84e0b..b5c3d89 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -712,6 +712,11 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, h->plt.refcount++; } + /* Non-GOT reference may need a copy reloc in executable or + a dynamic reloc in shared library. */ + if (h != NULL) + h->non_got_ref = 1; + /* If we are creating a shared library, we need to copy the reloc into the shared library. */ if (bfd_link_pic (info) @@ -929,6 +934,11 @@ elf_vax_adjust_dynamic_symbol (struct bfd_link_info *info, if (bfd_link_pic (info)) return TRUE; + /* If there are no references to this symbol that do not use the + GOT relocation, we don't need to generate a copy reloc. */ + if (!h->non_got_ref) + return TRUE; + /* We must allocate the symbol in our .dynbss section, which will become part of the .bss section of the executable. There will be an entry for this symbol in the .dynsym section. The dynamic |