This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/21884: Check ELF section header only for ELF output
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>, Nick Clifton <nickc at redhat dot com>
- Date: Wed, 2 Aug 2017 06:09:31 -0700
- Subject: Re: [PATCH] PR ld/21884: Check ELF section header only for ELF output
- Authentication-results: sourceware.org; auth=none
- References: <20170802115351.GA29044@gmail.com> <20170802125418.GD1953@bubble.grove.modra.org>
On Wed, Aug 2, 2017 at 5:54 AM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Aug 02, 2017 at 04:53:51AM -0700, H.J. Lu wrote:
>> --- a/ld/emultempl/elf32.em
>> +++ b/ld/emultempl/elf32.em
>> @@ -2136,7 +2136,8 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
>> }
>>
>> /* Look through the script to see where to place this section. */
>> - if (constraint == 0)
>> + if (constraint == 0
>> + && link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour)
>> for (os = lang_output_section_find (secname);
>> os != NULL;
>> os = next_matching_output_section_statement (os, 0))
>
> This doesn't look to be the right place to me. I think the loop
> should run but the ELF specific tests be omitted when either input or
> output is non-ELF.
>
> Also, there is a similar problem with the .mbind code just a little
> earlier.
We can do something like this. There is no need to check for
ELF specific info if either input or output isn't ELF.
--
H.J.
From b5b768d5acb5796144e60f18226627f0688581a9 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 2 Aug 2017 06:07:39 -0700
Subject: [PATCH] Skip ELF section header check if not needed
There is no need to check for ELF section header if either input or output
isn't ELF.
* 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 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 75ded127f3..b2a9760a6d 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;
--
2.13.3