@@ -109,8 +109,8 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
109
109
MMI, Streamer);
110
110
}
111
111
112
- static SectionKind
113
- getELFKindForNamedSection (StringRef Name, SectionKind K ) {
112
+ static SectionKind getELFKindForNamedSection (StringRef Name, SectionKind K,
113
+ const Triple &TargetTriple ) {
114
114
// N.B.: The defaults used in here are no the same ones used in MC.
115
115
// We follow gcc, MC follows gas. For example, given ".section .eh_frame",
116
116
// both gas and MC will produce a section with no flags. Given
@@ -141,6 +141,7 @@ getELFKindForNamedSection(StringRef Name, SectionKind K) {
141
141
return SectionKind::getThreadData ();
142
142
143
143
if (Name == " .tbss" ||
144
+ (TargetTriple.isAndroid () && Name == " .tcommon" ) || // LDC
144
145
Name.startswith (" .tbss." ) ||
145
146
Name.startswith (" .gnu.linkonce.tb." ) ||
146
147
Name.startswith (" .llvm.linkonce.tb." ))
@@ -172,7 +173,7 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) {
172
173
return ELF::SHT_PROGBITS;
173
174
}
174
175
175
- static unsigned getELFSectionFlags (SectionKind K) {
176
+ static unsigned getELFSectionFlags (SectionKind K, const Triple &TargetTriple ) {
176
177
unsigned Flags = 0 ;
177
178
178
179
if (!K.isMetadata ())
@@ -187,7 +188,7 @@ static unsigned getELFSectionFlags(SectionKind K) {
187
188
if (K.isWriteable ())
188
189
Flags |= ELF::SHF_WRITE;
189
190
190
- if (K.isThreadLocal ())
191
+ if (K.isThreadLocal () && !TargetTriple. isAndroid ()) // LDC
191
192
Flags |= ELF::SHF_TLS;
192
193
193
194
if (K.isMergeableCString () || K.isMergeableConst ())
@@ -216,10 +217,10 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
216
217
StringRef SectionName = GO->getSection ();
217
218
218
219
// Infer section flags from the section name if we can.
219
- Kind = getELFKindForNamedSection (SectionName, Kind);
220
+ Kind = getELFKindForNamedSection (SectionName, Kind, getTargetTriple () );
220
221
221
222
StringRef Group = " " ;
222
- unsigned Flags = getELFSectionFlags (Kind);
223
+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
223
224
if (const Comdat *C = getELFComdat (GO)) {
224
225
Group = C->getName ();
225
226
Flags |= ELF::SHF_GROUP;
@@ -324,7 +325,7 @@ selectELFSectionForGlobal(MCContext &Ctx, const GlobalObject *GO,
324
325
325
326
MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal (
326
327
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
327
- unsigned Flags = getELFSectionFlags (Kind);
328
+ unsigned Flags = getELFSectionFlags (Kind, getTargetTriple () );
328
329
329
330
// If we have -ffunction-section or -fdata-section then we should emit the
330
331
// global value to a uniqued section specifically for it.
0 commit comments