Skip to content

Commit 41472ad

Browse files
committed
Address review feedback from MaskRay
1 parent 537dd6d commit 41472ad

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lld/ELF/Driver.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,9 +1644,9 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
16441644
auto reports = {
16451645
std::make_pair("bti-report", &ctx.arg.zBtiReport),
16461646
std::make_pair("cet-report", &ctx.arg.zCetReport),
1647+
std::make_pair("execute-only-report", &ctx.arg.zExecuteOnlyReport),
16471648
std::make_pair("gcs-report", &ctx.arg.zGcsReport),
1648-
std::make_pair("pauth-report", &ctx.arg.zPauthReport),
1649-
std::make_pair("execute-only-report", &ctx.arg.zExecuteOnlyReport)};
1649+
std::make_pair("pauth-report", &ctx.arg.zPauthReport)};
16501650
for (opt::Arg *arg : args.filtered(OPT_z)) {
16511651
std::pair<StringRef, StringRef> option =
16521652
StringRef(arg->getValue()).split('=');
@@ -2945,15 +2945,15 @@ static void checkExecuteOnly(Ctx &ctx) {
29452945
};
29462946

29472947
for (ELFFileBase *file : ctx.objectFiles) {
2948-
for (InputSectionBase *section : file->getSections()) {
2949-
if (!(section && section->flags & SHF_EXECINSTR))
2948+
for (InputSectionBase *sec : file->getSections()) {
2949+
if (!(sec && sec->flags & SHF_EXECINSTR))
29502950
continue;
29512951

2952-
OutputSection *outputSection = section->getOutputSection();
2953-
if (outputSection && outputSection->name == ".text") {
2952+
OutputSection *osec = sec->getOutputSection();
2953+
if (osec && osec->name == ".text") {
29542954
reportUnless(ctx.arg.zExecuteOnlyReport,
2955-
section->flags & SHF_AARCH64_PURECODE)
2956-
<< file << ": -z execute-only-report: section " << section->name
2955+
sec->flags & SHF_AARCH64_PURECODE)
2956+
<< "-z execute-only-report: " << sec
29572957
<< " does not have SHF_AARCH64_PURECODE flag set";
29582958
}
29592959
}

lld/ELF/OutputSections.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ using namespace lld::elf;
4242

4343
uint32_t OutputSection::getPhdrFlags() const {
4444
uint32_t ret = 0;
45-
if ((ctx.arg.emachine != EM_ARM || !(flags & SHF_ARM_PURECODE)) &&
46-
(ctx.arg.emachine != EM_AARCH64 || !(flags & SHF_AARCH64_PURECODE)))
45+
bool purecode =
46+
(ctx.arg.emachine == EM_ARM && (flags & SHF_ARM_PURECODE)) ||
47+
(ctx.arg.emachine == EM_AARCH64 && (flags & SHF_AARCH64_PURECODE));
48+
if (!purecode)
4749
ret |= PF_R;
4850
if (flags & SHF_WRITE)
4951
ret |= PF_W;

lld/test/ELF/aarch64-execute-only-report.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// RUN: not ld.lld -z execute-only-report=error %t.o -o /dev/null 2>&1 \
88
// RUN: | FileCheck --check-prefix=ERROR %s
99

10-
// WARNING: warning: {{.*}}.o: -z execute-only-report: section .text does not have SHF_AARCH64_PURECODE flag set
11-
// ERROR: error: {{.*}}.o: -z execute-only-report: section .text does not have SHF_AARCH64_PURECODE flag set
10+
// WARNING: warning: -z execute-only-report: {{.*}}.o:(.text) does not have SHF_AARCH64_PURECODE flag set
11+
// ERROR: error: -z execute-only-report: {{.*}}.o:(.text) does not have SHF_AARCH64_PURECODE flag set
1212

1313
.section .text,"ax"
1414
.globl _start

0 commit comments

Comments
 (0)