aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf32-i386.c4
-rw-r--r--bfd/elf64-x86-64.c5
3 files changed, 13 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 71933e6..d545c1d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2012-08-31 H.J. Lu <hongjiu.lu@intel.com>
+ * 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.
+
+2012-08-31 H.J. Lu <hongjiu.lu@intel.com>
+
* elf32-i386.c (elf_i386_convert_mov_to_lea): New.
(elf_i386_size_dynamic_sections): Use it on input sections.
(elf_i386_relocate_section): Don't convert
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index c9bc694..eab963c 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)
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 0c37cd3..9edc5ae 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2667,9 +2667,12 @@ elf_x86_64_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_X86_64_GOTPCREL relocation. */
+ /* STT_GNU_IFUNC must keep R_X86_64_GOTPCREL 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)