diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-04-29 12:46:50 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-04-29 12:46:50 +0000 |
commit | b60c829a2a83fd21f0c4c78a956d9e6a7a21918f (patch) | |
tree | 2a071ed6ee2304e7f5a7cfbf539b2d6caa80fb13 /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 6468f5d3094708b2290ebddc28a2ba3fa1f25f6f (diff) | |
download | llvm-b60c829a2a83fd21f0c4c78a956d9e6a7a21918f.zip llvm-b60c829a2a83fd21f0c4c78a956d9e6a7a21918f.tar.gz llvm-b60c829a2a83fd21f0c4c78a956d9e6a7a21918f.tar.bz2 |
Centralize the handling of the thumb bit.
This patch centralizes the handling of the thumb bit around
MCStreamer::isThumbFunc and makes isThumbFunc handle aliases.
This fixes a corner case, but the main advantage is having just one
way to check if a MCSymbol is thumb or not. This should still be
refactored to be ARM only, but at least now it is just one predicate
that has to be refactored instead of 3 (isThumbFunc,
ELF_Other_ThumbFunc, and SF_ThumbFunc).
llvm-svn: 207522
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 1b7ac64..2e07e22 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -215,7 +215,8 @@ class ELFObjectWriter : public MCObjectWriter { const MCAsmLayout &Layout, SectionIndexMapTy &SectionIndexMap); - bool shouldRelocateWithSymbol(const MCSymbolRefExpr *RefA, + bool shouldRelocateWithSymbol(const MCAssembler &Asm, + const MCSymbolRefExpr *RefA, const MCSymbolData *SD, uint64_t C, unsigned Type) const; @@ -486,6 +487,7 @@ void ELFObjectWriter::WriteHeader(const MCAssembler &Asm, uint64_t ELFObjectWriter::SymbolValue(MCSymbolData &OrigData, const MCAsmLayout &Layout) { + const MCSymbol &OrigSymbol = OrigData.getSymbol(); MCSymbolData *Data = &OrigData; if (Data->isCommon() && Data->isExternal()) return Data->getCommonAlignment(); @@ -512,8 +514,8 @@ uint64_t ELFObjectWriter::SymbolValue(MCSymbolData &OrigData, } } - if ((Data && Data->getFlags() & ELF_Other_ThumbFunc) || - OrigData.getFlags() & ELF_Other_ThumbFunc) + const MCAssembler &Asm = Layout.getAssembler(); + if (Asm.isThumbFunc(&OrigSymbol)) Res |= 1; if (!Symbol || !Symbol->isInSection()) @@ -641,8 +643,6 @@ void ELFObjectWriter::WriteSymbol(SymbolTableWriter &Writer, ELFSymbolData &MSD, BaseSD = &Layout.getAssembler().getSymbolData(*Base); Type = mergeTypeForSet(Type, MCELF::GetType(*BaseSD)); } - if (OrigData.getFlags() & ELF_Other_ThumbFunc) - Type = ELF::STT_FUNC; uint8_t Info = (Binding << ELF_STB_Shift) | (Type << ELF_STT_Shift); // Other and Visibility share the same byte with Visibility using the lower @@ -737,7 +737,8 @@ void ELFObjectWriter::WriteSymbolTable(MCDataFragment *SymtabF, // It is always valid to create a relocation with a symbol. It is preferable // to use a relocation with a section if that is possible. Using the section // allows us to omit some local symbols from the symbol table. -bool ELFObjectWriter::shouldRelocateWithSymbol(const MCSymbolRefExpr *RefA, +bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm, + const MCSymbolRefExpr *RefA, const MCSymbolData *SD, uint64_t C, unsigned Type) const { @@ -825,7 +826,7 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCSymbolRefExpr *RefA, // bit. With a symbol that is done by just having the symbol have that bit // set, so we would lose the bit if we relocated with the section. // FIXME: We could use the section but add the bit to the relocation value. - if (SD->getFlags() & ELF_Other_ThumbFunc) + if (Asm.isThumbFunc(&Sym)) return true; if (TargetObjectWriter->needsRelocateWithSymbol(Type)) @@ -887,7 +888,7 @@ void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm, const MCSymbolData *SymAD = SymA ? &Asm.getSymbolData(*SymA) : nullptr; unsigned Type = GetRelocType(Target, Fixup, IsPCRel); - bool RelocateWithSymbol = shouldRelocateWithSymbol(RefA, SymAD, C, Type); + bool RelocateWithSymbol = shouldRelocateWithSymbol(Asm, RefA, SymAD, C, Type); if (!RelocateWithSymbol && SymA && !SymA->isUndefined()) C += Layout.getSymbolOffset(SymAD); |