-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[PAC][ThinLTO] Fix auth key for GOT entries of function symbols #131467
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| ; REQUIRES: aarch64 | ||
|
|
||
| ; RUN: llvm-as %s -o %t.o | ||
| ; RUN: ld.lld %t.o -shared -o %t | ||
| ; RUN: llvm-readelf -r -x.got %t | FileCheck %s | ||
|
|
||
| ; CHECK: Relocation section '.rela.dyn' at offset 0x2a8 contains 2 entries: | ||
| ; CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend | ||
| ; CHECK-NEXT: 00000000000203d8 0000000100000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 foo + 0 | ||
| ; CHECK-NEXT: 00000000000203e0 0000000200000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 var + 0 | ||
|
|
||
| ; CHECK: Hex dump of section '.got': | ||
| ; CHECK-NEXT: 0x000203d8 00000000 00000080 00000000 000000a0 | ||
| ;; ^^ 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA | ||
| ;; ^^ 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA | ||
|
|
||
| target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
| target triple = "aarch64-unknown-linux-gnu" | ||
|
|
||
| @var = external global ptr | ||
|
|
||
| declare void @foo() | ||
|
|
||
| define void @bar() #0 { | ||
| entry: | ||
| store ptr ptrauth (ptr @foo, i32 0), ptr @var | ||
| ret void | ||
| } | ||
|
|
||
| define void @_start() { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = {"target-features"="+pauth"} | ||
|
|
||
| !llvm.module.flags = !{!0} | ||
| !0 = !{i32 8, !"ptrauth-elf-got", i32 1} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps rename var to something else then add
Use llvm.used so that the symbols will not be optimized out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm doing smth wrong, but it looks like that
llvm.usedhas no effect and only the symbol from the last store operation is present in GOT. This is what I've added to the code (right before@bardefinition, just in case):Adding
@gto this array, removingsection "llvm.metadata", moving this array definition to the end of the file does not change the behavior.This smells like a bug, given
llvm.useddescription from IR reference: https://llvm.org/docs/LangRef.html#the-llvm-used-global-variable.@MaskRay does this look like a bug for you as well, or maybe I'm just mis-using this special array?
As for now, I've just used a separate global for each store - g1, g2, g3, g4. Not elegant, but at least it works :)