$ cat xx.c #include <stdio.h> int main(int argc, char **argv) { printf("Hallo\n"); return 0; } $ gcc -O2 -o xx xx.c $ readelf -a xx|grep STACK GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4 $ gcc -flto -O2 -o xx xx.c $ readelf -a xx|grep STACK GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4 -flto should not create executable stacks.
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2011-07-11 18:39:13 Modified files: bfd : ChangeLog elflink.c Log message: Also skip BFD_PLUGIN when setting stack_flags. 2011-07-11 H.J. Lu <hongjiu.lu@intel.com> PR ld/12982 * elflink.c (bfd_elf_size_dynamic_sections): Also skip BFD_PLUGIN when setting stack_flags. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5420&r2=1.5421 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.414&r2=1.415
Fixed.
The testcase that was added for this on 2012-12-07 (pr12982.c, pr12982.d) is failing on multiple targets, including nios2-linux-gnu, arm-none-eabi, mips-linux-gnu. I've looked at the nios2-linux-gnu failure; there is no GNU_STACK segment in the output. Is it a requirement that there be one, or is the test making an incorrect assumption that it exists on all targets?
The test is making unwarranted assumptions about the compiler, C library and startup files. At least one object needs a .note.GNU-stack section for this test to pass. If the target defaults to an executable stack then all objects involved must have .note.GNU-stack saying non-exec.
CVSROOT: /cvs/src Module name: src Changes by: amodra@sourceware.org 2013-05-21 07:15:22 Modified files: ld/testsuite : ChangeLog ld/testsuite/ld-plugin: pr12982.d Log message: PR ld/12982 * ld-plugin/pr12982.d: Fail if RWE GNU_STACK present. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1720&r2=1.1721 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/pr12982.d.diff?cvsroot=src&r1=1.1&r2=1.2
The master branch has been updated by YunQiang Su <syq@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a0631c1501c113c04891c9a24a9ff5276257f28d commit a0631c1501c113c04891c9a24a9ff5276257f28d Author: YunQiang Su <yunqiang.su@cipunited.com> Date: Tue May 16 09:46:46 2023 +0800 MIPS: fix some ld testcases with compiler 1. config/default.exp: use -mabi=32 not for -gnuabi64 xfail_from_runlist: remove an element and mark it xfail. 2. ld-elf/indirect.exp: xfail indirect5a indirect5b indirect6a indirect6b indirect5c indirect5d indirect6c indirect6d 3. ld-elf/pr23658-2: mips output is not common 4. ld-elf/shared.exp: non-run on mips: Build libpr16496b.so 5. ld-elfvers/vers.exp: xfail vers4, vers4b no-run on mips: vers24a, vers24b, vers24c 6. ld-gc/gc.exp: add -KPIC into asflags for pr13683, pr14265, pr19161 7. ld-mips-elf/mips-elf.exp: use noarch for mips16-local-stubs-1, since it use -mips4 8. ld-plugin/lto.exp: no-run on mips/linux: PR ld/12982 add -KPIC into asflags for lto-3r, lto-5r, PR ld/19317 (2) xfail PR ld/15323 (4), PR ld/19317 (3) 9. ld-plugin/plugin.exp: xfail plugin claimfile lost symbol plugin claimfile replace symbol plugin claimfile replace symbol plugin claimfile lost symbol with source plugin claimfile replace symbol with source plugin claimfile resolve symbol with source plugin 2 with source lib load plugin 2 with source plugin 3 with source lib load plugin 3 with source 11. ld-selective/selective.exp: add -fno-PIC, which is needed for -mno-abicalls 12. ld-shared/shared.exp: xfail shared (non PIC), shared (PIC main, non PIC so)