mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[llvm-readelf] Symbol index in symbol table printing is not reset
Stop using static variables for keeping track of symbol indices. Bugfix for: https://bugs.llvm.org/show_bug.cgi?id=46777 Differential revision: https://reviews.llvm.org/D84606
This commit is contained in:
parent
bd1fad1fc2
commit
b144aa73c9
@ -103,6 +103,16 @@
|
||||
# RUN: llvm-readobj --dyn-symbols %t64 | FileCheck %s --implicit-check-not="{{^}}Symbols ["
|
||||
# RUN: llvm-readelf --dyn-symbols %t64 | FileCheck %s --implicit-check-not="Symbol table '.symtab'"
|
||||
|
||||
## Case 6: Test that the Num index starts from zero at every new symbol table.
|
||||
# RUN: llvm-readelf --symbols %t64 %t64 | FileCheck %s --check-prefix=NUM-INDEX
|
||||
|
||||
# NUM-INDEX: Symbol table '.symtab' contains 3 entries:
|
||||
# NUM-INDEX-NEXT: Num: {{.*}}
|
||||
# NUM-INDEX-NEXT: 0: {{.*}}
|
||||
# NUM-INDEX: Symbol table '.symtab' contains 3 entries:
|
||||
# NUM-INDEX-NEXT: Num: {{.*}}
|
||||
# NUM-INDEX-NEXT: 0: {{.*}}
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS[[BITS]]
|
||||
|
@ -3924,21 +3924,10 @@ void GNUStyle<ELFT>::printSymbol(const ELFO *Obj, const Elf_Sym *Symbol,
|
||||
const Elf_Sym *FirstSym,
|
||||
Optional<StringRef> StrTable, bool IsDynamic,
|
||||
bool NonVisibilityBitsUsed) {
|
||||
static int Idx = 0;
|
||||
static bool Dynamic = true;
|
||||
|
||||
// If this function was called with a different value from IsDynamic
|
||||
// from last call, happens when we move from dynamic to static symbol
|
||||
// table, "Num" field should be reset.
|
||||
if (!Dynamic != !IsDynamic) {
|
||||
Idx = 0;
|
||||
Dynamic = false;
|
||||
}
|
||||
|
||||
unsigned Bias = ELFT::Is64Bits ? 8 : 0;
|
||||
Field Fields[8] = {0, 8, 17 + Bias, 23 + Bias,
|
||||
31 + Bias, 38 + Bias, 48 + Bias, 51 + Bias};
|
||||
Fields[0].Str = to_string(format_decimal(Idx++, 6)) + ":";
|
||||
Fields[0].Str = to_string(format_decimal(Symbol - FirstSym, 6)) + ":";
|
||||
Fields[1].Str = to_string(
|
||||
format_hex_no_prefix(Symbol->st_value, ELFT::Is64Bits ? 16 : 8));
|
||||
Fields[2].Str = to_string(format_decimal(Symbol->st_size, 5));
|
||||
|
Loading…
Reference in New Issue
Block a user