@@ -990,10 +990,17 @@ bool RelocationScanner::isStaticLinkTimeConstant(RelExpr e, RelType type,
990
990
// only the low bits are used.
991
991
if (e == R_GOT || e == R_PLT)
992
992
return ctx.target ->usesOnlyLowPageBits (type) || !ctx.arg .isPic ;
993
-
994
993
// R_AARCH64_AUTH_ABS64 requires a dynamic relocation.
995
- if (sym. isPreemptible || e == RE_AARCH64_AUTH)
994
+ if (e == RE_AARCH64_AUTH)
996
995
return false ;
996
+
997
+ // The behavior of an undefined weak reference is implementation defined.
998
+ // (We treat undefined non-weak the same as undefined weak.) For static
999
+ // -no-pie linking, dynamic relocations are generally avoided (except
1000
+ // IRELATIVE). Emitting dynamic relocations for -shared aligns with its -z
1001
+ // undefs default. Dynamic -no-pie linking and -pie allow flexibility.
1002
+ if (sym.isPreemptible )
1003
+ return sym.isUndefined () && !ctx.arg .isPic ;
997
1004
if (!ctx.arg .isPic )
998
1005
return true ;
999
1006
@@ -1113,19 +1120,7 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
1113
1120
// If the relocation is known to be a link-time constant, we know no dynamic
1114
1121
// relocation will be created, pass the control to relocateAlloc() or
1115
1122
// relocateNonAlloc() to resolve it.
1116
- //
1117
- // The behavior of an undefined weak reference is implementation defined. For
1118
- // non-link-time constants, we resolve relocations statically (let
1119
- // relocate{,Non}Alloc() resolve them) for -no-pie and try producing dynamic
1120
- // relocations for -pie and -shared.
1121
- //
1122
- // The general expectation of -no-pie static linking is that there is no
1123
- // dynamic relocation (except IRELATIVE). Emitting dynamic relocations for
1124
- // -shared matches the spirit of its -z undefs default. -pie has freedom on
1125
- // choices, and we choose dynamic relocations to be consistent with the
1126
- // handling of GOT-generating relocations.
1127
- if (isStaticLinkTimeConstant (expr, type, sym, offset) ||
1128
- (!ctx.arg .isPic && sym.isUndefWeak ())) {
1123
+ if (isStaticLinkTimeConstant (expr, type, sym, offset)) {
1129
1124
sec->addReloc ({expr, type, offset, addend, &sym});
1130
1125
return ;
1131
1126
}
0 commit comments