Bug 49703 - -flto makes stack executable by default with GNU ld linker plugin
Summary: -flto makes stack executable by default with GNU ld linker plugin
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.6.1
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: http://www.sourceware.org/bugzilla/sh...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-11 11:59 UTC by marcus
Modified: 2011-07-11 18:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-07-11 12:31:19


Attachments
xx.c (63 bytes, text/x-csrc)
2011-07-11 12:11 UTC, marcus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marcus 2011-07-11 11:59:16 UTC
$ 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.
Comment 1 Richard Biener 2011-07-11 12:08:34 UTC
Works for me ...

please provide preprocessed source.
Comment 2 marcus 2011-07-11 12:11:35 UTC
Created attachment 24738 [details]
xx.c

gcc -O2 -flto -o xx xx.c
readelf -a xx|grep GNU_STACK

should NOT show "RWE" but only "RW"
Comment 3 Richard Biener 2011-07-11 12:13:57 UTC
Works for me.
Comment 4 Richard Biener 2011-07-11 12:31:19 UTC
I can reproduce it at least on {x86_64,ppc}-linux with the linker plugin from
> ld --version
GNU ld (GNU Binutils; openSUSE Factory) 2.21.1
and the GCC 4.6.1 release.

It works without -fuse-linker-plugin, so I suspect a GNU ld bug.  It works
with gold.  Dave?
Comment 5 H.J. Lu 2011-07-11 18:35:41 UTC
It is a linker bug:

http://www.sourceware.org/bugzilla/show_bug.cgi?id=12982