syms.h - scc - simple c99 compiler
HTML git clone git://git.simple-cc.org/scc
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
syms.h (4004B)
---
1 /*
2 * This file is inspired in:
3 * - the book "Understanding and using COFF"
4 * - the book "UNIX System V 386 R3.2 Programmers guide, Vol 2"
5 */
6
7 /* Special n_scnum values */
8 #define N_TV -3
9 #define N_DEBUG -2
10 #define N_ABS -1
11 #define N_UNDEF 0
12 #define N_SCNUM(x) ((x) > 0)
13
14 /* basic types */
15 #define T_NULL 0
16 #define T_VOID 1
17 #define T_CHAR 2
18 #define T_SHORT 3
19 #define T_INT 4
20 #define T_LONG 5
21 #define T_FLOAT 6
22 #define T_DOUBLE 7
23 #define T_STRUCT 8
24 #define T_UNION 9
25 #define T_ENUM 10
26 #define T_MOE 11
27 #define T_UCHAR 12
28 #define T_USHORT 13
29 #define T_UINT 14
30 #define T_ULONG 15
31 #define T_LNGDBL 16
32
33 /* derivated types */
34 #define DT_NON 0
35 #define DT_PTR 1
36 #define DT_FCN 2
37 #define DT_ARY 3
38
39 #define SYMNMLEN 8
40 #define FILNMLEN 14
41
42 #define SYMENT struct syment
43 #define SYMESZ 18
44
45 #define AUXENT union auxent
46 #define AUXESZ 18
47
48 #define n_name _n._n_name
49 #define n_zeroes _n._n_n._n_zeroes
50 #define n_offset _n._n_n._n_offset
51 #define n_nptr _n._n_nptr[1]
52
53 #define E_FILNMLEN 18
54 #define DIMNUM 4
55
56 struct syment {
57 union {
58 char _n_name[SYMNMLEN]; /* symbol name */
59 struct {
60 long _n_zeroes; /* if _n_name[0-3] == 0 */
61 long _n_offset; /* offset into string table */
62 } _n_n;
63 char *_n_nptr[2]; /* allows overlaying */
64 } _n;
65 unsigned long n_value; /* value of symbol */
66 short n_scnum; /* section number */
67 unsigned short n_type; /* type and derived type */
68 char n_sclass; /* storage class */
69 char n_numaux; /* number of aux. entries */
70 };
71
72 #define x_fname _x_file._x_fname
73 #define x_zeroes _x_file._x_n._x_zeroes
74 #define x_offset _x_file._x_n._x_offset
75 #define x_tagndx _x_sym._x_tagndx
76 #define x_lnno _x_sym._x_misc._x_lnsz._x_lnno
77 #define x_size _x_sym._x_misc._x_lnsz._x_size
78 #define x_fsize _x_sym._x_misc._x_fsize
79 #define x_lnnoptr _x_sym._x_fcnary._x_fcn._x_lnnoptr
80 #define x_endndx _x_sym._x_fcnary._x_fcn._x_endndx
81 #define x_dimen _x_sym._x_fcnary._x_ary._x_dimen
82 #define x_tvndx _x_sym._x_tvndx
83 #define x_scnlen _x_scn._x_scnlen
84 #define x_nreloc _x_scn._x_nreloc
85 #define x_nlinno _x_scn._x_nlinno
86 #define x_checksum _x_scn._x_checksum
87 #define x_associated _x_scn._x_associated
88 #define x_comdat _x_scn._x_comdat
89 #define x_tvfill _x_tv._x_tvfill
90 #define x_tvlen _x_tv._x_tvlen
91 #define x_tvran _x_tv._x_tvran
92
93 union auxent {
94 union {
95 char _x_fname[E_FILNMLEN]; /* file name */
96 struct {
97 long _x_zeroes; /* if _x_fname[0-3] == 0 */
98 long _x_offset; /* offset into string table */
99 } _x_n;
100 } _x_file;
101
102 struct {
103 long _x_tagndx; /* str, un, or enum tag indx */
104 union {
105 struct {
106 unsigned short _x_lnno; /* declaration line number */
107 unsigned short _x_size; /* str, union, array size */
108 } _x_lnsz;
109 long _x_fsize; /* size of function */
110 } _x_misc;
111
112 union {
113 struct { /* if ISFCN, tag, or .bb */
114 long _x_lnnoptr; /* ptr to fcn line # */
115 long _x_endndx; /* entry ndx past block end */
116 } _x_fcn;
117 struct { /* if ISARY, up to 4 dimen. */
118 unsigned short _x_dimen[DIMNUM];
119 } _x_ary;
120 } _x_fcnary;
121
122 unsigned short _x_tvndx; /* tv index */
123 } _x_sym;
124
125 struct {
126 long _x_scnlen; /* section length */
127 unsigned short _x_nreloc; /* number of relocation entries */
128 unsigned short _x_nlinno; /* number of line numbers */
129 unsigned long _x_checksum; /* section COMDAT checksum */
130 unsigned short _x_associated; /* COMDAT associated section index */
131 unsigned char _x_comdat; /* COMDAT selection number */
132 } _x_scn;
133
134 struct { /* info about .tv section (in auxent of symbol .tv)) */
135 long _x_tvfill; /* tv fill value */
136 unsigned short _x_tvlen; /* length of .tv */
137 unsigned short _x_tvran[2]; /* tv range */
138 } _x_tv;
139 };