diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-01-30 04:46:33 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-01-30 04:46:33 +0000 |
commit | 15d16d809b46dbb328b8c30b212d921d8989d325 (patch) | |
tree | c9752648df707a9d5adc7aba733c177bb3dbf633 /llvm/tools/llvm-readobj/ELFDumper.cpp | |
parent | 5d962d31f11d4b63c1ed7b72dafbecd9fe37adb8 (diff) | |
download | llvm-15d16d809b46dbb328b8c30b212d921d8989d325.zip llvm-15d16d809b46dbb328b8c30b212d921d8989d325.tar.gz llvm-15d16d809b46dbb328b8c30b212d921d8989d325.tar.bz2 |
tools: add support for decoding ARM attributes
Enhance the ARM specific parsing support in llvm-readobj to support attributes.
This allows for simpler tests to validate encoding of the build attributes as
specified in the ARM ELF specification.
llvm-svn: 200450
Diffstat (limited to 'llvm/tools/llvm-readobj/ELFDumper.cpp')
-rw-r--r-- | llvm/tools/llvm-readobj/ELFDumper.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index feb77fd..bf3c942 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -13,12 +13,15 @@ //===----------------------------------------------------------------------===// #include "llvm-readobj.h" +#include "ARMAttributeParser.h" #include "ARMEHABIPrinter.h" #include "Error.h" #include "ObjDumper.h" #include "StreamWriter.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Object/ELFObjectFile.h" +#include "llvm/Support/ARMBuildAttributes.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Format.h" #include "llvm/Support/MathExtras.h" @@ -50,6 +53,8 @@ public: virtual void printNeededLibraries() LLVM_OVERRIDE; virtual void printProgramHeaders() LLVM_OVERRIDE; + virtual void printAttributes() LLVM_OVERRIDE; + private: typedef ELFFile<ELFT> ELFO; typedef typename ELFO::Elf_Shdr Elf_Shdr; @@ -855,3 +860,42 @@ void ELFDumper<ELFT>::printProgramHeaders() { W.printNumber("Alignment", PI->p_align); } } + +template <class ELFT> +void ELFDumper<ELFT>::printAttributes() { + W.startLine() << "Attributes not implemented.\n"; +} + +namespace { +template <> +void ELFDumper<ELFType<support::little, 2, false> >::printAttributes() { + if (Obj->getHeader()->e_machine != EM_ARM) { + W.startLine() << "Attributes not implemented.\n"; + return; + } + + DictScope BA(W, "BuildAttributes"); + for (typename ELFO::Elf_Shdr_Iter SI = Obj->begin_sections(), + SE = Obj->end_sections(); SI != SE; ++SI) { + if (SI->sh_type != ELF::SHT_ARM_ATTRIBUTES) + continue; + + ErrorOr<ArrayRef<uint8_t> > Contents = Obj->getSectionContents(&(*SI)); + if (!Contents) + continue; + + if ((*Contents)[0] != ARMBuildAttrs::Format_Version) { + errs() << "unrecognised FormatVersion: 0x" << utohexstr((*Contents)[0]) + << '\n'; + continue; + } + + W.printHex("FormatVersion", (*Contents)[0]); + if (Contents->size() == 1) + continue; + + ARMAttributeParser(W).Parse(*Contents); + } +} +} + |