@@ -911,33 +911,39 @@ void elf::addGotEntry(Ctx &ctx, Symbol &sym) {
911
911
912
912
// If preemptible, emit a GLOB_DAT relocation.
913
913
if (sym.isPreemptible ) {
914
- RelType gotRel = ctx.target ->gotRel ;
915
- if (sym.hasFlag (NEEDS_GOT_AUTH)) {
916
- assert (ctx.arg .emachine == EM_AARCH64);
917
- gotRel = R_AARCH64_AUTH_GLOB_DAT;
918
- }
919
- ctx.mainPart ->relaDyn ->addReloc ({gotRel, ctx.in .got .get (), off,
914
+ ctx.mainPart ->relaDyn ->addReloc ({ctx.target ->gotRel , ctx.in .got .get (), off,
920
915
DynamicReloc::AgainstSymbol, sym, 0 ,
921
916
R_ABS});
922
917
return ;
923
918
}
924
919
925
920
// Otherwise, the value is either a link-time constant or the load base
926
- // plus a constant. Signed GOT requires dynamic relocation.
927
- if (sym.hasFlag (NEEDS_GOT_AUTH)) {
928
- ctx.in .got ->getPartition (ctx).relaDyn ->addReloc (
929
- {R_AARCH64_AUTH_RELATIVE, ctx.in .got .get (), off,
930
- DynamicReloc::AddendOnlyWithTargetVA, sym, 0 , R_ABS});
931
- return ;
932
- }
933
-
921
+ // plus a constant.
934
922
if (!ctx.arg .isPic || isAbsolute (sym))
935
923
ctx.in .got ->addConstant ({R_ABS, ctx.target ->symbolicRel , off, 0 , &sym});
936
924
else
937
925
addRelativeReloc (ctx, *ctx.in .got , off, sym, 0 , R_ABS,
938
926
ctx.target ->symbolicRel );
939
927
}
940
928
929
+ static void addGotAuthEntry (Ctx &ctx, Symbol &sym) {
930
+ ctx.in .got ->addEntry (sym);
931
+ uint64_t off = sym.getGotOffset (ctx);
932
+
933
+ // If preemptible, emit a GLOB_DAT relocation.
934
+ if (sym.isPreemptible ) {
935
+ ctx.mainPart ->relaDyn ->addReloc ({R_AARCH64_AUTH_GLOB_DAT, ctx.in .got .get (),
936
+ off, DynamicReloc::AgainstSymbol, sym, 0 ,
937
+ R_ABS});
938
+ return ;
939
+ }
940
+
941
+ // Signed GOT requires dynamic relocation.
942
+ ctx.in .got ->getPartition (ctx).relaDyn ->addReloc (
943
+ {R_AARCH64_AUTH_RELATIVE, ctx.in .got .get (), off,
944
+ DynamicReloc::AddendOnlyWithTargetVA, sym, 0 , R_ABS});
945
+ }
946
+
941
947
static void addTpOffsetGotEntry (Ctx &ctx, Symbol &sym) {
942
948
ctx.in .got ->addEntry (sym);
943
949
uint64_t off = sym.getGotOffset (ctx);
@@ -1809,8 +1815,12 @@ void elf::postScanRelocations(Ctx &ctx) {
1809
1815
return ;
1810
1816
sym.allocateAux (ctx);
1811
1817
1812
- if (flags & NEEDS_GOT)
1813
- addGotEntry (ctx, sym);
1818
+ if (flags & NEEDS_GOT) {
1819
+ if (flags & NEEDS_GOT_AUTH)
1820
+ addGotAuthEntry (ctx, sym);
1821
+ else
1822
+ addGotEntry (ctx, sym);
1823
+ }
1814
1824
if (flags & NEEDS_PLT)
1815
1825
addPltEntry (ctx, *ctx.in .plt , *ctx.in .gotPlt , *ctx.in .relaPlt ,
1816
1826
ctx.target ->pltRel , sym);
0 commit comments