diff options
author | Ian Lance Taylor <ian@airs.com> | 1995-03-07 19:56:31 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1995-03-07 19:56:31 +0000 |
commit | f135c692723ff3b1513345b1379fcfa0b7e40239 (patch) | |
tree | 3db61c9084d187e67381f5f86758c9c20cf9d78b /bfd | |
parent | 597e3d58ba3f7849f8659333bb90e61f745e8a93 (diff) | |
download | gdb-f135c692723ff3b1513345b1379fcfa0b7e40239.zip gdb-f135c692723ff3b1513345b1379fcfa0b7e40239.tar.gz gdb-f135c692723ff3b1513345b1379fcfa0b7e40239.tar.bz2 |
* coffcode.h (bfd_coff_backend_data): Add new field
_bfd_coff_adjust_symndx.
(bfd_coff_adjust_symndx): Define.
(coff_adjust_symndx): Define as NULL if not already defined.
(bfd_coff_std_swap_table): Initialize new field to
coff_adjust_symndx.
* cofflink.c (coff_link_input_bfd): Call coff_adjust_symndx if it
is defined.
* coff-a29k.c (coff_a29k_adjust_symndx): New static function.
(coff_adjust_symndx): Define before including coffcode.h.
* libcoff.h: Rebuild.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 12 | ||||
-rw-r--r-- | bfd/coff-a29k.c | 25 | ||||
-rw-r--r-- | bfd/coffcode.h | 106 |
3 files changed, 127 insertions, 16 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 67e6087..0c6df02 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,17 @@ Tue Mar 7 12:23:47 1995 Ian Lance Taylor <ian@cygnus.com> + * coffcode.h (bfd_coff_backend_data): Add new field + _bfd_coff_adjust_symndx. + (bfd_coff_adjust_symndx): Define. + (coff_adjust_symndx): Define as NULL if not already defined. + (bfd_coff_std_swap_table): Initialize new field to + coff_adjust_symndx. + * cofflink.c (coff_link_input_bfd): Call coff_adjust_symndx if it + is defined. + * coff-a29k.c (coff_a29k_adjust_symndx): New static function. + (coff_adjust_symndx): Define before including coffcode.h. + * libcoff.h: Rebuild. + * format.c (bfd_check_format_matches): Skip binary_vec when searching through bfd_target_vector. diff --git a/bfd/coff-a29k.c b/bfd/coff-a29k.c index 35c748a..db29499 100644 --- a/bfd/coff-a29k.c +++ b/bfd/coff-a29k.c @@ -34,6 +34,9 @@ static bfd_reloc_status_type a29k_reloc static boolean coff_a29k_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, struct internal_reloc *, struct internal_syment *, asection **)); +static boolean coff_a29k_adjust_symndx + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, + struct internal_reloc *, boolean *)); #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) @@ -537,6 +540,28 @@ coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section, #define coff_relocate_section coff_a29k_relocate_section +/* We don't want to change the symndx of a R_IHCONST reloc, since it + is actually an addend, not a symbol index at all. */ + +/*ARGSUSED*/ +static boolean +coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) + bfd *obfd; + struct bfd_link_info *info; + bfd *ibfd; + asection *sec; + struct internal_reloc *irel; + boolean *adjustedp; +{ + if (irel->r_type == R_IHCONST) + *adjustedp = true; + else + *adjustedp = false; + return true; +} + +#define coff_adjust_symndx coff_a29k_adjust_symndx + #include "coffcode.h" const bfd_target a29kcoff_big_vec = diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 4c3850d..feca758 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1,5 +1,5 @@ /* Support for the generic parts of most COFF variants, for BFD. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -527,7 +527,7 @@ styp_to_sec_flags (abfd, hdr, name) return (sec_flags); } -#define get_index(symbol) ((long) (symbol)->udata) +#define get_index(symbol) ((symbol)->udata.i) /* INTERNAL_DEFINITION @@ -681,6 +681,20 @@ dependent COFF routines: . struct internal_reloc *relocs, . struct internal_syment *syms, . asection **sections)); +. reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS (( +. bfd *abfd, +. asection *sec, +. struct internal_reloc *rel, +. struct coff_link_hash_entry *h, +. struct internal_syment *sym, +. bfd_vma *addendp)); +. boolean (*_bfd_coff_adjust_symndx) PARAMS (( +. bfd *obfd, +. struct bfd_link_info *info, +. bfd *ibfd, +. asection *sec, +. struct internal_reloc *reloc, +. boolean *adjustedp)); . .} bfd_coff_backend_data; . @@ -778,6 +792,12 @@ dependent COFF routines: .#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ . ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ . (obfd, info, ibfd, o, con, rel, isyms, secs)) +.#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ +. ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ +. (abfd, sec, rel, h, sym, addendp)) +.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ +. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ +. (obfd, info, ibfd, sec, rel, adjustedp)) . */ @@ -836,7 +856,8 @@ coff_new_section_hook (abfd, section) bfd * abfd; asection * section; { - section->alignment_power = abfd->xvec->align_power_min; + section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; + /* Allocate aux records for section symbols, to store size and related info. @@ -845,17 +866,20 @@ coff_new_section_hook (abfd, section) (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10); -#ifdef COFF_SPARC - /* This is to allow double-word operations on addresses in data or bss. */ - if (strcmp (section->name, ".data") == 0 - || strcmp (section->name, ".bss") == 0) - section->alignment_power = 3; -#endif /* COFF_SPARC */ + /* The .stab section must be aligned to 2**2 at most, because + otherwise there may be gaps in the section which gdb will not + know how to interpret. Examining the section name is a hack, but + that is also how gdb locates the section. We also align the + .stabstr section this way for backward compatibility, although I + believe it would work anyhow. */ + if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 2 + && (strcmp (section->name, ".stab") == 0 + || strcmp (section->name, ".stabstr") == 0)) + section->alignment_power = 2; return true; } - #ifdef I960 /* Set the alignment of a BFD section. */ @@ -1086,8 +1110,9 @@ coff_set_arch_mach_hook (abfd, filehdr) break; #endif -#ifdef SH_ARCH_MAGIC - case SH_ARCH_MAGIC: +#ifdef SH_ARCH_MAGIC_BIG + case SH_ARCH_MAGIC_BIG: + case SH_ARCH_MAGIC_LITTLE: arch = bfd_arch_sh; machine = 0; break; @@ -1332,9 +1357,12 @@ coff_set_flags (abfd, magicp, flagsp) break; #endif -#ifdef SH_ARCH_MAGIC +#ifdef SH_ARCH_MAGIC_BIG case bfd_arch_sh: - *magicp = SH_ARCH_MAGIC; + if (abfd->xvec->byteorder_big_p) + *magicp = SH_ARCH_MAGIC_BIG; + else + *magicp = SH_ARCH_MAGIC_LITTLE; return true; break; #endif @@ -2309,7 +2337,7 @@ coff_slurp_symbol_table (abfd) dst->native = src; - dst->symbol.udata = 0; + dst->symbol.udata.i = 0; dst->lineno = (alent *) NULL; this_index += (src->u.syment.n_numaux) + 1; dst++; @@ -2518,6 +2546,42 @@ coff_slurp_reloc_table (abfd, asect, symbols) return true; } +#ifndef coff_rtype_to_howto +#ifdef RTYPE2HOWTO + +/* Get the howto structure for a reloc. This is only used if the file + including this one defines coff_relocate_section to be + _bfd_coff_generic_relocate_section, so it is OK if it does not + always work. It is the responsibility of the including file to + make sure it is reasonable if it is needed. */ + +static reloc_howto_type *coff_rtype_to_howto + PARAMS ((bfd *, asection *, struct internal_reloc *, + struct coff_link_hash_entry *, struct internal_syment *, + bfd_vma *)); + +/*ARGSUSED*/ +static reloc_howto_type * +coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp) + bfd *abfd; + asection *sec; + struct internal_reloc *rel; + struct coff_link_hash_entry *h; + struct internal_syment *sym; + bfd_vma *addendp; +{ + arelent genrel; + + RTYPE2HOWTO (&genrel, rel); + return genrel.howto; +} + +#else /* ! defined (RTYPE2HOWTO) */ + +#define coff_rtype_to_howto NULL + +#endif /* ! defined (RTYPE2HOWTO) */ +#endif /* ! defined (coff_rtype_to_howto) */ /* This is stupid. This function should be a boolean predicate. */ static long @@ -2607,9 +2671,15 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, /* If coff_relocate_section is defined, we can use the optimized COFF backend linker. Otherwise we must continue to use the old linker. */ #ifdef coff_relocate_section +#ifndef coff_bfd_link_hash_table_create #define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create +#endif +#ifndef coff_bfd_link_add_symbols #define coff_bfd_link_add_symbols _bfd_coff_link_add_symbols +#endif +#ifndef coff_bfd_final_link #define coff_bfd_final_link _bfd_coff_final_link +#endif #else /* ! defined (coff_relocate_section) */ #define coff_relocate_section NULL #define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create @@ -2617,6 +2687,10 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, #define coff_bfd_final_link _bfd_generic_final_link #endif /* ! defined (coff_relocate_section) */ +#ifndef coff_adjust_symndx +#define coff_adjust_symndx NULL +#endif + static CONST bfd_coff_backend_data bfd_coff_std_swap_table = { coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in, @@ -2636,7 +2710,7 @@ static CONST bfd_coff_backend_data bfd_coff_std_swap_table = coff_set_alignment_hook, coff_slurp_symbol_table, symname_in_debug_hook, coff_reloc16_extra_cases, coff_reloc16_estimate, coff_sym_is_global, coff_compute_section_file_positions, - coff_relocate_section + coff_relocate_section, coff_rtype_to_howto, coff_adjust_symndx }; #define coff_close_and_cleanup _bfd_generic_close_and_cleanup |