mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-02 07:41:38 +00:00
Convert obj->getSymbolName to sym->getName.
I doesn't depend on the object anymore. llvm-svn: 240996
This commit is contained in:
parent
7882eec9af
commit
811342ba38
@ -371,7 +371,6 @@ public:
|
|||||||
///
|
///
|
||||||
/// \p SymTab is used to lookup the string table to use to get the symbol's
|
/// \p SymTab is used to lookup the string table to use to get the symbol's
|
||||||
/// name.
|
/// name.
|
||||||
ErrorOr<StringRef> getSymbolName(StringRef StrTab, const Elf_Sym *Symb) const;
|
|
||||||
ErrorOr<StringRef> getSectionName(const Elf_Shdr *Section) const;
|
ErrorOr<StringRef> getSectionName(const Elf_Shdr *Section) const;
|
||||||
uint64_t getSymbolIndex(const Elf_Sym *sym) const;
|
uint64_t getSymbolIndex(const Elf_Sym *sym) const;
|
||||||
ErrorOr<ArrayRef<uint8_t> > getSectionContents(const Elf_Shdr *Sec) const;
|
ErrorOr<ArrayRef<uint8_t> > getSectionContents(const Elf_Shdr *Sec) const;
|
||||||
@ -881,7 +880,7 @@ const char *ELFFile<ELFT>::getDynamicString(uintX_t Offset) const {
|
|||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
ErrorOr<StringRef>
|
ErrorOr<StringRef>
|
||||||
ELFFile<ELFT>::getStaticSymbolName(const Elf_Sym *Symb) const {
|
ELFFile<ELFT>::getStaticSymbolName(const Elf_Sym *Symb) const {
|
||||||
return getSymbolName(DotStrtab, Symb);
|
return Symb->getName(DotStrtab);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
@ -898,15 +897,6 @@ ErrorOr<StringRef> ELFFile<ELFT>::getSymbolName(const Elf_Sym *Symb,
|
|||||||
return getStaticSymbolName(Symb);
|
return getStaticSymbolName(Symb);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
|
||||||
ErrorOr<StringRef> ELFFile<ELFT>::getSymbolName(StringRef StrTab,
|
|
||||||
const Elf_Sym *Sym) const {
|
|
||||||
uint32_t Offset = Sym->st_name;
|
|
||||||
if (Offset >= StrTab.size())
|
|
||||||
return object_error::parse_failed;
|
|
||||||
return StringRef(StrTab.data() + Offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
ErrorOr<StringRef>
|
ErrorOr<StringRef>
|
||||||
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
|
ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const {
|
||||||
@ -932,7 +922,7 @@ ErrorOr<StringRef> ELFFile<ELFT>::getSymbolVersion(const Elf_Shdr *section,
|
|||||||
// Non-dynamic symbols can have versions in their names
|
// Non-dynamic symbols can have versions in their names
|
||||||
// A name of the form 'foo@V1' indicates version 'V1', non-default.
|
// A name of the form 'foo@V1' indicates version 'V1', non-default.
|
||||||
// A name of the form 'foo@@V2' indicates version 'V2', default version.
|
// A name of the form 'foo@@V2' indicates version 'V2', default version.
|
||||||
ErrorOr<StringRef> SymName = getSymbolName(StrTab, symb);
|
ErrorOr<StringRef> SymName = symb->getName(StrTab);
|
||||||
if (!SymName)
|
if (!SymName)
|
||||||
return SymName;
|
return SymName;
|
||||||
StringRef Name = *SymName;
|
StringRef Name = *SymName;
|
||||||
|
@ -10,9 +10,11 @@
|
|||||||
#ifndef LLVM_OBJECT_ELFTYPES_H
|
#ifndef LLVM_OBJECT_ELFTYPES_H
|
||||||
#define LLVM_OBJECT_ELFTYPES_H
|
#define LLVM_OBJECT_ELFTYPES_H
|
||||||
|
|
||||||
|
#include "llvm/Object/Error.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/Endian.h"
|
#include "llvm/Support/Endian.h"
|
||||||
|
#include "llvm/Support/ErrorOr.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace object {
|
namespace object {
|
||||||
@ -205,8 +207,18 @@ struct Elf_Sym_Impl : Elf_Sym_Base<ELFT> {
|
|||||||
bool isExternal() const {
|
bool isExternal() const {
|
||||||
return getBinding() != ELF::STB_LOCAL;
|
return getBinding() != ELF::STB_LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<StringRef> getName(StringRef StrTab) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class ELFT>
|
||||||
|
ErrorOr<StringRef> Elf_Sym_Impl<ELFT>::getName(StringRef StrTab) const {
|
||||||
|
uint32_t Offset = this->st_name;
|
||||||
|
if (Offset >= StrTab.size())
|
||||||
|
return object_error::parse_failed;
|
||||||
|
return StringRef(StrTab.data() + Offset);
|
||||||
|
}
|
||||||
|
|
||||||
/// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section
|
/// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section
|
||||||
/// (.gnu.version). This structure is identical for ELF32 and ELF64.
|
/// (.gnu.version). This structure is identical for ELF32 and ELF64.
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
|
@ -359,7 +359,7 @@ static std::error_code getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
|
|||||||
return EC;
|
return EC;
|
||||||
Target = *SecName;
|
Target = *SecName;
|
||||||
} else {
|
} else {
|
||||||
ErrorOr<StringRef> SymName = EF.getSymbolName(StrTab, symb);
|
ErrorOr<StringRef> SymName = symb->getName(StrTab);
|
||||||
if (!SymName)
|
if (!SymName)
|
||||||
return SymName.getError();
|
return SymName.getError();
|
||||||
Target = *SymName;
|
Target = *SymName;
|
||||||
|
@ -760,8 +760,7 @@ void ELFDumper<ELFT>::printRelocation(const Elf_Shdr *Sec,
|
|||||||
const Elf_Shdr *StrTableSec = Obj->getSection(SymTable->sh_link);
|
const Elf_Shdr *StrTableSec = Obj->getSection(SymTable->sh_link);
|
||||||
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTable(StrTableSec);
|
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTable(StrTableSec);
|
||||||
if (!error(StrTableOrErr.getError()))
|
if (!error(StrTableOrErr.getError()))
|
||||||
TargetName =
|
TargetName = errorOrDefault(Sym.second->getName(*StrTableOrErr));
|
||||||
errorOrDefault(Obj->getSymbolName(*StrTableOrErr, Sym.second));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts::ExpandRelocs) {
|
if (opts::ExpandRelocs) {
|
||||||
|
@ -189,7 +189,7 @@ std::error_code ELFDumper<ELFT>::dumpRelocation(const Elf_Shdr *Shdr,
|
|||||||
return EC;
|
return EC;
|
||||||
StringRef StrTab = *StrTabOrErr;
|
StringRef StrTab = *StrTabOrErr;
|
||||||
|
|
||||||
ErrorOr<StringRef> NameOrErr = Obj.getSymbolName(StrTab, NamePair.second);
|
ErrorOr<StringRef> NameOrErr = NamePair.second->getName(StrTab);
|
||||||
if (std::error_code EC = NameOrErr.getError())
|
if (std::error_code EC = NameOrErr.getError())
|
||||||
return EC;
|
return EC;
|
||||||
R.Symbol = NameOrErr.get();
|
R.Symbol = NameOrErr.get();
|
||||||
@ -314,7 +314,7 @@ ErrorOr<ELFYAML::Group *> ELFDumper<ELFT>::dumpGroup(const Elf_Shdr *Shdr) {
|
|||||||
auto sectionContents = Obj.getSectionContents(Shdr);
|
auto sectionContents = Obj.getSectionContents(Shdr);
|
||||||
if (std::error_code ec = sectionContents.getError())
|
if (std::error_code ec = sectionContents.getError())
|
||||||
return ec;
|
return ec;
|
||||||
ErrorOr<StringRef> symbolName = Obj.getSymbolName(StrTab, symbol);
|
ErrorOr<StringRef> symbolName = symbol->getName(StrTab);
|
||||||
if (std::error_code EC = symbolName.getError())
|
if (std::error_code EC = symbolName.getError())
|
||||||
return EC;
|
return EC;
|
||||||
S->Info = *symbolName;
|
S->Info = *symbolName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user