Apply patch from Daniel Schürmann: https://sourceforge.net/p/boomerang/bugs/78/
[boomerang.git] / boomerang / loader / IntelCoffFile.h
blobeff0d4915cb573601acc68c4c27424b4ea17bb09
1 #ifndef __INTELCOFFFILE_H__
2 #define __INTELCOFFFILE_H__
4 #include <stdint.h>
5 #include "BinaryFile.h"
6 #include "SymTab.h"
8 #define PACKED __attribute__((packed))
10 struct coff_header
12 uint16_t coff_magic;
13 uint16_t coff_sections;
14 uint32_t coff_timestamp;
15 uint32_t coff_symtab_ofs;
16 uint32_t coff_num_syment;
17 uint16_t coff_opthead_size;
18 uint16_t coff_flags;
19 } PACKED;
21 class IntelCoffFile : public BinaryFile
23 public:
25 // Interface
27 IntelCoffFile();
28 ~IntelCoffFile();
30 virtual void UnLoad();
32 virtual bool Open(const char *sName);
33 virtual bool RealLoad(const char*);
34 virtual bool PostLoad(void*);
35 virtual void Close();
37 virtual LOAD_FMT GetFormat() const;
38 virtual MACHINE GetMachine() const;
39 virtual const char *getFilename() const;
40 virtual bool isLibrary() const;
41 virtual std::list<const char *> getDependencyList();
42 virtual ADDRESS getImageBase();
43 virtual size_t getImageSize();
44 virtual ADDRESS GetMainEntryPoint();
45 virtual ADDRESS GetEntryPoint();
46 virtual std::list<SectionInfo*>& GetEntryPoints(const char* pEntry = "main");
48 virtual const char* SymbolByAddress(ADDRESS uNative);
49 // Lookup the name, return the address. If not found, return NO_ADDRESS
50 // virtual ADDRESS GetAddressByName(const char* pName, bool bNoTypeOK = false);
51 // virtual void AddSymbol(ADDRESS uNative, const char *pName) { }
52 virtual bool IsDynamicLinkedProc(ADDRESS uNative);
53 virtual bool IsRelocationAt(ADDRESS uNative);
54 virtual std::map<ADDRESS, std::string> &getSymbols();
56 virtual int readNative4(ADDRESS a);
57 virtual int readNative2(ADDRESS a);
58 virtual int readNative1(ADDRESS a);
60 private:
62 // Internal stuff
64 const char *m_pFilename;
65 int m_fd;
66 std::list<SectionInfo*> m_EntryPoints;
67 std::list<ADDRESS> m_Relocations;
68 struct coff_header m_Header;
70 PSectionInfo AddSection(SectionInfo*);
71 unsigned char* getAddrPtr(ADDRESS a, ADDRESS range);
72 int readNative(ADDRESS a, unsigned short n);
74 SymTab m_Symbols;
77 #endif // !defined(__INTELCOFFFILE_H__)