exercism / x86-64-assembly

Exercism exercises in x86-64 Assembly.
https://exercism.org/tracks/x86-64-assembly
MIT License
22 stars 18 forks source link

Exercises won't work without .note.GNU-stack section under linux #160

Closed 0x28 closed 2 years ago

0x28 commented 2 years ago

Hi, I have the following problem since I upgraded to binutils 2.38:

/usr/bin/ld: warning: matching_brackets.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
collect2: error: ld returned 1 exit status
make: *** [Makefile:29: tests] Error 1

This is happening for every exercise not just for matching-brackets. Adding -Wl,--no-warn-execstack to the ALL_LDFLAGS in the Makefile solves this problem for now. Judging by the deprecation warning this won't be a long term solution.

bergjohan commented 2 years ago

Hi, thanks for opening an issue on this, interesting..

Searching for note gnu stack, I found the following: https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart

The interesting part is the section "How to fix the stack (in practice)".

TL;DR we should add the following at the end of all assembly files:

section .note.GNU-stack noalloc noexec nowrite progbits

Could you verify that this solves the problem?

0x28 commented 2 years ago

That would be a solution. I tried it with several exercises and it works flawlessly every time.

bergjohan commented 2 years ago

Cool, thanks! If you'd like to make a PR, I'd be happy to review it. Otherwise I'll try to fix this when I find some time.