public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/107971] New: linking an assembler object creates an executable stack @ 2022-12-05 9:07 contact@alexander-pick.com 2022-12-05 9:19 ` [Bug c/107971] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: contact@alexander-pick.com @ 2022-12-05 9:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107971 Bug ID: 107971 Summary: linking an assembler object creates an executable stack Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: contact@alexander-pick.com Target Milestone: --- Created attachment 54011 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54011&action=edit simple testcase for the issue I encountered a strange behavior with gcc and linking an assembler object. Doing so will create a binary with executable stack. A testcase is attached. The code will compile a very simple assembler file as an object and link it to an object compiled from C. The binary will have an executable stack by default which isn't that great from a security point of view. Setting "-z noexecstack" as a workaround is the only way to prevent this. 31: STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4 32- filesz 0x0000000000000000 memsz 0x0000000000000000 flags rwx ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/107971] linking an assembler object creates an executable stack 2022-12-05 9:07 [Bug c/107971] New: linking an assembler object creates an executable stack contact@alexander-pick.com @ 2022-12-05 9:19 ` pinskia at gcc dot gnu.org 2022-12-05 9:21 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-05 9:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107971 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Gcc just invokes the assembly. The problem is legacy assembly code might still use an executable stack. Best way to fix this is for you to add the option. There is nothing gcc is going to change to be different here. Also the assembler is not part of gcc. Most likely you are using gnu binutils. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/107971] linking an assembler object creates an executable stack 2022-12-05 9:07 [Bug c/107971] New: linking an assembler object creates an executable stack contact@alexander-pick.com 2022-12-05 9:19 ` [Bug c/107971] " pinskia at gcc dot gnu.org @ 2022-12-05 9:21 ` pinskia at gcc dot gnu.org 2022-12-05 9:58 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-05 9:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107971 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- You can use the assembler note to communicate to the linker that the assembly code does not use executable stack. This is all documented in the linker documentation and is not part of gcc documentation. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/107971] linking an assembler object creates an executable stack 2022-12-05 9:07 [Bug c/107971] New: linking an assembler object creates an executable stack contact@alexander-pick.com 2022-12-05 9:19 ` [Bug c/107971] " pinskia at gcc dot gnu.org 2022-12-05 9:21 ` pinskia at gcc dot gnu.org @ 2022-12-05 9:58 ` pinskia at gcc dot gnu.org 2022-12-05 10:22 ` contact@alexander-pick.com 2022-12-05 12:45 ` amonakov at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-05 9:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107971 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- https://sourceware.org/binutils/docs-2.39/ld/Options.html#index-_002d_002dwarn_002dexecstack ``` Note: ELF format input files specify that they need an executable stack by having a .note.GNU-stack section with the executable bit set in its section flags. They can specify that they do not need an executable stack by having that section, but without the executable flag bit set. If an input file does not have a .note.GNU-stack section present then the default behaviour is target specific. For some targets, then absence of such a section implies that an executable stack is required. ****This is often a problem for hand crafted assembler files.**** ``` Added emphasize is mine. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/107971] linking an assembler object creates an executable stack 2022-12-05 9:07 [Bug c/107971] New: linking an assembler object creates an executable stack contact@alexander-pick.com ` (2 preceding siblings ...) 2022-12-05 9:58 ` pinskia at gcc dot gnu.org @ 2022-12-05 10:22 ` contact@alexander-pick.com 2022-12-05 12:45 ` amonakov at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: contact@alexander-pick.com @ 2022-12-05 10:22 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107971 --- Comment #4 from Alexander Pick <contact@alexander-pick.com> --- Thanks a lot for the explanation. Do you think that it is worth reporting it to binutils as the text in the link also says that there should be a warning unless the option to have an executable stack is explicitly specified? In the test case there is no such warning. I also tried to link the objects with LD directly - same result and also no warning. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/107971] linking an assembler object creates an executable stack 2022-12-05 9:07 [Bug c/107971] New: linking an assembler object creates an executable stack contact@alexander-pick.com ` (3 preceding siblings ...) 2022-12-05 10:22 ` contact@alexander-pick.com @ 2022-12-05 12:45 ` amonakov at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: amonakov at gcc dot gnu.org @ 2022-12-05 12:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107971 Alexander Monakov <amonakov at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amonakov at gcc dot gnu.org --- Comment #5 from Alexander Monakov <amonakov at gcc dot gnu.org> --- The warning is new in binutils-2.39 (the latest release at this time), perhaps your linker is older. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-05 12:45 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-12-05 9:07 [Bug c/107971] New: linking an assembler object creates an executable stack contact@alexander-pick.com 2022-12-05 9:19 ` [Bug c/107971] " pinskia at gcc dot gnu.org 2022-12-05 9:21 ` pinskia at gcc dot gnu.org 2022-12-05 9:58 ` pinskia at gcc dot gnu.org 2022-12-05 10:22 ` contact@alexander-pick.com 2022-12-05 12:45 ` amonakov at gcc dot gnu.org
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).