Re: linking an assembler object creates an executable stack

2022-12-05 Thread Nick Clifton

Hi Alexander,


During development of a project I noticed that linking a object created
from assembler to another object created from C code results in a
binary with executable stack.


Blowing my own trumpet slightly, I wrote a blog about this kind of problem
which might be of help:

https://www.redhat.com/en/blog/linkers-warnings-about-executable-stacks-and-segments

Cheers
  Nick





Re: linking an assembler object creates an executable stack

2022-12-05 Thread Andreas Schwab
2.39

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



Re: linking an assembler object creates an executable stack

2022-12-05 Thread Alexander Pick
Thanks for the email. Is this a recent change, which ld version is
this? I use 2.38 which is current Ubuntu one on 22.04 LTS.

On Mon, 2022-12-05 at 15:43 +0100, Andreas Schwab wrote:
> On Dez 05 2022, Alexander Pick wrote:
> 
> > There is also no warning that the stack is executable during the
> > process.
> 
> /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-
> linux/bin/ld: warning: test2.o: missing .note.GNU-stack section
> implies executable stack
> /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-
> linux/bin/ld: NOTE: This behaviour is deprecated and will be removed
> in a future version of the linker
> 



Re: linking an assembler object creates an executable stack

2022-12-05 Thread Andreas Schwab
On Dez 05 2022, Alexander Pick wrote:

> There is also no warning that the stack is executable during the
> process.

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: 
warning: test2.o: missing .note.GNU-stack section implies executable stack
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: NOTE: 
This behaviour is deprecated and will be removed in a future version of the 
linker

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



linking an assembler object creates an executable stack

2022-12-05 Thread Alexander Pick
I reported this behaviour to the gcc team, but they told me it's rather
related to binutils. So I wanted to leave a note here.

Reference to the gcc ticket:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107971

During development of a project I noticed that linking a object created
from assembler to another object created from C code results in a
binary with executable stack.

There is also no warning that the stack is executable during the
process. From the documentation it reads as if there should be one: 

"On the other hand the linker will normally warn if the stack is made
executable"

Ref:
https://sourceware.org/binutils/docs-2.39/ld/Options.html#index-_002d_002dwarn_002dexecstack

In my case the executable stack caused some totally unrelated issues
which were very difficult to debug.

I attached a testcase which demonstrates the issue. The testcase uses
gcc for linking but using ld directly has the same result.

Even if this is intended behaviour, the mentioned warning that the
stack is now executable would be nice to have.

Thanks,
Alex


testcase.tgz
Description: testcase.tgz