@@ -232,7 +232,8 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
232
232
MMI, Streamer);
233
233
}
234
234
235
- static SectionKind getELFKindForNamedSection (StringRef Name, SectionKind K) {
235
+ static SectionKind getELFKindForNamedSection (StringRef Name, SectionKind K,
236
+ const Triple &TargetTriple) {
236
237
// N.B.: The defaults used in here are not the same ones used in MC.
237
238
// We follow gcc, MC follows gas. For example, given ".section .eh_frame",
238
239
// both gas and MC will produce a section with no flags. Given
@@ -264,6 +265,7 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
264
265
return SectionKind::getThreadData ();
265
266
266
267
if (Name == " .tbss" ||
268
+ (TargetTriple.isAndroid () && Name == " .tcommon" ) || // LDC
267
269
Name.startswith (" .tbss." ) ||
268
270
Name.startswith (" .gnu.linkonce.tb." ) ||
269
271
Name.startswith (" .llvm.linkonce.tb." ))
@@ -294,7 +296,7 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) {
294
296
return ELF::SHT_PROGBITS;
295
297
}
296
298
297
- static unsigned getELFSectionFlags (SectionKind K) {
299
+ static unsigned getELFSectionFlags (SectionKind K, const Triple &TargetTriple ) {
298
300
unsigned Flags = 0 ;
299
301
300
302
if (!K.isMetadata ())
@@ -309,7 +311,7 @@ static unsigned getELFSectionFlags(SectionKind K) {
309
311
if (K.isWriteable ())
310
312
Flags |= ELF::SHF_WRITE;
311
313
312
- if (K.isThreadLocal ())
314
+ if (K.isThreadLocal () && !TargetTriple. isAndroid ()) // LDC
313
315
Flags |= ELF::SHF_TLS;
314
316
315
317
if (K.isMergeableCString () || K.isMergeableConst ())
@@ -375,10 +377,10 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
375
377
}
376
378
377
379
// Infer section flags from the section name if we can.
378
- Kind = getELFKindForNamedSection (SectionName, Kind);
380
+ Kind = getELFKindForNamedSection (SectionName, Kind, getTargetTriple () );
379
381
380
382
StringRef Group = " " ;
381
- unsigned Flags = getELFSectionFlags (Kind);
383
+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
382
384
if (const Comdat *C = getELFComdat (GO)) {
383
385
Group = C->getName ();
384
386
Flags |= ELF::SHF_GROUP;
@@ -502,7 +504,7 @@ static MCSectionELF *selectELFSectionForGlobal(
502
504
503
505
MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal (
504
506
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
505
- unsigned Flags = getELFSectionFlags (Kind);
507
+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
506
508
507
509
// If we have -ffunction-section or -fdata-section then we should emit the
508
510
// global value to a uniqued section specifically for it.
0 commit comments