mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
Introduce convenience typedefs for the 4 ELF object types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181509 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -839,6 +839,13 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Use an alignment of 2 for the typedefs since that is the worst case for
|
||||||
|
// ELF files in archives.
|
||||||
|
typedef ELFObjectFile<ELFType<support::little, 2, false> > ELF32LEObjectFile;
|
||||||
|
typedef ELFObjectFile<ELFType<support::little, 2, true> > ELF64LEObjectFile;
|
||||||
|
typedef ELFObjectFile<ELFType<support::big, 2, false> > ELF32BEObjectFile;
|
||||||
|
typedef ELFObjectFile<ELFType<support::big, 2, true> > ELF64BEObjectFile;
|
||||||
|
|
||||||
// Iterate through the version definitions, and place each Elf_Verdef
|
// Iterate through the version definitions, and place each Elf_Verdef
|
||||||
// in the VersionMap according to its index.
|
// in the VersionMap according to its index.
|
||||||
template<class ELFT>
|
template<class ELFT>
|
||||||
@@ -2955,23 +2962,19 @@ static inline error_code getELFRelocationAddend(const RelocationRef R,
|
|||||||
const ObjectFile *Obj = R.getObjectFile();
|
const ObjectFile *Obj = R.getObjectFile();
|
||||||
DataRefImpl DRI = R.getRawDataRefImpl();
|
DataRefImpl DRI = R.getRawDataRefImpl();
|
||||||
// Little-endian 32-bit
|
// Little-endian 32-bit
|
||||||
if (const ELFObjectFile<ELFType<support::little, 4, false> > *ELFObj =
|
if (const ELF32LEObjectFile *ELFObj = dyn_cast<ELF32LEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::little, 4, false> > >(Obj))
|
|
||||||
return ELFObj->getRelocationAddend(DRI, Addend);
|
return ELFObj->getRelocationAddend(DRI, Addend);
|
||||||
|
|
||||||
// Big-endian 32-bit
|
// Big-endian 32-bit
|
||||||
if (const ELFObjectFile<ELFType<support::big, 4, false> > *ELFObj =
|
if (const ELF32BEObjectFile *ELFObj = dyn_cast<ELF32BEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::big, 4, false> > >(Obj))
|
|
||||||
return ELFObj->getRelocationAddend(DRI, Addend);
|
return ELFObj->getRelocationAddend(DRI, Addend);
|
||||||
|
|
||||||
// Little-endian 64-bit
|
// Little-endian 64-bit
|
||||||
if (const ELFObjectFile<ELFType<support::little, 8, true> > *ELFObj =
|
if (const ELF64LEObjectFile *ELFObj = dyn_cast<ELF64LEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::little, 8, true> > >(Obj))
|
|
||||||
return ELFObj->getRelocationAddend(DRI, Addend);
|
return ELFObj->getRelocationAddend(DRI, Addend);
|
||||||
|
|
||||||
// Big-endian 64-bit
|
// Big-endian 64-bit
|
||||||
if (const ELFObjectFile<ELFType<support::big, 8, true> > *ELFObj =
|
if (const ELF64BEObjectFile *ELFObj = dyn_cast<ELF64BEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::big, 8, true> > >(Obj))
|
|
||||||
return ELFObj->getRelocationAddend(DRI, Addend);
|
return ELFObj->getRelocationAddend(DRI, Addend);
|
||||||
|
|
||||||
llvm_unreachable("Object passed to getELFRelocationAddend() is not ELF");
|
llvm_unreachable("Object passed to getELFRelocationAddend() is not ELF");
|
||||||
@@ -2984,23 +2987,19 @@ static inline error_code GetELFSymbolVersion(const ObjectFile *Obj,
|
|||||||
StringRef &Version,
|
StringRef &Version,
|
||||||
bool &IsDefault) {
|
bool &IsDefault) {
|
||||||
// Little-endian 32-bit
|
// Little-endian 32-bit
|
||||||
if (const ELFObjectFile<ELFType<support::little, 4, false> > *ELFObj =
|
if (const ELF32LEObjectFile *ELFObj = dyn_cast<ELF32LEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::little, 4, false> > >(Obj))
|
|
||||||
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
||||||
|
|
||||||
// Big-endian 32-bit
|
// Big-endian 32-bit
|
||||||
if (const ELFObjectFile<ELFType<support::big, 4, false> > *ELFObj =
|
if (const ELF32BEObjectFile *ELFObj = dyn_cast<ELF32BEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::big, 4, false> > >(Obj))
|
|
||||||
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
||||||
|
|
||||||
// Little-endian 64-bit
|
// Little-endian 64-bit
|
||||||
if (const ELFObjectFile<ELFType<support::little, 8, true> > *ELFObj =
|
if (const ELF64LEObjectFile *ELFObj = dyn_cast<ELF64LEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::little, 8, true> > >(Obj))
|
|
||||||
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
||||||
|
|
||||||
// Big-endian 64-bit
|
// Big-endian 64-bit
|
||||||
if (const ELFObjectFile<ELFType<support::big, 8, true> > *ELFObj =
|
if (const ELF64BEObjectFile *ELFObj = dyn_cast<ELF64BEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::big, 8, true> > >(Obj))
|
|
||||||
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
|
||||||
|
|
||||||
llvm_unreachable("Object passed to GetELFSymbolVersion() is not ELF");
|
llvm_unreachable("Object passed to GetELFSymbolVersion() is not ELF");
|
||||||
|
@@ -79,22 +79,18 @@ void printProgramHeaders(
|
|||||||
|
|
||||||
void llvm::printELFFileHeader(const object::ObjectFile *Obj) {
|
void llvm::printELFFileHeader(const object::ObjectFile *Obj) {
|
||||||
// Little-endian 32-bit
|
// Little-endian 32-bit
|
||||||
if (const ELFObjectFile<ELFType<support::little, 4, false> > *ELFObj =
|
if (const ELF32LEObjectFile *ELFObj = dyn_cast<ELF32LEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::little, 4, false> > >(Obj))
|
|
||||||
printProgramHeaders(ELFObj);
|
printProgramHeaders(ELFObj);
|
||||||
|
|
||||||
// Big-endian 32-bit
|
// Big-endian 32-bit
|
||||||
if (const ELFObjectFile<ELFType<support::big, 4, false> > *ELFObj =
|
if (const ELF32BEObjectFile *ELFObj = dyn_cast<ELF32BEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::big, 4, false> > >(Obj))
|
|
||||||
printProgramHeaders(ELFObj);
|
printProgramHeaders(ELFObj);
|
||||||
|
|
||||||
// Little-endian 64-bit
|
// Little-endian 64-bit
|
||||||
if (const ELFObjectFile<ELFType<support::little, 8, true> > *ELFObj =
|
if (const ELF64LEObjectFile *ELFObj = dyn_cast<ELF64LEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::little, 8, true> > >(Obj))
|
|
||||||
printProgramHeaders(ELFObj);
|
printProgramHeaders(ELFObj);
|
||||||
|
|
||||||
// Big-endian 64-bit
|
// Big-endian 64-bit
|
||||||
if (const ELFObjectFile<ELFType<support::big, 8, true> > *ELFObj =
|
if (const ELF64BEObjectFile *ELFObj = dyn_cast<ELF64BEObjectFile>(Obj))
|
||||||
dyn_cast<ELFObjectFile<ELFType<support::big, 8, true> > >(Obj))
|
|
||||||
printProgramHeaders(ELFObj);
|
printProgramHeaders(ELFObj);
|
||||||
}
|
}
|
||||||
|
@@ -69,42 +69,32 @@ private:
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
template <class ELFT>
|
||||||
|
static error_code createELFDumper(const ELFObjectFile<ELFT> *Obj,
|
||||||
|
StreamWriter &Writer,
|
||||||
|
OwningPtr<ObjDumper> &Result) {
|
||||||
|
Result.reset(new ELFDumper<ELFT>(Obj, Writer));
|
||||||
|
return readobj_error::success;
|
||||||
|
}
|
||||||
|
|
||||||
error_code createELFDumper(const object::ObjectFile *Obj,
|
error_code createELFDumper(const object::ObjectFile *Obj,
|
||||||
StreamWriter& Writer,
|
StreamWriter& Writer,
|
||||||
OwningPtr<ObjDumper> &Result) {
|
OwningPtr<ObjDumper> &Result) {
|
||||||
typedef ELFType<support::little, 4, false> Little32ELF;
|
|
||||||
typedef ELFType<support::big, 4, false> Big32ELF;
|
|
||||||
typedef ELFType<support::little, 4, true > Little64ELF;
|
|
||||||
typedef ELFType<support::big, 8, true > Big64ELF;
|
|
||||||
|
|
||||||
typedef ELFObjectFile<Little32ELF> LittleELF32Obj;
|
|
||||||
typedef ELFObjectFile<Big32ELF > BigELF32Obj;
|
|
||||||
typedef ELFObjectFile<Little64ELF> LittleELF64Obj;
|
|
||||||
typedef ELFObjectFile<Big64ELF > BigELF64Obj;
|
|
||||||
|
|
||||||
// Little-endian 32-bit
|
// Little-endian 32-bit
|
||||||
if (const LittleELF32Obj *ELFObj = dyn_cast<LittleELF32Obj>(Obj)) {
|
if (const ELF32LEObjectFile *ELFObj = dyn_cast<ELF32LEObjectFile>(Obj))
|
||||||
Result.reset(new ELFDumper<Little32ELF>(ELFObj, Writer));
|
return createELFDumper(ELFObj, Writer, Result);
|
||||||
return readobj_error::success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Big-endian 32-bit
|
// Big-endian 32-bit
|
||||||
if (const BigELF32Obj *ELFObj = dyn_cast<BigELF32Obj>(Obj)) {
|
if (const ELF32BEObjectFile *ELFObj = dyn_cast<ELF32BEObjectFile>(Obj))
|
||||||
Result.reset(new ELFDumper<Big32ELF>(ELFObj, Writer));
|
return createELFDumper(ELFObj, Writer, Result);
|
||||||
return readobj_error::success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Little-endian 64-bit
|
// Little-endian 64-bit
|
||||||
if (const LittleELF64Obj *ELFObj = dyn_cast<LittleELF64Obj>(Obj)) {
|
if (const ELF64LEObjectFile *ELFObj = dyn_cast<ELF64LEObjectFile>(Obj))
|
||||||
Result.reset(new ELFDumper<Little64ELF>(ELFObj, Writer));
|
return createELFDumper(ELFObj, Writer, Result);
|
||||||
return readobj_error::success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Big-endian 64-bit
|
// Big-endian 64-bit
|
||||||
if (const BigELF64Obj *ELFObj = dyn_cast<BigELF64Obj>(Obj)) {
|
if (const ELF64BEObjectFile *ELFObj = dyn_cast<ELF64BEObjectFile>(Obj))
|
||||||
Result.reset(new ELFDumper<Big64ELF>(ELFObj, Writer));
|
return createELFDumper(ELFObj, Writer, Result);
|
||||||
return readobj_error::success;
|
|
||||||
}
|
|
||||||
|
|
||||||
return readobj_error::unsupported_obj_file_format;
|
return readobj_error::unsupported_obj_file_format;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user