diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2013-06-10 20:36:52 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2013-06-10 20:36:52 +0000 | 
| commit | 59d6cff90eecf31cb3dd860c4e786674cfdd42eb (patch) | |
| tree | 909310b2e05119d1d6efda049977042abbb58bb1 /lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
| parent | 4a16efa3e43e35f0cc9efe3a67f620f0017c3d36 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
| -rw-r--r-- | lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 55 | 
1 files changed, 50 insertions, 5 deletions
| diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 3bdca4c64078..7e7359a8feed 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -523,11 +523,6 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,  const MCSection *TargetLoweringObjectFileMachO::  SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,                         Mangler *Mang, const TargetMachine &TM) const { - -  // Handle thread local data. -  if (Kind.isThreadBSS()) return TLSBSSSection; -  if (Kind.isThreadData()) return TLSDataSection; -    if (Kind.isText())      return GV->isWeakForLinker() ? TextCoalSection : TextSection; @@ -580,6 +575,10 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,    if (Kind.isBSSLocal())      return DataBSSSection; +  // Handle thread local data. +  if (Kind.isThreadBSS()) return TLSBSSSection; +  if (Kind.isThreadData()) return TLSDataSection; +    // Otherwise, just drop the variable in the normal data section.    return DataSection;  } @@ -782,3 +781,49 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,    return getDataSection();  } +void TargetLoweringObjectFileCOFF:: +emitModuleFlags(MCStreamer &Streamer, +                ArrayRef<Module::ModuleFlagEntry> ModuleFlags, +                Mangler *Mang, const TargetMachine &TM) const { +  MDNode *LinkerOptions = 0; + +  // Look for the "Linker Options" flag, since it's the only one we support. +  for (ArrayRef<Module::ModuleFlagEntry>::iterator +       i = ModuleFlags.begin(), e = ModuleFlags.end(); i != e; ++i) { +    const Module::ModuleFlagEntry &MFE = *i; +    StringRef Key = MFE.Key->getString(); +    Value *Val = MFE.Val; +    if (Key == "Linker Options") { +      LinkerOptions = cast<MDNode>(Val); +      break; +    } +  } +  if (!LinkerOptions) +    return; + +  // Emit the linker options to the linker .drectve section.  According to the +  // spec, this section is a space-separated string containing flags for linker. +  const MCSection *Sec = getDrectveSection(); +  Streamer.SwitchSection(Sec); +  for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i != e; ++i) { +    MDNode *MDOptions = cast<MDNode>(LinkerOptions->getOperand(i)); +    for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) { +      MDString *MDOption = cast<MDString>(MDOptions->getOperand(ii)); +      StringRef Op = MDOption->getString(); +      // Lead with a space for consistency with our dllexport implementation. +      std::string Escaped(" "); +      if (Op.find(" ") != StringRef::npos) { +        // The PE-COFF spec says args with spaces must be quoted.  It doesn't say +        // how to escape quotes, but it probably uses this algorithm: +        // http://msdn.microsoft.com/en-us/library/17w5ykft(v=vs.85).aspx +        // FIXME: Reuse escaping code from Support/Windows/Program.inc +        Escaped.push_back('\"'); +        Escaped.append(Op); +        Escaped.push_back('\"'); +      } else { +        Escaped.append(Op); +      } +      Streamer.EmitBytes(Escaped); +    } +  } +} | 
