* [committed] exec-stack warning for test which wants executable stacks
@ 2022-04-24 17:42 Jeff Law
2022-04-25 12:56 ` Martin Liška
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Law @ 2022-04-24 17:42 UTC (permalink / raw)
To: gcc, binutils
[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]
About a week ago many targets started failing pr94157_0.c test like this
(bfin-elf, but many other targets are also affected):
> spawn -ignore SIGHUP /home/jlaw/test/obj/bfin-elf/obj/gcc/gcc/xgcc
> -B/home/jlaw/test/obj/bfin-elf/obj/gcc/gcc/ c_lto_pr94157_0.o
> -fdiagnostics-plain-output -dumpbase -O0 -fipa-vrp -flto
> -Wa,--noexecstack -Wa,--noexecstack -Wa,--execstack -Wa,--execstack
> -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack
> -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack
> -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -msim
> -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort
> -Wl,gcc_tg.o -o gcc-dg-lto-pr94157-01.exe^M
> /home/jlaw/test/obj/bfin-elf/installed/bfin-elf/bin/ld: warning:
> /tmp/ccfJUEvZ.ltrans0.ltrans.o: requires executable stack (because the
> .note.GNU-stack section is executable)^M
> FAIL: gcc.dg/lto/pr94157 c_lto_pr94157_0.o-c_lto_pr94157_0.o link,
> -O0 -fipa-vrp -flto -Wa,--noexecstack -Wa,--noexecstack
> -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack
> -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack
> -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack
> -Wa,--execstack -Wa,--execstack
This is due to a new binutils warning. This patch just suppresses the
warning for the one test where we explicitly wanted an executable stack.
I'm guessing the repeated -Wa,--noexecstack options in this test are
supposed to trigger a buffer overflow or something similar, so I left
those alone and just appended to the argument list.
I used -z execstack rather than --no-warn-execstack as the former is
recognized by older versions of ld, but the latter is a new option.
The other approach would have been to prune the warning, but this seemed
better since we'd like most tests to fail if somehow their stacks were
executable.
Committed to the trunk.
Jeff
[-- Attachment #2: P --]
[-- Type: text/plain, Size: 1286 bytes --]
commit 6b7441a46c771aa6ecdc0c8ed96197417d036b9a
Author: Jeff Law <jeffreyalaw@gmail.com>
Date: Sun Apr 24 13:38:14 2022 -0400
[committed] exec-stack warning for test which wants executable stacks
gcc/testsuite
* gcc.dg/lto/pr94157_0.c: Also request executable stack from
the linker.
diff --git a/gcc/testsuite/gcc.dg/lto/pr94157_0.c b/gcc/testsuite/gcc.dg/lto/pr94157_0.c
index a6e308b855b..a76141b1809 100644
--- a/gcc/testsuite/gcc.dg/lto/pr94157_0.c
+++ b/gcc/testsuite/gcc.dg/lto/pr94157_0.c
@@ -1,6 +1,6 @@
/* { dg-lto-do link } */
/* { dg-require-effective-target gas } */
-/* { dg-lto-options { { -O0 -fipa-vrp -flto -Wa,--noexecstack -Wa,--noexecstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack } } } */
+/* { dg-lto-options { { -O0 -fipa-vrp -flto -Wa,--noexecstack -Wa,--noexecstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wl,-z,execstack} } } */
int main() {
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-24 17:42 [committed] exec-stack warning for test which wants executable stacks Jeff Law
@ 2022-04-25 12:56 ` Martin Liška
2022-04-25 14:37 ` Jeff Law
0 siblings, 1 reply; 10+ messages in thread
From: Martin Liška @ 2022-04-25 12:56 UTC (permalink / raw)
To: Jeff Law, gcc, binutils
On 4/24/22 19:42, Jeff Law via Gcc wrote:
> About a week ago many targets started failing pr94157_0.c test like this (bfin-elf, but many other targets are also affected):
>
>> spawn -ignore SIGHUP /home/jlaw/test/obj/bfin-elf/obj/gcc/gcc/xgcc -B/home/jlaw/test/obj/bfin-elf/obj/gcc/gcc/ c_lto_pr94157_0.o -fdiagnostics-plain-output -dumpbase -O0 -fipa-vrp -flto -Wa,--noexecstack -Wa,--noexecstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -msim -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,gcc_tg.o -o gcc-dg-lto-pr94157-01.exe^M
>> /home/jlaw/test/obj/bfin-elf/installed/bfin-elf/bin/ld: warning: /tmp/ccfJUEvZ.ltrans0.ltrans.o: requires executable stack (because the .note.GNU-stack section is executable)^M
>> FAIL: gcc.dg/lto/pr94157 c_lto_pr94157_0.o-c_lto_pr94157_0.o link, -O0 -fipa-vrp -flto -Wa,--noexecstack -Wa,--noexecstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack
>
> This is due to a new binutils warning. This patch just suppresses the warning for the one test where we explicitly wanted an executable stack.
>
> I'm guessing the repeated -Wa,--noexecstack options in this test are supposed to trigger a buffer overflow or something similar, so I left those alone and just appended to the argument list.
Yes.
>
> I used -z execstack rather than --no-warn-execstack as the former is recognized by older versions of ld, but the latter is a new option.
Thanks for it.
Martin
>
> The other approach would have been to prune the warning, but this seemed better since we'd like most tests to fail if somehow their stacks were executable.
>
>
> Committed to the trunk.
>
> Jeff
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-25 12:56 ` Martin Liška
@ 2022-04-25 14:37 ` Jeff Law
2022-04-25 14:42 ` Nick Clifton
2022-04-26 13:54 ` Jeff Law
0 siblings, 2 replies; 10+ messages in thread
From: Jeff Law @ 2022-04-25 14:37 UTC (permalink / raw)
To: Martin Liška, gcc, binutils
On 4/25/2022 6:56 AM, Martin Liška wrote:
>
>> I used -z execstack rather than --no-warn-execstack as the former is recognized by older versions of ld, but the latter is a new option.
> Thanks for it.
Unfortunately, I should have looked at the other failures that have
popped up over the last week. Essentially all the nested function tests
are failing on some targets due to the same linker warning.
Either pruning or adding the option to all those tests is going to be
necessary ;(
jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-25 14:37 ` Jeff Law
@ 2022-04-25 14:42 ` Nick Clifton
2022-04-25 14:59 ` Jeff Law
2022-04-26 13:54 ` Jeff Law
1 sibling, 1 reply; 10+ messages in thread
From: Nick Clifton @ 2022-04-25 14:42 UTC (permalink / raw)
To: Jeff Law, Martin Liška, gcc, binutils
Hi Jeff,
>>> I used -z execstack rather than --no-warn-execstack as the former is recognized by older versions of ld, but the latter is a new option.
>> Thanks for it.
> Unfortunately, I should have looked at the other failures that have popped up over the last week. Essentially all the nested function tests are failing on some targets due
> to the same linker warning.
>
> Either pruning or adding the option to all those tests is going to be necessary ;(
Sorry for causing you so much hassle. If it helps, Alan has already added
some pruning code to binutils/testsuite/lib/binutils-common.exp in the
prune_extra_warnings proc...
Cheers
Nick
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-25 14:42 ` Nick Clifton
@ 2022-04-25 14:59 ` Jeff Law
2022-04-25 15:26 ` Nick Clifton
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Law @ 2022-04-25 14:59 UTC (permalink / raw)
To: Nick Clifton, Martin Liška, gcc, binutils
On 4/25/2022 8:42 AM, Nick Clifton wrote:
> Hi Jeff,
>
>>>> I used -z execstack rather than --no-warn-execstack as the former
>>>> is recognized by older versions of ld, but the latter is a new option.
>>> Thanks for it.
>> Unfortunately, I should have looked at the other failures that have
>> popped up over the last week. Essentially all the nested function
>> tests are failing on some targets due to the same linker warning.
>>
>> Either pruning or adding the option to all those tests is going to
>> be necessary ;(
>
> Sorry for causing you so much hassle.
No worries. It's a very reasonable warning. And it's only if you're
testing with the latest binutils that it causes problems -- which is one
of the goals of the tester -- to find this stuff when it happens, not
6-12 months later.
> If it helps, Alan has already added
> some pruning code to binutils/testsuite/lib/binutils-common.exp in the
> prune_extra_warnings proc...
Yea. I saw that. I ultimately decided against pruning as it would be
useful to know if a test suddenly needs execstack. That would
generally be a sign of something gone horribly wrong. I just (locally)
added the magic to the rest of the affected tests and I'm testing it now.
jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-25 14:59 ` Jeff Law
@ 2022-04-25 15:26 ` Nick Clifton
2022-04-25 15:30 ` Jeff Law
0 siblings, 1 reply; 10+ messages in thread
From: Nick Clifton @ 2022-04-25 15:26 UTC (permalink / raw)
To: Jeff Law, Martin Liška; +Cc: gcc, Binutils
Hi Jeff,
Just FYI - I am also looking at adding in another warning. This time for
when the linker creates a PT_LOAD segment which has all of the RWX flags
set. At the moment my testing seems to show that it only causes problems
when a custom linker script is used that defines its own program headers
and does not provide separate headers for code and data.
Cheers
Nick
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-25 15:26 ` Nick Clifton
@ 2022-04-25 15:30 ` Jeff Law
2022-05-26 1:17 ` Hans-Peter Nilsson
0 siblings, 1 reply; 10+ messages in thread
From: Jeff Law @ 2022-04-25 15:30 UTC (permalink / raw)
To: Nick Clifton, Martin Liška; +Cc: gcc, Binutils
On 4/25/2022 9:26 AM, Nick Clifton wrote:
> Hi Jeff,
>
> Just FYI - I am also looking at adding in another warning. This
> time for
> when the linker creates a PT_LOAD segment which has all of the RWX
> flags
> set. At the moment my testing seems to show that it only causes
> problems
> when a custom linker script is used that defines its own program
> headers
> and does not provide separate headers for code and data.
That also sounds quite reasonable. My biggest worry would be the
embedded targets which have their own linker scripts -- but like the
executable stack warning, I think you should go for it and we'll deal
with the fallout.
jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-25 15:30 ` Jeff Law
@ 2022-05-26 1:17 ` Hans-Peter Nilsson
2022-05-26 23:17 ` Hans-Peter Nilsson
0 siblings, 1 reply; 10+ messages in thread
From: Hans-Peter Nilsson @ 2022-05-26 1:17 UTC (permalink / raw)
To: binutils; +Cc: Jeff Law, nickc, mliska, gcc
> From: Jeff Law via Binutils <binutils@sourceware.org>
> Date: Mon, 25 Apr 2022 17:30:59 +0200
> On 4/25/2022 9:26 AM, Nick Clifton wrote:
> > Hi Jeff,
> >
> > Just FYI - I am also looking at adding in another warning. This
> > time for
> > when the linker creates a PT_LOAD segment which has all of the RWX
> > flags
> > set. At the moment my testing seems to show that it only causes
> > problems
> > when a custom linker script is used that defines its own program
> > headers
> > and does not provide separate headers for code and data.
> That also sounds quite reasonable. My biggest worry would be the
> embedded targets which have their own linker scripts -- but like the
> executable stack warning, I think you should go for it and we'll deal
> with the fallout.
(Looks like I'm first to be hit by the
--enable-warn-rwx-segments default, or the first one to
bother, lucky me.)
So, with my autotester for cris-elf not able to update
binutils on its own because of all the warnings in the gcc
test-suite (all code and data get a single LOAD header,
which naturally is RWX), let's discuss a method for a
binutils target to default turn off this
configure-time-default-on warning. I just don't think its
reasonable to require an extra configure option for the
intended default behavior for a target.
How about the usual method, a line in the ld emulparams
file for the target?
brgds, H-P
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-05-26 1:17 ` Hans-Peter Nilsson
@ 2022-05-26 23:17 ` Hans-Peter Nilsson
0 siblings, 0 replies; 10+ messages in thread
From: Hans-Peter Nilsson @ 2022-05-26 23:17 UTC (permalink / raw)
To: binutils, gcc
> From: Hans-Peter Nilsson <Hans-Peter.Nilsson@axis.com>
> Date: Thu, 26 May 2022 03:17:01 +0200
Regarding setting the default for the RWX-segment warning
per-target:
> How about the usual method, a line in the ld emulparams
> file for the target?
JFTR: no extra infrastructure bits needed. I found the
right spot, just a trivial clause in ld/configure.tgt.
brgds, H-P
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [committed] exec-stack warning for test which wants executable stacks
2022-04-25 14:37 ` Jeff Law
2022-04-25 14:42 ` Nick Clifton
@ 2022-04-26 13:54 ` Jeff Law
1 sibling, 0 replies; 10+ messages in thread
From: Jeff Law @ 2022-04-26 13:54 UTC (permalink / raw)
To: Martin Liška, gcc, binutils
On 4/25/2022 8:37 AM, Jeff Law wrote:
>
>
> On 4/25/2022 6:56 AM, Martin Liška wrote:
>>
>>> I used -z execstack rather than --no-warn-execstack as the former is
>>> recognized by older versions of ld, but the latter is a new option.
>> Thanks for it.
> Unfortunately, I should have looked at the other failures that have
> popped up over the last week. Essentially all the nested function
> tests are failing on some targets due to the same linker warning.
>
> Either pruning or adding the option to all those tests is going to be
> necessary ;(
And -z execstack is not universally accepted either. In fact, we even
have some elf targets that don't support it due to oversights (?) in
their linker configurations. But the key thing AFAICT is that -z
execstack is an ELF specific flag (I didn't know that until just now).
So we can't really depend on it across the board. In fact, I wouldn't
be surprised if AIX has regressed on the one file I adjusted earlier.
So I think that means we're stuck with the less desirable option of
pruning the output. I'll take care of it and reverting the change that
added -z execstack to the one test.
jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-05-26 23:17 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24 17:42 [committed] exec-stack warning for test which wants executable stacks Jeff Law
2022-04-25 12:56 ` Martin Liška
2022-04-25 14:37 ` Jeff Law
2022-04-25 14:42 ` Nick Clifton
2022-04-25 14:59 ` Jeff Law
2022-04-25 15:26 ` Nick Clifton
2022-04-25 15:30 ` Jeff Law
2022-05-26 1:17 ` Hans-Peter Nilsson
2022-05-26 23:17 ` Hans-Peter Nilsson
2022-04-26 13:54 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).