Skip to content

-Wa,--noexecstack does not emit .note.GNU-stack section #186004

Description

@jtschuster

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());

Metadata

Metadata

Assignees

Labels

clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'llvm:mcMachine (object) code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions