summaryrefslogtreecommitdiff
path: root/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-03-17 17:13:54 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-03-17 17:13:54 +0000
commit5b5e5abd20e27217bf151c8bbf1da102e1a5c969 (patch)
tree87f25d9b026abc23af6ef34e9b67687bbfd8e5d2 /lib/MC/ELFObjectWriter.cpp
parent8c8fe42a0d81f002fbae486ed45027d32dae7eeb (diff)
downloadllvm-5b5e5abd20e27217bf151c8bbf1da102e1a5c969.tar.gz
llvm-5b5e5abd20e27217bf151c8bbf1da102e1a5c969.tar.bz2
llvm-5b5e5abd20e27217bf151c8bbf1da102e1a5c969.tar.xz
ARM IAS: support .thumb_set
This performs the equivalent of a .set directive in that it creates a symbol which is an alias for another symbol or value which may possibly be yet undefined. This directive also has the added property in that it marks the aliased symbol as being a thumb function entry point, in the same way that the .thumb_func directive does. The current implementation fails one test due to an unrelated issue. Functions within .thumb sections are not marked as thumb_func. The result is that the aliasee function is not valued correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r--lib/MC/ELFObjectWriter.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index 54703b9912..dd06304b71 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -470,6 +470,7 @@ uint64_t ELFObjectWriter::SymbolValue(MCSymbolData &OrigData,
return Data->getCommonAlignment();
const MCSymbol *Symbol = &Data->getSymbol();
+ const bool IsThumbFunc = OrigData.getFlags() & ELF_Other_ThumbFunc;
uint64_t Res = 0;
if (Symbol->isVariable()) {
@@ -479,7 +480,10 @@ uint64_t ELFObjectWriter::SymbolValue(MCSymbolData &OrigData,
return 0;
if (Value.getSymB())
return 0;
+
Res = Value.getConstant();
+ if (IsThumbFunc)
+ Res |= 1;
const MCSymbolRefExpr *A = Value.getSymA();
if (!A)
@@ -496,8 +500,8 @@ uint64_t ELFObjectWriter::SymbolValue(MCSymbolData &OrigData,
return 0;
Res += Layout.getSymbolOffset(Data);
- if (Data->getFlags() & ELF_Other_ThumbFunc)
- ++Res;
+ if (IsThumbFunc || Data->getFlags() & ELF_Other_ThumbFunc)
+ Res |= 1;
return Res;
}
@@ -590,6 +594,8 @@ void ELFObjectWriter::WriteSymbol(MCDataFragment *SymtabF,
// Binding and Type share the same byte as upper and lower nibbles
uint8_t Binding = MCELF::GetBinding(OrigData);
uint8_t Type = mergeTypeForSet(MCELF::GetType(OrigData), MCELF::GetType(Data));
+ 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