Changeset View
Standalone View
ELF/Writer.cpp
Show First 20 Lines • Show All 1,600 Lines • ▼ Show 20 Lines | template <class ELFT> void Writer<ELFT>::finalizeSections() { | ||||
// Define __rel[a]_iplt_{start,end} symbols if needed. | // Define __rel[a]_iplt_{start,end} symbols if needed. | ||||
addRelIpltSymbols(); | addRelIpltSymbols(); | ||||
// RISC-V's gp can address +/- 2 KiB, set it to .sdata + 0x800 if not defined. | // RISC-V's gp can address +/- 2 KiB, set it to .sdata + 0x800 if not defined. | ||||
if (Config->EMachine == EM_RISCV) | if (Config->EMachine == EM_RISCV) | ||||
if (!dyn_cast_or_null<Defined>(Symtab->find("__global_pointer$"))) | if (!dyn_cast_or_null<Defined>(Symtab->find("__global_pointer$"))) | ||||
addOptionalRegular("__global_pointer$", findSection(".sdata"), 0x800); | addOptionalRegular("__global_pointer$", findSection(".sdata"), 0x800); | ||||
if (Config->EMachine == EM_X86_64) { | |||||
grimar: i.e. how much reasonable this check is? | |||||
In GNU linkers, _TLS_MODULE_BASE_ is defined on demand on i386/x86-64/arm/aarch64/s390. Many targets don't have an ABI for TLSDESC. If you feel we don't have to special case the TLSDESC targets that support TLSDESC, I can make this unconditional. MaskRay: In GNU linkers, `_TLS_MODULE_BASE_` is defined on demand on i386/x86-64/arm/aarch64/s390. Many… | |||||
I am not sure. Let see what Rui think. Perhaps whitelisting was fine. Without any conditions, I think arm/aarch64 will be just broken with this change (i.e. LLD will produce broken output instead of link error it seems). grimar: I am not sure. Let see what Rui think. Perhaps whitelisting was fine. Without any conditions, I… | |||||
// On targets that support TLSDESC, _TLS_MODULE_BASE_ is defined in such a | |||||
// way that: | |||||
// | |||||
// 1) With LD->LE relaxation: _TLS_MODULE_BASE_@tpoff = 0 (lowest address in | |||||
tlsBase -> TlsBase grimar: `tlsBase` -> `TlsBase` | |||||
// the TLS block). | |||||
// 2) Without relaxation: it produces a dynamic TLSDESC relocation that | |||||
// computes 0. | |||||
// | |||||
// 1) is special cased in @tpoff computation. To satisfy 2), we define it as | |||||
// an absolute symbol of zero. This is different from GNU linkers which | |||||
// define _TLS_MODULE_BASE_ relative to the first TLS section. | |||||
Symbol *S = Symtab->find("_TLS_MODULE_BASE_"); | |||||
if (S && S->isUndefined()) | |||||
S->resolve(Defined{/*File=*/nullptr, S->getName(), STB_GLOBAL, STV_HIDDEN, | |||||
STT_TLS, /*Value=*/0, 0, | |||||
/*Section=*/nullptr}); | |||||
Symtab->TlsModuleBase = S; | |||||
grimarUnsubmitted Should this assignment be under if (S && S->isUndefined()) check? I am not sure how much is real (I guess not at all honestly). but if user defines his own _TLS_MODULE_BASE_ symbol, then grimar: Should this assignment be under `if (S && S->isUndefined())` check?
I am not sure how much is… | |||||
grimarUnsubmitted i.e. if (S && S->isUndefined()) { S->resolve(Defined{/*File=*/nullptr, S->getName(), STB_GLOBAL, STV_HIDDEN, STT_TLS, /*Value=*/0, 0, /*Section=*/nullptr}); Symtab->TlsModuleBase = S; } grimar: i.e.
```
if (S && S->isUndefined()) {
S->resolve(Defined{/*File=*/nullptr, S->getName()… | |||||
} | |||||
// This responsible for splitting up .eh_frame section into | // This responsible for splitting up .eh_frame section into | ||||
// pieces. The relocation scan uses those pieces, so this has to be | // pieces. The relocation scan uses those pieces, so this has to be | ||||
// earlier. | // earlier. | ||||
finalizeSynthetic(In.EhFrame); | finalizeSynthetic(In.EhFrame); | ||||
Symtab->forEachSymbol([](Symbol *S) { | Symtab->forEachSymbol([](Symbol *S) { | ||||
if (!S->IsPreemptible) | if (!S->IsPreemptible) | ||||
S->IsPreemptible = computeIsPreemptible(*S); | S->IsPreemptible = computeIsPreemptible(*S); | ||||
▲ Show 20 Lines • Show All 962 Lines • Show Last 20 Lines |
i.e. how much reasonable this check is?