1
2
3
4typedef struct filehdr {
5 unsigned short f_magic;
6 unsigned short f_nscns;
7 long f_timdat;
8 long f_symptr;
9 long f_nsyms;
10 unsigned short f_opthdr;
11 unsigned short f_flags;
12} FILHDR;
13#define FILHSZ sizeof(FILHDR)
14
15#define MIPSEBMAGIC 0x160
16#define MIPSELMAGIC 0x162
17
18typedef struct scnhdr {
19 char s_name[8];
20 long s_paddr;
21 long s_vaddr;
22 long s_size;
23 long s_scnptr;
24 long s_relptr;
25 long s_lnnoptr;
26 unsigned short s_nreloc;
27 unsigned short s_nlnno;
28 long s_flags;
29} SCNHDR;
30#define SCNHSZ sizeof(SCNHDR)
31#define SCNROUND ((long)16)
32
33typedef struct aouthdr {
34 short magic;
35 short vstamp;
36 long tsize;
37 long dsize;
38 long bsize;
39 long entry;
40 long text_start;
41 long data_start;
42 long bss_start;
43 long gprmask;
44 long cprmask[4];
45 long gp_value;
46} AOUTHDR;
47#define AOUTHSZ sizeof(AOUTHDR)
48
49#define OMAGIC 0407
50#define NMAGIC 0410
51#define ZMAGIC 0413
52#define SMAGIC 0411
53#define LIBMAGIC 0443
54
55#define N_TXTOFF(f, a) \
56 ((a).magic == ZMAGIC || (a).magic == LIBMAGIC ? 0 : \
57 ((a).vstamp < 23 ? \
58 ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + 7) & 0xfffffff8) : \
59 ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + SCNROUND-1) & ~(SCNROUND-1)) ) )
60#define N_DATOFF(f, a) \
61 N_TXTOFF(f, a) + (a).tsize;
62