mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-04 02:40:42 +00:00
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:
parent
596516bef8
commit
3008f80562
@ -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));
|
||||
|
@ -10,8 +10,28 @@
|
||||
// Test that we don't create a symbol for the symtab_shndx section.
|
||||
// SYMBOLS-NOT: symtab_shndx
|
||||
|
||||
// Test that this file has one section too many.
|
||||
|
||||
// Test that both a and b show up in the correct section.
|
||||
// SYMBOLS: Name: a (1)
|
||||
// SYMBOLS-NEXT: Value: 0x0
|
||||
// SYMBOLS-NEXT: Size: 0
|
||||
// SYMBOLS-NEXT: Binding: Local (0x0)
|
||||
// SYMBOLS-NEXT: Type: None (0x0)
|
||||
// SYMBOLS-NEXT: Other: 0
|
||||
// SYMBOLS-NEXT: Section: last (0xFF00)
|
||||
// SYMBOLS-NEXT: }
|
||||
// SYMBOLS-NEXT: Symbol {
|
||||
// SYMBOLS-NEXT: Name: b (3)
|
||||
// SYMBOLS-NEXT: Value: 0x1
|
||||
// SYMBOLS-NEXT: Size: 0
|
||||
// SYMBOLS-NEXT: Binding: Local (0x0)
|
||||
// SYMBOLS-NEXT: Type: None (0x0)
|
||||
// SYMBOLS-NEXT: Other: 0
|
||||
// SYMBOLS-NEXT: Section: last (0xFF00)
|
||||
// SYMBOLS-NEXT: }
|
||||
|
||||
|
||||
// Test that this file has one section too many.
|
||||
// SYMBOLS: Name: last (0)
|
||||
// SYMBOLS-NEXT: Value: 0x0
|
||||
// SYMBOLS-NEXT: Size: 0
|
||||
@ -109,3 +129,5 @@ gen_sections8 l
|
||||
gen_sections4 m
|
||||
|
||||
.section last
|
||||
a:
|
||||
b = a + 1
|
||||
|
Loading…
Reference in New Issue
Block a user