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