This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>, binutils at sourceware dot org
- Cc: nd at arm dot com, Rich Felker <dalias at libc dot org>
- Date: Fri, 20 Jul 2018 10:30:08 +0100
- Subject: Re: [PATCH] x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed
- References: <20180719173643.GA8163@intel.com> <20180719213301.GA4717@intel.com>
On 19/07/18 22:33, H.J. Lu wrote:
Here is the updated patch. Any comments?
H.J.
--
When -z separate-code, which is enabled by default for Linux/x86, is
used to create executable, ld won't place any data in the code-only
PT_LOAD segment. If there are no data sections placed before the
code-only PT_LOAD segment, the program headers won't be mapped into
any PT_LOAD segment. When the executable tries to access it (based
on the program header address passed in AT_PHDR), it will lead to
segfault. This patch inserts a GNU_PROPERTY_X86_ISA_1_USED note if
there may be no data sections before the text section so that the
first PT_LOAD segment won't be code-only and will contain the program
header.
i agree with Rich's comment on the bugzilla ticket:
simply always adding a .phdrs section that covers
the program headers would ensure that this kind of
bug is not introduced on other targets and seems
less hackish than adding a note.
i don't know why there is no such section already,
or if there is any drawback adding such a section,
is the requirement to access program headers in a
static linked executable a linux only thing?
Testcases are adjusted to either pass "-z noseparate-code" to ld or
discard the .note.gnu.property section. A Linux/x86 run-time test is
added.
bfd/
PR ld/23428
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the
separate code program header is needed, make sure that the first
read-only PT_LOAD segment has no code by adding a
GNU_PROPERTY_X86_ISA_1_USED note.