X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FObject%2FCOFFObjectFile.cpp;h=ec8989d5c67cb07ffc35abdad0b8e36be568ebdd;hb=daa4c91647ae5abfc55bd1425ecf146680ca7bd1;hp=007d28e6bdf1324f3c1e0a1bba737ac2c527cc91;hpb=6846082281272b80c3a01b913a25e75031407c0d;p=oota-llvm.git diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp index 007d28e6bdf..ec8989d5c67 100644 --- a/lib/Object/COFFObjectFile.cpp +++ b/lib/Object/COFFObjectFile.cpp @@ -23,16 +23,13 @@ using namespace llvm; using namespace object; -namespace { using support::ulittle8_t; using support::ulittle16_t; using support::ulittle32_t; using support::little16_t; -} -namespace { // Returns false if size is greater than the buffer size. And sets ec. -bool checkSize(const MemoryBuffer *M, error_code &EC, uint64_t Size) { +static bool checkSize(const MemoryBuffer *M, error_code &EC, uint64_t Size) { if (M->getBufferSize() < Size) { EC = object_error::unexpected_eof; return false; @@ -43,8 +40,8 @@ bool checkSize(const MemoryBuffer *M, error_code &EC, uint64_t Size) { // Sets Obj unless any bytes in [addr, addr + size) fall outsize of m. // Returns unexpected_eof if error. template -error_code getObject(const T *&Obj, const MemoryBuffer *M, const uint8_t *Ptr, - const size_t Size = sizeof(T)) { +static error_code getObject(const T *&Obj, const MemoryBuffer *M, + const uint8_t *Ptr, const size_t Size = sizeof(T)) { uintptr_t Addr = uintptr_t(Ptr); if (Addr + Size < Addr || Addr + Size < Size || @@ -54,7 +51,6 @@ error_code getObject(const T *&Obj, const MemoryBuffer *M, const uint8_t *Ptr, Obj = reinterpret_cast(Addr); return object_error::success; } -} const coff_symbol *COFFObjectFile::toSymb(DataRefImpl Ref) const { const coff_symbol *Addr = reinterpret_cast(Ref.p); @@ -462,7 +458,8 @@ error_code COFFObjectFile::initExportTablePtr() { uintptr_t IntPtr = 0; if (error_code EC = getRvaPtr(ExportTableRva, IntPtr)) return EC; - ExportDirectory = reinterpret_cast(IntPtr); + ExportDirectory = + reinterpret_cast(IntPtr); return object_error::success; } @@ -737,7 +734,8 @@ ArrayRef COFFObjectFile::getSymbolAuxData( == 0 && "Aux Symbol data did not point to the beginning of a symbol"); # endif } - return ArrayRef(Aux, Symbol->NumberOfAuxSymbols * sizeof(coff_symbol)); + return ArrayRef(Aux, + Symbol->NumberOfAuxSymbols * sizeof(coff_symbol)); } error_code COFFObjectFile::getSectionName(const coff_section *Sec, @@ -953,6 +951,22 @@ ExportDirectoryEntryRef::getNext(ExportDirectoryEntryRef &Result) const { return object_error::success; } +// Returns the name of the current export symbol. If the symbol is exported only +// by ordinal, the empty string is set as a result. +error_code ExportDirectoryEntryRef::getDllName(StringRef &Result) const { + uintptr_t IntPtr = 0; + if (error_code EC = OwningObject->getRvaPtr(ExportTable->NameRVA, IntPtr)) + return EC; + Result = StringRef(reinterpret_cast(IntPtr)); + return object_error::success; +} + +// Returns the starting ordinal number. +error_code ExportDirectoryEntryRef::getOrdinalBase(uint32_t &Result) const { + Result = ExportTable->OrdinalBase; + return object_error::success; +} + // Returns the export ordinal of the current export symbol. error_code ExportDirectoryEntryRef::getOrdinal(uint32_t &Result) const { Result = ExportTable->OrdinalBase + Index; @@ -965,14 +979,15 @@ error_code ExportDirectoryEntryRef::getExportRVA(uint32_t &Result) const { if (error_code EC = OwningObject->getRvaPtr( ExportTable->ExportAddressTableRVA, IntPtr)) return EC; - const export_address_table_entry *entry = reinterpret_cast(IntPtr); + const export_address_table_entry *entry = + reinterpret_cast(IntPtr); Result = entry[Index].ExportRVA; return object_error::success; } // Returns the name of the current export symbol. If the symbol is exported only // by ordinal, the empty string is set as a result. -error_code ExportDirectoryEntryRef::getName(StringRef &Result) const { +error_code ExportDirectoryEntryRef::getSymbolName(StringRef &Result) const { uintptr_t IntPtr = 0; if (error_code EC = OwningObject->getRvaPtr( ExportTable->OrdinalTableRVA, IntPtr)) @@ -1003,4 +1018,4 @@ ObjectFile *ObjectFile::createCOFFObjectFile(MemoryBuffer *Object) { error_code EC; return new COFFObjectFile(Object, EC); } -} // end namespace llvm +}