Bug 24355

Summary: Executable stack error building Ada
Product: gcc Reporter: The Written Word <bugzilla-gcc>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED INVALID    
Severity: normal CC: gcc-bugs
Priority: P2 Keywords: build
Version: 4.0.2   
Target Milestone: ---   
Host: Target: hppa2.0w-hp-hpux11.23
Build: Known to work:
Known to fail: Last reconfirmed:

Description The Written Word 2005-10-13 19:30:58 UTC
I tried building Ada from a bootstrap binary found on the net. HP-UX 11.23 unlike 11.00 and 11i, doesn't allow executing code on the stack by default. To enable this for individual binaries:
  $ chatr +es enable [binary]

To enable execution of code on the stack system-wide, the executable_stack kernel tunable needs to be 1 or 2. The default is 0 (disallow execution).

While building 4.0.2, I encountered the following:
  ...
  stage1/xgcc -Bstage1/ -B/opt/TWWfsw/gcc402/hppa2.0-hp-hpux11.23/bin/ -c -g -O2 -mdisable-indexing     -gnatpg -gnata -I- -I. -Iada -I/opt/build/gcc-4.0.2/gcc/ada /opt/build/gcc-4.0.2/gcc/ada/ada.ads -o ada/ada.o
  Execution of code located on a program's stack is not permitted.
  cmd: stage1/gnat1 -I- -I. -Iada -I/opt/build/gcc-4.0.2/gcc/ada -quiet -dumpbase ada.ads -O2 -g -mdisable-indexing -gnatpg -gnata -gn
  PID 24258 has been terminated.  See the '+es enable' option of chatr(1).
  xgcc: Internal error: Killed (program gnat1)
  Please submit a full bug report.
  See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2005-10-13 19:36:13 UTC
This also effects some C code too like:

int f(int (*fptr)(void))
{
  return fptr();
}


int main(void)
{
  int t;
  int g(void){ return t; }
  t = 2;
  f(&g);
}

Compile at -O0 and you will see that it fails too.
Comment 2 Arnaud Charlet 2005-10-14 08:17:17 UTC
There is no bug here, you found the solution which is to modify the settings
of your OS.

Arno