@@ -1292,6 +1292,27 @@ static unsigned handleMipsTlsRelocation(Ctx &ctx, RelType type, Symbol &sym,
1292
1292
return 0 ;
1293
1293
}
1294
1294
1295
+ static unsigned handleAArch64PAuthTlsRelocation (InputSectionBase *sec,
1296
+ RelExpr expr, RelType type,
1297
+ uint64_t offset, Symbol &sym,
1298
+ int64_t addend) {
1299
+ // Do not optimize signed TLSDESC to LE/IE (as described in pauthabielf64).
1300
+ // https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#general-restrictions
1301
+ // > PAUTHELF64 only supports the descriptor based TLS (TLSDESC).
1302
+ if (oneof<RE_AARCH64_AUTH_TLSDESC_PAGE, RE_AARCH64_AUTH_TLSDESC>(expr)) {
1303
+ sym.setFlags (NEEDS_TLSDESC | NEEDS_TLSDESC_AUTH);
1304
+ sec->addReloc ({expr, type, offset, addend, &sym});
1305
+ return 1 ;
1306
+ }
1307
+
1308
+ // TLSDESC_CALL hint relocation should not be emitted by compiler with signed
1309
+ // TLSDESC enabled.
1310
+ if (expr == R_TLSDESC_CALL)
1311
+ sym.setFlags (NEEDS_TLSDESC_NONAUTH);
1312
+
1313
+ return 0 ;
1314
+ }
1315
+
1295
1316
// Notes about General Dynamic and Local Dynamic TLS models below. They may
1296
1317
// require the generation of a pair of GOT entries that have associated dynamic
1297
1318
// relocations. The pair of GOT entries created are of the form GOT[e0] Module
@@ -1302,6 +1323,11 @@ static unsigned handleMipsTlsRelocation(Ctx &ctx, RelType type, Symbol &sym,
1302
1323
unsigned RelocationScanner::handleTlsRelocation (RelExpr expr, RelType type,
1303
1324
uint64_t offset, Symbol &sym,
1304
1325
int64_t addend) {
1326
+ if (ctx.arg .emachine == EM_AARCH64)
1327
+ if (unsigned processed = handleAArch64PAuthTlsRelocation (
1328
+ sec, expr, type, offset, sym, addend))
1329
+ return processed;
1330
+
1305
1331
if (expr == R_TPREL || expr == R_TPREL_NEG) {
1306
1332
if (ctx.arg .shared ) {
1307
1333
auto diag = Err (ctx);
@@ -1328,20 +1354,6 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
1328
1354
return 1 ;
1329
1355
}
1330
1356
1331
- // Do not optimize signed TLSDESC (as described in pauthabielf64 to LE/IE).
1332
- // https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#general-restrictions
1333
- // > PAUTHELF64 only supports the descriptor based TLS (TLSDESC).
1334
- if (oneof<RE_AARCH64_AUTH_TLSDESC_PAGE, RE_AARCH64_AUTH_TLSDESC>(expr)) {
1335
- sym.setFlags (NEEDS_TLSDESC | NEEDS_TLSDESC_AUTH);
1336
- sec->addReloc ({expr, type, offset, addend, &sym});
1337
- return 1 ;
1338
- }
1339
-
1340
- // TLSDESC_CALL hint relocation should not be emitted by compiler with signed
1341
- // TLSDESC enabled.
1342
- if (expr == R_TLSDESC_CALL)
1343
- sym.setFlags (NEEDS_TLSDESC_NONAUTH);
1344
-
1345
1357
bool isRISCV = ctx.arg .emachine == EM_RISCV;
1346
1358
1347
1359
if (oneof<RE_AARCH64_TLSDESC_PAGE, R_TLSDESC, R_TLSDESC_CALL, R_TLSDESC_PC,
@@ -1351,7 +1363,9 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
1351
1363
// set NEEDS_TLSDESC on the label.
1352
1364
if (expr != R_TLSDESC_CALL) {
1353
1365
if (!isRISCV || type == R_RISCV_TLSDESC_HI20)
1354
- sym.setFlags (NEEDS_TLSDESC | NEEDS_TLSDESC_NONAUTH);
1366
+ sym.setFlags (
1367
+ NEEDS_TLSDESC |
1368
+ (ctx.arg .emachine == EM_AARCH64 ? NEEDS_TLSDESC_NONAUTH : 0 ));
1355
1369
sec->addReloc ({expr, type, offset, addend, &sym});
1356
1370
}
1357
1371
return 1 ;
@@ -1862,10 +1876,10 @@ void elf::postScanRelocations(Ctx &ctx) {
1862
1876
1863
1877
if (flags & NEEDS_TLSDESC) {
1864
1878
if ((flags & NEEDS_TLSDESC_AUTH) && (flags & NEEDS_TLSDESC_NONAUTH)) {
1865
- auto diag = Err (ctx);
1866
- diag << " both AUTH and non-AUTH TLSDESC entries for '" << sym.getName ()
1867
- << " ' requested, but only one type of TLSDESC entry per symbol is "
1868
- " supported" ;
1879
+ Err (ctx)
1880
+ << " both AUTH and non-AUTH TLSDESC entries for '" << sym.getName ()
1881
+ << " ' requested, but only one type of TLSDESC entry per symbol is "
1882
+ " supported" ;
1869
1883
return ;
1870
1884
}
1871
1885
got->addTlsDescEntry (sym);
0 commit comments