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