diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-24 21:57:39 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-24 21:57:39 +0000 |
commit | 25958730dffe0a16f9c251a1fa317799b8419a1f (patch) | |
tree | a9223e455a84f95e29c73b82f114b6d3ef344857 /lib/MC | |
parent | 8b4e60c276fc2e7f01a07343197d3956d3526d8d (diff) |
Behave a bit more like gnu as and use the symbol (instead of the section)
for any relocation to a symbol defined in a tls section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 12 | ||||
-rw-r--r-- | lib/MC/MCParser/ELFAsmParser.cpp | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 7c322f3577..3b649dbbd2 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -718,10 +718,17 @@ const MCSymbol *ELFObjectWriter::SymbolToReloc(const MCAssembler &Asm, const MCSectionELF &Section = static_cast<const MCSectionELF&>(ASymbol.getSection()); + const SectionKind secKind = Section.getKind(); - if (Section.getKind().isBSS()) + if (secKind.isBSS()) return NULL; + if (secKind.isThreadLocal()) { + if (Renamed) + return Renamed; + return &Symbol; + } + MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind(); const MCSectionELF &Sec2 = static_cast<const MCSectionELF&>(F.getParent()->getSection()); @@ -729,8 +736,7 @@ const MCSymbol *ELFObjectWriter::SymbolToReloc(const MCAssembler &Asm, if (&Sec2 != &Section && (Kind == MCSymbolRefExpr::VK_PLT || Kind == MCSymbolRefExpr::VK_GOTPCREL || - Kind == MCSymbolRefExpr::VK_GOTOFF || - Kind == MCSymbolRefExpr::VK_NTPOFF)) { + Kind == MCSymbolRefExpr::VK_GOTOFF)) { if (Renamed) return Renamed; return &Symbol; diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index d074ea9d78..42cd919472 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/lib/MC/MCParser/ELFAsmParser.cpp @@ -193,6 +193,14 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) { return false; } +static SectionKind computeSectionKind(unsigned Flags) { + if (Flags & MCSectionELF::SHF_EXECINSTR) + return SectionKind::getText(); + if (Flags & MCSectionELF::SHF_TLS) + return SectionKind::getThreadData(); + return SectionKind::getDataRel(); +} + // FIXME: This is a work in progress. bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { StringRef SectionName; @@ -322,9 +330,7 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { return TokError("unknown section type"); } - SectionKind Kind = (Flags & MCSectionELF::SHF_EXECINSTR) - ? SectionKind::getText() - : SectionKind::getDataRel(); + SectionKind Kind = computeSectionKind(Flags); getStreamer().SwitchSection(getContext().getELFSection(SectionName, Type, Flags, Kind, Size, GroupName)); |