aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-alpha.c
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/coff-alpha.c
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/coff-alpha.c')
-rw-r--r--bfd/coff-alpha.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 1bbfbdb..9b67dfb 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -35,6 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
static const bfd_target *alpha_ecoff_object_p PARAMS ((bfd *));
static boolean alpha_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
+static PTR alpha_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
static void alpha_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
struct internal_reloc *));
static void alpha_ecoff_swap_reloc_out PARAMS ((bfd *,
@@ -472,6 +473,40 @@ alpha_ecoff_bad_format_hook (abfd, filehdr)
return true;
}
+
+/* This is a hook called by coff_real_object_p to create any backend
+ specific information. */
+
+static PTR
+alpha_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
+ bfd *abfd;
+ PTR filehdr;
+ PTR aouthdr;
+{
+ PTR ecoff;
+
+ ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
+
+ if (ecoff != NULL)
+ {
+ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+ /* Set additional BFD flags according to the object type from the
+ machine specific file header flags. */
+ switch (internal_f->f_flags & F_ALPHA_OBJECT_TYPE_MASK)
+ {
+ case F_ALPHA_SHARABLE:
+ abfd->flags |= DYNAMIC;
+ break;
+ case F_ALPHA_CALL_SHARED:
+ /* Always executable if using shared libraries as the run time
+ loader might resolve undefined references. */
+ abfd->flags |= (DYNAMIC | EXEC_P);
+ break;
+ }
+ }
+ return ecoff;
+}
/* Reloc handling. */
@@ -641,7 +676,7 @@ alpha_adjust_reloc_in (abfd, intern, rptr)
some reason the address of this reloc type is not adjusted by
the section vma. We record the gp value for this object file
here, for convenience when doing the GPDISP relocation. */
- rptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
rptr->address = intern->r_vaddr;
rptr->addend = ecoff_data (abfd)->gp;
break;
@@ -954,7 +989,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
/* Figure out the relocation of this symbol. */
symbol = *rel->sym_ptr_ptr;
- if (symbol->section == &bfd_und_section)
+ if (bfd_is_und_section (symbol->section))
r = bfd_reloc_undefined;
if (bfd_is_com_section (symbol->section))
@@ -1014,7 +1049,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
/* Figure out the relocation of this symbol. */
symbol = *rel->sym_ptr_ptr;
- if (symbol->section == &bfd_und_section)
+ if (bfd_is_und_section (symbol->section))
r = bfd_reloc_undefined;
if (bfd_is_com_section (symbol->section))
@@ -1047,7 +1082,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
/* Figure out the relocation of this symbol. */
symbol = *rel->sym_ptr_ptr;
- if (symbol->section == &bfd_und_section)
+ if (bfd_is_und_section (symbol->section))
r = bfd_reloc_undefined;
if (bfd_is_com_section (symbol->section))
@@ -1382,7 +1417,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_get_section_by_name (input_bfd, ".fini");
symndx_to_section[RELOC_SECTION_LITA] =
bfd_get_section_by_name (input_bfd, ".lita");
- symndx_to_section[RELOC_SECTION_ABS] = &bfd_abs_section;
+ symndx_to_section[RELOC_SECTION_ABS] = bfd_abs_section_ptr;
ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
}
@@ -1911,13 +1946,14 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
(unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
alpha_ecoff_swap_scnhdr_out,
- FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, true,
+ FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true,
alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
- alpha_ecoff_swap_scnhdr_in, alpha_ecoff_bad_format_hook,
- _bfd_ecoff_set_arch_mach_hook, _bfd_ecoff_mkobject_hook,
- _bfd_ecoff_styp_to_sec_flags, _bfd_ecoff_make_section_hook,
- _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
- NULL, NULL
+ alpha_ecoff_swap_scnhdr_in, NULL,
+ alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
+ alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
+ _bfd_ecoff_make_section_hook, _bfd_ecoff_set_alignment_hook,
+ _bfd_ecoff_slurp_symbol_table,
+ NULL, NULL, NULL, NULL, NULL, NULL
},
/* Supported architecture. */
bfd_arch_alpha,
@@ -2004,7 +2040,7 @@ const bfd_target ecoffalpha_little_vec =
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+ HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect
flags */