This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Skip ELF section header check if not needed
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Wed, 2 Aug 2017 07:45:01 -0700
- Subject: [PATCH] Skip ELF section header check if not needed
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
When placing an orpha input section, there is no need to check for ELF
section header if either input or output isn't ELF.
OK for master?
H.J.
---
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Skip
ELF section header check if either input or output isn't ELF.
---
ld/emultempl/elf32.em | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 75ded127f3..3a0404c61b 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2095,6 +2095,8 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
}
if (!bfd_link_relocatable (&link_info)
+ && iself
+ && link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour
&& (s->flags & SEC_ALLOC) != 0
&& (elf_section_flags (s) & SHF_GNU_MBIND) != 0)
{
@@ -2137,6 +2139,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
/* Look through the script to see where to place this section. */
if (constraint == 0
+ && iself
&& link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour)
for (os = lang_output_section_find (secname);
os != NULL;
@@ -2155,11 +2158,11 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
== elf_section_data (s)->this_hdr.sh_info)
&& (os->bfd_section->flags == 0
|| ((!bfd_link_relocatable (&link_info)
- || (iself && (((elf_section_flags (s)
- ^ elf_section_flags (os->bfd_section))
- & SHF_EXCLUDE) == 0)))
+ || (((elf_section_flags (s)
+ ^ elf_section_flags (os->bfd_section))
+ & SHF_EXCLUDE) == 0))
&& ((s->flags ^ os->bfd_section->flags)
- & (SEC_LOAD | SEC_ALLOC)) == 0
+ & (SEC_LOAD | SEC_ALLOC)) == 0
&& _bfd_elf_match_sections_by_type (link_info.output_bfd,
os->bfd_section,
s->owner, s))))
--
2.13.3