binutils-gdb/gas/config/obj-aout.h

254 lines
8.7 KiB
C
Raw Normal View History

1999-05-03 09:29:11 +02:00
/* obj-aout.h, a.out object file format for gas, the assembler.
2002-09-05 02:01:18 +02:00
Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000,
2002, 2003, 2005 Free Software Foundation, Inc.
1999-05-03 09:29:11 +02:00
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2,
or (at your option) any later version.
GAS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
1999-05-03 09:29:11 +02:00
/* Tag to validate a.out object file format processing */
#define OBJ_AOUT 1
#include "targ-cpu.h"
#ifdef BFD_ASSEMBLER
#include "bfd/libaout.h"
#define OUTPUT_FLAVOR bfd_target_aout_flavour
#else /* ! BFD_ASSEMBLER */
#ifndef VMS
#include "aout_gnu.h" /* Needed to define struct nlist. Sigh. */
1999-05-03 09:29:11 +02:00
#else
#include "a_out.h"
#endif
#ifndef AOUT_MACHTYPE
#define AOUT_MACHTYPE 0
#endif /* AOUT_MACHTYPE */
extern const short seg_N_TYPE[];
extern const segT N_TYPE_seg[];
#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC)
#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */
#endif /* ! BFD_ASSEMBLER */
extern const pseudo_typeS aout_pseudo_table[];
#ifndef obj_pop_insert
#define obj_pop_insert() pop_insert (aout_pseudo_table)
#endif
/* Symbol table entry data type. */
1999-05-03 09:29:11 +02:00
typedef struct nlist obj_symbol_type; /* Symbol table entry. */
1999-05-03 09:29:11 +02:00
/* Symbol table macros and constants */
#ifdef BFD_ASSEMBLER
Add support for storing local symbols in a small structure to save memory when assembling large files. * as.h: Don't include struc-symbol.h. (symbolS): Add typedef. * symbols.c: Include struc-symbol.h. (local_hash): New static variable. (save_symbol_name): New static function, from symbol_create. (symbol_create): Call save_symbol_name. (local_symbol_count): New static variable. (local_symbol_conversion_count): Likewise. (LOCAL_SYMBOL_CHECK): Define. (local_symbol_make): New static function. (local_symbol_convert): New static function. (colon): Handle local symbols. Create local symbol for local label name. (symbol_table_insert): Handle local symbols. (symbol_find_or_make): Create local symbol for local label name. (symbol_find_base): Check for local symbol. (symbol_append, symbol_insert): Check for local symbols. (symbol_clear_list_pointers, symbol_remove): Likewise. (verify_symbol_chain): Likewise. (copy_symbol_attributes): Likewise. (resolve_symbol_value): Handle local symbols. (resolve_local_symbol): New static function. (resolve_local_symbol_values): New function. (S_GET_VALUE, S_SET_VALUE): Handle local symbols. (S_IS_FUNCTION, S_IS_EXTERNAL, S_IS_WEAK, S_IS_COMMON): Likewise. (S_IS_DEFINED, S_IS_DEBUG, S_IS_LOCAL, S_GET_NAME): Likewise. (S_GET_SEGMENT, S_SET_SEGMENT, S_SET_EXTERNAL): Likewise. (S_CLEAR_EXTERNAL, S_SET_WEAK, S_SET_NAME): Likewise. (symbol_previous, symbol_next): New functions. (symbol_get_value_expression): Likewise. (symbol_set_value_expression): Likewise. (symbol_set_frag, symbol_get_frag): Likewise. (symbol_mark_used, symbol_clear_used, symbol_used_p): Likewise. (symbol_mark_used_in_reloc): Likewise. (symbol_clear_used_in_reloc, symbol_used_in_reloc_p): Likewise. (symbol_mark_mri_common, symbol_clear_mri_common): Likewise. (symbol_mri_common_p): Likewise. (symbol_mark_written, symbol_clear_written): Likewise. (symbol_written_p): Likewise. (symbol_mark_resolved, symbol_resolved_p): Likewise. (symbol_section_p, symbol_equated_p): Likewise. (symbol_constant_p): Likewise. (symbol_get_bfdsym, symbol_set_bfdsym): Likewise. (symbol_get_obj, symbol_set_obj): Likewise. (symbol_get_tc, symbol_set_tc): Likewise. (symbol_begin): Initialize local_hash. (print_symbol_value_1): Handle local symbols. (symbol_print_statistics): Print local symbol statistics. * symbols.h: Include "struc-symbol.h" if not BFD_ASSEMBLER. Declare new symbols.c functions. Move many declarations here from struc-symbol.h. (SYMBOLS_NEED_BACKPOINTERS): Define if needed. * struc-symbol.h (SYMBOLS_NEED_BACKPOINTERS): Don't set. (struct symbol): Move bsym to make it clearly the first field. Remove TARGET_SYMBOL_FIELDS. (symbolS): Don't typedef. (struct broken_word): Remove. (N_TYPE_seg, seg_N_TYPE): Move to symbol.h. (SEGMENT_TO_SYMBOL_TYPE, N_REGISTER): Likewise. (symbol_clear_list_pointers): Likewise. (symbol_insert, symbol_remove): Likewise. (symbol_previous, symbol_append): Likewise. (verify_symbol_chain, verify_symbol_chain_2): Likewise. (struct local_symbol): Define. (local_symbol_converted_p, local_symbol_mark_converted): Define. (local_symbol_resolved_p, local_symbol_mark_resolved): Define. (local_symbol_get_frag, local_symbol_set_frag): Define. (local_symbol_get_real_symbol): Define. (local_symbol_set_real_symbol): Define. Define. * write.c (write_object_file): Call resolve_local_symbol_values. * config/obj-ecoff.h (OBJ_SYMFIELD_TYPE): Define. (TARGET_SYMBOL_FIELDS): Don't define. * config/obj-elf.h (OBJ_SYMFIELD_TYPE): Add local field. If ECOFF_DEBUGGING, add ECOFF fields. (ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define. * config/obj-multi.h (struct elf_obj_sy): Add local field. If ECOFF_DEBUGGING, add ECOFF fields. (ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define. (ECOFF_DEBUG_TARGET_SYMBOL_FIELDS): Don't define. * config/tc-mcore.h: Don't include struc-symbol.h. (TARGET_SYMBOL_FIELDS): Don't define. (struct mcore_tc_sy): Define. (TC_SYMFIELD_TYPE): Define. * Many files: Use symbolS instead of struct symbol. Use new accessor functions rather than referring to symbolS fields directly. * read.c (s_mri_common): Don't add in value of line_label. * config/tc-mips.c (md_apply_fix): Correct parenthesization when checking for SEC_LINK_ONCE. * config/tc-sh.h (sh_fix_adjustable): Declare.
1999-06-03 02:29:48 +02:00
#define S_SET_OTHER(S,V) \
(aout_symbol (symbol_get_bfdsym (S))->other = (V))
#define S_SET_TYPE(S,T) \
(aout_symbol (symbol_get_bfdsym (S))->type = (T))
#define S_SET_DESC(S,D) \
(aout_symbol (symbol_get_bfdsym (S))->desc = (D))
#define S_GET_OTHER(S) \
(aout_symbol (symbol_get_bfdsym (S))->other)
#define S_GET_TYPE(S) \
(aout_symbol (symbol_get_bfdsym (S))->type)
#define S_GET_DESC(S) \
(aout_symbol (symbol_get_bfdsym (S))->desc)
1999-05-03 09:29:11 +02:00
asection *text_section, *data_section, *bss_section;
#define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT)
2002-09-05 02:01:18 +02:00
#define obj_frob_file_before_fix() obj_aout_frob_file_before_fix ()
1999-05-03 09:29:11 +02:00
extern void obj_aout_frob_symbol (symbolS *, int *);
extern void obj_aout_frob_file_before_fix (void);
#define obj_sec_sym_ok_for_reloc(SEC) 1
1999-05-03 09:29:11 +02:00
#else
/* We use the sy_obj field to record whether a symbol is weak. */
#define OBJ_SYMFIELD_TYPE char
/* Macros to extract information from a symbol table entry.
This syntactic indirection allows independence regarding a.out or coff.
The argument (s) of all these macros is a pointer to a symbol table entry. */
1999-05-03 09:29:11 +02:00
/* True if the symbol is external. */
1999-05-03 09:29:11 +02:00
#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT)
/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT. */
1999-05-03 09:29:11 +02:00
#define S_IS_DEFINED(s) \
(S_GET_TYPE (s) != N_UNDF || S_GET_DESC (s) != 0)
#define S_IS_COMMON(s) \
(S_GET_TYPE (s) == N_UNDF && S_GET_VALUE (s) != 0)
2002-09-05 02:01:18 +02:00
/* Return true for symbols that should not be reduced to section
symbols or eliminated from expressions, because they may be
overridden by the linker. */
* symbols.c (S_FORCE_RELOC): Add "strict" param. * symbols.h (S_FORCE_RELOC): Likewise. * config/obj-aout.h (S_FORCE_RELOC): Likewise. * config/obj-bout.h (S_FORCE_RELOC): Likewise. * config/obj-coff.h (S_FORCE_RELOC): Likewise. * config/obj-ieee.h (S_FORCE_RELOC): Likewise. * config/obj-vms.h (S_FORCE_RELOC): Likewise. * write.c (generic_force_reloc): New function. (TC_FORCE_RELOCATION): Use it here instead of S_FORCE_RELOC. (TC_FORCE_RELOCATION_SUB_SAME): Test TC_FORCE_RELOCATION too. (adjust_reloc_syms): Adjust S_FORCE_RELOC call. * as.h (generic_force_reloc): Declare. * doc/internals.texi (S_FORCE_RELOC): Update. (TC_FORCE_RELOCATION_SUB_SAME): Update. * config/tc-alpha.c (alpha_force_relocation): Adjust to use generic_force_reloc. (alpha_fix_adjustable): Likewise. * config/tc-arm.c (arm_force_relocation): Likewise. * config/tc-cris.c (md_cris_force_relocation): Likewise. * config/tc-frv.c (frv_force_relocation): Likewise. * config/tc-i386.c (md_apply_fix3): Likewise. * config/tc-ia64.c (ia64_force_relocation): Likewise. * config/tc-ip2k.c (ip2k_force_relocation): Likewise. * config/tc-m32r.c (m32r_force_relocation): Likewise. * config/tc-m68hc11.c (tc_m68hc11_force_relocation): Likewise. * config/tc-mcore.c (mcore_force_relocation): Likewise. * config/tc-mips.c (mips_force_relocation): Likewise. * config/tc-mmix.c (mmix_force_relocation): Likewise. * config/tc-ppc.c (ppc_force_relocation): Likewise. * config/tc-s390.c (tc_s390_force_relocation): Likewise. * config/tc-sh.c (sh_force_relocation): Likewise. (md_pcrel_from_section): Likewise. * config/tc-sparc.c (tc_gen_reloc): Likewise. * config/tc-v850.c (v850_force_relocation): Likewise. * config/tc-xstormy16.c (xstormy16_force_relocation): Likewise. * config/tc-i386.h (TC_FORCE_RELOCATION): Likewise. * config/tc-mcore.h (TC_FORCE_RELOCATION): Likewise. * config/tc-sparc.h (tc_fix_adjustable): Likewise. * config/tc-d10v.c (d10v_force_relocation): Delete. * config/tc-d10v.h (TC_FORCE_RELOCATION): Don't define. * config/tc-dlx.c (md_dlx_force_relocation): Delete. * config/tc-dlx.h (TC_FORCE_RELOCATION): Don't define. * config/tc-fr30.c (fr30_force_relocation): Delete. * config/tc-fr30.h (TC_FORCE_RELOCATION): Don't define. * config/tc-mn10300.c (mn10300_force_relocation): Delete. * config/tc-mn10300.h (TC_FORCE_RELOCATION): Don't define. (TC_FORCE_RELOCATION_SUB_SAME): Test TC_FORCE_RELOCATION too. * config/tc-i960.h (TC_FORCE_RELOCATION_SUB_SAME): Likewise. * config/tc-hppa.c (hppa_force_relocation): Adjust S_FORCE_RELOC call. * config/tc-mips.c (RELAX_BRANCH_TOOFAR): Warning fix. * config/tc-mips.h (TC_FORCE_RELOCATION_SUB_SAME): Don't define. * config/tc-openrisc.c (openrisc_force_relocation): Delete. * config/tc-openrisc.h (TC_FORCE_RELOCATION): Don't define. * config/tc-sparc.c (elf32_sparc_force_relocation): Delete. * config/tc-sparc.h (TC_FORCE_RELOCATION): Don't define for ELF. * config/tc-i386.c (i386_force_relocation): Delete. * config/tc-i386.h (TC_FORCE_RELOCATION): Don't define for BFD_ASSEMBLER. (EXTERN_FORCE_RELOC): Fix TE_PE and STRICT_PE_FORMAT nesting. * config/tc-m68k.h (TC_FORCE_RELOCATION): Don't define. * config/tc-pj.h (TC_FORCE_RELOCATION): Don't define. * config/tc-sh.h (TC_FORCE_RELOCATION_SUB_ABS): Don't call S_FORCE_RELOC. (TC_FORCE_RELOCATION_SUB_SAME): Test TC_FORCE_RELOCATION too. * config/tc-sh64.h (TC_FORCE_RELOCATION_SUB_SAME): Likewise.
2003-01-23 13:51:05 +01:00
#define S_FORCE_RELOC(s, strict) \
2002-09-05 02:01:18 +02:00
(!SEG_NORMAL (S_GET_SEGMENT (s)))
1999-05-03 09:29:11 +02:00
#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER)
/* True if a debug special symbol entry. */
1999-05-03 09:29:11 +02:00
#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB)
/* True if a symbol is local symbol name. */
1999-05-03 09:29:11 +02:00
#define S_IS_LOCAL(s) \
((S_GET_NAME (s) \
&& !S_IS_DEBUG (s) \
&& (strchr (S_GET_NAME (s), '\001') != NULL \
|| strchr (S_GET_NAME (s), '\002') != NULL \
|| (S_LOCAL_NAME(s) && !flag_keep_locals))) \
|| (flag_strip_local_absolute \
&& ! S_IS_EXTERNAL(s) \
&& S_GET_SEGMENT (s) == absolute_section))
/* True if the symbol has been generated because of a .stabd directive. */
#define S_IS_STABD(s) (S_GET_NAME(s) == NULL)
1999-05-03 09:29:11 +02:00
/* Accessors. */
/* The name of the symbol. */
1999-05-03 09:29:11 +02:00
#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name)
/* The pointer to the string table. */
1999-05-03 09:29:11 +02:00
#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx)
/* The type of the symbol. */
1999-05-03 09:29:11 +02:00
#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE)
/* The numeric value of the segment. */
1999-05-03 09:29:11 +02:00
#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)])
/* The n_other expression value. */
1999-05-03 09:29:11 +02:00
#define S_GET_OTHER(s) ((s)->sy_symbol.n_other)
/* The n_desc expression value. */
1999-05-03 09:29:11 +02:00
#define S_GET_DESC(s) ((s)->sy_symbol.n_desc)
/* Whether the symbol is weak. */
#define S_GET_WEAK(s) ((s)->sy_obj)
/* Modifiers. */
/* Assume that a symbol cannot be simultaneously in more than on segment. */
/* Set segment. */
#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type |= SEGMENT_TO_SYMBOL_TYPE (seg))
/* The symbol is external. */
1999-05-03 09:29:11 +02:00
#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT)
/* The symbol is not external. */
1999-05-03 09:29:11 +02:00
#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT)
/* Set the name of the symbol. */
1999-05-03 09:29:11 +02:00
#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v))
/* Set the offset in the string table. */
1999-05-03 09:29:11 +02:00
#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v))
/* Set the n_type field. */
1999-05-03 09:29:11 +02:00
#define S_SET_TYPE(s,t) ((s)->sy_symbol.n_type = (t))
/* Set the n_other expression value. */
1999-05-03 09:29:11 +02:00
#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v))
/* Set the n_desc expression value. */
1999-05-03 09:29:11 +02:00
#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v))
/* Mark the symbol as weak. This causes n_type to be adjusted when
the symbol is written out. */
#define S_SET_WEAK(s) ((s)->sy_obj = 1)
/* File header macro and type definition. */
1999-05-03 09:29:11 +02:00
#define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE (h) \
+ H_GET_TEXT_SIZE (h) \
+ H_GET_DATA_SIZE (h) \
+ H_GET_TEXT_RELOCATION_SIZE (h) \
+ H_GET_DATA_RELOCATION_SIZE (h) \
+ H_GET_LINENO_SIZE (h) \
+ H_GET_SYMBOL_TABLE_SIZE (h) \
+ H_GET_STRING_SIZE (h))
1999-05-03 09:29:11 +02:00
#define H_GET_HEADER_SIZE(h) (EXEC_BYTES_SIZE)
#define H_GET_TEXT_SIZE(h) ((h)->header.a_text)
#define H_GET_DATA_SIZE(h) ((h)->header.a_data)
#define H_GET_BSS_SIZE(h) ((h)->header.a_bss)
#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize)
#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize)
#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms)
#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry)
#define H_GET_STRING_SIZE(h) ((h)->string_table_size)
#define H_GET_LINENO_SIZE(h) (0)
#define H_GET_DYNAMIC(h) ((h)->header.a_info >> 31)
#define H_GET_VERSION(h) (((h)->header.a_info >> 24) & 0x7f)
#define H_GET_MACHTYPE(h) (((h)->header.a_info >> 16) & 0xff)
#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info & 0xffff)
#define H_SET_DYNAMIC(h,v) ((h)->header.a_info = (((v) << 31) \
| (H_GET_VERSION (h) << 24) \
| (H_GET_MACHTYPE (h) << 16) \
| (H_GET_MAGIC_NUMBER (h))))
1999-05-03 09:29:11 +02:00
#define H_SET_VERSION(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC (h) << 31) \
1999-05-03 09:29:11 +02:00
| ((v) << 24) \
| (H_GET_MACHTYPE (h) << 16) \
| (H_GET_MAGIC_NUMBER (h))))
1999-05-03 09:29:11 +02:00
#define H_SET_MACHTYPE(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC (h) << 31) \
| (H_GET_VERSION (h) << 24) \
1999-05-03 09:29:11 +02:00
| ((v) << 16) \
| (H_GET_MAGIC_NUMBER (h))))
1999-05-03 09:29:11 +02:00
#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = ((H_GET_DYNAMIC (h) << 31) \
| (H_GET_VERSION (h) << 24) \
| (H_GET_MACHTYPE (h) << 16) \
1999-05-03 09:29:11 +02:00
| ((v))))
#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align (SEG_TEXT, (v)))
#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align (SEG_DATA, (v)))
#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align (SEG_BSS, (v)))
1999-05-03 09:29:11 +02:00
#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE ((h),(t)),\
H_SET_DATA_RELOCATION_SIZE ((h),(d)))
1999-05-03 09:29:11 +02:00
#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * 12)
#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v))
#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
typedef struct
{
struct exec header; /* a.out header. */
long string_table_size; /* names + '\0' + sizeof (int). */
}
1999-05-03 09:29:11 +02:00
object_headers;
/* Line numbering stuff. */
1999-05-03 09:29:11 +02:00
#define OBJ_EMIT_LINENO(a, b, c) {;}
struct fix;
extern void tc_aout_fix_to_chars (char *, struct fix *, relax_addressT);
1999-05-03 09:29:11 +02:00
#endif
#define obj_read_begin_hook() {;}
1999-05-03 09:29:11 +02:00
#define obj_symbol_new_hook(s) {;}
#define EMIT_SECTION_SYMBOLS 0
#define AOUT_STABS