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