From 0e673e27fdd0692779d073fa4e3c6960a979237a Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 1 Sep 2012 02:50:10 +0000 Subject: Don't optimize relocation against _DYNAMIC bfd/ * elf32-i386.c (elf_i386_convert_mov_to_lea): Don't optimize _DYNAMIC. * elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise. ld/testsuite/ * ld-i386/i386.exp: Run mov1a, mov1b. * ld-x86-64/x86-64.exp: Run mov1a, mov1b, mov1c, mov1d. * ld-i386/mov1.s: New file. * ld-i386/mov1a.d: Likewise. * ld-i386/mov1b.d: Likewise. * ld-x86-64/mov1.s: Likewise. * ld-x86-64/mov1a.d: Likewise. * ld-x86-64/mov1b.d: Likewise. * ld-x86-64/mov1c.d: Likewise. * ld-x86-64/mov1d.d: Likewise. --- bfd/elf32-i386.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bfd/elf32-i386.c') diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index c9bc6944c4..eab963c2b4 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2631,9 +2631,11 @@ elf_i386_convert_mov_to_lea (bfd *abfd, asection *sec, || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; - /* STT_GNU_IFUNC must keep R_386_GOT32 relocation. */ + /* STT_GNU_IFUNC must keep R_386_GOT32 relocation. We also avoid + optimizing _DYNAMIC since ld.so may use its link-time address. */ if (h->def_regular && h->type != STT_GNU_IFUNC + && strcmp (h->root.root.string, "_DYNAMIC") != 0 && SYMBOL_REFERENCES_LOCAL (link_info, h) && bfd_get_8 (input_bfd, contents + irel->r_offset - 2) == 0x8b) -- cgit v1.2.1