New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AArch64] .note.gnu.property always generated for object file without code #45825
Comments
assigned to @DanielKristofKiss |
This patch will fix this: https://reviews.llvm.org/D80791 |
I don't think this is a bug. From the Arm ELF64 ABI(2020Q2) we have first from "GNU_PROPERTY_AARCH64_FEATURE_1_AND describes a set of processor features with Certainly an object that contains no code is compatible with the PAC and BTI "Static linkers processing ELF relocatable objects must set the feature bit If the compiler didn't set those feature bits in an object file, which did not |
Also |
This behaviour is in spec but from a practical deployment point of view I don't think it's good - at present we have the latest release of at least Debian (which is pretty widely used, especially on arm64) shipping a version of binutils that complains loudly any time it sees one of the notes but there's no way to stop the compiler emitting them. The fact that Debian is affected is especially unfortunate since it's quite commonly used as a basis for Docker containers used in CI systems. The kernel is passing -mbranch-protection=none for separate reasons, it's doing it because the compiler might not default to none (eg, a distribution trying to get everything built with branch protection) but this can cause issues if the kernel is not expecting it (eg, if we have userspace but not kernel mode PAC any PAC instructions in the kernel will crash). |
Equivalently, there's no way of stopping the linker from emitting the warnings, I presume. I absolutely agree there is a problem that we need to solve, but so far I'm not convinced that the problem is in the specification or the compiler. It's in the linker. |
Not that we're aware of.
Or the packaging of the compiler - if we're saying an updated linker is required then distributions of the compiler such as provided by llvm.org really ought to be ensuring that a suitable linker is available. Unfortunately lld still seems to have issues building the kernel and isn't used by default: $ clang-11 -target aarch64-linux-gnu /tmp/foo.c /tmp/bar.c |
Extended Description
The .note.gnu.property is generated even when -mbranch-protection=none is used, on a source file that only has data (no code).
$ cat foo.c
int global = 5;
$ clang --target=aarch64-linux-gnu -c -o foo.o foo.c
$ readelf -n foo.o
Displaying notes found in: .note.gnu.property
Owner Data size Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: AArch64 feature: BTI, PAC
$ clang --target=aarch64-linux-gnu -mbranch-protection=none -c -o foo.o foo.c
$ readelf -n foo.o
Displaying notes found in: .note.gnu.property
Owner Data size Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: AArch64 feature: BTI, PAC
$ aarch64-linux-gnu-gcc -c -o foo.o foo.c
$ readelf -n foo.o
$ aarch64-linux-gnu-gcc -mbranch-protection=bti -c -o foo.o foo.c
$ readelf -n foo.o
Displaying notes found in: .note.gnu.property
Owner Data size Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: AArch64 feature: BTI
$ cat bar.c
int code(void) { return 5; }
$ clang --target=aarch64-linux-gnu -c -o bar.o bar.c
$ readelf -n bar.o
$ clang --target=aarch64-linux-gnu -mbranch-protection=bti -c -o bar.o bar.c
$ readelf -n bar.o
Displaying notes found in: .note.gnu.property
Owner Data size Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: AArch64 feature: BTI
The text was updated successfully, but these errors were encountered: