* config/obj-coff.h (TC_SPARC): Don't define TARGET_FORMAT.
[deliverable/binutils-gdb.git] / gas / config / obj-aout.h
CommitLineData
def66e24
DM
1/* obj-aout.h, a.out object file format for gas, the assembler.
2 Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3
a39116f1 4 This file is part of GAS, the GNU Assembler.
def66e24 5
a39116f1
RP
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.
def66e24 10
a39116f1
RP
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.
def66e24 15
a39116f1
RP
16 You should have received a copy of the GNU General Public
17 License along with GAS; see the file COPYING. If not, write
9e396994 18 to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
def66e24
DM
25#ifdef BFD_ASSEMBLER
26
9e396994 27#include "bfd/libaout.h"
def66e24 28
9e396994 29#define OUTPUT_FLAVOR bfd_target_aout_flavour
def66e24
DM
30
31#else /* ! BFD_ASSEMBLER */
32
33#ifndef VMS
34#include "aout_gnu.h" /* Needed to define struct nlist. Sigh. */
fecd2382
RP
35#else
36#include "a_out.h"
37#endif
38
a39116f1
RP
39#ifndef AOUT_MACHTYPE
40#define AOUT_MACHTYPE 0
41#endif /* AOUT_MACHTYPE */
d1a9e594 42
fecd2382 43extern const short seg_N_TYPE[];
def66e24 44extern const segT N_TYPE_seg[];
fecd2382
RP
45
46#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
47#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC)
48#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */
49
def66e24
DM
50#endif /* ! BFD_ASSEMBLER */
51
fecd2382
RP
52/* SYMBOL TABLE */
53/* Symbol table entry data type */
54
def66e24 55typedef struct nlist obj_symbol_type; /* Symbol table entry */
fecd2382 56
fecd2382
RP
57/* Symbol table macros and constants */
58
def66e24
DM
59#ifdef BFD_ASSEMBLER
60
61#define S_SET_OTHER(S,V) (aout_symbol((S)->bsym)->other = (V))
62#define S_SET_TYPE(S,T) (aout_symbol((S)->bsym)->type = (T))
63#define S_SET_DESC(S,D) (aout_symbol((S)->bsym)->desc = (D))
64#define S_GET_OTHER(S) (aout_symbol((S)->bsym)->other)
65#define S_GET_TYPE(S) (aout_symbol((S)->bsym)->type)
66#define S_GET_DESC(S) (aout_symbol((S)->bsym)->desc)
67
68asection *text_section, *data_section, *bss_section;
69
70#define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT)
71#define obj_frob_file() obj_aout_frob_file ()
72extern void obj_aout_frob_symbol PARAMS ((struct symbol *, int *));
73extern void obj_aout_frob_file PARAMS ((void));
74
75#define obj_sec_sym_ok_for_reloc(SEC) (1)
76
77#else
78
9e396994
ILT
79/* We use the sy_obj field to record whether a symbol is weak. */
80#define OBJ_SYMFIELD_TYPE char
81
fecd2382
RP
82/*
83 * Macros to extract information from a symbol table entry.
84 * This syntaxic indirection allows independence regarding a.out or coff.
85 * The argument (s) of all these macros is a pointer to a symbol table entry.
86 */
87
88/* True if the symbol is external */
89#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
90
91/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
92#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_OTHER(s) != 0) || (S_GET_DESC(s) != 0))
93
94#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
95
96/* True if a debug special symbol entry */
97#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
98/* True if a symbol is local symbol name */
9e396994
ILT
99#define S_IS_LOCAL(s) \
100 (S_GET_NAME (s) \
101 && !S_IS_DEBUG (s) \
102 && (strchr (S_GET_NAME (s), '\001') != NULL \
103 || strchr (S_GET_NAME (s), '\002') != NULL \
104 || (S_LOCAL_NAME(s) && !flag_keep_locals)))
fecd2382
RP
105/* True if a symbol is not defined in this file */
106#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT)
107/* True if the symbol has been generated because of a .stabd directive */
108#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0)
109
110/* Accessors */
fecd2382
RP
111/* The name of the symbol */
112#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
113/* The pointer to the string table */
114#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
115/* The type of the symbol */
116#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
117/* The numeric value of the segment */
118#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
119/* The n_other expression value */
120#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
121/* The n_desc expression value */
122#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
9e396994
ILT
123/* Whether the symbol is weak. */
124#define S_GET_WEAK(s) ((s)->sy_obj)
fecd2382
RP
125
126/* Modifiers */
fecd2382 127/* Assume that a symbol cannot be simultaneously in more than on segment */
a39116f1 128/* set segment */
fecd2382
RP
129#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
130/* The symbol is external */
131#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
132/* The symbol is not external */
133#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
134/* Set the name of the symbol */
135#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
136/* Set the offset in the string table */
137#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
def66e24
DM
138/* Set the n_type field */
139#define S_SET_TYPE(s,t) ((s)->sy_symbol.n_type = (t))
fecd2382
RP
140/* Set the n_other expression value */
141#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
142/* Set the n_desc expression value */
143#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
9e396994
ILT
144/* Mark the symbol as weak. This causes n_type to be adjusted when
145 the symbol is written out. */
146#define S_SET_WEAK(s) ((s)->sy_obj = 1)
fecd2382
RP
147
148/* File header macro and type definition */
149
f6e504fe
RP
150#define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE(h) \
151 + H_GET_TEXT_SIZE(h) \
152 + H_GET_DATA_SIZE(h) \
153 + H_GET_SYMBOL_TABLE_SIZE(h) \
154 + H_GET_TEXT_RELOCATION_SIZE(h) \
155 + H_GET_DATA_RELOCATION_SIZE(h) \
156 + H_GET_STRING_SIZE(h))
fecd2382 157
def66e24 158#define H_GET_HEADER_SIZE(h) (EXEC_BYTES_SIZE)
fecd2382
RP
159#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
160#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
161#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
162#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
163#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
164#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
fecd2382
RP
165#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
166#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
f6e504fe
RP
167#define H_GET_LINENO_SIZE(h) (0)
168
a39116f1
RP
169#define H_GET_DYNAMIC(h) ((h)->header.a_info >> 31)
170#define H_GET_VERSION(h) (((h)->header.a_info >> 24) & 0x7f)
171#define H_GET_MACHTYPE(h) (((h)->header.a_info >> 16) & 0xff)
172#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info & 0xffff)
f6e504fe 173
a39116f1
RP
174#define H_SET_DYNAMIC(h,v) ((h)->header.a_info = (((v) << 31) \
175 | (H_GET_VERSION(h) << 24) \
176 | (H_GET_MACHTYPE(h) << 16) \
177 | (H_GET_MAGIC_NUMBER(h))))
178
179#define H_SET_VERSION(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
180 | ((v) << 24) \
181 | (H_GET_MACHTYPE(h) << 16) \
182 | (H_GET_MAGIC_NUMBER(h))))
183
184#define H_SET_MACHTYPE(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
185 | (H_GET_VERSION(h) << 24) \
186 | ((v) << 16) \
187 | (H_GET_MAGIC_NUMBER(h))))
188
189#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
190 | (H_GET_VERSION(h) << 24) \
191 | (H_GET_MACHTYPE(h) << 16) \
192 | ((v))))
fecd2382
RP
193
194#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
195#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
196#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
197
198#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
199 H_SET_DATA_RELOCATION_SIZE((h),(d)))
200
201#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
202#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
def66e24 203#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * 12)
fecd2382 204
fecd2382
RP
205#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
206#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
fecd2382 207
def66e24
DM
208typedef struct
209 {
210 struct exec header; /* a.out header */
211 long string_table_size; /* names + '\0' + sizeof(int) */
212 }
fecd2382 213
def66e24 214object_headers;
fecd2382
RP
215
216/* line numbering stuff. */
a39116f1
RP
217#define OBJ_EMIT_LINENO(a, b, c) {;}
218
a39116f1 219struct fix;
def66e24 220void tc_aout_fix_to_chars PARAMS ((char *where, struct fix *fixP, relax_addressT segment_address));
fecd2382 221
def66e24
DM
222#endif
223
224#define obj_symbol_new_hook(s) {;}
225
226#define EMIT_SECTION_SYMBOLS 0
fecd2382 227
9e396994
ILT
228#define AOUT_STABS
229
fecd2382 230/* end of obj-aout.h */
This page took 0.244973 seconds and 4 git commands to generate.