diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-03-17 17:13:54 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-03-17 17:13:54 +0000 |
commit | 11543a9953111cd29623653d5f9ca5749f05b8d6 (patch) | |
tree | ccd76e775f53a933c0aa6310f7530cdd402406c7 /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 24381f1cb74d230d029e4804f8eaf46b7ff5deb2 (diff) | |
download | llvm-11543a9953111cd29623653d5f9ca5749f05b8d6.zip llvm-11543a9953111cd29623653d5f9ca5749f05b8d6.tar.gz llvm-11543a9953111cd29623653d5f9ca5749f05b8d6.tar.bz2 |
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.
llvm-svn: 204059
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 54703b9..dd06304 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/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 |