Skip to content

Commit 589c645

Browse files
committed
Address trivial review comments
1 parent c493d78 commit 589c645

File tree

4 files changed

+35
-30
lines changed

4 files changed

+35
-30
lines changed

lld/ELF/Driver.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,44 +2648,44 @@ static uint32_t getAndFeatures() {
26482648
return ret;
26492649
}
26502650

2651-
static void getAarch64PauthInfo() {
2651+
static void getAArch64PauthInfo() {
26522652
if (ctx.objectFiles.empty())
26532653
return;
26542654

2655-
auto NonEmptyIt = std::find_if(
2655+
auto it = std::find_if(
26562656
ctx.objectFiles.begin(), ctx.objectFiles.end(),
26572657
[](const ELFFileBase *f) { return !f->aarch64PauthAbiTag.empty(); });
2658-
if (NonEmptyIt == ctx.objectFiles.end())
2658+
if (it == ctx.objectFiles.end())
26592659
return;
26602660

2661-
ctx.aarch64PauthAbiTag = (*NonEmptyIt)->aarch64PauthAbiTag;
2662-
StringRef F1 = (*NonEmptyIt)->getName();
2663-
for (ELFFileBase *F : ArrayRef(ctx.objectFiles)) {
2664-
StringRef F2 = F->getName();
2665-
const SmallVector<uint8_t, 0> &D1 = ctx.aarch64PauthAbiTag;
2666-
const SmallVector<uint8_t, 0> &D2 = F->aarch64PauthAbiTag;
2667-
if (D1.empty() != D2.empty()) {
2668-
auto Helper = [](StringRef Report, const Twine &Msg) {
2669-
if (Report == "warning")
2670-
warn(Msg);
2671-
else if (Report == "error")
2672-
error(Msg);
2661+
ctx.aarch64PauthAbiTag = (*it)->aarch64PauthAbiTag;
2662+
StringRef f1 = (*it)->getName();
2663+
for (ELFFileBase *f : ArrayRef(ctx.objectFiles)) {
2664+
StringRef f2 = f->getName();
2665+
const SmallVector<uint8_t, 0> &d1 = ctx.aarch64PauthAbiTag;
2666+
const SmallVector<uint8_t, 0> &d2 = f->aarch64PauthAbiTag;
2667+
if (d1.empty() != d2.empty()) {
2668+
auto helper = [](StringRef report, const Twine &msg) {
2669+
if (report == "warning")
2670+
warn(msg);
2671+
else if (report == "error")
2672+
error(msg);
26732673
};
26742674

2675-
Helper(config->zPauthReport,
2676-
(D1.empty() ? F1.str() : F2.str()) +
2675+
helper(config->zPauthReport,
2676+
(d1.empty() ? f1.str() : f2.str()) +
26772677
" has no AArch64 PAuth compatibility info while " +
2678-
(D1.empty() ? F2.str() : F1.str()) +
2678+
(d1.empty() ? f2.str() : f1.str()) +
26792679
" has one; either all or no input files must have it");
26802680
}
26812681

2682-
if (!D1.empty() && !D2.empty() &&
2683-
!std::equal(D1.begin(), D1.end(), D2.begin(), D2.end()))
2682+
if (!d1.empty() && !d2.empty() &&
2683+
!std::equal(d1.begin(), d1.end(), d2.begin(), d2.end()))
26842684
errorOrWarn(
26852685
"incompatible values of AArch64 PAuth compatibility info found"
26862686
"\n" +
2687-
F1 + ": 0x" + toHex(ArrayRef(D1.data(), D1.size())) + "\n" + F2 +
2688-
": 0x" + toHex(ArrayRef(D2.data(), D2.size())));
2687+
f1 + ": 0x" + toHex(ArrayRef(d1.data(), d1.size())) + "\n" + f2 +
2688+
": 0x" + toHex(ArrayRef(d2.data(), d2.size())));
26892689
}
26902690
}
26912691

@@ -3027,7 +3027,7 @@ void LinkerDriver::link(opt::InputArgList &args) {
30273027
config->andFeatures = getAndFeatures();
30283028

30293029
if (config->emachine == EM_AARCH64)
3030-
getAarch64PauthInfo();
3030+
getAArch64PauthInfo();
30313031

30323032
// The Target instance handles target-specific stuff, such as applying
30333033
// relocations or writing a PLT section. It also contains target-dependent

lld/ELF/InputFiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ static void readAArch64PauthAbiTag(const InputSection &sec, ObjFile<ELFT> &f) {
992992

993993
ArrayRef<uint8_t> desc = note.getDesc(sec.addralign);
994994
if (desc.size() < 16) {
995-
reportError("too short AArch64 PAuth compatibility info "
995+
reportError("AArch64 PAuth compatibility info is too short "
996996
"(at least 16 bytes expected)");
997997
return;
998998
}

lld/test/ELF/aarch64-bti-pac-cli-error.s

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
# REQUIRES: x86
22
# RUN: llvm-mc --triple=x86_64-pc-linux --filetype=obj -o %t.o %s
3-
# RUN: not ld.lld -z pac-plt -z force-bti -z bti-report=error %t.o -o /dev/null 2>&1 | FileCheck %s
3+
# RUN: not ld.lld -z pac-plt -z force-bti -z bti-report=error \
4+
# RUN: -z pauth-report=error %t.o -o /dev/null 2>&1 | FileCheck %s
5+
# RUN: not ld.lld -z pac-plt -z force-bti -z bti-report=warning \
6+
# RUN: -z pauth-report=warning %t.o -o /dev/null 2>&1 | FileCheck %s
47
#
5-
## Check that we error if -z pac-plt, -z force-bti and -z bti-report=error are used when target is not
6-
## aarch64
8+
## Check that we error if -z pac-plt, -z force-bti are present and
9+
## -z bti-report and -z pauth-report are not none when target is not aarch64
710

811
# CHECK: error: -z pac-plt only supported on AArch64
912
# CHECK-NEXT: error: -z force-bti only supported on AArch64
1013
# CHECK-NEXT: error: -z bti-report only supported on AArch64
14+
# CHECK-NEXT: error: -z pauth-report only supported on AArch64
1115

12-
# RUN: not ld.lld -z bti-report=something %t.o -o /dev/null 2>&1 | \
13-
# RUN: FileCheck --check-prefix=REPORT_INVALID %s
16+
# RUN: not ld.lld -z bti-report=something -z pauth-report=something \
17+
# RUN: %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=REPORT_INVALID %s
1418
# REPORT_INVALID: error: -z bti-report= parameter something is not recognized
19+
# REPORT_INVALID: error: -z pauth-report= parameter something is not recognized
1520
# REPORT_INVALID-EMPTY:
1621

1722
.globl start

lld/test/ELF/aarch64-feature-pauth.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
# ERR2: error: {{.*}}: invalid type field value 42 (1 expected)
2323
# ERR2-NEXT: error: {{.*}}: invalid name field value XXX (ARM expected)
24-
# ERR2-NEXT: error: {{.*}}: too short AArch64 PAuth compatibility info (at least 16 bytes expected)
24+
# ERR2-NEXT: error: {{.*}}: AArch64 PAuth compatibility info is too short (at least 16 bytes expected)
2525

2626
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu abi-tag-short.s -o short.o
2727
# RUN: not ld.lld short.o -o /dev/null 2>&1 | FileCheck --check-prefix ERR3 %s

0 commit comments

Comments
 (0)