Ignore discarded section when converting mov to lea

H.J. Lu hjl.tools@gmail.com
Tue Sep 18 00:44:00 GMT 2012


Hi,

I checked in this patch to ignore discarded section when converting mov to lea.


-- 
H.J.
---
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.5808
diff -u -p -r1.5808 ChangeLog
--- ChangeLog	17 Sep 2012 18:31:14 -0000	1.5808
+++ ChangeLog	18 Sep 2012 00:41:14 -0000
@@ -1,5 +1,11 @@
 2012-09-17  H.J. Lu  <hongjiu.lu@intel.com>

+	* elf32-i386.c (elf_i386_convert_mov_to_lea): Ignore discarded
+	section.
+	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
+
+2012-09-17  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Replace return
 	FALSE with abort.
 	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
Index: elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.284
diff -u -p -r1.284 elf32-i386.c
--- elf32-i386.c	17 Sep 2012 18:31:15 -0000	1.284
+++ elf32-i386.c	18 Sep 2012 00:41:14 -0000
@@ -2559,9 +2559,10 @@ elf_i386_convert_mov_to_lea (bfd *abfd,
   if (!is_elf_hash_table (link_info->hash))
     return FALSE;

-  /* Nothing to do if there are no codes or no relocations.  */
+  /* Nothing to do if there are no codes, no relocations or no output.  */
   if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC)
-      || sec->reloc_count == 0)
+      || sec->reloc_count == 0
+      || discarded_section (sec))
     return TRUE;

   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
Index: elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.275
diff -u -p -r1.275 elf64-x86-64.c
--- elf64-x86-64.c	17 Sep 2012 18:31:15 -0000	1.275
+++ elf64-x86-64.c	18 Sep 2012 00:41:14 -0000
@@ -2595,9 +2595,10 @@ elf_x86_64_convert_mov_to_lea (bfd *abfd
   if (!is_elf_hash_table (link_info->hash))
     return FALSE;

-  /* Nothing to do if there are no codes or no relocations.  */
+  /* Nothing to do if there are no codes, no relocations or no output.  */
   if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC)
-      || sec->reloc_count == 0)
+      || sec->reloc_count == 0
+      || discarded_section (sec))
     return TRUE;

   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;



More information about the Binutils mailing list