@@ -2418,6 +2418,15 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForExternalReference(
24182418 SmallString<128 > Name;
24192419 getNameWithPrefix (Name, GO, TM);
24202420
2421+ // AIX TLS local-dynamic does not need the external reference for the
2422+ // "_$TLSML" symbol.
2423+ if (GO->getThreadLocalMode () == GlobalVariable::LocalDynamicTLSModel &&
2424+ GO->hasName () && GO->getName () == " _$TLSML" ) {
2425+ return getContext ().getXCOFFSection (
2426+ Name, SectionKind::getData (),
2427+ XCOFF::CsectProperties (XCOFF::XMC_TC, XCOFF::XTY_SD));
2428+ }
2429+
24212430 XCOFF::StorageMappingClass SMC =
24222431 isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA;
24232432 if (GO->isThreadLocal ())
@@ -2675,13 +2684,17 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry(
26752684 // the chance of needing -bbigtoc is decreased. Also, the toc-entry for
26762685 // EH info is never referenced directly using instructions so it can be
26772686 // allocated with TE storage-mapping class.
2687+ // The "_$TLSML" symbol for TLS local-dynamic mode requires XMC_TC, otherwise
2688+ // the AIX assembler will complain.
26782689 return getContext ().getXCOFFSection (
26792690 cast<MCSymbolXCOFF>(Sym)->getSymbolTableName (), SectionKind::getData (),
2680- XCOFF::CsectProperties ((TM.getCodeModel () == CodeModel::Large ||
2681- cast<MCSymbolXCOFF>(Sym)->isEHInfo ())
2682- ? XCOFF::XMC_TE
2683- : XCOFF::XMC_TC,
2684- XCOFF::XTY_SD));
2691+ XCOFF::CsectProperties (
2692+ ((TM.getCodeModel () == CodeModel::Large &&
2693+ cast<MCSymbolXCOFF>(Sym)->getSymbolTableName () != " _$TLSML" ) ||
2694+ cast<MCSymbolXCOFF>(Sym)->isEHInfo ())
2695+ ? XCOFF::XMC_TE
2696+ : XCOFF::XMC_TC,
2697+ XCOFF::XTY_SD));
26852698}
26862699
26872700MCSection *TargetLoweringObjectFileXCOFF::getSectionForLSDA (
0 commit comments