-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[RISCV] Support .note.gnu.property for enable Zicfiss and Zicfilp extension #77414
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
61aaf8d
[RISCV][ELF] Add RISCV GNU property label
SuHo-llrr 601815a
[RISCV][ELF] Emit .note.gnu.property for Zicfiss/Zicfilip(CFI extension)
SuHo-llrr 1e4142e
[llvm-readobj] Parse .note.gnu.property in RISCV for Zicfiss/Zicfilip…
SuHo-llrr 1db55d6
[LLD] Emit .note.gnu.property in RISCV for Zicfiss/Zicfilip(CFI exten…
SuHo-llrr 9363ff1
[LLD] Add force enable Zicfiss/Zicfilip(CFI extension) option
SuHo-llrr 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,9 +323,18 @@ void GnuPropertySection::writeTo(uint8_t *buf) { | |
write32(buf + 8, NT_GNU_PROPERTY_TYPE_0); // Type | ||
memcpy(buf + 12, "GNU", 4); // Name string | ||
|
||
uint32_t featureAndType = config->emachine == EM_AARCH64 | ||
? GNU_PROPERTY_AARCH64_FEATURE_1_AND | ||
: GNU_PROPERTY_X86_FEATURE_1_AND; | ||
uint32_t featureAndType = 0; | ||
switch (config->emachine) { | ||
default: | ||
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. Also change the default statement to |
||
featureAndType = GNU_PROPERTY_X86_FEATURE_1_AND; | ||
break; | ||
case EM_AARCH64: | ||
featureAndType = GNU_PROPERTY_AARCH64_FEATURE_1_AND; | ||
break; | ||
case EM_RISCV: | ||
featureAndType = GNU_PROPERTY_RISCV_FEATURE_1_AND; | ||
break; | ||
} | ||
|
||
unsigned offset = 16; | ||
if (config->andFeatures != 0) { | ||
|
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,36 @@ | ||
# REQUIRES: riscv | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=riscv32-unknown-elf %s -o %t.rv32_lp.o | ||
# RUN: ld.lld %t.rv32_lp.o -zforce-zicfilp -o %t.rv32_lp | count 0 | ||
# RUN: llvm-readobj -n %t.rv32_lp | FileCheck -check-prefix=CHECK -check-prefix=CHECK_ZICFILP %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=riscv64-unknown-elf %s -o %t.rv64_lp.o | ||
# RUN: ld.lld %t.rv64_lp.o -zforce-zicfilp -o %t.rv64_lp | count 0 | ||
# RUN: llvm-readobj -n %t.rv64_lp | FileCheck -check-prefix=CHECK -check-prefix=CHECK_ZICFILP %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=riscv32-unknown-elf %s -o %t.rv32_ss.o | ||
# RUN: ld.lld %t.rv32_ss.o -zforce-zicfiss -o %t.rv32_ss | count 0 | ||
# RUN: llvm-readobj -n %t.rv32_ss | FileCheck -check-prefix=CHECK -check-prefix=CHECK_ZICFISS %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=riscv64-unknown-elf %s -o %t.rv64_ss.o | ||
# RUN: ld.lld %t.rv64_ss.o -zforce-zicfiss -o %t.rv64_ss | count 0 | ||
# RUN: llvm-readobj -n %t.rv64_ss | FileCheck -check-prefix=CHECK -check-prefix=CHECK_ZICFISS %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=riscv32-unknown-elf %s -o %t.rv32_lp_ss.o | ||
# RUN: ld.lld %t.rv32_lp_ss.o -zforce-zicfilp -zforce-zicfiss -o %t.rv32_lp_ss | count 0 | ||
# RUN: llvm-readobj -n %t.rv32_lp_ss | FileCheck -check-prefix=CHECK -check-prefix=CHECK_ZICFILP_ZICFISS %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=riscv64-unknown-elf %s -o %t.rv64_lp_ss.o | ||
# RUN: ld.lld %t.rv64_lp_ss.o -zforce-zicfilp -zforce-zicfiss -o %t.rv64_lp_ss | count 0 | ||
# RUN: llvm-readobj -n %t.rv64_lp_ss | FileCheck -check-prefix=CHECK -check-prefix=CHECK_ZICFILP_ZICFISS %s | ||
|
||
|
||
|
||
// CHECK: Name: .note.gnu.property | ||
// CHECK: Type: NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// CHECK: Property [ | ||
// CHECK_ZICFISS: riscv feature: Zicfiss | ||
// CHECK_ZICFILP: riscv feature: Zicfilp | ||
// CHECK_ZICFILP_ZICFISS: riscv feature: Zicfilp, Zicfiss | ||
// CHECK: ] | ||
|
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
78 changes: 78 additions & 0 deletions
78
llvm/test/tools/llvm-readobj/ELF/RISCV/riscv-cfi-property.s
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,78 @@ | ||
# RUN: rm -rf %t && split-file %s %t && cd %t | ||
|
||
#--- gnu-property-riscv32.s | ||
// RUN: llvm-mc -triple riscv32 -filetype obj gnu-property-riscv32.s -o gnu-property-riscv32.o | ||
// RUN: llvm-readobj -n gnu-property-riscv32.o | FileCheck -check-prefix=LLVM gnu-property-riscv32.s | ||
// RUN: llvm-readobj -n --elf-output-style=GNU gnu-property-riscv32.o | FileCheck -check-prefix=GNU gnu-property-riscv32.s | ||
|
||
|
||
// LLVM: Notes [ | ||
// LLVM-NEXT: NoteSection { | ||
// LLVM-NEXT: Name: .note.gnu.property | ||
// LLVM-NEXT: Offset: 0x34 | ||
// LLVM-NEXT: Size: 0x1C | ||
// LLVM-NEXT: Note { | ||
// LLVM-NEXT: Owner: GNU | ||
// LLVM-NEXT: Data size: 0xC | ||
// LLVM-NEXT: Type: NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// LLVM-NEXT: Property [ | ||
// LLVM-NEXT: riscv feature: Zicfilp, Zicfiss | ||
// LLVM-NEXT: ] | ||
// LLVM-NEXT: } | ||
// LLVM-NEXT: } | ||
// LLVM-NEXT: ] | ||
|
||
// GNU: Displaying notes found in: .note.gnu.property | ||
// GNU-NEXT: Owner Data size Description | ||
// GNU-NEXT: GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// GNU-NEXT: Properties: riscv feature: Zicfilp, Zicfiss | ||
|
||
// GNU Note Section Example | ||
.section .note.gnu.property, "a" | ||
.p2align 2 | ||
.long 4 | ||
.long 12; | ||
.long 5 | ||
.asciz "GNU" | ||
.long 0xc0000000 | ||
.long 4 | ||
.long 3 | ||
|
||
#--- gnu-property-riscv64.s | ||
// RUN: llvm-mc -triple riscv64 -filetype obj gnu-property-riscv64.s -o gnu-property-riscv64.o | ||
// RUN: llvm-readobj -n gnu-property-riscv64.o | FileCheck -check-prefix=LLVM64 gnu-property-riscv64.s | ||
// RUN: llvm-readobj -n --elf-output-style=GNU gnu-property-riscv64.o | FileCheck -check-prefix=GNU64 gnu-property-riscv64.s | ||
|
||
|
||
// LLVM64: Notes [ | ||
// LLVM64-NEXT: NoteSection { | ||
// LLVM64-NEXT: Name: .note.gnu.property | ||
// LLVM64-NEXT: Offset: 0x40 | ||
// LLVM64-NEXT: Size: 0x20 | ||
// LLVM64-NEXT: Note { | ||
// LLVM64-NEXT: Owner: GNU | ||
// LLVM64-NEXT: Data size: 0x10 | ||
// LLVM64-NEXT: Type: NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// LLVM64-NEXT: Property [ | ||
// LLVM64-NEXT: riscv feature: Zicfilp, Zicfiss | ||
// LLVM64-NEXT: ] | ||
// LLVM64-NEXT: } | ||
// LLVM64-NEXT: } | ||
// LLVM64-NEXT: ] | ||
|
||
// GNU64: Displaying notes found in: .note.gnu.property | ||
// GNU64-NEXT: Owner Data size Description | ||
// GNU64-NEXT: GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 (property note) | ||
// GNU64-NEXT: Properties: riscv feature: Zicfilp, Zicfiss | ||
|
||
// GNU Note Section Example | ||
.section .note.gnu.property, "a" | ||
.p2align 2 | ||
.long 4 | ||
.long 16; | ||
.long 5 | ||
.asciz "GNU" | ||
.long 0xc0000000 | ||
.long 4 | ||
.long 3 | ||
.long 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.
I'm not sure if using
bool
here is suitable now. Currently, we have a second PLT scheme for Zicfilp: the function-signature-based one at riscv-non-isa/riscv-elf-psabi-doc#434 , so in the foreseeable future, this field would likely to be changed to an enum.