/* coff object file format
- Copyright (C) 1989, 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
+ Copyright (C) 1989, 90, 91, 92, 94, 95, 96, 97, 98, 99, 2000
+ Free Software Foundation, Inc.
This file is part of GAS.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 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. */
#ifndef OBJ_FORMAT_H
#define OBJ_FORMAT_H
#undef internal_lineno
/* CPU-specific setup: */
+
+#ifdef TC_ARM
+#include "coff/arm.h"
+#ifndef TARGET_FORMAT
+#define TARGET_FORMAT "coff-arm"
+#endif
+#endif
+
#ifdef TC_PPC
+#ifdef TE_PE
+#include "coff/powerpc.h"
+#else
#include "coff/rs6000.h"
#endif
+#endif
#ifdef TC_SPARC
#include "coff/sparc.h"
-#ifdef TE_LYNX
-#define TARGET_FORMAT "coff-sparc-lynx"
-#else
-#define TARGET_FORMAT "coff-sparc"
-#endif
#endif
#ifdef TC_I386
#include "coff/i386.h"
+
+#ifdef TE_PE
+#define TARGET_FORMAT "pe-i386"
+#endif
+
#ifndef TARGET_FORMAT
#define TARGET_FORMAT "coff-i386"
#endif
#endif
#ifdef TC_SH
+
+#ifdef TE_PE
+#define COFF_WITH_PE
+#endif
+
#include "coff/sh.h"
-#define TARGET_FORMAT (shl ? "coff-shl" : "coff-sh")
+
+#ifdef TE_PE
+#define TARGET_FORMAT "pe-shl"
+#else
+#define TARGET_FORMAT \
+ (shl \
+ ? (sh_small ? "coff-shl-small" : "coff-shl") \
+ : (sh_small ? "coff-sh-small" : "coff-sh"))
+#endif
+#endif
+
+#ifdef TC_MIPS
+#define COFF_WITH_PE
+#include "coff/mipspe.h"
+#undef TARGET_FORMAT
+#define TARGET_FORMAT "pe-mips"
#endif
#ifdef TC_M88K
#define TARGET_FORMAT "coff-m88kbcs"
#endif
+#ifdef TC_W65
+#include "coff/w65.h"
+#define TARGET_FORMAT "coff-w65"
+#endif
+
+#ifdef TC_TIC30
+#include "coff/tic30.h"
+#define TARGET_FORMAT "coff-tic30"
+#endif
+
+#ifdef TC_TIC54X
+#include "coff/tic54x.h"
+#define TARGET_FORMAT "coff1-c54x"
+#endif
+
+#ifdef TC_TIC80
+#include "coff/tic80.h"
+#define TARGET_FORMAT "coff-tic80"
+#define ALIGNMENT_IN_S_FLAGS 1
+#endif
+
+#ifdef TC_MCORE
+#include "coff/mcore.h"
+#ifndef TARGET_FORMAT
+#define TARGET_FORMAT "pe-mcore"
+#endif
+#endif
+
/* Targets may also set this. Also, if BFD_ASSEMBLER is defined, this
will already have been defined. */
#undef SYMBOLS_NEED_BACKPOINTERS
#define OBJ_COFF_MAX_AUXENTRIES 1
#endif /* OBJ_COFF_MAX_AUXENTRIES */
+extern void coff_obj_symbol_new_hook PARAMS ((symbolS *));
+#define obj_symbol_new_hook coff_obj_symbol_new_hook
+
+extern void coff_obj_read_begin_hook PARAMS ((void));
+#define obj_read_begin_hook coff_obj_read_begin_hook
+
/* ***********************************************************************
This file really contains two implementations of the COFF back end.
#include "bfd/libcoff.h"
+#define OUTPUT_FLAVOR bfd_target_coff_flavour
+
/* SYMBOL TABLE */
/* Alter the field names, for now, until we've fixed up the other
references to use the new name. */
#ifdef TC_I960
-#define TC_SYMFIELD_TYPE struct symbol *
+#define TC_SYMFIELD_TYPE symbolS *
#define sy_tc bal
#endif
#define OBJ_SYMFIELD_TYPE unsigned long
#define sy_obj sy_flags
-#define SYM_AUXENT(S) (&coffsymbol ((S)->bsym)->native[1].u.auxent)
+#define SYM_AUXENT(S) \
+ (&coffsymbol (symbol_get_bfdsym (S))->native[1].u.auxent)
+#define SYM_AUXINFO(S) \
+ (&coffsymbol (symbol_get_bfdsym (S))->native[1])
#define DO_NOT_STRIP 0
-#define DO_STRIP 1
extern void obj_coff_section PARAMS ((int));
/* The number of auxiliary entries */
-#define S_GET_NUMBER_AUXILIARY(s) (coffsymbol((s)->bsym)->native->u.syment.n_numaux)
+#define S_GET_NUMBER_AUXILIARY(s) \
+ (coffsymbol (symbol_get_bfdsym (s))->native->u.syment.n_numaux)
/* The number of auxiliary entries */
#define S_SET_NUMBER_AUXILIARY(s,v) (S_GET_NUMBER_AUXILIARY (s) = (v))
/* True if a symbol name is in the string table, i.e. its length is > 8. */
#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
-extern int S_SET_DATA_TYPE PARAMS ((struct symbol *, int));
-extern int S_SET_STORAGE_CLASS PARAMS ((struct symbol *, int));
-extern int S_GET_STORAGE_CLASS PARAMS ((struct symbol *));
-extern void SA_SET_SYM_ENDNDX PARAMS ((struct symbol *, struct symbol *));
+extern int S_SET_DATA_TYPE PARAMS ((symbolS *, int));
+extern int S_SET_STORAGE_CLASS PARAMS ((symbolS *, int));
+extern int S_GET_STORAGE_CLASS PARAMS ((symbolS *));
+extern void SA_SET_SYM_ENDNDX PARAMS ((symbolS *, symbolS *));
/* Auxiliary entry macros. SA_ stands for symbol auxiliary */
/* Omit the tv related fields */
/* All other bits are unused. */
/* Accessors */
-#define SF_GET(s) ((s)->sy_flags)
-#define SF_GET_DEBUG(s) ((s)->bsym->flags & BSF_DEBUGGING)
-#define SF_SET_DEBUG(s) ((s)->bsym->flags |= BSF_DEBUGGING)
+#define SF_GET(s) (*symbol_get_obj (s))
+#define SF_GET_DEBUG(s) (symbol_get_bfdsym (s)->flags & BSF_DEBUGGING)
+#define SF_SET_DEBUG(s) (symbol_get_bfdsym (s)->flags |= BSF_DEBUGGING)
#define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK)
#define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK)
#define SF_GET_FILE(s) (SF_GET (s) & SF_FILE)
/* -------------- Line number handling ------- */
extern int text_lineno_number;
extern int coff_line_base;
+extern int coff_n_line_nos;
#define obj_emit_lineno(WHERE,LINE,FILE_START) abort ()
-extern void coff_add_linesym PARAMS ((struct symbol *));
+extern void coff_add_linesym PARAMS ((symbolS *));
-void c_dot_file_symbol PARAMS ((char *filename));
+void c_dot_file_symbol PARAMS ((const char *filename));
+#define obj_app_file c_dot_file_symbol
-extern void coff_frob_symbol PARAMS ((struct symbol *, int *));
+extern void coff_frob_symbol PARAMS ((symbolS *, int *));
extern void coff_adjust_symtab PARAMS ((void));
extern void coff_frob_section PARAMS ((segT));
extern void coff_adjust_section_syms PARAMS ((bfd *, asection *, PTR));
-extern void coff_frob_file PARAMS ((void));
+extern void coff_frob_file_after_relocs PARAMS ((void));
#define obj_frob_symbol(S,P) coff_frob_symbol(S,&P)
+#ifndef obj_adjust_symtab
#define obj_adjust_symtab() coff_adjust_symtab()
+#endif
#define obj_frob_section(S) coff_frob_section (S)
-#define obj_frob_file() coff_frob_file ()
+#define obj_frob_file_after_relocs() coff_frob_file_after_relocs ()
-extern struct symbol *coff_last_function;
+extern symbolS *coff_last_function;
/* Forward the segment of a forwarded symbol, handle assignments that
just copy symbol values, etc. */
+#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
#ifndef TE_I386AIX
#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest,src) \
(SF_GET_GET_SEGMENT (dest) \
? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
: 0)
#endif
+#endif
/* sanity check */
#ifndef DO_NOT_STRIP
#define DO_NOT_STRIP 0
-#define DO_STRIP 1
#endif
/* Symbol table macros and constants */
#define C_DEBUG_SECTION N_DEBUG
#define C_NTV_SECTION N_TV
#define C_PTV_SECTION P_TV
-#define C_REGISTER_SECTION 20
+#define C_REGISTER_SECTION 50
/*
* Macros to extract information from a symbol table entry.
/* A symbol name whose name includes ^A is a gas internal pseudo symbol */
#define S_IS_LOCAL(s) \
((s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION \
- || (S_LOCAL_NAME(s) && !flag_keep_locals) \
- || (strchr (S_GET_NAME (s), '\001') != NULL))
+ || (S_LOCAL_NAME(s) && ! flag_keep_locals && ! S_IS_DEBUG (s)) \
+ || strchr (S_GET_NAME (s), '\001') != NULL \
+ || strchr (S_GET_NAME (s), '\002') != NULL \
+ || (flag_strip_local_absolute \
+ && !S_IS_EXTERNAL(s) \
+ && (s)->sy_symbol.ost_entry.n_scnum == C_ABS_SECTION))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 \
&& S_GET_VALUE (s) == 0)
/* True if a symbol name is in the string table, i.e. its length is > 8. */
#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
+/* True if a symbol is defined as weak. */
+#ifdef TE_PE
+#define S_IS_WEAK(s) \
+ ((s)->sy_symbol.ost_entry.n_sclass == C_NT_WEAK \
+ || (s)->sy_symbol.ost_entry.n_sclass == C_WEAKEXT)
+#else
+#define S_IS_WEAK(s) \
+ ((s)->sy_symbol.ost_entry.n_sclass == C_WEAKEXT)
+#endif
+
/* Accessors */
/* The name of the symbol */
#define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset)
#define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l)
#define SA_GET_SYM_DIMEN(s,i) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)])
#define SA_GET_FILE_FNAME(s) (SYM_AUXENT (s)->x_file.x_fname)
+#define SA_GET_FILE_FNAME_OFFSET(s) (SYM_AUXENT (s)->x_file.x_n.x_offset)
+#define SA_GET_FILE_FNAME_ZEROS(s) (SYM_AUXENT (s)->x_file.x_n.x_zeroes)
#define SA_GET_SCN_SCNLEN(s) (SYM_AUXENT (s)->x_scn.x_scnlen)
#define SA_GET_SCN_NRELOC(s) (SYM_AUXENT (s)->x_scn.x_nreloc)
#define SA_GET_SCN_NLINNO(s) (SYM_AUXENT (s)->x_scn.x_nlinno)
#define SA_SET_SYM_ENDNDX(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
#define SA_SET_SYM_DIMEN(s,i,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
#define SA_SET_FILE_FNAME(s,v) strncpy(SYM_AUXENT (s)->x_file.x_fname,(v),FILNMLEN)
+#define SA_SET_FILE_FNAME_OFFSET(s,v) (SYM_AUXENT (s)->x_file.x_n.x_offset=(v))
+#define SA_SET_FILE_FNAME_ZEROS(s,v) (SYM_AUXENT (s)->x_file.x_n.x_zeroes=(v))
#define SA_SET_SCN_SCNLEN(s,v) (SYM_AUXENT (s)->x_scn.x_scnlen=(v))
#define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc=(v))
#define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->x_scn.x_nlinno=(v))
#define SF_TAG (0x00080000) /* Is a tag */
#define SF_DEBUG (0x00100000) /* Is in debug or abs section */
#define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */
+#define SF_ADJ_LNNOPTR (0x00400000) /* Has a lnnoptr */
/* All other bits are unused. */
/* Accessors */
#define SF_GET_TAGGED(s) (SF_GET (s) & SF_TAGGED)
#define SF_GET_TAG(s) (SF_GET (s) & SF_TAG)
#define SF_GET_GET_SEGMENT(s) (SF_GET (s) & SF_GET_SEGMENT)
+#define SF_GET_ADJ_LNNOPTR(s) (SF_GET (s) & SF_ADJ_LNNOPTR)
#define SF_GET_I960(s) (SF_GET (s) & SF_I960_MASK) /* used by i960 */
#define SF_GET_BALNAME(s) (SF_GET (s) & SF_BALNAME) /* used by i960 */
#define SF_GET_CALLNAME(s) (SF_GET (s) & SF_CALLNAME) /* used by i960 */
#define SF_SET_TAGGED(s) (SF_GET (s) |= SF_TAGGED)
#define SF_SET_TAG(s) (SF_GET (s) |= SF_TAG)
#define SF_SET_GET_SEGMENT(s) (SF_GET (s) |= SF_GET_SEGMENT)
+#define SF_SET_ADJ_LNNOPTR(s) (SF_GET (s) |= SF_ADJ_LNNOPTR)
#define SF_SET_I960(s,v) (SF_GET (s) |= ((v) & SF_I960_MASK)) /* used by i960 */
#define SF_SET_BALNAME(s) (SF_GET (s) |= SF_BALNAME) /* used by i960 */
#define SF_SET_CALLNAME(s) (SF_GET (s) |= SF_CALLNAME) /* used by i960 */
extern void obj_coff_section PARAMS ((int));
extern void c_dot_file_symbol PARAMS ((char *filename));
+#define obj_app_file c_dot_file_symbol
extern void obj_extra_stuff PARAMS ((object_headers * headers));
-extern segT s_get_segment PARAMS ((struct symbol * ptr));
+extern segT s_get_segment PARAMS ((symbolS *ptr));
extern void c_section_header PARAMS ((struct internal_scnhdr * header,
char *name,
long alignment));
#ifndef tc_coff_symbol_emit_hook
-void tc_coff_symbol_emit_hook PARAMS ((struct symbol *));
+void tc_coff_symbol_emit_hook PARAMS ((symbolS *));
#endif
/* sanity check */
? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
: 0)
+#ifdef TE_PE
+#define obj_handle_link_once(t) obj_coff_pe_handle_link_once (t)
+extern void obj_coff_pe_handle_link_once ();
+#endif
+
#endif /* not BFD_ASSEMBLER */
+extern const pseudo_typeS coff_pseudo_table[];
+
+#ifndef obj_pop_insert
+#define obj_pop_insert() pop_insert (coff_pseudo_table)
+#endif
+
+/* In COFF, if a symbol is defined using .def/.val SYM/.endef, it's OK
+ to redefine the symbol later on. This can happen if C symbols use
+ a prefix, and a symbol is defined both with and without the prefix,
+ as in start/_start/__start in gcc/libgcc1-test.c. */
+#define RESOLVE_SYMBOL_REDEFINITION(sym) \
+(SF_GET_GET_SEGMENT (sym) \
+ ? (sym->sy_frag = frag_now, \
+ S_SET_VALUE (sym, frag_now_fix ()), \
+ S_SET_SEGMENT (sym, now_seg), \
+ 0) \
+ : 0)
+
/* Stabs in a coff file go into their own section. */
-#define SEPARATE_STAB_SECTIONS
+#define SEPARATE_STAB_SECTIONS 1
/* We need 12 bytes at the start of the section to hold some initial
information. */
extern void obj_coff_init_stab_section PARAMS ((segT));
#define INIT_STAB_SECTION(seg) obj_coff_init_stab_section (seg)
+/* Store the number of relocations in the section aux entry. */
+#define SET_SECTION_RELOCS(sec, relocs, n) \
+ SA_SET_SCN_NRELOC (section_symbol (sec), n)
+
#endif /* OBJ_FORMAT_H */