diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-06-13 11:53:31 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-06-13 11:53:31 +0000 |
commit | 5e45dc40d329829ad23bf444f32dca221215e239 (patch) | |
tree | 717bb23e6e1af2314d66495c62843a8a8725a5f1 /include | |
parent | bc437ebbca77cf8a7e2e47e3666c4a0114ccc2d1 (diff) | |
download | llvm-5e45dc40d329829ad23bf444f32dca221215e239.tar.gz llvm-5e45dc40d329829ad23bf444f32dca221215e239.tar.bz2 llvm-5e45dc40d329829ad23bf444f32dca221215e239.tar.xz |
Revert the last two commits in the series. r132911, r132912.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132913 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Object/Binary.h | 7 | ||||
-rw-r--r-- | include/llvm/Object/COFF.h | 111 | ||||
-rw-r--r-- | include/llvm/Object/ObjectFile.h | 29 |
3 files changed, 17 insertions, 130 deletions
diff --git a/include/llvm/Object/Binary.h b/include/llvm/Object/Binary.h index cd092fd8e4..89cd24bfb9 100644 --- a/include/llvm/Object/Binary.h +++ b/include/llvm/Object/Binary.h @@ -38,13 +38,10 @@ protected: enum { isArchive, - - // Object and children. - isObject, isCOFF, isELF, isMachO, - lastObject + isObject }; public: @@ -55,7 +52,7 @@ public: // Cast methods. unsigned int getType() const { return TypeID; } - static inline bool classof(const Binary *v) { return true; } + static inline bool classof(Binary const *v) { return true; } }; error_code createBinary(MemoryBuffer *Source, OwningPtr<Binary> &Result); diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h deleted file mode 100644 index 5ed8aa01be..0000000000 --- a/include/llvm/Object/COFF.h +++ /dev/null @@ -1,111 +0,0 @@ -//===- COFF.h - COFF object file implementation -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the COFFObjectFile class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_OBJECT_COFF_H -#define LLVM_OBJECT_COFF_H - -#include "llvm/Object/ObjectFile.h" -#include "llvm/Support/COFF.h" -#include "llvm/Support/Endian.h" - -namespace llvm { -namespace object { - -struct coff_file_header { - support::ulittle16_t Machine; - support::ulittle16_t NumberOfSections; - support::ulittle32_t TimeDateStamp; - support::ulittle32_t PointerToSymbolTable; - support::ulittle32_t NumberOfSymbols; - support::ulittle16_t SizeOfOptionalHeader; - support::ulittle16_t Characteristics; -}; - -struct coff_symbol { - struct StringTableOffset { - support::ulittle32_t Zeroes; - support::ulittle32_t Offset; - }; - - union { - char ShortName[8]; - StringTableOffset Offset; - } Name; - - support::ulittle32_t Value; - support::little16_t SectionNumber; - - struct { - support::ulittle8_t BaseType; - support::ulittle8_t ComplexType; - } Type; - - support::ulittle8_t StorageClass; - support::ulittle8_t NumberOfAuxSymbols; -}; - -struct coff_section { - char Name[8]; - support::ulittle32_t VirtualSize; - support::ulittle32_t VirtualAddress; - support::ulittle32_t SizeOfRawData; - support::ulittle32_t PointerToRawData; - support::ulittle32_t PointerToRelocations; - support::ulittle32_t PointerToLinenumbers; - support::ulittle16_t NumberOfRelocations; - support::ulittle16_t NumberOfLinenumbers; - support::ulittle32_t Characteristics; -}; - -class COFFObjectFile : public ObjectFile { -private: - uint64_t HeaderOff; - const coff_file_header *Header; - const coff_section *SectionTable; - const coff_symbol *SymbolTable; - const char *StringTable; - - const coff_section *getSection(std::size_t index) const; - const char *getString(std::size_t offset) const; - -protected: - virtual SymbolRef getSymbolNext(DataRefImpl Symb) const; - virtual StringRef getSymbolName(DataRefImpl Symb) const; - virtual uint64_t getSymbolAddress(DataRefImpl Symb) const; - virtual uint64_t getSymbolSize(DataRefImpl Symb) const; - virtual char getSymbolNMTypeChar(DataRefImpl Symb) const; - virtual bool isSymbolInternal(DataRefImpl Symb) const; - - virtual SectionRef getSectionNext(DataRefImpl Sec) const; - virtual StringRef getSectionName(DataRefImpl Sec) const; - virtual uint64_t getSectionAddress(DataRefImpl Sec) const; - virtual uint64_t getSectionSize(DataRefImpl Sec) const; - virtual StringRef getSectionContents(DataRefImpl Sec) const; - virtual bool isSectionText(DataRefImpl Sec) const; - -public: - COFFObjectFile(MemoryBuffer *Object, error_code &ec); - virtual symbol_iterator begin_symbols() const; - virtual symbol_iterator end_symbols() const; - virtual section_iterator begin_sections() const; - virtual section_iterator end_sections() const; - - virtual uint8_t getBytesInAddress() const; - virtual StringRef getFileFormatName() const; - virtual unsigned getArch() const; -}; - -} -} - -#endif diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index d16e4dda6c..eee9d447cd 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -14,13 +14,15 @@ #ifndef LLVM_OBJECT_OBJECT_FILE_H #define LLVM_OBJECT_OBJECT_FILE_H -#include "llvm/Object/Binary.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/MemoryBuffer.h" #include <cstring> namespace llvm { + +class MemoryBuffer; +class StringRef; + namespace object { class ObjectFile; @@ -91,17 +93,16 @@ const uint64_t UnknownAddressOrSize = ~0ULL; /// ObjectFile - This class is the base class for all object file types. /// Concrete instances of this object are created by createObjectFile, which /// figure out which type to create. -class ObjectFile : public Binary { +class ObjectFile { private: ObjectFile(); // = delete ObjectFile(const ObjectFile &other); // = delete protected: - ObjectFile(unsigned int Type, MemoryBuffer *source, error_code &ec); + MemoryBuffer *MapFile; + const uint8_t *base; - const uint8_t *base() const { - return reinterpret_cast<const uint8_t *>(Data->getBufferStart()); - } + ObjectFile(MemoryBuffer *Object); // These functions are for SymbolRef to call internally. The main goal of // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol @@ -155,6 +156,8 @@ public: typedef content_iterator<SymbolRef> symbol_iterator; typedef content_iterator<SectionRef> section_iterator; + virtual ~ObjectFile(); + virtual symbol_iterator begin_symbols() const = 0; virtual symbol_iterator end_symbols() const = 0; @@ -168,6 +171,8 @@ public: virtual StringRef getFileFormatName() const = 0; virtual /* Triple::ArchType */ unsigned getArch() const = 0; + StringRef getFilename() const; + /// @returns Pointer to ObjectFile subclass to handle this type of object. /// @param ObjectPath The path to the object file. ObjectPath.isObject must /// return true. @@ -175,16 +180,12 @@ public: static ObjectFile *createObjectFile(StringRef ObjectPath); static ObjectFile *createObjectFile(MemoryBuffer *Object); - static inline bool classof(const Binary *v) { - return v->getType() >= isObject && - v->getType() < lastObject; - } - static inline bool classof(const ObjectFile *v) { return true; } - -public: +private: static ObjectFile *createCOFFObjectFile(MemoryBuffer *Object); static ObjectFile *createELFObjectFile(MemoryBuffer *Object); static ObjectFile *createMachOObjectFile(MemoryBuffer *Object); + static ObjectFile *createArchiveObjectFile(MemoryBuffer *Object); + static ObjectFile *createLibObjectFile(MemoryBuffer *Object); }; // Inline function definitions. |