summaryrefslogtreecommitdiff
path: root/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-09-18 15:03:21 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-09-18 15:03:21 +0000
commitad49cf586624c400302d17ecc2c2e41ea4346f1a (patch)
treed5f830915f4aefbd2f80f85ade1e45459333106b /lib/MC/ELFObjectWriter.cpp
parent9e8d1f97e9f32c87aac1189edbc3263a1f4a81f3 (diff)
downloadllvm-ad49cf586624c400302d17ecc2c2e41ea4346f1a.tar.gz
llvm-ad49cf586624c400302d17ecc2c2e41ea4346f1a.tar.bz2
llvm-ad49cf586624c400302d17ecc2c2e41ea4346f1a.tar.xz
Make sure the STT_FILE symbol is the first one in the symbol table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r--lib/MC/ELFObjectWriter.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index d0fc9cac47..35f029d2fa 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -34,6 +34,15 @@
#include <vector>
using namespace llvm;
+static unsigned GetType(const MCSymbolData &SD) {
+ uint32_t Type = (SD.getFlags() & (0xf << ELF_STT_Shift)) >> ELF_STT_Shift;
+ assert(Type == ELF::STT_NOTYPE || Type == ELF::STT_OBJECT ||
+ Type == ELF::STT_FUNC || Type == ELF::STT_SECTION ||
+ Type == ELF::STT_FILE || Type == ELF::STT_COMMON ||
+ Type == ELF::STT_TLS);
+ return Type;
+}
+
namespace {
class ELFObjectWriterImpl {
@@ -64,6 +73,10 @@ namespace {
// Support lexicographic sorting.
bool operator<(const ELFSymbolData &RHS) const {
+ if (GetType(*SymbolData) == ELF::STT_FILE)
+ return true;
+ if (GetType(*RHS.SymbolData) == ELF::STT_FILE)
+ return false;
return SymbolData->getSymbol().getName() <
RHS.SymbolData->getSymbol().getName();
}