This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
GNU_STACK header is not present when linking with gc-sections.
- From: Sriraman Tallam <tmsriram at google dot com>
- To: Ian Lance Taylor <iant at google dot com>, binutils <binutils at sourceware dot org>
- Date: Thu, 14 Jan 2010 16:44:53 -0800
- Subject: GNU_STACK header is not present when linking with gc-sections.
Hi,
This bug was noticed by Ian with gc-sections.
Reason :
In Sized_relobj::do_layout
bool seen_gnu_stack = false;
...
for (unsigned int i = 1; i < shnum; ++i, pshdrs += This::shdr_size)
{
if (!is_gc_pass_two)
{
...
// The .note.GNU-stack section is special. It gives the
// protection flags that this object file requires for the stack
// in memory.
if (strcmp(name, ".note.GNU-stack") == 0)
{
seen_gnu_stack = true;
...
}
}
}
...
if (!is_gc_pass_one)
layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags);
In the second pass of do_layout, seen_gnu_stack is always false.
The fix is to call layout_gnu_stack in the first pass of do_layout.
This should be ok as layout_gnu_stack just sets 2 flags to true in the
layout object.
This patch should fix that.
Index: object.cc
===================================================================
RCS file: /cvs/src/src/gold/object.cc,v
retrieving revision 1.117
diff -u -u -p -r1.117 object.cc
--- object.cc 8 Jan 2010 22:34:34 -0000 1.117
+++ object.cc 15 Jan 2010 00:34:15 -0000
@@ -1321,7 +1321,7 @@ Sized_relobj<size, big_endian>::do_layou
}
}
- if (!is_gc_pass_one)
+ if (!is_gc_pass_two)
layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags);
Is this ok to submit ?
Thanks,
-Sriraman.