From 3008f805620b3a4ff7cdad482cd9f226c9f2c133 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 26 Mar 2014 00:16:43 +0000 Subject: Correctly detect if a symbol uses a reserved section index or not. The logic was incorrect for variables, causing them to end up in the wrong section if the section had an index >= 0xff00. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204771 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/ELFObjectWriter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/MC/ELFObjectWriter.cpp') diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index eb8b9bfe0c..7c2135b248 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -612,13 +612,15 @@ void ELFObjectWriter::WriteSymbol(SymbolTableWriter &Writer, ELFSymbolData &MSD, MCSymbolData &Data = Layout.getAssembler().getSymbolData(OrigData.getSymbol().AliasedSymbol()); - bool IsReserved = Data.isCommon() || Data.getSymbol().isAbsolute() || - Data.getSymbol().isVariable(); + const MCSymbol *Base = getBaseSymbol(Layout, OrigData.getSymbol()); + + // This has to be in sync with when computeSymbolTable uses SHN_ABS or + // SHN_COMMON. + bool IsReserved = !Base || OrigData.isCommon(); // Binding and Type share the same byte as upper and lower nibbles uint8_t Binding = MCELF::GetBinding(OrigData); uint8_t Type = MCELF::GetType(OrigData); - const MCSymbol *Base = getBaseSymbol(Layout, OrigData.getSymbol()); if (Base) { MCSymbolData BaseSD = Layout.getAssembler().getSymbolData(*Base); Type = mergeTypeForSet(Type, MCELF::GetType(BaseSD)); -- cgit v1.2.3