Skip to content

symbol-check: Only ELFv1 ppc64 doesn't set .note.GNU-stack#1215

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
Gelbpunkt:ppc64-symbol-check
May 26, 2026
Merged

symbol-check: Only ELFv1 ppc64 doesn't set .note.GNU-stack#1215
tgross35 merged 1 commit into
rust-lang:mainfrom
Gelbpunkt:ppc64-symbol-check

Conversation

@Gelbpunkt
Copy link
Copy Markdown
Contributor

powerpc64-unknown-linux-gnu currently is an ELFv1 target, while powerpc64-unknown-linux-musl is an ELFv2 target.

Big-endian and little-endian ELFv2 targets both behave normally: they emit .note.GNU-stack. Therefore, currently the tests would fail on big-endian powerpc64 with ELFv2 ABI.

To determine whether we need to special-case powerpc64, we should check the ABI instead of the endianness. The problem here is that the e_flags part of the ELF header is actually 0 in the output of cc -O0 -ffunction-sections -fdata-sections -fPIC -m64 -mabi=elfv2 -Wall -Wextra -o missing_gnu_stack_section.o -c missing_gnu_stack_section.S, the output of that command is bit-for-bit identical on ELFv1 and ELFv2 hosts. In order to know when to allow an unset .note.GNU-stack we therefore must set .abiversion 2 to be able to tell them apart from the ELF header.

This makes all tests pass on powerpc64-unknown-linux-musl.

@Gelbpunkt
Copy link
Copy Markdown
Contributor Author

Successful powerpc64-unknown-linux-musl CI run: https://github.com/Gelbpunkt/compiler-builtins/actions/runs/25989194981/job/76392149895

Copy link
Copy Markdown
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh awesome, I'm very glad you were able to add some context because I was struggling to find it. One question then LGTM.

View changes since this review

Comment thread crates/symbol-check/src/main.rs Outdated
@Gelbpunkt Gelbpunkt force-pushed the ppc64-symbol-check branch from 4e40e1c to 4c5cdb7 Compare May 20, 2026 22:13
Copy link
Copy Markdown
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

View changes since this review

@tgross35 tgross35 merged commit 0afa607 into rust-lang:main May 26, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants