@@ -168,8 +168,8 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
168168 MMI, Streamer);
169169}
170170
171- static SectionKind
172- getELFKindForNamedSection (StringRef Name, SectionKind K ) {
171+ static SectionKind getELFKindForNamedSection (StringRef Name, SectionKind K,
172+ const Triple &TargetTriple ) {
173173 // N.B.: The defaults used in here are no the same ones used in MC.
174174 // We follow gcc, MC follows gas. For example, given ".section .eh_frame",
175175 // both gas and MC will produce a section with no flags. Given
@@ -201,6 +201,7 @@ getELFKindForNamedSection(StringRef Name, SectionKind K) {
201201 return SectionKind::getThreadData ();
202202
203203 if (Name == " .tbss" ||
204+ (TargetTriple.isAndroid () && Name == " .tcommon" ) || // LDC
204205 Name.startswith (" .tbss." ) ||
205206 Name.startswith (" .gnu.linkonce.tb." ) ||
206207 Name.startswith (" .llvm.linkonce.tb." ))
@@ -231,7 +232,7 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) {
231232 return ELF::SHT_PROGBITS;
232233}
233234
234- static unsigned getELFSectionFlags (SectionKind K) {
235+ static unsigned getELFSectionFlags (SectionKind K, const Triple &TargetTriple ) {
235236 unsigned Flags = 0 ;
236237
237238 if (!K.isMetadata ())
@@ -246,7 +247,7 @@ static unsigned getELFSectionFlags(SectionKind K) {
246247 if (K.isWriteable ())
247248 Flags |= ELF::SHF_WRITE;
248249
249- if (K.isThreadLocal ())
250+ if (K.isThreadLocal () && !TargetTriple. isAndroid ()) // LDC
250251 Flags |= ELF::SHF_TLS;
251252
252253 if (K.isMergeableCString () || K.isMergeableConst ())
@@ -312,10 +313,10 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
312313 }
313314
314315 // Infer section flags from the section name if we can.
315- Kind = getELFKindForNamedSection (SectionName, Kind);
316+ Kind = getELFKindForNamedSection (SectionName, Kind, getTargetTriple () );
316317
317318 StringRef Group = " " ;
318- unsigned Flags = getELFSectionFlags (Kind);
319+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
319320 if (const Comdat *C = getELFComdat (GO)) {
320321 Group = C->getName ();
321322 Flags |= ELF::SHF_GROUP;
@@ -433,7 +434,7 @@ static MCSectionELF *selectELFSectionForGlobal(
433434
434435MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal (
435436 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
436- unsigned Flags = getELFSectionFlags (Kind);
437+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
437438
438439 // If we have -ffunction-section or -fdata-section then we should emit the
439440 // global value to a uniqued section specifically for it.
0 commit comments