@@ -914,6 +914,7 @@ void elf::addGotEntry(Ctx &ctx, Symbol &sym) {
914914
915915static void addGotAuthEntry (Ctx &ctx, Symbol &sym) {
916916 ctx.in .got ->addEntry (sym);
917+ ctx.in .got ->addAuthEntry (sym);
917918 uint64_t off = sym.getGotOffset (ctx);
918919
919920 // If preemptible, emit a GLOB_DAT relocation.
@@ -1096,18 +1097,10 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
10961097 } else if (!sym.isTls () || ctx.arg .emachine != EM_LOONGARCH) {
10971098 // Many LoongArch TLS relocs reuse the RE_LOONGARCH_GOT type, in which
10981099 // case the NEEDS_GOT flag shouldn't get set.
1099- bool needsGotAuth =
1100- (expr == RE_AARCH64_AUTH_GOT || expr == RE_AARCH64_AUTH_GOT_PAGE_PC);
1101- uint16_t flags = sym.flags .load (std::memory_order_relaxed);
1102- if (!(flags & NEEDS_GOT)) {
1103- sym.setFlags (needsGotAuth ? (NEEDS_GOT | NEEDS_GOT_AUTH) : NEEDS_GOT);
1104- } else if (needsGotAuth != static_cast <bool >(flags & NEEDS_GOT_AUTH)) {
1105- auto diag = Err (ctx);
1106- diag << " both AUTH and non-AUTH GOT entries for '" << sym.getName ()
1107- << " ' requested, but only one type of GOT entry per symbol is "
1108- " supported" ;
1109- printLocation (diag, *sec, sym, offset);
1110- }
1100+ if (expr == RE_AARCH64_AUTH_GOT || expr == RE_AARCH64_AUTH_GOT_PAGE_PC)
1101+ sym.setFlags (NEEDS_GOT | NEEDS_GOT_AUTH);
1102+ else
1103+ sym.setFlags (NEEDS_GOT | NEEDS_GOT_NONAUTH);
11111104 }
11121105 } else if (needsPlt (expr)) {
11131106 sym.setFlags (NEEDS_PLT);
@@ -1808,6 +1801,12 @@ void elf::postScanRelocations(Ctx &ctx) {
18081801 sym.allocateAux (ctx);
18091802
18101803 if (flags & NEEDS_GOT) {
1804+ if ((flags & NEEDS_GOT_AUTH) && (flags & NEEDS_GOT_NONAUTH)) {
1805+ auto diag = Err (ctx);
1806+ diag << " both AUTH and non-AUTH GOT entries for '" << sym.getName ()
1807+ << " ' requested, but only one type of GOT entry per symbol is "
1808+ " supported" ;
1809+ }
18111810 if (flags & NEEDS_GOT_AUTH)
18121811 addGotAuthEntry (ctx, sym);
18131812 else
0 commit comments