mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-17 05:24:49 +00:00
Merge elf::toString and coff::toString.
The two overloaded functions hid each other. This patch merges them. llvm-svn: 291222
This commit is contained in:
parent
dac6169214
commit
ce039266c1
@ -372,6 +372,8 @@ MachineTypes BitcodeFile::getMachineType() {
|
||||
return IMAGE_FILE_MACHINE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
||||
// Returns the last element of a path, which is supposed to be a filename.
|
||||
static StringRef getBasename(StringRef Path) {
|
||||
@ -382,7 +384,7 @@ static StringRef getBasename(StringRef Path) {
|
||||
}
|
||||
|
||||
// Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".
|
||||
std::string toString(InputFile *File) {
|
||||
std::string lld::toString(coff::InputFile *File) {
|
||||
if (!File)
|
||||
return "(internal)";
|
||||
if (File->ParentName.empty())
|
||||
@ -393,6 +395,3 @@ std::string toString(InputFile *File) {
|
||||
.str();
|
||||
return StringRef(Res).lower();
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
@ -202,10 +202,9 @@ private:
|
||||
llvm::BumpPtrAllocator Alloc;
|
||||
std::unique_ptr<LTOModule> M;
|
||||
};
|
||||
|
||||
std::string toString(InputFile *File);
|
||||
|
||||
} // namespace coff
|
||||
|
||||
std::string toString(coff::InputFile *File);
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
@ -73,13 +73,12 @@ Defined *Undefined::getWeakAlias() {
|
||||
return D;
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace coff
|
||||
|
||||
// Returns a symbol name for an error message.
|
||||
std::string toString(SymbolBody &B) {
|
||||
if (Optional<std::string> S = demangle(B.getName()))
|
||||
std::string lld::toString(coff::SymbolBody &B) {
|
||||
if (Optional<std::string> S = coff::demangle(B.getName()))
|
||||
return ("\"" + *S + "\" (" + B.getName() + ")").str();
|
||||
return B.getName();
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
@ -428,10 +428,9 @@ inline Symbol *SymbolBody::symbol() {
|
||||
return reinterpret_cast<Symbol *>(reinterpret_cast<char *>(this) -
|
||||
offsetof(Symbol, Body));
|
||||
}
|
||||
|
||||
std::string toString(SymbolBody &B);
|
||||
|
||||
} // namespace coff
|
||||
|
||||
std::string toString(coff::SymbolBody &B);
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
@ -96,7 +96,7 @@ std::string elf::ObjectFile<ELFT>::getLineInfo(InputSectionBase<ELFT> *S,
|
||||
}
|
||||
|
||||
// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
|
||||
std::string elf::toString(const InputFile *F) {
|
||||
std::string lld::toString(const InputFile *F) {
|
||||
if (!F)
|
||||
return "(internal)";
|
||||
if (!F->ArchiveName.empty())
|
||||
|
@ -35,11 +35,17 @@ class InputFile;
|
||||
}
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
class InputFile;
|
||||
}
|
||||
|
||||
// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
|
||||
std::string toString(const elf::InputFile *F);
|
||||
|
||||
namespace elf {
|
||||
|
||||
using llvm::object::Archive;
|
||||
|
||||
class InputFile;
|
||||
class Lazy;
|
||||
class SymbolBody;
|
||||
|
||||
@ -84,9 +90,6 @@ private:
|
||||
const Kind FileKind;
|
||||
};
|
||||
|
||||
// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
|
||||
std::string toString(const InputFile *F);
|
||||
|
||||
template <typename ELFT> class ELFFileBase : public InputFile {
|
||||
public:
|
||||
typedef typename ELFT::Shdr Elf_Shdr;
|
||||
|
@ -34,7 +34,7 @@ using namespace lld::elf;
|
||||
|
||||
// Returns a string to construct an error message.
|
||||
template <class ELFT>
|
||||
std::string elf::toString(const InputSectionBase<ELFT> *Sec) {
|
||||
std::string lld::toString(const InputSectionBase<ELFT> *Sec) {
|
||||
return (Sec->getFile()->getName() + ":(" + Sec->Name + ")").str();
|
||||
}
|
||||
|
||||
@ -844,7 +844,7 @@ template class elf::MergeInputSection<ELF32BE>;
|
||||
template class elf::MergeInputSection<ELF64LE>;
|
||||
template class elf::MergeInputSection<ELF64BE>;
|
||||
|
||||
template std::string elf::toString(const InputSectionBase<ELF32LE> *);
|
||||
template std::string elf::toString(const InputSectionBase<ELF32BE> *);
|
||||
template std::string elf::toString(const InputSectionBase<ELF64LE> *);
|
||||
template std::string elf::toString(const InputSectionBase<ELF64BE> *);
|
||||
template std::string lld::toString(const InputSectionBase<ELF32LE> *);
|
||||
template std::string lld::toString(const InputSectionBase<ELF32BE> *);
|
||||
template std::string lld::toString(const InputSectionBase<ELF64LE> *);
|
||||
template std::string lld::toString(const InputSectionBase<ELF64BE> *);
|
||||
|
@ -318,10 +318,9 @@ private:
|
||||
};
|
||||
|
||||
template <class ELFT> InputSection<ELFT> InputSection<ELFT>::Discarded;
|
||||
|
||||
template <class ELFT> std::string toString(const InputSectionBase<ELFT> *);
|
||||
|
||||
} // namespace elf
|
||||
|
||||
template <class ELFT> std::string toString(const elf::InputSectionBase<ELFT> *);
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
@ -305,7 +305,7 @@ void elf::printTraceSymbol(Symbol *Sym) {
|
||||
}
|
||||
|
||||
// Returns a symbol for an error message.
|
||||
std::string elf::toString(const SymbolBody &B) {
|
||||
std::string lld::toString(const SymbolBody &B) {
|
||||
if (Config->Demangle)
|
||||
if (Optional<std::string> S = demangle(B.getName()))
|
||||
return *S;
|
||||
|
@ -453,10 +453,9 @@ inline Symbol *SymbolBody::symbol() {
|
||||
return reinterpret_cast<Symbol *>(reinterpret_cast<char *>(this) -
|
||||
offsetof(Symbol, Body));
|
||||
}
|
||||
|
||||
std::string toString(const SymbolBody &B);
|
||||
|
||||
} // namespace elf
|
||||
|
||||
std::string toString(const elf::SymbolBody &B);
|
||||
} // namespace lld
|
||||
|
||||
#endif
|
||||
|
@ -44,6 +44,10 @@ using namespace llvm::object;
|
||||
using namespace llvm::support::endian;
|
||||
using namespace llvm::ELF;
|
||||
|
||||
std::string lld::toString(uint32_t Type) {
|
||||
return getELFRelocationTypeName(elf::Config->EMachine, Type);
|
||||
}
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
|
||||
@ -52,10 +56,6 @@ TargetInfo *Target;
|
||||
static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); }
|
||||
static void or32be(uint8_t *P, int32_t V) { write32be(P, read32be(P) | V); }
|
||||
|
||||
std::string toString(uint32_t Type) {
|
||||
return getELFRelocationTypeName(Config->EMachine, Type);
|
||||
}
|
||||
|
||||
template <class ELFT> static std::string getErrorLoc(uint8_t *Loc) {
|
||||
for (InputSectionData *D : Symtab<ELFT>::X->Sections) {
|
||||
auto *IS = dyn_cast_or_null<InputSection<ELFT>>(D);
|
||||
|
@ -104,13 +104,14 @@ public:
|
||||
virtual void relaxTlsLdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;
|
||||
};
|
||||
|
||||
std::string toString(uint32_t RelType);
|
||||
uint64_t getPPC64TocBase();
|
||||
uint64_t getAArch64Page(uint64_t Expr);
|
||||
|
||||
extern TargetInfo *Target;
|
||||
TargetInfo *createTarget();
|
||||
}
|
||||
|
||||
std::string toString(uint32_t RelType);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user