-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[PAC][ELF][AArch64] Support signed personality function pointer #119361
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
3 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 |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=OFF | ||
| // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-elf-got -emit-llvm %s -o - | FileCheck %s --check-prefix=ELFGOT | ||
| // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm %s -o - | FileCheck %s --check-prefix=PERSONALITY | ||
|
|
||
| // ELFGOT: !llvm.module.flags = !{ | ||
| // ELFGOT-SAME: !1 | ||
| // ELFGOT: !1 = !{i32 8, !"ptrauth-elf-got", i32 1} | ||
|
|
||
| // PERSONALITY: !llvm.module.flags = !{ | ||
| // PERSONALITY-SAME: !1 | ||
| // PERSONALITY: !1 = !{i32 8, !"ptrauth-sign-personality", i32 1} | ||
|
|
||
| // OFF-NOT: "ptrauth- |
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 |
|---|---|---|
|
|
@@ -413,7 +413,8 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol( | |
| } | ||
|
|
||
| void TargetLoweringObjectFileELF::emitPersonalityValue( | ||
| MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const { | ||
| MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, | ||
| const MachineModuleInfo *MMI) const { | ||
| SmallString<64> NameData("DW.ref."); | ||
| NameData += Sym->getName(); | ||
| MCSymbolELF *Label = | ||
|
|
@@ -431,6 +432,13 @@ void TargetLoweringObjectFileELF::emitPersonalityValue( | |
| Streamer.emitELFSize(Label, E); | ||
| Streamer.emitLabel(Label); | ||
|
|
||
| emitPersonalityValueImpl(Streamer, DL, Sym, MMI); | ||
| } | ||
|
|
||
| void TargetLoweringObjectFileELF::emitPersonalityValueImpl( | ||
| MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, | ||
| const MachineModuleInfo *MMI) const { | ||
| unsigned Size = DL.getPointerSize(); | ||
|
||
| Streamer.emitSymbolValue(Sym, Size); | ||
| } | ||
|
|
||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| ; RUN: rm -rf %t && split-file %s %t && cd %t | ||
| ; RUN: cat common.ll authflag.ll > auth.ll | ||
| ; RUN: cat common.ll noauthflag.ll > noauth1.ll | ||
| ; RUN: cat common.ll > noauth2.ll | ||
|
|
||
| ; RUN: llc -mtriple=aarch64-linux -filetype=asm auth.ll -o - | \ | ||
| ; RUN: FileCheck --check-prefix=AUTH-ASM %s | ||
| ; RUN: llc -mtriple=aarch64-linux -filetype=obj auth.ll -o - | \ | ||
| ; RUN: llvm-readelf -r -x .data.DW.ref.__gxx_personality_v0 - | \ | ||
| ; RUN: FileCheck --check-prefix=AUTH-RELOC %s | ||
|
|
||
| ; AUTH-ASM: DW.ref.__gxx_personality_v0: | ||
| ; AUTH-ASM-NEXT: .xword __gxx_personality_v0@AUTH(ia,32429,addr) | ||
|
|
||
| ; AUTH-RELOC: Relocation section '.rela.data.DW.ref.__gxx_personality_v0' at offset 0x2a0 contains 1 entries: | ||
| ; AUTH-RELOC-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend | ||
| ; AUTH-RELOC-NEXT: 0000000000000000 0000000f00000244 R_AARCH64_AUTH_ABS64 0000000000000000 __gxx_personality_v0 + 0 | ||
|
|
||
| ; AUTH-RELOC: Hex dump of section '.data.DW.ref.__gxx_personality_v0': | ||
| ; AUTH-RELOC-NEXT: 0x00000000 00000000 ad7e0080 | ||
| ; ^^^^ 0x7EAD = discriminator | ||
| ; ^^ 0b10000000: bit 63 = 1 -> address diversity enabled, bits 61:60 = 0b00 -> key is IA | ||
|
|
||
| ; RUN: llc -mtriple=aarch64-linux -filetype=asm noauth1.ll -o - | \ | ||
| ; RUN: FileCheck --check-prefix=NOAUTH-ASM %s | ||
| ; RUN: llc -mtriple=aarch64-linux -filetype=obj noauth1.ll -o - | \ | ||
| ; RUN: llvm-readelf -r -x .data.DW.ref.__gxx_personality_v0 - | \ | ||
| ; RUN: FileCheck --check-prefix=NOAUTH-RELOC %s | ||
|
|
||
| ; RUN: llc -mtriple=aarch64-linux -filetype=asm noauth2.ll -o - | \ | ||
| ; RUN: FileCheck --check-prefix=NOAUTH-ASM %s | ||
| ; RUN: llc -mtriple=aarch64-linux -filetype=obj noauth2.ll -o - | \ | ||
| ; RUN: llvm-readelf -r -x .data.DW.ref.__gxx_personality_v0 - | \ | ||
| ; RUN: FileCheck --check-prefix=NOAUTH-RELOC %s | ||
|
|
||
| ; NOAUTH-ASM: DW.ref.__gxx_personality_v0: | ||
| ; NOAUTH-ASM-NEXT: .xword __gxx_personality_v0{{$}} | ||
|
|
||
| ; NOAUTH-RELOC: Relocation section '.rela.data.DW.ref.__gxx_personality_v0' at offset 0x2a0 contains 1 entries: | ||
| ; NOAUTH-RELOC-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend | ||
| ; NOAUTH-RELOC-NEXT: 0000000000000000 0000000f00000101 R_AARCH64_ABS64 0000000000000000 __gxx_personality_v0 + 0 | ||
|
|
||
| ; NOAUTH-RELOC: Hex dump of section '.data.DW.ref.__gxx_personality_v0': | ||
| ; NOAUTH-RELOC-NEXT: 0x00000000 00000000 00000000 | ||
|
|
||
| ;--- common.ll | ||
| @_ZTISt9exception = external constant ptr | ||
|
|
||
| define i32 @main() personality ptr @__gxx_personality_v0 { | ||
| entry: | ||
| invoke void @foo() to label %cont unwind label %lpad | ||
|
|
||
| lpad: | ||
| %0 = landingpad { ptr, i32 } | ||
| catch ptr null | ||
| catch ptr @_ZTISt9exception | ||
| ret i32 0 | ||
|
|
||
| cont: | ||
| ret i32 0 | ||
| } | ||
|
|
||
| declare i32 @__gxx_personality_v0(...) | ||
|
|
||
| declare void @foo() | ||
|
|
||
| ;--- authflag.ll | ||
| !llvm.module.flags = !{!0} | ||
| !0 = !{i32 8, !"ptrauth-sign-personality", i32 1} | ||
|
|
||
| ;--- noauthflag.ll | ||
| !llvm.module.flags = !{!0} | ||
| !0 = !{i32 8, !"ptrauth-sign-personality", i32 0} |
Oops, something went wrong.
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.
HasSignedPersonality = Flag && ... == 1