diff options
author | Amara Emerson <amara.emerson@arm.com> | 2013-05-03 11:36:35 +0000 |
---|---|---|
committer | Amara Emerson <amara.emerson@arm.com> | 2013-05-03 11:36:35 +0000 |
commit | 5d446e61d992f105a05aade62d5305fd8a346081 (patch) | |
tree | 397251bdb3b58c7cbe7a93b1885cc2f77d3c058e /tools | |
parent | 820b3fd7716cf5ab26961d1b2b21fd5d0f330fe1 (diff) |
Add support for reading ARM ELF build attributes.
Build attribute sections can now be read if they exist via ELFObjectFile, and
the llvm-readobj tool has been extended with an option to dump this information
if requested. Regression tests are also included which exercise these features.
Also update the docs with a fixed ARM ABI link and a new link to the Addenda
which provides the build attributes specification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181009 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-readobj/ELFDumper.cpp | 63 | ||||
-rw-r--r-- | tools/llvm-readobj/ObjDumper.h | 1 | ||||
-rw-r--r-- | tools/llvm-readobj/llvm-readobj.cpp | 6 |
3 files changed, 70 insertions, 0 deletions
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index ea1b83f32f..6fa9026399 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -51,6 +51,7 @@ public: virtual void printDynamicTable() LLVM_OVERRIDE; virtual void printNeededLibraries() LLVM_OVERRIDE; virtual void printProgramHeaders() LLVM_OVERRIDE; + virtual void printARMBuildAttributes() LLVM_OVERRIDE; private: typedef ELFObjectFile<ELFT> ELFO; @@ -858,3 +859,65 @@ void ELFDumper<ELFT>::printProgramHeaders() { W.printNumber("Alignment", PI->p_align); } } + +#define LLVM_READOBJ_ARMATTR_NUMCASE(X) case ARMBuildAttrs::X: \ + W.printNumber(" Tag_" #X, BuildAttrs.Tag_##X); \ + break; \ + +#define LLVM_READOBJ_ARMATTR_STRCASE(X) case ARMBuildAttrs::X: \ + W.printString(" Tag_" #X, BuildAttrs.Tag_##X); \ + break; \ + +template<class ELFT> +void ELFDumper<ELFT>::printARMBuildAttributes() { + if (Obj->getArch() != Triple::arm || !Obj->hasARMBuildAttributes()) + return; + ARMBuildAttrs::ARMGenericBuildAttrInfo BuildAttrs; + SmallVector<unsigned, 16> AttrsRead; + error_code EC = Obj->readARMBuildAttributes(BuildAttrs, AttrsRead); + if (error(EC)) + return; + + DictScope D(W, "ARMBuildAttributes"); + + for (SmallVector<unsigned, 16>::iterator I = AttrsRead.begin(), + E = AttrsRead.end(); I != E; ++I) { + switch (*I) { + LLVM_READOBJ_ARMATTR_STRCASE(CPU_name) + LLVM_READOBJ_ARMATTR_STRCASE(CPU_raw_name) + LLVM_READOBJ_ARMATTR_NUMCASE(CPU_arch) + LLVM_READOBJ_ARMATTR_NUMCASE(CPU_arch_profile) + LLVM_READOBJ_ARMATTR_NUMCASE(ARM_ISA_use) + LLVM_READOBJ_ARMATTR_NUMCASE(THUMB_ISA_use) + LLVM_READOBJ_ARMATTR_NUMCASE(FP_arch) + LLVM_READOBJ_ARMATTR_NUMCASE(WMMX_arch) + LLVM_READOBJ_ARMATTR_NUMCASE(Advanced_SIMD_arch) + LLVM_READOBJ_ARMATTR_NUMCASE(PCS_config) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_PCS_R9_use) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_PCS_RW_data) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_PCS_RO_data) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_PCS_GOT_use) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_PCS_wchar_t) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_FP_rounding) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_FP_denormal) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_FP_exceptions) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_FP_user_exceptions) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_FP_number_model) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_align8_needed) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_align8_preserved) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_enum_size) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_HardFP_use) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_VFP_args) + LLVM_READOBJ_ARMATTR_NUMCASE(CPU_unaligned_access) + LLVM_READOBJ_ARMATTR_NUMCASE(FP_HP_extension) + LLVM_READOBJ_ARMATTR_NUMCASE(MPextension_use) + LLVM_READOBJ_ARMATTR_NUMCASE(DIV_use) + LLVM_READOBJ_ARMATTR_NUMCASE(T2EE_use) + LLVM_READOBJ_ARMATTR_NUMCASE(Virtualization_use) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_optimization_goals) + LLVM_READOBJ_ARMATTR_NUMCASE(ABI_FP_optimization_goals) + default: + break; + } + } +} diff --git a/tools/llvm-readobj/ObjDumper.h b/tools/llvm-readobj/ObjDumper.h index 6918e28cb9..9a8f0c157a 100644 --- a/tools/llvm-readobj/ObjDumper.h +++ b/tools/llvm-readobj/ObjDumper.h @@ -39,6 +39,7 @@ public: virtual void printDynamicTable() { } virtual void printNeededLibraries() { } virtual void printProgramHeaders() { } + virtual void printARMBuildAttributes() { } protected: StreamWriter& W; diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index 2e95b6b551..d5eb85429c 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -128,6 +128,10 @@ namespace opts { // -expand-relocs cl::opt<bool> ExpandRelocs("expand-relocs", cl::desc("Expand each shown relocation to multiple lines")); + + // -arm-buildattrs + cl::opt<bool> ArmBuildAttrs("arm-buildattrs", + cl::desc("Display ARM ELF build attributes")); } // namespace opts namespace llvm { @@ -221,6 +225,8 @@ static void dumpObject(const ObjectFile *Obj) { Dumper->printNeededLibraries(); if (opts::ProgramHeaders) Dumper->printProgramHeaders(); + if (opts::ArmBuildAttrs) + Dumper->printARMBuildAttributes(); } |