aboutsummaryrefslogtreecommitdiff
path: root/bfd/libcoff-in.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1994-09-06 19:28:55 +0000
committerIan Lance Taylor <ian@airs.com>1994-09-06 19:28:55 +0000
commit69645d10fb4647f6855c76ae54a1acf60f28fc94 (patch)
tree61e36c9f73fda03557d67fda9f185ea6a7828b5f /bfd/libcoff-in.h
parentde733a0edf37f2e2f4a7733da66b55a07ef1f804 (diff)
downloadgdb-69645d10fb4647f6855c76ae54a1acf60f28fc94.zip
gdb-69645d10fb4647f6855c76ae54a1acf60f28fc94.tar.gz
gdb-69645d10fb4647f6855c76ae54a1acf60f28fc94.tar.bz2
Add new style linker support to COFF backend. a29k only for now.
* cofflink.c: New file. * libcoff-in.h: Include bfdlink.h. (obj_coff_external_syms, obj_coff_strings): Define accessor macro. (obj_coff_sym_hashes): Define accessor macro. (struct coff_tdata): Add fields external_syms, strings, and sym_hashes. (struct coff_link_hash_entry): Define. (struct coff_link_hash_table): Define. (coff_link_hash_lookup, coff_link_hash_traverse): Define. (coff_hash_table): Define. (_bfd_coff_link_hash_table_create): Declare. (_bfd_coff_link_add_symbols, _bfd_coff_final_link): Declare. * coffcode.h (bfd_coff_backend_data): Add fields _bfd_relsz, _bfd_coff_swap_reloc_in, _bfd_coff_sym_is_global, _bfd_coff_compute_section_file_positions, _bfd_coff_relocate_section. (bfd_coff_relsz, bfd_coff_swap_reloc_in): Define. (bfd_coff_sym_is_global): Define. (bfd_coff_compute_section_file_positions): Define. (bfd_coff_relocate_section): Define. (coff_mkobject_hook): Initialize obj_raw_syment_count and obj_conv_table_size. (coff_compute_section_file_positions): Set target_index of all sections. Set output_has_begun field. (coff_write_object_contents): Don't set target_index; now done by coff_compute_section_file_positions. Remove obsolete handling of scn_base and data_base. Don't bother to check that target_index is positive, since it always is. Remove use of pad, which is always zero. Check obj_raw_syment_count, not bfd_get_symcount, for the number of symbols, but only write them out if bfd_get_symcount is non-zero. (coff_slurp_symbol_table): Use obj_raw_syment_count, not bfd_get_symcount for the number of symbols. Don't set obj_conv_table_size. (coff_sym_is_global): New static function or macro. (coff_slurp_reloc_table): Call coff_swap_reloc_in, not bfd_swap_reloc_in. (coff_bfd_link_hash_table_create): If coff_relocate_section is defined, define as _bfd_coff_link_hash_table_create. (coff_bfd_link_add_symbols): Similar change. (coff_bfd_final_link): Similar change. (coff_relocate_section): Define as NULL if not defined. (bfd_coff_std_swap_table): Initialize new fields. * coffgen.c (coff_real_object_p): Don't set obj_raw_syment_count and obj_conv_table_size here. (coff_count_linenumbers): Reindent. If bfd_get_symcount is zero, add up the line numbers from the sections. (coff_write_symbols): Don't set bfd_get_symcount. (coff_pointerize_aux): Don't pointerize a nonpositive x_endndx field. (coff_get_normalized_symtab): Use obj_raw_syment_count, not bfd_get_symcount. (coff_print_symbol): If auxp->fix_end, print x_endndx value. * coffswap.h (coff_swap_reloc_in): Rename from bfd_swap_reloc_in. Reindent. Change argument type to PTR. * coff-a29k.c (coff_a29k_relocate_section): New static function. (coff_relocate_section): Define. * configure.in (a29kcoff_big_vec): Compile cofflink.o. * coff-alpha.c (alpha_ecoff_backend_data): Initialize new fields. * coff-mips.c (mips_ecoff_backend_data): Likewise. * libcoff.h: Rebuilt. * Makefile.in: Rebuilt dependencies. (BFD32_BACKENDS): Add cofflink.o. (CFILES): Add cofflink.c.
Diffstat (limited to 'bfd/libcoff-in.h')
-rw-r--r--bfd/libcoff-in.h84
1 files changed, 72 insertions, 12 deletions
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
index 277080e..4b14921 100644
--- a/bfd/libcoff-in.h
+++ b/bfd/libcoff-in.h
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include "bfdlink.h"
/* Object file tdata; access macros */
@@ -31,12 +32,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
-#if CFILE_STUFF
-#define obj_symbol_slew(bfd) (coff_data(bfd)->symbol_index_slew)
-#else
-#define obj_symbol_slew(bfd) 0
-#endif
+#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
+#define obj_coff_strings(bfd) (coff_data (bfd)->strings)
+#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
/* `Tdata' information kept for COFF files. */
@@ -47,13 +46,8 @@ typedef struct coff_tdata
int conv_table_size;
file_ptr sym_filepos;
- long symbol_index_slew; /* used during read to mark whether a
- C_FILE symbol as been added. */
-
struct coff_ptr_struct *raw_syments;
- struct lineno *raw_linenos;
unsigned int raw_syment_count;
- unsigned short flags;
/* These are only valid once writing has begun */
long int relocbase;
@@ -68,14 +62,71 @@ typedef struct coff_tdata
unsigned local_symesz;
unsigned local_auxesz;
unsigned local_linesz;
+
+ /* Used by the COFF backend linker. */
+ PTR external_syms;
+ char *strings;
+ struct coff_link_hash_entry **sym_hashes;
} coff_data_type;
/* We take the address of the first element of a asymbol to ensure that the
* macro is only ever applied to an asymbol. */
#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
+/* COFF linker hash table entries. */
+
+struct coff_link_hash_entry
+{
+ struct bfd_link_hash_entry root;
+
+ /* Symbol index in output file. Set to -1 initially. Set to -2 if
+ there is a reloc against this symbol. */
+ long indx;
+
+ /* Symbol type. */
+ unsigned short type;
+
+ /* Symbol class. */
+ unsigned char class;
+
+ /* Number of auxiliary entries. */
+ char numaux;
+
+ /* BFD to take auxiliary entries from. */
+ bfd *auxbfd;
+
+ /* Pointer to array of auxiliary entries, if any. */
+ union internal_auxent *aux;
+};
+
+/* COFF linker hash table. */
+
+struct coff_link_hash_table
+{
+ struct bfd_link_hash_table root;
+};
+
+/* Look up an entry in a COFF linker hash table. */
+
+#define coff_link_hash_lookup(table, string, create, copy, follow) \
+ ((struct coff_link_hash_entry *) \
+ bfd_link_hash_lookup (&(table)->root, (string), (create), \
+ (copy), (follow)))
+
+/* Traverse a COFF linker hash table. */
+
+#define coff_link_hash_traverse(table, func, info) \
+ (bfd_link_hash_traverse \
+ (&(table)->root, \
+ (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
+ (info)))
+
+/* Get the COFF linker hash table from a link_info structure. */
+
+#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
+
/* Functions in coffgen.c. */
-extern bfd_target *coff_object_p PARAMS ((bfd *));
+extern const bfd_target *coff_object_p PARAMS ((bfd *));
extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
@@ -83,7 +134,7 @@ extern int coff_count_linenumbers PARAMS ((bfd *));
extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
extern boolean coff_renumber_symbols PARAMS ((bfd *));
extern void coff_mangle_symbols PARAMS ((bfd *));
-extern void coff_write_symbols PARAMS ((bfd *));
+extern boolean coff_write_symbols PARAMS ((bfd *));
extern boolean coff_write_linenumbers PARAMS ((bfd *));
extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
@@ -116,5 +167,14 @@ extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
asection *input_section,
bfd_vma val));
+/* Functions in cofflink.c. */
+
+extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
+ PARAMS ((bfd *));
+extern boolean _bfd_coff_link_add_symbols
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_coff_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+
/* And more taken from the source .. */