-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[PAC][lld][AArch64][ELF] Support signed GOT #96169
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
71cdd36
[PAC][lld][AArch64][ELF] Support signed GOT
kovdan01 5ae637c
Merge branch 'main' into pauth-signed-got-lld
kovdan01 dca427b
Address review comments
kovdan01 586cd40
Merge branch 'main' into pauth-signed-got-lld
kovdan01 f7e184c
Fix relocs names according to #96158
kovdan01 679848a
Merge branch 'main' into pauth-signed-got-lld
kovdan01 5fab582
Merge branch 'main' into pauth-signed-got-lld
kovdan01 15225ee
Use `ctx.arg` instead of `config`
kovdan01 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
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
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
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 |
---|---|---|
|
@@ -131,6 +131,11 @@ class GotSection final : public SyntheticSection { | |
size_t numEntries = 0; | ||
uint32_t tlsIndexOff = -1; | ||
uint64_t size = 0; | ||
struct AuthEntryInfo { | ||
size_t offset; | ||
bool isSymbolFunc; | ||
}; | ||
SmallVector<AuthEntryInfo> authEntries; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, thanks, see dca427b |
||
}; | ||
|
||
// .note.GNU-stack section. | ||
|
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,94 @@ | ||
# REQUIRES: aarch64 | ||
|
||
# RUN: rm -rf %t && split-file %s %t && cd %t | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %p/Inputs/shared.s -o a.o | ||
# RUN: ld.lld -shared a.o -o a.so | ||
|
||
#--- ok.s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux ok.s -o ok.o | ||
|
||
# RUN: ld.lld ok.o a.so -pie -o external | ||
# RUN: llvm-readelf -r -S -x .got external | FileCheck %s --check-prefix=EXTERNAL | ||
|
||
# RUN: ld.lld ok.o a.o -pie -o local | ||
# RUN: llvm-readelf -r -S -x .got -s local | FileCheck %s --check-prefix=LOCAL | ||
|
||
# EXTERNAL: Offset Info Type Symbol's Value Symbol's Name + Addend | ||
# EXTERNAL-NEXT: 0000000000020380 000000010000e201 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 bar + 0 | ||
# EXTERNAL-NEXT: 0000000000020388 000000020000e201 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 zed + 0 | ||
|
||
## Symbol's values for bar and zed are equal since they contain no content (see Inputs/shared.s) | ||
# LOCAL: Offset Info Type Symbol's Value Symbol's Name + Addend | ||
# LOCAL-NEXT: 0000000000020320 0000000000000411 R_AARCH64_AUTH_RELATIVE 10260 | ||
# LOCAL-NEXT: 0000000000020328 0000000000000411 R_AARCH64_AUTH_RELATIVE 10260 | ||
|
||
# EXTERNAL: Hex dump of section '.got': | ||
# EXTERNAL-NEXT: 0x00020380 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 | ||
|
||
# LOCAL: Symbol table '.symtab' contains {{.*}} entries: | ||
# LOCAL: Num: Value Size Type Bind Vis Ndx Name | ||
# LOCAL: 0000000000010260 0 FUNC GLOBAL DEFAULT 6 bar | ||
# LOCAL: 0000000000010260 0 NOTYPE GLOBAL DEFAULT 6 zed | ||
|
||
# LOCAL: Hex dump of section '.got': | ||
# LOCAL-NEXT: 0x00020320 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 | ||
|
||
# RUN: llvm-objdump -d external | FileCheck %s --check-prefix=EXTERNAL-ASM | ||
|
||
# EXTERNAL-ASM: <_start>: | ||
# EXTERNAL-ASM-NEXT: adrp x0, 0x20000 | ||
# EXTERNAL-ASM-NEXT: ldr x0, [x0, #0x380] | ||
# EXTERNAL-ASM-NEXT: adrp x1, 0x20000 | ||
# EXTERNAL-ASM-NEXT: add x1, x1, #0x380 | ||
# EXTERNAL-ASM-NEXT: adrp x0, 0x20000 | ||
# EXTERNAL-ASM-NEXT: ldr x0, [x0, #0x388] | ||
# EXTERNAL-ASM-NEXT: adrp x1, 0x20000 | ||
# EXTERNAL-ASM-NEXT: add x1, x1, #0x388 | ||
|
||
# RUN: llvm-objdump -d local | FileCheck %s --check-prefix=LOCAL-ASM | ||
|
||
# LOCAL-ASM: <_start>: | ||
# LOCAL-ASM-NEXT: adrp x0, 0x20000 | ||
# LOCAL-ASM-NEXT: ldr x0, [x0, #0x320] | ||
# LOCAL-ASM-NEXT: adrp x1, 0x20000 | ||
# LOCAL-ASM-NEXT: add x1, x1, #0x320 | ||
# LOCAL-ASM-NEXT: adrp x0, 0x20000 | ||
# LOCAL-ASM-NEXT: ldr x0, [x0, #0x328] | ||
# LOCAL-ASM-NEXT: adrp x1, 0x20000 | ||
# LOCAL-ASM-NEXT: add x1, x1, #0x328 | ||
|
||
.globl _start | ||
_start: | ||
adrp x0, :got_auth:bar | ||
ldr x0, [x0, :got_auth_lo12:bar] | ||
adrp x1, :got_auth:bar | ||
add x1, x1, :got_auth_lo12:bar | ||
adrp x0, :got_auth:zed | ||
ldr x0, [x0, :got_auth_lo12:zed] | ||
adrp x1, :got_auth:zed | ||
add x1, x1, :got_auth_lo12:zed | ||
|
||
#--- err.s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux err.s -o err.o | ||
|
||
# RUN: not ld.lld err.o a.so -pie -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR | ||
|
||
# ERR: error: both AUTH and non-AUTH GOT entries for 'bar' requested, but only one type of GOT entry per symbol is supported | ||
|
||
.globl _start | ||
_start: | ||
adrp x0, :got_auth:bar | ||
ldr x0, [x0, :got_auth_lo12:bar] | ||
adrp x0, :got:bar | ||
ldr x0, [x0, :got_lo12:bar] |
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.
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.
This assert and the above assert are not useful.
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.
I've deleted the assert, thanks, see dca427b.
Regarding the assertion above - I'll delete that and similar ones in
addTlsDescEntry
andaddDynTlsEntry
if they are considered useless (I just don't want to mess new features with refactoring existing code).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.
Update. Opened #98028 deleting similar assertions in
GotSection::addEntry
GotSection::addTlsDescEntry
GotSection::addDynTlsEntry
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.
assert(sym.auxIdx == symAux.size() - 1);
assertions are useful to prevent allocating more than one entries for one symbol. I used the assertions to prevent some failures.NEEDS_GOT_AUTH
is clearly AArch64 specific.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.
I probably misunderstood your phrase "and the above assert are not useful" - I thought you mean the one I deleted in #98028. Thanks for explaining your point, now I get what you meant.
The aarch64-specific useless assert was deleted, see dca427b