@@ -193,14 +193,30 @@ static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
193
193
void SparcMCExpr::fixELFSymbolsInTLSFixups (MCAssembler &Asm) const {
194
194
switch (getKind ()) {
195
195
default : return ;
196
+ case VK_Sparc_TLS_GD_CALL:
197
+ case VK_Sparc_TLS_LDM_CALL: {
198
+ // The corresponding relocations reference __tls_get_addr, as they call it,
199
+ // but this is only implicit; there is no connection in the ELF file
200
+ // between the relocation and the symbol, other than the specification for
201
+ // the semantics of the relocations. However, the symbol must be included
202
+ // in our symbol table despite the lack of references to it, since it needs
203
+ // to be bound during linking for these relocations. For details see
204
+ // https://sourceware.org/bugzilla/show_bug.cgi?id=22832.
205
+ MCSymbol *Symbol = Asm.getContext ().getOrCreateSymbol (" __tls_get_addr" );
206
+ Asm.registerSymbol (*Symbol);
207
+ auto ELFSymbol = cast<MCSymbolELF>(Symbol);
208
+ if (!ELFSymbol->isBindingSet ()) {
209
+ ELFSymbol->setBinding (ELF::STB_GLOBAL);
210
+ ELFSymbol->setExternal (true );
211
+ }
212
+ LLVM_FALLTHROUGH;
213
+ }
196
214
case VK_Sparc_TLS_GD_HI22:
197
215
case VK_Sparc_TLS_GD_LO10:
198
216
case VK_Sparc_TLS_GD_ADD:
199
- case VK_Sparc_TLS_GD_CALL:
200
217
case VK_Sparc_TLS_LDM_HI22:
201
218
case VK_Sparc_TLS_LDM_LO10:
202
219
case VK_Sparc_TLS_LDM_ADD:
203
- case VK_Sparc_TLS_LDM_CALL:
204
220
case VK_Sparc_TLS_LDO_HIX22:
205
221
case VK_Sparc_TLS_LDO_LOX10:
206
222
case VK_Sparc_TLS_LDO_ADD:
0 commit comments