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
This commit is contained in:
Rafael Espindola
2014-03-26 00:16:43 +00:00
parent 596516bef8
commit 3008f80562
2 changed files with 28 additions and 4 deletions

View File

@@ -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));