[llvm-commits] [llvm] r158484 - in /llvm/trunk: include/llvm/Object/COFF.h lib/Object/COFFObjectFile.cpp
Marshall Clow
mclow at qualcomm.com
Thu Jun 14 18:08:25 PDT 2012
Author: marshall
Date: Thu Jun 14 20:08:25 2012
New Revision: 158484
URL: http://llvm.org/viewvc/llvm-project?rev=158484&view=rev
Log:
Adding acessors to COFFObjectFile so that clients can get at the (non-generic) bits
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=158484&r1=158483&r2=158484&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Thu Jun 14 20:08:25 2012
@@ -168,6 +168,9 @@
virtual section_iterator begin_sections() const;
virtual section_iterator end_sections() const;
+ const coff_section *getCOFFSection(section_iterator &It) const;
+ const coff_symbol *getCOFFSymbol(symbol_iterator &It) const;
+
virtual uint8_t getBytesInAddress() const;
virtual StringRef getFileFormatName() const;
virtual unsigned getArch() const;
@@ -184,6 +187,8 @@
return ec;
}
error_code getSymbolName(const coff_symbol *symbol, StringRef &Res) const;
+ ArrayRef<uint8_t> getSymbolAuxData(const coff_symbol *symbol) const;
+
error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
error_code getSectionContents(const coff_section *Sec,
ArrayRef<uint8_t> &Res) const;
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=158484&r1=158483&r2=158484&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Thu Jun 14 20:08:25 2012
@@ -622,6 +622,28 @@
return object_error::success;
}
+ArrayRef<uint8_t> COFFObjectFile::getSymbolAuxData(
+ const coff_symbol *symbol) const {
+ const uint8_t *aux = NULL;
+
+ if ( symbol->NumberOfAuxSymbols > 0 ) {
+ // AUX data comes immediately after the symbol in COFF
+ aux = reinterpret_cast<const uint8_t *>(symbol + 1);
+# ifndef NDEBUG
+ // Verify that the aux symbol points to a valid entry in the symbol table.
+ uintptr_t offset = uintptr_t(aux) - uintptr_t(base());
+ if (offset < Header->PointerToSymbolTable
+ || offset >= Header->PointerToSymbolTable
+ + (Header->NumberOfSymbols * sizeof(coff_symbol)))
+ report_fatal_error("Aux Symbol data was outside of symbol table.");
+
+ assert((offset - Header->PointerToSymbolTable) % sizeof(coff_symbol)
+ == 0 && "Aux Symbol data did not point to the beginning of a symbol");
+ }
+# endif
+ return ArrayRef<uint8_t>(aux, symbol->NumberOfAuxSymbols * sizeof(coff_symbol));
+}
+
error_code COFFObjectFile::getSectionName(const coff_section *Sec,
StringRef &Res) const {
StringRef Name;
@@ -694,6 +716,15 @@
return object_error::success;
}
+const coff_section *COFFObjectFile::getCOFFSection(section_iterator &It) const {
+ return toSec(It->getRawDataRefImpl());
+}
+
+const coff_symbol *COFFObjectFile::getCOFFSymbol(symbol_iterator &It) const {
+ return toSymb(It->getRawDataRefImpl());
+}
+
+
#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(enum) \
case COFF::enum: res = #enum; break;
More information about the llvm-commits
mailing list