[PATCH] ld: Remove PF_X from PT_PHDR segment
H.J. Lu
hjl.tools@gmail.com
Sun Nov 12 01:24:00 GMT 2017
It was reasonable to mark PT_PHDR segment with PF_X for compatibility
with UnixWare and Solaris linkers 20 years ago. But it is inappropriate
today when the primary OS of GNU ld is Linux. This patch removes PF_X
from PT_PHDR segment as gold does.
I will check it in next Monday if there is no objections.
H.J.
--
bfd/
PR ld/22423
* elf.c (_bfd_elf_map_sections_to_segments): Remove PF_X from
PT_PHDR segment.
ld/
PR ld/22423
* testsuite/ld-elf/pr22423.d: New test.
---
bfd/elf.c | 3 +--
ld/testsuite/ld-elf/pr22423.d | 8 ++++++++
2 files changed, 9 insertions(+), 2 deletions(-)
create mode 100644 ld/testsuite/ld-elf/pr22423.d
diff --git a/bfd/elf.c b/bfd/elf.c
index 9cecb24922..694e43540f 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4610,8 +4610,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
goto error_return;
m->next = NULL;
m->p_type = PT_PHDR;
- /* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not. */
- m->p_flags = PF_R | PF_X;
+ m->p_flags = PF_R;
m->p_flags_valid = 1;
m->includes_phdrs = 1;
linker_created_pt_phdr_segment = TRUE;
diff --git a/ld/testsuite/ld-elf/pr22423.d b/ld/testsuite/ld-elf/pr22423.d
new file mode 100644
index 0000000000..7376302869
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr22423.d
@@ -0,0 +1,8 @@
+#source: start.s
+#readelf: -l -W
+#ld: -pie
+#target: *-*-linux* *-*-gnu*
+
+#...
+ +PHDR +0x[0-9a-f]+ +0x[0-9a-f]+ +0x[0-9a-f]+ +0x[0-9a-f]+ +0x[0-9a-f]+ +R +0x[48]?
+#pass
--
2.13.6
More information about the Binutils
mailing list