Flag error if absolute constant is too large for an immediate field.
[deliverable/binutils-gdb.git] / gas / config / obj-aout.h
CommitLineData
fecd2382
RP
1/* a.out object file format
2 Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
a39116f1
RP
3
4 This file is part of GAS, the GNU Assembler.
5
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2,
9 or (at your option) any later version.
10
11 GAS is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
14 the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public
17 License along with GAS; see the file COPYING. If not, write
18 to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
fecd2382 19
fecd2382
RP
20/* Tag to validate a.out object file format processing */
21#define OBJ_AOUT 1
22
23#include "targ-cpu.h"
24
25#ifndef VMS
26#include "a.out.gnu.h" /* Needed to define struct nlist. Sigh. */
27#else
28#include "a_out.h"
29#endif
30
a39116f1
RP
31#ifndef AOUT_MACHTYPE
32#define AOUT_MACHTYPE 0
33#endif /* AOUT_MACHTYPE */
d1a9e594 34
fecd2382
RP
35extern const short seg_N_TYPE[];
36extern const segT N_TYPE_seg[];
37
38#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
39#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC)
40#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */
41
42/* SYMBOL TABLE */
43/* Symbol table entry data type */
44
45typedef struct nlist obj_symbol_type; /* Symbol table entry */
46
fecd2382
RP
47/* Symbol table macros and constants */
48
49/*
50 * Macros to extract information from a symbol table entry.
51 * This syntaxic indirection allows independence regarding a.out or coff.
52 * The argument (s) of all these macros is a pointer to a symbol table entry.
53 */
54
55/* True if the symbol is external */
56#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
57
58/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
59#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_OTHER(s) != 0) || (S_GET_DESC(s) != 0))
60
61#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
62
63/* True if a debug special symbol entry */
64#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
65/* True if a symbol is local symbol name */
66/* A symbol name whose name begin with ^A is a gas internal pseudo symbol
67 nameless symbols come from .stab directives. */
68#define S_IS_LOCAL(s) (S_GET_NAME(s) && \
69 !S_IS_DEBUG(s) && \
70 (S_GET_NAME(s)[0] == '\001' || \
71 (S_LOCAL_NAME(s) && !flagseen['L'])))
72/* True if a symbol is not defined in this file */
73#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
74/* True if the symbol has been generated because of a .stabd directive */
75#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
76
77/* Accessors */
78/* The value of the symbol */
79#define S_GET_VALUE(s) (((s)->sy_symbol.n_value))
80/* The name of the symbol */
81#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
82/* The pointer to the string table */
83#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
84/* The type of the symbol */
85#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
86/* The numeric value of the segment */
87#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
88/* The n_other expression value */
89#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
90/* The n_desc expression value */
91#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
92
93/* Modifiers */
94/* Set the value of the symbol */
95#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v))
96/* Assume that a symbol cannot be simultaneously in more than on segment */
a39116f1 97/* set segment */
fecd2382
RP
98#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
99/* The symbol is external */
100#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
101/* The symbol is not external */
102#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
103/* Set the name of the symbol */
104#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
105/* Set the offset in the string table */
106#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
107/* Set the n_other expression value */
108#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
109/* Set the n_desc expression value */
110#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
111
112/* File header macro and type definition */
113
f6e504fe
RP
114#define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE(h) \
115 + H_GET_TEXT_SIZE(h) \
116 + H_GET_DATA_SIZE(h) \
117 + H_GET_SYMBOL_TABLE_SIZE(h) \
118 + H_GET_TEXT_RELOCATION_SIZE(h) \
119 + H_GET_DATA_RELOCATION_SIZE(h) \
120 + H_GET_STRING_SIZE(h))
fecd2382 121
f6e504fe 122#define H_GET_HEADER_SIZE(h) (sizeof(struct exec))
fecd2382
RP
123#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
124#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
125#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
126#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
127#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
128#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
fecd2382
RP
129#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
130#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
f6e504fe
RP
131#define H_GET_LINENO_SIZE(h) (0)
132
a39116f1
RP
133#define H_GET_DYNAMIC(h) ((h)->header.a_info >> 31)
134#define H_GET_VERSION(h) (((h)->header.a_info >> 24) & 0x7f)
135#define H_GET_MACHTYPE(h) (((h)->header.a_info >> 16) & 0xff)
136#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info & 0xffff)
f6e504fe 137
a39116f1
RP
138#define H_SET_DYNAMIC(h,v) ((h)->header.a_info = (((v) << 31) \
139 | (H_GET_VERSION(h) << 24) \
140 | (H_GET_MACHTYPE(h) << 16) \
141 | (H_GET_MAGIC_NUMBER(h))))
142
143#define H_SET_VERSION(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
144 | ((v) << 24) \
145 | (H_GET_MACHTYPE(h) << 16) \
146 | (H_GET_MAGIC_NUMBER(h))))
147
148#define H_SET_MACHTYPE(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
149 | (H_GET_VERSION(h) << 24) \
150 | ((v) << 16) \
151 | (H_GET_MAGIC_NUMBER(h))))
152
153#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
154 | (H_GET_VERSION(h) << 24) \
155 | (H_GET_MACHTYPE(h) << 16) \
156 | ((v))))
fecd2382
RP
157
158#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
159#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
160#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
161
162#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
163 H_SET_DATA_RELOCATION_SIZE((h),(d)))
164
165#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
166#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
167#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \
168 sizeof(struct nlist))
169
fecd2382
RP
170#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
171#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
fecd2382
RP
172
173/*
174 * Current means for getting the name of a segment.
175 * This will change for infinite-segments support (e.g. COFF).
176 */
177#define segment_name(seg) ( seg_name[(int)(seg)] )
178extern char *const seg_name[];
179
180typedef struct {
a39116f1
RP
181 struct exec header; /* a.out header */
182 long string_table_size; /* names + '\0' + sizeof(int) */
fecd2382
RP
183} object_headers;
184
185/* line numbering stuff. */
a39116f1
RP
186#define OBJ_EMIT_LINENO(a, b, c) {;}
187
188#define obj_symbol_new_hook(s) {;}
189
190#ifdef __STDC__
191struct fix;
192void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address);
193#else
194void tc_aout_fix_to_chars();
195#endif /* __STDC__ */
fecd2382
RP
196
197/*
198 * Local Variables:
199 * comment-column: 0
200 * fill-column: 131
201 * End:
202 */
203
204/* end of obj-aout.h */
This page took 0.061047 seconds and 4 git commands to generate.