Index: llvm/test/tools/llvm-readobj/ELF/mips-got.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/mips-got.test +++ llvm/test/tools/llvm-readobj/ELF/mips-got.test @@ -672,6 +672,12 @@ # SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON) # SEC-SYMS-LLVM-NEXT: Name: (0) # SEC-SYMS-LLVM-NEXT: } +# SEC-SYMS-LLVM-NEXT: Entry { +# SEC-SYMS-LLVM: Type: Section (0x3) +# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': extended symbol index (4) is past the end of the SHT_SYMTAB_SHNDX section of size 0 +# SEC-SYMS-LLVM-NEXT: Section: Reserved (0xFFFF) +# SEC-SYMS-LLVM-NEXT: Name: (0) +# SEC-SYMS-LLVM-NEXT: } # SEC-SYMS-LLVM-NEXT: ] # SEC-SYMS-GNU: Global entries: @@ -681,6 +687,8 @@ # SEC-SYMS-GNU-NEXT: {{.*}} 1 .got # SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON) # SEC-SYMS-GNU-NEXT: {{.*}} COM +# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': extended symbol index (4) is past the end of the SHT_SYMTAB_SHNDX section of size 0 +# SEC-SYMS-GNU-NEXT: {{.*}} RSV[0xffff] --- !ELF FileHeader: @@ -709,3 +717,5 @@ Section: .got - Type: STT_SECTION Index: SHN_COMMON + - Type: STT_SECTION + Index: SHN_XINDEX Index: llvm/test/tools/llvm-readobj/ELF/mips-plt.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/mips-plt.test +++ llvm/test/tools/llvm-readobj/ELF/mips-plt.test @@ -162,6 +162,12 @@ # SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON) # SEC-SYMS-LLVM-NEXT: Name: (0) # SEC-SYMS-LLVM-NEXT: } +# SEC-SYMS-LLVM-NEXT: Entry { +# SEC-SYMS-LLVM: Type: Section (0x3) +# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': extended symbol index (4) is past the end of the SHT_SYMTAB_SHNDX section of size 0 +# SEC-SYMS-LLVM-NEXT: Section: Reserved (0xFFFF) +# SEC-SYMS-LLVM-NEXT: Name: (0) +# SEC-SYMS-LLVM-NEXT: } # SEC-SYMS-LLVM-NEXT: ] # SEC-SYMS-LLVM-NEXT: } @@ -173,6 +179,8 @@ # SEC-SYMS-GNU-NEXT: 0000000000002018 {{.*}} 2 .got.plt # SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON) # SEC-SYMS-GNU-NEXT: 0000000000002020 {{.*}} COM +# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': extended symbol index (4) is past the end of the SHT_SYMTAB_SHNDX section of size 0 +# SEC-SYMS-GNU-NEXT: 0000000000002028 {{.*}} RSV[0xffff] --- !ELF FileHeader: @@ -196,11 +204,14 @@ - Offset: 0x2 Symbol: 3 Type: R_MIPS_JUMP_SLOT + - Offset: 0x3 + Symbol: 4 + Type: R_MIPS_JUMP_SLOT - Name: .got.plt Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] Address: 0x2000 - Size: 40 ## (dynamic symbols number + 2) * 8 + Size: 48 ## (dynamic symbols number + 2) * 8 - Name: .dynamic Type: SHT_DYNAMIC Entries: @@ -215,3 +226,5 @@ Section: .got.plt - Type: STT_SECTION Index: SHN_COMMON + - Type: STT_SECTION + Index: SHN_XINDEX Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -2949,7 +2949,6 @@ uint64_t getGotAddress(const Entry * E) const; int64_t getGotOffset(const Entry * E) const; const Elf_Sym *getGotSym(const Entry *E) const; - Elf_Sym_Range getGotDynSyms() const { return GotDynSyms; } uint64_t getPltAddress(const Entry * E) const; const Elf_Sym *getPltSym(const Entry *E) const; @@ -5844,7 +5843,7 @@ const Elf_Sym *Sym = Parser.getGotSym(&E); const Elf_Sym *FirstSym = &this->dumper()->dynamic_symbols()[0]; std::string SymName = this->dumper()->getFullSymbolName( - Sym, FirstSym - Sym, this->dumper()->getDynamicStringTable(), false); + Sym, Sym - FirstSym, this->dumper()->getDynamicStringTable(), false); OS.PadToColumn(2); OS << to_string(format_hex_no_prefix(Parser.getGotAddress(&E), 8 + Bias)); @@ -5899,7 +5898,7 @@ cantFail(this->Obj.template getEntry( *Parser.getPltSymTable(), 0)); std::string SymName = this->dumper()->getFullSymbolName( - Sym, FirstSym - Sym, this->dumper()->getDynamicStringTable(), false); + Sym, Sym - FirstSym, this->dumper()->getDynamicStringTable(), false); OS.PadToColumn(2); OS << to_string(format_hex_no_prefix(Parser.getPltAddress(&E), 8 + Bias)); @@ -6772,11 +6771,12 @@ const Elf_Sym *Sym = Parser.getGotSym(&E); W.printHex("Value", Sym->st_value); W.printEnum("Type", Sym->getType(), makeArrayRef(ElfSymbolTypes)); - printSymbolSection(Sym, Sym - this->dumper()->dynamic_symbols().begin()); + + const unsigned SymIndex = Sym - this->dumper()->dynamic_symbols().begin(); + printSymbolSection(Sym, SymIndex); std::string SymName = this->dumper()->getFullSymbolName( - Sym, Sym - &Parser.getGotDynSyms()[0], - this->dumper()->getDynamicStringTable(), true); + Sym, SymIndex, this->dumper()->getDynamicStringTable(), true); W.printNumber("Name", SymName, Sym->st_name); } }