gcc-8-riscv64-linux-gnu produces binaries with executable stack by default
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-8-cross-ports (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
The gcc 8 RISC-V cross-compiler on Ubuntu 18.04, in contrast to other architectures such as ARM and x86, does not use noexecstack by default.
$ riscv64-
'riscv64-
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ echo "int main() { return 0; }" > test.c
$ riscv64-
$ readelf -lW test|grep GNU_STACK
(no output)
Expected output:
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10
$ riscv64-
$ scanelf -e test.o
TYPE STK/REL/PTL FILE
ET_REL !WX --- --- test.o
Expected output:
TYPE STK/REL/PTL FILE
ET_REL --- --- --- test.o
$ riscv64-
I've checked with the RISC-V toolchain on Fedora, and that does set the correct GNU_STACK permissions.
So I don't think this is expected behavior, and might result in cross-compiled executables being less hardened than expected.
As a workaround, `-Wl,-z,