aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-06-16 05:52:34 -0700
committerH.J. Lu <hjl.tools@gmail.com>2016-06-16 05:52:34 -0700
commit081b1afe5a8cfa02bf3b3cdefb80c266705c17d1 (patch)
tree6c6ff3dec59dc5748448b89a0861023f45debdf8 /bfd/elf32-i386.c
parent4c23f2ffa8fbd467bca51956130a1f30cfe34371 (diff)
downloadgdb-081b1afe5a8cfa02bf3b3cdefb80c266705c17d1.zip
gdb-081b1afe5a8cfa02bf3b3cdefb80c266705c17d1.tar.gz
gdb-081b1afe5a8cfa02bf3b3cdefb80c266705c17d1.tar.bz2
Skip 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. * elf32-i386.c (elf_i386_check_relocs): Skip relocations in non-loaded, non-alloced sections. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 793fb39..a519778 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1846,6 +1846,15 @@ elf_i386_check_relocs (bfd *abfd,
if (bfd_link_relocatable (info))
return TRUE;
+ /* 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. */
+ if ((sec->flags & SEC_ALLOC) == 0)
+ return TRUE;
+
BFD_ASSERT (is_i386_elf (abfd));
htab = elf_i386_hash_table (info);
@@ -2202,19 +2211,18 @@ do_size:
may need to keep relocations for symbols satisfied by a
dynamic library if we manage to avoid copy relocs for the
symbol. */
- if ((sec->flags & SEC_ALLOC) != 0
- && ((bfd_link_pic (info)
- && (r_type != R_386_PC32
- || (h != NULL
- && (! (bfd_link_pie (info)
- || SYMBOLIC_BIND (info, h))
- || h->root.type == bfd_link_hash_defweak
- || !h->def_regular))))
- || (ELIMINATE_COPY_RELOCS
- && !bfd_link_pic (info)
- && h != NULL
- && (h->root.type == bfd_link_hash_defweak
- || !h->def_regular))))
+ if ((bfd_link_pic (info)
+ && (r_type != R_386_PC32
+ || (h != NULL
+ && (! (bfd_link_pie (info)
+ || SYMBOLIC_BIND (info, h))
+ || h->root.type == bfd_link_hash_defweak
+ || !h->def_regular))))
+ || (ELIMINATE_COPY_RELOCS
+ && !bfd_link_pic (info)
+ && h != NULL
+ && (h->root.type == bfd_link_hash_defweak
+ || !h->def_regular)))
{
struct elf_dyn_relocs *p;
struct elf_dyn_relocs **head;