When -Wa,--noexecstack is passed, the assembler should emit the .note.GNU-stack section (without an X flag) to indicate that the object does not require an executable stack. This is not respected in clang 22.
Simple repro:
cat > test.s << 'EOF'
.text
.globl foo
foo:
ret
EOF
# clang-22: no .note.GNU-stack emitted
clang-22 -c -Wa,--noexecstack test.s -o test.o
readelf -S test.o | grep GNU-stack # No results
# the driver is forwarding the flag to cc1as:
clang-22 -c -Wa,--noexecstack test.s -o /dev/null -###
# With clang 20 (or 18), the same commands produce an object with .note.GNU-stack:
clang-18 -c -Wa,--noexecstack test.s -o test.o
readelf -S test.o | grep GNU-stack # present
913c5b4d1fff Removed a call to InitSections that passed Opts.NoExecStack. The other calls to InitSections pass false, and Run only calls it if NoInitialTextSection is false.
|
Failed = Parser->Run(Opts.NoInitialTextSection); |
|
bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { |
|
LTODiscardSymbols.clear(); |
|
|
|
// Create the initial section, if requested. |
|
if (!NoInitialTextSection) |
|
Out.initSections(false, getTargetParser().getSTI()); |
When -Wa,--noexecstack is passed, the assembler should emit the
.note.GNU-stacksection (without an X flag) to indicate that the object does not require an executable stack. This is not respected in clang 22.Simple repro:
913c5b4d1fff Removed a call to InitSections that passed Opts.NoExecStack. The other calls to InitSections pass
false, and Run only calls it ifNoInitialTextSectionis false.llvm-project/clang/tools/driver/cc1as_main.cpp
Line 622 in 913c5b4
llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp
Lines 935 to 940 in 913c5b4