@@ -168,8 +168,8 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
168
168
MMI, Streamer);
169
169
}
170
170
171
- static SectionKind
172
- getELFKindForNamedSection (StringRef Name, SectionKind K ) {
171
+ static SectionKind getELFKindForNamedSection (StringRef Name, SectionKind K,
172
+ const Triple &TargetTriple ) {
173
173
// N.B.: The defaults used in here are no the same ones used in MC.
174
174
// We follow gcc, MC follows gas. For example, given ".section .eh_frame",
175
175
// both gas and MC will produce a section with no flags. Given
@@ -201,6 +201,7 @@ getELFKindForNamedSection(StringRef Name, SectionKind K) {
201
201
return SectionKind::getThreadData ();
202
202
203
203
if (Name == " .tbss" ||
204
+ (TargetTriple.isAndroid () && Name == " .tcommon" ) || // LDC
204
205
Name.startswith (" .tbss." ) ||
205
206
Name.startswith (" .gnu.linkonce.tb." ) ||
206
207
Name.startswith (" .llvm.linkonce.tb." ))
@@ -231,7 +232,7 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) {
231
232
return ELF::SHT_PROGBITS;
232
233
}
233
234
234
- static unsigned getELFSectionFlags (SectionKind K) {
235
+ static unsigned getELFSectionFlags (SectionKind K, const Triple &TargetTriple ) {
235
236
unsigned Flags = 0 ;
236
237
237
238
if (!K.isMetadata ())
@@ -246,7 +247,7 @@ static unsigned getELFSectionFlags(SectionKind K) {
246
247
if (K.isWriteable ())
247
248
Flags |= ELF::SHF_WRITE;
248
249
249
- if (K.isThreadLocal ())
250
+ if (K.isThreadLocal () && !TargetTriple. isAndroid ()) // LDC
250
251
Flags |= ELF::SHF_TLS;
251
252
252
253
if (K.isMergeableCString () || K.isMergeableConst ())
@@ -312,10 +313,10 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
312
313
}
313
314
314
315
// Infer section flags from the section name if we can.
315
- Kind = getELFKindForNamedSection (SectionName, Kind);
316
+ Kind = getELFKindForNamedSection (SectionName, Kind, getTargetTriple () );
316
317
317
318
StringRef Group = " " ;
318
- unsigned Flags = getELFSectionFlags (Kind);
319
+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
319
320
if (const Comdat *C = getELFComdat (GO)) {
320
321
Group = C->getName ();
321
322
Flags |= ELF::SHF_GROUP;
@@ -433,7 +434,7 @@ static MCSectionELF *selectELFSectionForGlobal(
433
434
434
435
MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal (
435
436
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
436
- unsigned Flags = getELFSectionFlags (Kind);
437
+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
437
438
438
439
// If we have -ffunction-section or -fdata-section then we should emit the
439
440
// global value to a uniqued section specifically for it.
0 commit comments