-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LLD][ELF] Add -z execute-only-report that checks PURECODE section flags
#128883
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
69048e3
[LLD][ELF] Add `-z execute-only-report` that checks PURECODE flags
Il-Capitano aae4833
Address review feedback in tests
Il-Capitano 144b93f
Address review feedback in Writer.cpp
Il-Capitano ddaf54d
Update unknown argument error message
Il-Capitano 404ac5d
Reduce indentation depth in checkExecuteOnlyReport
Il-Capitano 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // REQUIRES: aarch64 | ||
|
|
||
| // RUN: rm -rf %t && mkdir %t && cd %t | ||
| // RUN: llvm-mc --triple=aarch64 --filetype=obj %s -o a.o | ||
|
|
||
| // RUN: ld.lld --defsym absolute=0xf0000000 -z execute-only-report=none --fatal-warnings a.o | ||
|
|
||
| // RUN: ld.lld --defsym absolute=0xf0000000 -z execute-only-report=warning a.o 2>&1 | \ | ||
| // RUN: FileCheck --check-prefix=WARNING %s | ||
| // RUN: ld.lld --defsym absolute=0xf0000000 --execute-only -z execute-only-report=warning a.o 2>&1 | \ | ||
| // RUN: FileCheck --check-prefix=WARNING %s | ||
|
|
||
| // WARNING-NOT: warning: -z execute-only-report: a.o:(.text) does not have SHF_AARCH64_PURECODE flag set | ||
| // WARNING-NOT: warning: -z execute-only-report: a.o:(.text.foo) does not have SHF_AARCH64_PURECODE flag set | ||
| // WARNING: warning: -z execute-only-report: a.o:(.text.bar) does not have SHF_AARCH64_PURECODE flag set | ||
| // WARNING-NOT: warning: -z execute-only-report: <internal>:({{.*}}) does not have SHF_AARCH64_PURECODE flag set | ||
|
|
||
| // RUN: not ld.lld --defsym absolute=0xf0000000 -z execute-only-report=error a.o 2>&1 | \ | ||
| // RUN: FileCheck --check-prefix=ERROR %s | ||
| // RUN: not ld.lld --defsym absolute=0xf0000000 --execute-only -z execute-only-report=error a.o 2>&1 | \ | ||
| // RUN: FileCheck --check-prefix=ERROR %s | ||
|
|
||
| // ERROR-NOT: error: -z execute-only-report: a.o:(.text) does not have SHF_AARCH64_PURECODE flag set | ||
| // ERROR-NOT: error: -z execute-only-report: a.o:(.text.foo) does not have SHF_AARCH64_PURECODE flag set | ||
| // ERROR: error: -z execute-only-report: a.o:(.text.bar) does not have SHF_AARCH64_PURECODE flag set | ||
| // ERROR-NOT: error: -z execute-only-report: <internal>:({{.*}}) does not have SHF_AARCH64_PURECODE flag set | ||
|
|
||
| .section .text,"axy",@progbits,unique,0 | ||
| .globl _start | ||
| _start: | ||
| bl foo | ||
| bl bar | ||
| bl absolute | ||
| ret | ||
|
|
||
| .section .text.foo,"axy",@progbits,unique,0 | ||
| .globl foo | ||
| foo: | ||
| ret | ||
|
|
||
| .section .text.bar,"ax",@progbits,unique,0 | ||
| .globl bar | ||
| bar: | ||
| ret |
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,40 @@ | ||
| // REQUIRES: arm | ||
|
|
||
| // RUN: rm -rf %t && mkdir %t && cd %t | ||
| // RUN: llvm-mc --triple=armv7 --filetype=obj %s -o a.o | ||
|
|
||
| // RUN: ld.lld --defsym absolute=0xf0000000 -z execute-only-report=none --fatal-warnings a.o | ||
|
|
||
| // RUN: ld.lld --defsym absolute=0xf0000000 -z execute-only-report=warning a.o 2>&1 | \ | ||
| // RUN: FileCheck --check-prefix=WARNING %s | ||
|
|
||
| // WARNING-NOT: warning: -z execute-only-report: a.o:(.text) does not have SHF_ARM_PURECODE flag set | ||
| // WARNING-NOT: warning: -z execute-only-report: a.o:(.text.foo) does not have SHF_ARM_PURECODE flag set | ||
| // WARNING: warning: -z execute-only-report: a.o:(.text.bar) does not have SHF_ARM_PURECODE flag set | ||
| // WARNING-NOT: warning: -z execute-only-report: <internal>:({{.*}}) does not have SHF_ARM_PURECODE flag set | ||
|
|
||
| // RUN: not ld.lld --defsym absolute=0xf0000000 -z execute-only-report=error a.o 2>&1 | \ | ||
| // RUN: FileCheck --check-prefix=ERROR %s | ||
|
|
||
| // ERROR-NOT: error: -z execute-only-report: a.o:(.text) does not have SHF_ARM_PURECODE flag set | ||
| // ERROR-NOT: error: -z execute-only-report: a.o:(.text.foo) does not have SHF_ARM_PURECODE flag set | ||
| // ERROR: error: -z execute-only-report: a.o:(.text.bar) does not have SHF_ARM_PURECODE flag set | ||
| // ERROR-NOT: error: -z execute-only-report: <internal>:({{.*}}) does not have SHF_ARM_PURECODE flag set | ||
|
|
||
| .section .text,"axy",%progbits,unique,0 | ||
| .globl _start | ||
| _start: | ||
| bl foo | ||
| bl bar | ||
| bl absolute | ||
| bx lr | ||
|
|
||
| .section .text.foo,"axy",%progbits,unique,0 | ||
| .globl foo | ||
| foo: | ||
| bx lr | ||
|
|
||
| .section .text.bar,"ax",%progbits,unique,0 | ||
| .globl bar | ||
| bar: | ||
| bx lr |
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
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.
move into
checkExecuteOnlyThere 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 didn't do this yet, because I think that
checkExecuteOnlyandcheckExecuteOnlyReportaside from the similar naming do different things and they should be separate.