summaryrefslogtreecommitdiff
path: root/includes/mipsobj.h
blob: 18ac504bc4580e73b102e120a2fc5559455b40ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __MIPSOBJ_H__
#define __MIPSOBJ_H__

#include <map>
#include <Exceptions.h>
#include <Handle.h>

enum mips_reloc_t {
    R_MIPS_26,
    R_MIPS_32,
    R_MIPS_HI16,
    R_MIPS_LO16,
};

enum symbol_type_t {
    LOCAL,
    GLOBAL,
    EXTERN,
};

enum section_type_t {
    TEXT,
    DATA,
    BSS,
};

struct reloc_t {
    String symbol;
    int type;
    Uint32 offset;
};

struct symbol_t {
    String name;
    String section;
    int type;
    Uint32 offset;
};

class section : public Base {
  public:
      section(const String &, int);
      section();
      virtual ~section();
    void setname(const String &);
    void settype(int);
    void putdatas(const Uint8 *, int);
    int gettype();
    int getsize();
    const Uint8 * getdatas();
    void putreloc(const String &, int, Uint32);
    void putreloc(const struct reloc_t &);
    std::vector<struct reloc_t> relocs;
  private:
    String name;
    int type;
    Uint8 * datas;
    int length;
};

class mipsobj : public Base {
  public:
      mipsobj();
      virtual ~mipsobj();
    std::map<String, section> sections;
    std::map<String, symbol_t> symbols;
    void loadELF(Handle *) throw (GeneralException);
    void loadOBJ(Handle *) throw (GeneralException);
    void loadLIB(Handle *, const String &) throw (GeneralException);
  private:
    bool loaded;
};

#endif