Skip to content

Commit 07d26fa

Browse files
committed
Use Err(ctx) instead of fatal and use getLocation in error message
1 parent 39ddd59 commit 07d26fa

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lld/ELF/Relocations.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,10 +1326,11 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
13261326
return 1;
13271327
}
13281328

1329-
auto fatalBothAuthAndNonAuth = [&sym]() {
1330-
fatal("both AUTH and non-AUTH TLSDESC entries for '" + sym.getName() +
1331-
"' requested, but only one type of TLSDESC entry per symbol is "
1332-
"supported");
1329+
auto errBothAuthAndNonAuth = [this, &sym, offset]() {
1330+
Err(ctx) << "both AUTH and non-AUTH TLSDESC entries for '" << sym.getName()
1331+
<< "' requested, but only one type of TLSDESC entry per symbol is "
1332+
"supported"
1333+
<< getLocation(ctx, *sec, sym, offset);
13331334
};
13341335

13351336
// Do not optimize signed TLSDESC (as described in pauthabielf64 to LE/IE).
@@ -1338,10 +1339,12 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
13381339
if (oneof<RE_AARCH64_AUTH_TLSDESC_PAGE, RE_AARCH64_AUTH_TLSDESC>(
13391340
expr)) {
13401341
assert(ctx.arg.emachine == EM_AARCH64);
1341-
if (!sym.hasFlag(NEEDS_TLSDESC))
1342+
if (!sym.hasFlag(NEEDS_TLSDESC)) {
13421343
sym.setFlags(NEEDS_TLSDESC | NEEDS_TLSDESC_AUTH);
1343-
else if (!sym.hasFlag(NEEDS_TLSDESC_AUTH))
1344-
fatalBothAuthAndNonAuth();
1344+
} else if (!sym.hasFlag(NEEDS_TLSDESC_AUTH)) {
1345+
errBothAuthAndNonAuth();
1346+
return 1;
1347+
}
13451348
sec->addReloc({expr, type, offset, addend, &sym});
13461349
return 1;
13471350
}
@@ -1352,7 +1355,7 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
13521355
// with signed TLSDESC enabled since it does not give any value, but leave a
13531356
// check against that just in case someone uses it.
13541357
if (expr != R_TLSDESC_CALL)
1355-
fatalBothAuthAndNonAuth();
1358+
errBothAuthAndNonAuth();
13561359
return 1;
13571360
}
13581361

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ local2:
101101

102102
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err1.s -o err1.o
103103
// RUN: not ld.lld -shared err1.o -o err1.so 2>&1 | FileCheck --check-prefix=ERR1 %s
104-
// ERR1: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported
104+
// ERR1: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported
105+
// ERR1-NEXT: >>> defined in err1.o
106+
// ERR1-NEXT: >>> referenced by err1.o:(.text+0x10)
105107
.text
106108
adrp x0, :tlsdesc_auth:a
107109
ldr x16, [x0, :tlsdesc_auth_lo12:a]
@@ -119,7 +121,9 @@ local2:
119121

120122
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err2.s -o err2.o
121123
// RUN: not ld.lld -shared err2.o -o err2.so 2>&1 | FileCheck --check-prefix=ERR2 %s
122-
// ERR2: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported
124+
// ERR2: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported
125+
// ERR2-NEXT: >>> defined in err2.o
126+
// ERR2-NEXT: >>> referenced by err2.o:(.text+0x10)
123127
.text
124128
adrp x0, :tlsdesc:a
125129
ldr x1, [x0, :tlsdesc_lo12:a]

0 commit comments

Comments
 (0)