Changeset View
Changeset View
Standalone View
Standalone View
lld/ELF/Relocations.cpp
Show First 20 Lines • Show All 1,394 Lines • ▼ Show 20 Lines | static void scanReloc(InputSectionBase &sec, OffsetGetter &getOffset, RelTy *&i, | ||||
// The 4 types that relative GOTPLT are all x86 and x86-64 specific. | // The 4 types that relative GOTPLT are all x86 and x86-64 specific. | ||||
if (oneof<R_GOTPLTONLY_PC, R_GOTPLTREL, R_GOTPLT, R_TLSGD_GOTPLT>(expr)) { | if (oneof<R_GOTPLTONLY_PC, R_GOTPLTREL, R_GOTPLT, R_TLSGD_GOTPLT>(expr)) { | ||||
in.gotPlt->hasGotPltOffRel = true; | in.gotPlt->hasGotPltOffRel = true; | ||||
} else if (oneof<R_GOTONLY_PC, R_GOTREL, R_PPC64_TOCBASE, R_PPC64_RELAX_TOC>( | } else if (oneof<R_GOTONLY_PC, R_GOTREL, R_PPC64_TOCBASE, R_PPC64_RELAX_TOC>( | ||||
expr)) { | expr)) { | ||||
in.got->hasGotOffRel = true; | in.got->hasGotOffRel = true; | ||||
} | } | ||||
// Process some TLS relocations, including relaxing TLS relocations. | // Process TLS relocations, including relaxing TLS relocations. Note that | ||||
// Note that this function does not handle all TLS relocations. | // R_TPREL and R_TPREL_NEG relocations are resolved in processRelocAux. | ||||
if (unsigned processed = | if (expr == R_TPREL || expr == R_TPREL_NEG) { | ||||
rprichard: I think this should also check for R_NEG_TLS. AFAIK R_NEG_TLS/R_386_TLS_LE_32 is only used on… | |||||
Thanks. R_386_TLS_LE_32 is an obsoleted Solaris TLS relocation type. MaskRay: Thanks. R_386_TLS_LE_32 is an obsoleted Solaris TLS relocation type. | |||||
handleTlsRelocation<ELFT>(type, sym, sec, offset, addend, expr)) { | if (config->shared) { | ||||
errorOrWarn("relocation " + toString(type) + " against " + toString(sym) + | |||||
" cannot be used with -shared" + | |||||
getLocation(sec, sym, offset)); | |||||
return; | |||||
} | |||||
} else if (unsigned processed = handleTlsRelocation<ELFT>( | |||||
handleTlsRelocation has a number of config->shared checks. Can these be dropped given this new diagnostic? jhenderson: `handleTlsRelocation` has a number of `config->shared` checks. Can these be dropped given this… | |||||
No. The config->shared checks in handleTlsRelocation are about whether GD/LD/IE can be relaxed to IE/LE. This check is about LE in -shared. Actually, R_TLS should really be renamed to R_TPOFFSET to be less confusing and I am going to send such a patch. MaskRay: No. The `config->shared` checks in `handleTlsRelocation` are about whether GD/LD/IE can be… | |||||
type, sym, sec, offset, addend, expr)) { | |||||
i += (processed - 1); | i += (processed - 1); | ||||
return; | return; | ||||
} | } | ||||
// We were asked not to generate PLT entries for ifuncs. Instead, pass the | // We were asked not to generate PLT entries for ifuncs. Instead, pass the | ||||
// direct relocation on through. | // direct relocation on through. | ||||
if (sym.isGnuIFunc() && config->zIfuncNoplt) { | if (sym.isGnuIFunc() && config->zIfuncNoplt) { | ||||
sym.exportDynamic = true; | sym.exportDynamic = true; | ||||
▲ Show 20 Lines • Show All 706 Lines • Show Last 20 Lines |
I think this should also check for R_NEG_TLS. AFAIK R_NEG_TLS/R_386_TLS_LE_32 is only used on 32-bit x86, and compilers usually prefer R_TLS/R_386_TLS_LE, but it's possible to bypass the new error with assembly:
movl %gs:TlsVar@NTPOFF, %eax ==> R_TLS
movl %gs:TlsVar@TPOFF, %eax ==> R_NEG_TLS