[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/24322] New: ld -z shstk sometimes sets IBT property even if -z i
From: |
bonzini at gnu dot org |
Subject: |
[Bug ld/24322] New: ld -z shstk sometimes sets IBT property even if -z ibt is not passed |
Date: |
Tue, 12 Mar 2019 10:53:46 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=24322
Bug ID: 24322
Summary: ld -z shstk sometimes sets IBT property even if -z ibt
is not passed
Product: binutils
Version: 2.31
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: bonzini at gnu dot org
Target Milestone: ---
Reproducer
cat > f.s <<\EOF
.text
.global _start
_start:
xor %edi, %edi
mov $60, %eax
syscall
EOF
cat > g.s <<\EOF
.text
.global main
main:
xor %edi, %edi
mov $60, %eax
syscall
EOF
cat > Makefile <<\EOF
all: f g
f: f.o; ld -o $@ $< -z shstk
g: g.o; gcc -o $@ $< -Wl,-z,shstk
f.o: f.s
g.o: g.s
.s.o:; as --64 -o $@ $<
.PHONY: all
EOF
Now:
$ make
as --64 -o f.o f.s
ld -o f f.o -z shstk
as --64 -o g.o g.s
gcc -o g g.o -Wl,-z,shstk
$ readelf -n f # correct
Displaying notes found in: .note.gnu.property
Owner Data size Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: x86 feature: SHSTK
$ readelf -n g # wrong
Displaying notes found in: .note.gnu.property
Owner Data size Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: x86 feature: IBT, SHSTK
and indeed running "g" on a machine with CET fails with a segv at the beginning
of "main" (it works if you add the endbr64 hint).
More information:
- the minimal ld command line that causes the bug and still allows "g" to build
is
/usr/bin/ld --no-add-needed \
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -o g \
/usr/lib64/crt1.o /usr/lib64/crti.o g.o -z shstk \
-L/lib64 -lc
- the minimal ld command line that causes the bug (but does not build a
runnable executable) is
/usr/bin/ld --no-add-needed -r -o h \
/usr/lib64/crt1.o /usr/lib64/crti.o g.o -z shstk
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/24322] New: ld -z shstk sometimes sets IBT property even if -z ibt is not passed,
bonzini at gnu dot org <=
- [Bug ld/24322] ld -z shstk sometimes sets IBT property even if -z ibt is not passed, bonzini at gnu dot org, 2019/03/12
- [Bug ld/24322] ld -z shstk sometimes sets IBT property even if -z ibt is not passed, bonzini at gnu dot org, 2019/03/12
- [Bug ld/24322] ld -z shstk sometimes sets IBT property even if -z ibt is not passed, hjl.tools at gmail dot com, 2019/03/12
- [Bug ld/24322] ld -z shstk sometimes sets IBT property even if -z ibt is not passed, cvs-commit at gcc dot gnu.org, 2019/03/13
- [Bug ld/24322] ld -z shstk sometimes sets IBT property even if -z ibt is not passed, nickc at redhat dot com, 2019/03/13
- [Bug ld/24322] ld -z shstk sometimes sets IBT property even if -z ibt is not passed, hjl.tools at gmail dot com, 2019/03/13