Rizin
unix-like reverse engineering framework and cli tools
p9bin.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2008 Anant Narayanan
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef P9BIN_H
5 #define P9BIN_H
6 
7 #include <rz_util.h>
8 
9 /*
10  * Binary loader for Plan 9's a.out executable format
11  *
12  * Copyright (C) 2008 Anant Narayanan
13  */
14 struct plan9_exec {
15  unsigned long magic; /* magic number */
16  unsigned long text; /* size of text segment */
17  unsigned long data; /* size of initialized data */
18  unsigned long bss; /* size of uninitialized data */
19  unsigned long syms; /* size of symbol table */
20  unsigned long entry; /* entry point */
21  unsigned long spsz; /* size of pc/sp offset table */
22  unsigned long pcsz; /* size of pc/line number table */
23 };
24 
25 #define HDR_MAGIC 0x00008000 /* header expansion */
26 
27 #define _MAGIC(f, b) ((f) | ((((4 * (b)) + 0) * (b)) + 7))
28 #define A_MAGIC _MAGIC(0, 8) /* 68020 */
29 #define I_MAGIC _MAGIC(0, 11) /* intel 386 */
30 #define J_MAGIC _MAGIC(0, 12) /* intel 960 (retired) */
31 #define K_MAGIC _MAGIC(0, 13) /* sparc */
32 #define V_MAGIC _MAGIC(0, 16) /* mips 3000 BE */
33 #define X_MAGIC _MAGIC(0, 17) /* att dsp 3210 (retired) */
34 #define M_MAGIC _MAGIC(0, 18) /* mips 4000 BE */
35 #define D_MAGIC _MAGIC(0, 19) /* amd 29000 (retired) */
36 #define E_MAGIC _MAGIC(0, 20) /* arm */
37 #define Q_MAGIC _MAGIC(0, 21) /* powerpc */
38 #define N_MAGIC _MAGIC(0, 22) /* mips 4000 LE */
39 #define L_MAGIC _MAGIC(0, 23) /* dec alpha */
40 #define P_MAGIC _MAGIC(0, 24) /* mips 3000 LE */
41 #define U_MAGIC _MAGIC(0, 25) /* sparc64 */
42 #define S_MAGIC _MAGIC(HDR_MAGIC, 26) /* amd64 */
43 #define T_MAGIC _MAGIC(HDR_MAGIC, 27) /* powerpc64 */
44 
45 #define TOS_SIZE 14 /* Size of Top of Stack: 56 / 4 */
46 #define HDR_SIZE 0x20
47 #define STR_ADDR 0x1000 /* Start Address */
48 #define TXT_ADDR HDR_SIZE + ex.text /* TEXT Address */
49 #define DAT_ADDR STR_ADDR + PAGE_ALIGN(TXT_ADDR) /* DATA&BSS Address */
50 
51 /*---*/
52 
53 #define p9bin_open(x) fopen(x, "r")
54 #define p9bin_close(x) fclose(x)
55 
56 /* Reads four bytes from b. */
57 int rz_bin_p9_get_arch(RzBuffer *b, int *bits, int *big_endian);
58 
59 #endif
int bits(struct state *s, int need)
Definition: blast.c:72
int rz_bin_p9_get_arch(RzBuffer *b, int *bits, int *big_endian)
Definition: p9bin.c:7
#define b(i)
Definition: sha256.c:42
unsigned long magic
Definition: p9bin.h:15
unsigned long syms
Definition: p9bin.h:19
unsigned long data
Definition: p9bin.h:17
unsigned long spsz
Definition: p9bin.h:21
unsigned long bss
Definition: p9bin.h:18
unsigned long text
Definition: p9bin.h:16
unsigned long pcsz
Definition: p9bin.h:22
unsigned long entry
Definition: p9bin.h:20