diff options
author | Ian Lance Taylor <ian@airs.com> | 1994-03-30 22:15:07 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1994-03-30 22:15:07 +0000 |
commit | 326e32d7ce8a83f59192657c48c9b9980466b939 (patch) | |
tree | a6d893226affe8172c0ad504e14f8aded908d849 | |
parent | 70f42bae0b1b4d71dfa1b0da6a29d1e82053b118 (diff) | |
download | gdb-326e32d7ce8a83f59192657c48c9b9980466b939.zip gdb-326e32d7ce8a83f59192657c48c9b9980466b939.tar.gz gdb-326e32d7ce8a83f59192657c48c9b9980466b939.tar.bz2 |
Wed Mar 30 16:25:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
Changes to let BFD return an error indication from
get_symtab_upper_bound, bfd_canonicalize_symtab,
bfd_get_reloc_upper_bound, and bfd_canonicalize_reloc. They now
return long instead of unsigned int, and use -1 to indicate an
error. Along the way, rename get_symtab_upper_bound to
bfd_get_symtab_upper_bound.
* bfd.c (bfd_get_reloc_upper_bound): Return long, and -1 on
errors.
(bfd_canonicalize_reloc): Likewise.
* syms.c (bfd_get_symtab_upper_bound): Renamed from
get_symtab_upper_bound.
* targets.c (bfd_target): Renamed _get_symtab_upper_bound to
_bfd_get_symtab_upper_bound, and changed it and
_bfd_canonicalize_symtab and _get_reloc_upper_bound and
_bfd_canonicalize_reloc to all return long.
* aoutx.h (NAME(aout,get_symtab)): Return long, and -1 on errors.
(NAME(aout,canonicalize_reloc)): Likewise.
(NAME(aout,get_reloc_upper_bound)): Likewise.
(NAME(aout,get_symtab_upper_bound)): Likewise.
* bout.c (b_out_canonicalize_reloc): Likewise.
(b_out_get_reloc_upper_bound): Likewise.
* coffcode.h (coff_canonicalize_reloc): Likewise.
* coffgen.c (coff_get_symtab_upper_bound): Likewise.
(coff_get_symtab): Likewise.
(coff_get_reloc_upper_bound): Likewise.
* ecoff.c (ecoff_get_symtab_upper_bound): Likewise.
(ecoff_get_symtab): Likewise.
(ecoff_canonicalize_reloc): Likewise.
* elfcode.h (elf_get_symtab_upper_bound): Likewise.
(elf_get_reloc_upper_bound): Likewise.
(elf_canonicalize_reloc): Likewise.
(elf_get_symtab): Likewise.
* hp300hpux.c (MY(get_symtab)): Likewise.
(MY(get_symtab_upper_bound)): Likewise.
(MY(canonicalize_reloc)): Likewise.
* i386lynx.c (NAME(lynx,canonicalize_reloc)): Likewise.
* ieee.c (ieee_slurp_external_symbols): Change return type to
boolean. Check for errors from get_symbol.
(ieee_slurp_symbol_table): Change return type to boolean. Check
for errors from ieee_slurp_external_symbols.
(ieee_get_symtab_upper_bound): Return long, and -1 on errors.
(ieee_get_symtab): Likewise.
(ieee_get_reloc_upper_bound): Likewise.
(ieee_canonicalize_reloc): Likewise.
* mipsbsd.c (MY(canonicalize_reloc)): Likewise.
* nlmcode.h (nlm_get_symtab_upper_bound): Likewise.
(nlm_get_symtab): Likewise.
(nlm_get_reloc_upper_bound): Likewise.
(nlm_canonicalize_reloc): Likewise.
* oasys.c (oasys_get_symtab_upper_bound): Likewise.
(oasys_get_symtab): Likewise.
(oasys_get_reloc_upper_bound): Likewise.
(oasys_canonicalize_reloc): Likewise.
* som.c (som_get_symtab_upper_bound): Likewise.
(som_get_symtab): Likewise.
(som_get_reloc_upper_bound): Likewise.
(som_canonicalize_reloc): Likewise.
* srec.c (srec_get_symtab_upper_bound): Likewise.
(srec_get_symtab): Likewise.
(srec_get_reloc_upper_bound): Define as bfd_0l.
(srec_canonicalize_reloc): Likewise.
* tekhex.c (tekhex_get_symtab): Return long, and -1 on errors.
(tekhex_get_symtab_upper_bound): Likewise.
(tekhex_get_reloc_upper_bound): Define as bfd_0l.
(tekhex_canonicalize_reloc): Likewise.
* libaout.h (NAME(aout,get_symtab_upper_bound)): Change
declaration to return long.
(NAME(aout,get_symtab)): Likewise.
(NAME(aout,canonicalize_reloc)): Likewise.
(NAME(aout,get_reloc_upper_bound)): Likewise.
* libcoff-in.h (coff_get_symtab_upper_bound): Likewise.
(coff_get_symtab): Likewise.
(coff_get_reloc_upper_bound): Likewise.
* libecoff.h (ecoff_get_symtab_upper_bound): Likewise.
(ecoff_get_symtab): Likewise.
(ecoff_canonicalize_reloc): Likewise.
* libelf.h (bfd_elf32_get_symtab_upper_bound): Likewise.
(bfd_elf32_get_symtab): Likewise.
(bfd_elf32_get_reloc_upper_bound): Likewise.
(bfd_elf32_canonicalize_reloc): Likewise.
(bfd_elf64_get_symtab_upper_bound): Likewise.
(bfd_elf64_get_symtab): Likewise.
(bfd_elf64_get_reloc_upper_bound): Likewise.
(bfd_elf64_canonicalize_reloc): Likewise.
* libnlm.h (nlmNAME(get_symtab_upper_bound)): Likewise.
(nlmNAME(get_symtab)): Likewise.
(nlmNAME(get_reloc_upper_bound)): Likewise.
(nlmNAME(canonicalize_reloc)): Likewise.
* archive.c (compute_and_write_armap): Use error_return and
no_memory_return labels rather than freeing information in various
places. Change storage, symcount and src_count to long. Check
errors from bfd_get_symtab_upper_bound and
bfd_canonicalize_symtab.
* bout.c (b_out_relax_section): Change reloc_size to long. Check
for errors from bfd_get_reloc_upper_bound and
bfd_canonicalize_reloc.
(b_out_get_relocated_section_contents): Likewise.
* coff-alpha.c (alpha_ecoff_get_relocated_section_contents):
Likewise.
* elf32-mips.c: Likewise.
* elf32-hppa.c (hppa_elf_stub_finish): Likewise.
(hppa_look_for_stubs_in_section): Check for errors from
bfd_get_symtab_upper_bound, bfd_canonicalize_symtab, and
bfd_canonicalize_reloc.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Check for errors
from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab.
* linker.c (generic_link_read_symbols): Likewise.
(_bfd_generic_final_link): Check for errors from
bfd_get_reloc_upper_bound and bfd_canonicalize_reloc.
* reloc.c (bfd_generic_get_relocated_section_contents): Likewise.
* reloc16.c (bfd_coff_reloc16_relax_section): Likewise.
(bfd_coff_reloc16_get_relocated_section_contents): Likewise.
* libbfd.c (bfd_0l): New function.
* libbfd-in.h (bfd_0l): Declare.
* aix386-core.c: Change get_symtab_upper_bound, get_symtab,
get_reloc_upper_bound, and canonicalize_reloc to use bfd_0l rather
than bfd_0u.
* cisco-core.c, hppabsd-core.c, hpux-core.c: Likewise.
* irix-core.c, osf-core.c, ptrace-core.c, trad-core.c: Likewise.
* bfd-in2.h: Rebuilt.
* libbfd.h: Rebuilt.
* libcoff.h: Rebuilt.
* nlm32-sparc.c (nlm_sparc_read_reloc): Remove unused variables
temp and name.
43 files changed, 1301 insertions, 961 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 49d94ad..8d8cd7d 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,131 @@ +Wed Mar 30 16:25:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Changes to let BFD return an error indication from + get_symtab_upper_bound, bfd_canonicalize_symtab, + bfd_get_reloc_upper_bound, and bfd_canonicalize_reloc. They now + return long instead of unsigned int, and use -1 to indicate an + error. Along the way, rename get_symtab_upper_bound to + bfd_get_symtab_upper_bound. + * bfd.c (bfd_get_reloc_upper_bound): Return long, and -1 on + errors. + (bfd_canonicalize_reloc): Likewise. + * syms.c (bfd_get_symtab_upper_bound): Renamed from + get_symtab_upper_bound. + * targets.c (bfd_target): Renamed _get_symtab_upper_bound to + _bfd_get_symtab_upper_bound, and changed it and + _bfd_canonicalize_symtab and _get_reloc_upper_bound and + _bfd_canonicalize_reloc to all return long. + * aoutx.h (NAME(aout,get_symtab)): Return long, and -1 on errors. + (NAME(aout,canonicalize_reloc)): Likewise. + (NAME(aout,get_reloc_upper_bound)): Likewise. + (NAME(aout,get_symtab_upper_bound)): Likewise. + * bout.c (b_out_canonicalize_reloc): Likewise. + (b_out_get_reloc_upper_bound): Likewise. + * coffcode.h (coff_canonicalize_reloc): Likewise. + * coffgen.c (coff_get_symtab_upper_bound): Likewise. + (coff_get_symtab): Likewise. + (coff_get_reloc_upper_bound): Likewise. + * ecoff.c (ecoff_get_symtab_upper_bound): Likewise. + (ecoff_get_symtab): Likewise. + (ecoff_canonicalize_reloc): Likewise. + * elfcode.h (elf_get_symtab_upper_bound): Likewise. + (elf_get_reloc_upper_bound): Likewise. + (elf_canonicalize_reloc): Likewise. + (elf_get_symtab): Likewise. + * hp300hpux.c (MY(get_symtab)): Likewise. + (MY(get_symtab_upper_bound)): Likewise. + (MY(canonicalize_reloc)): Likewise. + * i386lynx.c (NAME(lynx,canonicalize_reloc)): Likewise. + * ieee.c (ieee_slurp_external_symbols): Change return type to + boolean. Check for errors from get_symbol. + (ieee_slurp_symbol_table): Change return type to boolean. Check + for errors from ieee_slurp_external_symbols. + (ieee_get_symtab_upper_bound): Return long, and -1 on errors. + (ieee_get_symtab): Likewise. + (ieee_get_reloc_upper_bound): Likewise. + (ieee_canonicalize_reloc): Likewise. + * mipsbsd.c (MY(canonicalize_reloc)): Likewise. + * nlmcode.h (nlm_get_symtab_upper_bound): Likewise. + (nlm_get_symtab): Likewise. + (nlm_get_reloc_upper_bound): Likewise. + (nlm_canonicalize_reloc): Likewise. + * oasys.c (oasys_get_symtab_upper_bound): Likewise. + (oasys_get_symtab): Likewise. + (oasys_get_reloc_upper_bound): Likewise. + (oasys_canonicalize_reloc): Likewise. + * som.c (som_get_symtab_upper_bound): Likewise. + (som_get_symtab): Likewise. + (som_get_reloc_upper_bound): Likewise. + (som_canonicalize_reloc): Likewise. + * srec.c (srec_get_symtab_upper_bound): Likewise. + (srec_get_symtab): Likewise. + (srec_get_reloc_upper_bound): Define as bfd_0l. + (srec_canonicalize_reloc): Likewise. + * tekhex.c (tekhex_get_symtab): Return long, and -1 on errors. + (tekhex_get_symtab_upper_bound): Likewise. + (tekhex_get_reloc_upper_bound): Define as bfd_0l. + (tekhex_canonicalize_reloc): Likewise. + * libaout.h (NAME(aout,get_symtab_upper_bound)): Change + declaration to return long. + (NAME(aout,get_symtab)): Likewise. + (NAME(aout,canonicalize_reloc)): Likewise. + (NAME(aout,get_reloc_upper_bound)): Likewise. + * libcoff-in.h (coff_get_symtab_upper_bound): Likewise. + (coff_get_symtab): Likewise. + (coff_get_reloc_upper_bound): Likewise. + * libecoff.h (ecoff_get_symtab_upper_bound): Likewise. + (ecoff_get_symtab): Likewise. + (ecoff_canonicalize_reloc): Likewise. + * libelf.h (bfd_elf32_get_symtab_upper_bound): Likewise. + (bfd_elf32_get_symtab): Likewise. + (bfd_elf32_get_reloc_upper_bound): Likewise. + (bfd_elf32_canonicalize_reloc): Likewise. + (bfd_elf64_get_symtab_upper_bound): Likewise. + (bfd_elf64_get_symtab): Likewise. + (bfd_elf64_get_reloc_upper_bound): Likewise. + (bfd_elf64_canonicalize_reloc): Likewise. + * libnlm.h (nlmNAME(get_symtab_upper_bound)): Likewise. + (nlmNAME(get_symtab)): Likewise. + (nlmNAME(get_reloc_upper_bound)): Likewise. + (nlmNAME(canonicalize_reloc)): Likewise. + * archive.c (compute_and_write_armap): Use error_return and + no_memory_return labels rather than freeing information in various + places. Change storage, symcount and src_count to long. Check + errors from bfd_get_symtab_upper_bound and + bfd_canonicalize_symtab. + * bout.c (b_out_relax_section): Change reloc_size to long. Check + for errors from bfd_get_reloc_upper_bound and + bfd_canonicalize_reloc. + (b_out_get_relocated_section_contents): Likewise. + * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): + Likewise. + * elf32-mips.c: Likewise. + * elf32-hppa.c (hppa_elf_stub_finish): Likewise. + (hppa_look_for_stubs_in_section): Check for errors from + bfd_get_symtab_upper_bound, bfd_canonicalize_symtab, and + bfd_canonicalize_reloc. + * ecofflink.c (bfd_ecoff_debug_accumulate_other): Check for errors + from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. + * linker.c (generic_link_read_symbols): Likewise. + (_bfd_generic_final_link): Check for errors from + bfd_get_reloc_upper_bound and bfd_canonicalize_reloc. + * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. + * reloc16.c (bfd_coff_reloc16_relax_section): Likewise. + (bfd_coff_reloc16_get_relocated_section_contents): Likewise. + * libbfd.c (bfd_0l): New function. + * libbfd-in.h (bfd_0l): Declare. + * aix386-core.c: Change get_symtab_upper_bound, get_symtab, + get_reloc_upper_bound, and canonicalize_reloc to use bfd_0l rather + than bfd_0u. + * cisco-core.c, hppabsd-core.c, hpux-core.c: Likewise. + * irix-core.c, osf-core.c, ptrace-core.c, trad-core.c: Likewise. + * bfd-in2.h: Rebuilt. + * libbfd.h: Rebuilt. + * libcoff.h: Rebuilt. + + * nlm32-sparc.c (nlm_sparc_read_reloc): Remove unused variables + temp and name. + Wed Mar 30 08:33:04 1994 Jim Kingdon (kingdon@lioth.cygnus.com) * hosts/dpx2.h: Define POSIX_UTIME. diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c index d55b747..bf9c1af 100644 --- a/bfd/aix386-core.c +++ b/bfd/aix386-core.c @@ -261,13 +261,13 @@ aix386_core_file_matches_executable_p (core_bfd, exec_bfd) #define aix386_get_section_contents bfd_generic_get_section_contents #define aix386_new_section_hook (PROTO (boolean, (*), \ (bfd *, sec_ptr))) bfd_true -#define aix386_get_symtab_upper_bound bfd_0u -#define aix386_get_symtab (PROTO (unsigned int, (*), \ - (bfd *, struct symbol_cache_entry **))) bfd_0u -#define aix386_get_reloc_upper_bound (PROTO (unsigned int, (*), \ - (bfd *, sec_ptr))) bfd_0u -#define aix386_canonicalize_reloc (PROTO (unsigned int, (*), \ - (bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define aix386_get_symtab_upper_bound bfd_0l +#define aix386_get_symtab (PROTO (long, (*), \ + (bfd *, struct symbol_cache_entry **))) bfd_0l +#define aix386_get_reloc_upper_bound (PROTO (long, (*), \ + (bfd *, sec_ptr))) bfd_0l +#define aix386_canonicalize_reloc (PROTO (long, (*), \ + (bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define aix386_make_empty_symbol (PROTO ( \ struct symbol_cache_entry *, (*), (bfd *))) bfd_false #define aix386_print_symbol (PROTO (void, (*), \ diff --git a/bfd/aoutx.h b/bfd/aoutx.h index d46d387..14b4bd3 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1998,7 +1998,7 @@ NAME(aout,write_syms) (abfd) } -unsigned int +long NAME(aout,get_symtab) (abfd, location) bfd *abfd; asymbol **location; @@ -2006,7 +2006,8 @@ NAME(aout,get_symtab) (abfd, location) unsigned int counter = 0; aout_symbol_type *symbase; - if (!NAME(aout,slurp_symbol_table)(abfd)) return 0; + if (!NAME(aout,slurp_symbol_table)(abfd)) + return -1; for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);) *(location++) = (asymbol *)( symbase++); @@ -2504,7 +2505,7 @@ NAME(aout,squirt_out_relocs) (abfd, section) } /* This is stupid. This function should be a boolean predicate */ -unsigned int +long NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; @@ -2515,7 +2516,7 @@ NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols) unsigned int count; if (!(tblptr || NAME(aout,slurp_reloc_table)(abfd, section, symbols))) - return 0; + return -1; if (section->flags & SEC_CONSTRUCTOR) { arelent_chain *chain = section->constructor_chain; @@ -2538,7 +2539,7 @@ NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols) return section->reloc_count; } -unsigned int +long NAME(aout,get_reloc_upper_bound) (abfd, asect) bfd *abfd; sec_ptr asect; @@ -2547,7 +2548,7 @@ NAME(aout,get_reloc_upper_bound) (abfd, asect) if (bfd_get_format (abfd) != bfd_object) { bfd_set_error (bfd_error_invalid_operation); - return 0; + return -1; } if (asect->flags & SEC_CONSTRUCTOR) { return (sizeof (arelent *) * (asect->reloc_count+1)); @@ -2561,7 +2562,7 @@ NAME(aout,get_reloc_upper_bound) (abfd, asect) dynrel_count = ((*aout_backend_info (abfd)->read_dynamic_relocs) (abfd, &dynrels)); if (dynrel_count == (bfd_size_type) -1) - return 0; + return -1; } if (asect == obj_datasec (abfd)) @@ -2575,15 +2576,16 @@ NAME(aout,get_reloc_upper_bound) (abfd, asect) + dynrel_count + 1)); bfd_set_error (bfd_error_invalid_operation); - return 0; + return -1; } -unsigned int +long NAME(aout,get_symtab_upper_bound) (abfd) bfd *abfd; { - if (!NAME(aout,slurp_symbol_table)(abfd)) return 0; + if (!NAME(aout,slurp_symbol_table)(abfd)) + return -1; return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *)); } diff --git a/bfd/archive.c b/bfd/archive.c index 50421ca..88e6dfa 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -1596,15 +1596,15 @@ compute_and_write_armap (arch, elength) bfd *arch; unsigned int elength; { - char *first_name; + char *first_name = NULL; bfd *current; file_ptr elt_no = 0; - struct orl *map; + struct orl *map = NULL; int orl_max = 1024; /* fine initial default */ int orl_count = 0; int stridx = 0; /* string index */ asymbol **syms = NULL; - unsigned int syms_max = 0; + long syms_max = 0; boolean ret; /* Dunno if this is the best place for this info... */ @@ -1614,20 +1614,13 @@ compute_and_write_armap (arch, elength) map = (struct orl *) malloc (orl_max * sizeof (struct orl)); if (map == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; /* We put the symbol names on the arch obstack, and then discard them when done. */ first_name = bfd_alloc (arch, 1); if (first_name == NULL) - { - free (map); - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; /* Drop all the files called __.SYMDEF, we're going to make our own */ @@ -1643,11 +1636,14 @@ compute_and_write_armap (arch, elength) if ((bfd_check_format (current, bfd_object) == true) && ((bfd_get_file_flags (current) & HAS_SYMS))) { - unsigned int storage; - unsigned int symcount; - unsigned int src_count; + long storage; + long symcount; + long src_count; + + storage = bfd_get_symtab_upper_bound (current); + if (storage < 0) + goto error_return; - storage = get_symtab_upper_bound (current); if (storage != 0) { if (storage > syms_max) @@ -1655,16 +1651,13 @@ compute_and_write_armap (arch, elength) if (syms_max > 0) free (syms); syms_max = storage; - syms = (asymbol **) malloc (syms_max); + syms = (asymbol **) malloc ((size_t) syms_max); if (syms == NULL) - { - free (map); - bfd_release (arch, first_name); - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; } symcount = bfd_canonicalize_symtab (current, syms); + if (symcount < 0) + goto error_return; /* Now map over all the symbols, picking out the ones we want */ for (src_count = 0; src_count < symcount; src_count++) @@ -1689,14 +1682,7 @@ compute_and_write_armap (arch, elength) realloc ((PTR) map, orl_max * sizeof (struct orl))); if (new_map == (struct orl *) NULL) - { - free_and_quit: - free (syms); - free (map); - bfd_release (arch, first_name); - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; map = new_map; } @@ -1706,10 +1692,10 @@ compute_and_write_armap (arch, elength) bfd_alloc (arch, sizeof (char *))); if (map[orl_count].name == NULL) - goto free_and_quit; + goto no_memory_return; *(map[orl_count].name) = bfd_alloc (arch, namelen + 1); if (*(map[orl_count].name) == NULL) - goto free_and_quit; + goto no_memory_return; strcpy (*(map[orl_count].name), syms[src_count]->name); (map[orl_count]).pos = (file_ptr) current; (map[orl_count]).namidx = stridx; @@ -1728,10 +1714,25 @@ compute_and_write_armap (arch, elength) if (syms_max > 0) free (syms); - free (map); - bfd_release (arch, first_name); + if (map != NULL) + free (map); + if (first_name != NULL) + bfd_release (arch, first_name); return ret; + + no_memory_return: + bfd_set_error (bfd_error_no_memory); + + error_return: + if (syms_max > 0) + free (syms); + if (map != NULL) + free (map); + if (first_name != NULL) + bfd_release (arch, first_name); + + return false; } boolean diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 1c86271..e46f647 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1640,8 +1640,8 @@ typedef struct symbol_cache_entry PTR udata; } asymbol; -#define get_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _get_symtab_upper_bound, (abfd)) +#define bfd_get_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) boolean bfd_is_local_label PARAMS ((bfd *abfd, asymbol *sym)); @@ -1802,6 +1802,7 @@ struct _bfd struct sgi_core_struct *sgi_core_data; struct lynx_core_struct *lynx_core_data; struct osf_core_struct *osf_core_data; + struct cisco_core_struct *cisco_core_data; PTR any; } tdata; @@ -1845,10 +1846,10 @@ bfd_errmsg PARAMS ((bfd_error_type error_tag)); void bfd_perror PARAMS ((CONST char *message)); -unsigned int +long bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect)); -unsigned int +long bfd_canonicalize_reloc PARAMS ((bfd *abfd, asection *sec, @@ -1915,9 +1916,8 @@ bfd_copy_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd)); BFD_SEND (abfd, _bfd_get_relocated_section_contents, \ (abfd, link_info, link_order, data, relocateable, symbols)) -#define bfd_relax_section(abfd, section, link_info, symbols) \ - BFD_SEND (abfd, _bfd_relax_section, \ - (abfd, section, link_info, symbols)) +#define bfd_relax_section(abfd, section, link_info, again) \ + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) #define bfd_link_hash_table_create(abfd) \ BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) @@ -2040,12 +2040,12 @@ typedef struct bfd_target boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr, bfd *, sec_ptr)); boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *)); - unsigned int (*_get_symtab_upper_bound) PARAMS ((bfd *)); - unsigned int (*_bfd_canonicalize_symtab) PARAMS ((bfd *, - struct symbol_cache_entry **)); - unsigned int (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); - unsigned int (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, - struct symbol_cache_entry **)); + long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *)); + long (*_bfd_canonicalize_symtab) PARAMS ((bfd *, + struct symbol_cache_entry **)); + long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); + long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, + struct symbol_cache_entry **)); struct symbol_cache_entry * (*_bfd_make_empty_symbol) PARAMS ((bfd *)); void (*_bfd_print_symbol) PARAMS ((bfd *, PTR, @@ -2083,7 +2083,7 @@ typedef struct bfd_target struct symbol_cache_entry **)); boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *, - struct bfd_link_info *, struct symbol_cache_entry **)); + struct bfd_link_info *, boolean *again)); /* See documentation on reloc types. */ CONST struct reloc_howto_struct * @@ -168,6 +168,7 @@ CODE_FRAGMENT . struct sgi_core_struct *sgi_core_data; . struct lynx_core_struct *lynx_core_data; . struct osf_core_struct *osf_core_data; +. struct cisco_core_struct *cisco_core_data; . PTR any; . } tdata; . @@ -366,24 +367,24 @@ FUNCTION bfd_get_reloc_upper_bound SYNOPSIS - unsigned int bfd_get_reloc_upper_bound(bfd *abfd, asection *sect); + long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect); DESCRIPTION Return the number of bytes required to store the relocation information associated with section @var{sect} - attached to bfd @var{abfd}. + attached to bfd @var{abfd}. If an error occurs, return -1. */ -unsigned int +long bfd_get_reloc_upper_bound (abfd, asect) bfd *abfd; sec_ptr asect; { if (abfd->format != bfd_object) { bfd_set_error (bfd_error_invalid_operation); - return 0; + return -1; } return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect)); @@ -394,7 +395,7 @@ FUNCTION bfd_canonicalize_reloc SYNOPSIS - unsigned int bfd_canonicalize_reloc + long bfd_canonicalize_reloc (bfd *abfd, asection *sec, arelent **loc, @@ -406,14 +407,15 @@ DESCRIPTION information attached to @var{sec} into the internal canonical form. Place the table into memory at @var{loc}, which has been preallocated, usually by a call to - <<bfd_get_reloc_upper_bound>>. + <<bfd_get_reloc_upper_bound>>. Returns the number of relocs, or + -1 on error. The @var{syms} table is also needed for horrible internal magic reasons. */ -unsigned int +long bfd_canonicalize_reloc (abfd, asect, location, symbols) bfd *abfd; sec_ptr asect; @@ -422,7 +424,7 @@ bfd_canonicalize_reloc (abfd, asect, location, symbols) { if (abfd->format != bfd_object) { bfd_set_error (bfd_error_invalid_operation); - return 0; + return -1; } return BFD_SEND (abfd, _bfd_canonicalize_reloc, (abfd, asect, location, symbols)); @@ -739,6 +741,27 @@ bfd_scan_vma (string, end, base) /* FUNCTION + bfd_copy_private_bfd_data + +SYNOPSIS + boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd); + +DESCRIPTION + Copy private BFD information from the BFD @var{ibfd} to the + the BFD @var{obfd}. Return <<true>> on success, <<false>> on error. + Possible error returns are: + + o <<bfd_error_no_memory>> - + Not enough memory exists to create private data for @var{obfd}. + +.#define bfd_copy_private_bfd_data(ibfd, obfd) \ +. BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \ +. (ibfd, obfd)) + +*/ + +/* +FUNCTION stuff DESCRIPTION @@ -771,9 +794,8 @@ DESCRIPTION . BFD_SEND (abfd, _bfd_get_relocated_section_contents, \ . (abfd, link_info, link_order, data, relocateable, symbols)) . -.#define bfd_relax_section(abfd, section, link_info, symbols) \ -. BFD_SEND (abfd, _bfd_relax_section, \ -. (abfd, section, link_info, symbols)) +.#define bfd_relax_section(abfd, section, link_info, again) \ +. BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) . .#define bfd_link_hash_table_create(abfd) \ . BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) @@ -797,7 +797,7 @@ b_out_squirt_out_relocs (abfd, section) } /* This is stupid. This function should be a boolean predicate */ -static unsigned int +static long b_out_canonicalize_reloc (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; @@ -807,9 +807,11 @@ b_out_canonicalize_reloc (abfd, section, relptr, symbols) arelent *tblptr = section->relocation; unsigned int count = 0; - if (!(tblptr || b_out_slurp_reloc_table (abfd, section, symbols))) return 0; + if (!(tblptr || b_out_slurp_reloc_table (abfd, section, symbols))) + return -1; tblptr = section->relocation; - if (!tblptr) return 0; + if (!tblptr) + return -1; for (; count++ < section->reloc_count;) *relptr++ = tblptr++; @@ -819,14 +821,14 @@ b_out_canonicalize_reloc (abfd, section, relptr, symbols) return section->reloc_count; } -static unsigned int +static long b_out_get_reloc_upper_bound (abfd, asect) bfd *abfd; sec_ptr asect; { if (bfd_get_format (abfd) != bfd_object) { bfd_set_error (bfd_error_invalid_operation); - return 0; + return -1; } if (asect == obj_datasec (abfd)) @@ -843,7 +845,7 @@ b_out_get_reloc_upper_bound (abfd, asect) return 0; bfd_set_error (bfd_error_invalid_operation); - return 0; + return -1; } static boolean @@ -1099,8 +1101,11 @@ b_out_relax_section (abfd, i, link_info, again) asection *input_section = i; int shrink = 0 ; arelent **reloc_vector = NULL; - bfd_size_type reloc_size = bfd_get_reloc_upper_bound(input_bfd, - input_section); + long reloc_size = bfd_get_reloc_upper_bound(input_bfd, + input_section); + + if (reloc_size < 0) + return false; /* We only run this relaxation once. It might work to run it multiple times, but it hasn't been tested. */ @@ -1108,6 +1113,8 @@ b_out_relax_section (abfd, i, link_info, again) if (reloc_size) { + long reloc_count; + reloc_vector = (arelent **) malloc (reloc_size); if (reloc_vector == NULL && reloc_size != 0) { @@ -1116,8 +1123,12 @@ b_out_relax_section (abfd, i, link_info, again) } /* Get the relocs and think about them */ - if (bfd_canonicalize_reloc(input_bfd, input_section, reloc_vector, - _bfd_generic_link_get_symbols (input_bfd))) + reloc_count = + bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector, + _bfd_generic_link_get_symbols (input_bfd)); + if (reloc_count < 0) + goto error_return; + if (reloc_count > 0) { arelent **parent; for (parent = reloc_vector; *parent; parent++) @@ -1165,9 +1176,13 @@ b_out_get_relocated_section_contents (in_abfd, link_info, link_order, data, /* Get enough memory to hold the stuff */ bfd *input_bfd = link_order->u.indirect.section->owner; asection *input_section = link_order->u.indirect.section; - bfd_size_type reloc_size = bfd_get_reloc_upper_bound(input_bfd, - input_section); + long reloc_size = bfd_get_reloc_upper_bound(input_bfd, + input_section); arelent **reloc_vector = NULL; + long reloc_count; + + if (reloc_size < 0) + goto error_return; /* If producing relocateable output, don't bother to relax. */ if (relocateable) @@ -1192,10 +1207,13 @@ b_out_get_relocated_section_contents (in_abfd, link_info, link_order, data, 0, input_section->_raw_size)); - if (bfd_canonicalize_reloc(input_bfd, - input_section, - reloc_vector, - symbols) ) + reloc_count = bfd_canonicalize_reloc (input_bfd, + input_section, + reloc_vector, + symbols); + if (reloc_count < 0) + goto error_return; + if (reloc_count > 0) { arelent **parent = reloc_vector; arelent *reloc ; diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c index b20e309..dc9775f 100644 --- a/bfd/cisco-core.c +++ b/bfd/cisco-core.c @@ -112,8 +112,9 @@ cisco_core_file_p (abfd) /* OK, we believe you. You're a core file. */ - abfd->tdata.cisco_core_data = (struct cisco_core_struct *) - bfd_zmalloc (abfd, sizeof (struct cisco_core_struct)); + abfd->tdata.cisco_core_data = + ((struct cisco_core_struct *) + bfd_zmalloc (sizeof (struct cisco_core_struct))); if (abfd->tdata.cisco_core_data == NULL) { bfd_set_error (bfd_error_no_memory); @@ -245,7 +246,7 @@ cisco_core_file_p (abfd) free (asect); asect = nextsect; } - free (abfd->tdata); + free (abfd->tdata.cisco_core_data); return NULL; } } @@ -290,13 +291,13 @@ cisco_core_file_matches_executable_p (core_bfd, exec_bfd) #define cisco_get_section_contents bfd_generic_get_section_contents #define cisco_new_section_hook (boolean (*) PARAMS \ ((bfd *, sec_ptr))) bfd_true -#define cisco_get_symtab_upper_bound bfd_0u -#define cisco_get_symtab (unsigned int (*) PARAMS \ - ((bfd *, struct symbol_cache_entry **))) bfd_0u -#define cisco_get_reloc_upper_bound (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr))) bfd_0u -#define cisco_canonicalize_reloc (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define cisco_get_symtab_upper_bound bfd_0l +#define cisco_get_symtab (long (*) PARAMS \ + ((bfd *, struct symbol_cache_entry **))) bfd_0l +#define cisco_get_reloc_upper_bound (long (*) PARAMS \ + ((bfd *, sec_ptr))) bfd_0l +#define cisco_canonicalize_reloc (long (*) PARAMS \ + ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define cisco_make_empty_symbol (struct symbol_cache_entry * \ (*) PARAMS ((bfd *))) bfd_false #define cisco_print_symbol (void (*) PARAMS \ @@ -337,7 +338,7 @@ cisco_core_file_matches_executable_p (core_bfd, exec_bfd) #define cisco_bfd_copy_private_bfd_data \ ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false) #define cisco_bfd_is_local_label \ - ((boolean (*) PARAMS ((bfd *, asection *))) bfd_false) + ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false) bfd_target cisco_core_vec = { diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 4353078..49cb9df 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -714,14 +714,17 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, { bfd *input_bfd = link_order->u.indirect.section->owner; asection *input_section = link_order->u.indirect.section; - size_t reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); + long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); arelent **reloc_vector = NULL; + long reloc_count; bfd *output_bfd = relocateable ? abfd : (bfd *) NULL; bfd_vma gp; boolean gp_undefined; bfd_vma stack[RELOC_STACKSIZE]; int tos = 0; + if (reloc_size < 0) + goto error_return; reloc_vector = (arelent **) malloc (reloc_size); if (reloc_vector == NULL && reloc_size != 0) { @@ -737,9 +740,11 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, input_section->_cooked_size = input_section->_raw_size; input_section->reloc_done = true; - if (bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector, - symbols) - == 0) + reloc_count = bfd_canonicalize_reloc (input_bfd, input_section, + reloc_vector, symbols); + if (reloc_count < 0) + goto error_return; + if (reloc_count == 0) goto successful_return; /* Get the GP value for the output BFD. */ diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 8319cab..0f984fe 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -2376,7 +2376,7 @@ coff_slurp_reloc_table (abfd, asect, symbols) /* This is stupid. This function should be a boolean predicate. */ -static unsigned int +static long coff_canonicalize_reloc (abfd, section, relptr, symbols) bfd * abfd; sec_ptr section; @@ -2402,12 +2402,12 @@ coff_canonicalize_reloc (abfd, section, relptr, symbols) } else { - coff_slurp_reloc_table (abfd, section, symbols); - + if (! coff_slurp_reloc_table (abfd, section, symbols)) + return -1; tblptr = section->relocation; if (!tblptr) - return 0; + return -1; for (; count++ < section->reloc_count;) *relptr++ = tblptr++; diff --git a/bfd/coffgen.c b/bfd/coffgen.c index a7d367a..e088048 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -274,12 +274,12 @@ coff_section_from_bfd_index (abfd, index) /* Get the upper bound of a COFF symbol table. */ -unsigned int +long coff_get_symtab_upper_bound(abfd) bfd *abfd; { if (!bfd_coff_slurp_symbol_table(abfd)) - return 0; + return -1; return (bfd_get_symcount(abfd) + 1) * (sizeof(coff_symbol_type *)); } @@ -287,7 +287,7 @@ bfd *abfd; /* Canonicalize a COFF symbol table. */ -unsigned int +long coff_get_symtab (abfd, alocation) bfd *abfd; asymbol **alocation; @@ -296,7 +296,7 @@ coff_get_symtab (abfd, alocation) coff_symbol_type *symbase; coff_symbol_type **location = (coff_symbol_type **) (alocation); if (!bfd_coff_slurp_symbol_table(abfd)) - return 0; + return -1; symbase = obj_symbols(abfd); while (counter < bfd_get_symcount(abfd)) @@ -1337,14 +1337,14 @@ coff_get_normalized_symtab (abfd) return (internal); } /* coff_get_normalized_symtab() */ -unsigned int +long coff_get_reloc_upper_bound (abfd, asect) bfd *abfd; sec_ptr asect; { if (bfd_get_format(abfd) != bfd_object) { bfd_set_error (bfd_error_invalid_operation); - return 0; + return -1; } return (asect->reloc_count + 1) * sizeof(arelent *); } diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 0fbfc7d..93d35c4 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -1212,12 +1212,14 @@ ecoff_slurp_symbol_table (abfd) /* Return the amount of space needed for the canonical symbols. */ -unsigned int +long ecoff_get_symtab_upper_bound (abfd) bfd *abfd; { - if (ecoff_slurp_symbolic_info (abfd) == false - || bfd_get_symcount (abfd) == 0) + if (! ecoff_slurp_symbolic_info (abfd)) + return -1; + + if (bfd_get_symcount (abfd) == 0) return 0; return (bfd_get_symcount (abfd) + 1) * (sizeof (ecoff_symbol_type *)); @@ -1225,7 +1227,7 @@ ecoff_get_symtab_upper_bound (abfd) /* Get the canonical symbols. */ -unsigned int +long ecoff_get_symtab (abfd, alocation) bfd *abfd; asymbol **alocation; @@ -1234,8 +1236,9 @@ ecoff_get_symtab (abfd, alocation) ecoff_symbol_type *symbase; ecoff_symbol_type **location = (ecoff_symbol_type **) alocation; - if (ecoff_slurp_symbol_table (abfd) == false - || bfd_get_symcount (abfd) == 0) + if (ecoff_slurp_symbol_table (abfd) == false) + return -1; + if (bfd_get_symcount (abfd) == 0) return 0; symbase = ecoff_data (abfd)->canonical_symbols; @@ -1901,7 +1904,7 @@ ecoff_slurp_reloc_table (abfd, section, symbols) /* Get a canonical list of relocs. */ -unsigned int +long ecoff_canonicalize_reloc (abfd, section, relptr, symbols) bfd *abfd; asection *section; @@ -1927,11 +1930,11 @@ ecoff_canonicalize_reloc (abfd, section, relptr, symbols) arelent *tblptr; if (ecoff_slurp_reloc_table (abfd, section, symbols) == false) - return 0; + return -1; tblptr = section->relocation; if (tblptr == (arelent *) NULL) - return 0; + return -1; for (count = 0; count < section->reloc_count; count++) *relptr++ = tblptr++; diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index 4b14dcd..da72eb4 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -966,6 +966,8 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug, asymbol **symbols; asymbol **sym_ptr; asymbol **sym_end; + long symsize; + long symcount; PTR external_fdr; memset ((PTR) &fdr, 0, sizeof fdr); @@ -988,14 +990,19 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug, fdr.isymBase = output_symhdr->isymMax; /* Get the local symbols from the input BFD. */ - symbols = (asymbol **) bfd_alloc (output_bfd, - get_symtab_upper_bound (input_bfd)); + symsize = bfd_get_symtab_upper_bound (input_bfd); + if (symsize < 0) + return false; + symbols = (asymbol **) bfd_alloc (output_bfd, symsize); if (symbols == (asymbol **) NULL) { bfd_set_error (bfd_error_no_memory); return false; } - sym_end = symbols + bfd_canonicalize_symtab (input_bfd, symbols); + symcount = bfd_canonicalize_symtab (input_bfd, symbols); + if (symcount < 0) + return false; + sym_end = symbols + symcount; /* Handle the local symbols. Any external symbols are handled separately. */ diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 0da3f23..c08bcb3 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1930,8 +1930,9 @@ hppa_elf_stub_finish (output_bfd) bfd *stub_bfd = stub_list->this_bfd; asection *stub_sec = bfd_get_section_by_name (stub_bfd, ".hppa_linker_stubs"); - bfd_size_type reloc_size; + long reloc_size; arelent **reloc_vector; + long reloc_count; /* Some sanity checking. */ BFD_ASSERT (stub_sec == stub_list->stub_sec); @@ -1944,6 +1945,11 @@ hppa_elf_stub_finish (output_bfd) /* Make space to hold the relocations for the stub section. */ reloc_size = bfd_get_reloc_upper_bound (stub_bfd, stub_sec); + if (reloc_size < 0) + { + /* FIXME: Should return an error. */ + abort (); + } reloc_vector = (arelent **) malloc (reloc_size); if (reloc_vector == NULL && reloc_size != 0) { @@ -1953,8 +1959,15 @@ hppa_elf_stub_finish (output_bfd) } /* If we have relocations, do them. */ - if (bfd_canonicalize_reloc (stub_bfd, stub_sec, reloc_vector, - output_bfd->outsymbols)) + reloc_count = bfd_canonicalize_reloc (stub_bfd, stub_sec, + reloc_vector, + output_bfd->outsymbols); + if (reloc_count < 0) + { + /* FIXME: Should return an error. */ + abort (); + } + if (reloc_count > 0) { arelent **parent; for (parent = reloc_vector; *parent != NULL; parent++) @@ -2742,21 +2755,28 @@ hppa_look_for_stubs_in_section (stub_bfd, abfd, output_bfd, asec, location. */ if (bfd_get_outsymbols (abfd) == NULL) { - size_t symsize; + long symsize; + long symcount; - symsize = get_symtab_upper_bound (abfd); + symsize = bfd_get_symtab_upper_bound (abfd); + if (symsize < 0) + goto error_return; abfd->outsymbols = (asymbol **) bfd_alloc (abfd, symsize); - if (!abfd->outsymbols) + if (!abfd->outsymbols && symsize != 0) { bfd_set_error (bfd_error_no_memory); goto error_return; } - abfd->symcount = bfd_canonicalize_symtab (abfd, abfd->outsymbols); + symcount = bfd_canonicalize_symtab (abfd, abfd->outsymbols); + if (symcount < 0) + goto error_return; + abfd->symcount = symcount; } /* Now get the relocations. */ - bfd_canonicalize_reloc (abfd, asec, reloc_vector, - bfd_get_outsymbols (abfd)); + if (bfd_canonicalize_reloc (abfd, asec, reloc_vector, + bfd_get_outsymbols (abfd)) < 0) + goto error_return; /* Examine each relocation entry in this section. */ for (i = 0; i < asec->reloc_count; i++) diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 15debf8..7f4930d 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -1469,14 +1469,16 @@ mips_elf_final_link (abfd, info) { asection *input_section; bfd *input_bfd; - bfd_size_type relsize; + long relsize; arelent **relocs; - bfd_size_type reloc_count; + long reloc_count; input_section = p->u.indirect.section; input_bfd = input_section->owner; relsize = bfd_get_reloc_upper_bound (input_bfd, input_section); + if (relsize < 0) + return false; relocs = (arelent **) malloc (relsize); if (!relocs && relsize != 0) { @@ -1487,6 +1489,8 @@ mips_elf_final_link (abfd, info) bfd_canonicalize_reloc (input_bfd, input_section, relocs, bfd_get_outsymbols (input_bfd)); + if (reloc_count < 0) + return false; BFD_ASSERT (reloc_count == input_section->reloc_count); o->reloc_count += reloc_count; free (relocs); diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 3d79e0b..19ce05d 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -2740,14 +2740,14 @@ error_return: the vector allocated based on this size. However, the ELF symbol table always has a dummy entry as symbol #0, so it ends up even. */ -unsigned int +long elf_get_symtab_upper_bound (abfd) bfd *abfd; { - unsigned int symcount; - unsigned int symtab_size = 0; - + long symcount; + long symtab_size; Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr; + symcount = hdr->sh_size / sizeof (Elf_External_Sym); symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *)); @@ -2760,7 +2760,7 @@ elf_get_symtab_upper_bound (abfd) attached to bfd <<abfd>> */ -unsigned int +long elf_get_reloc_upper_bound (abfd, asect) bfd *abfd; sec_ptr asect; @@ -3038,7 +3038,7 @@ elf_slurp_reloc_table (abfd, asect, symbols) return true; } -unsigned int +long elf_canonicalize_reloc (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; @@ -3051,13 +3051,19 @@ elf_canonicalize_reloc (abfd, section, relptr, symbols) /* snarfed from coffcode.h */ if (use_rela_p) - elf_slurp_reloca_table (abfd, section, symbols); + { + if (! elf_slurp_reloca_table (abfd, section, symbols)) + return -1; + } else - elf_slurp_reloc_table (abfd, section, symbols); + { + if (! elf_slurp_reloc_table (abfd, section, symbols)) + return -1; + } tblptr = section->relocation; if (!tblptr) - return 0; + return -1; for (; count++ < section->reloc_count;) *relptr++ = tblptr++; @@ -3066,16 +3072,15 @@ elf_canonicalize_reloc (abfd, section, relptr, symbols) return section->reloc_count; } -unsigned int +long elf_get_symtab (abfd, alocation) bfd *abfd; asymbol **alocation; { - if (!elf_slurp_symbol_table (abfd, alocation)) - return 0; - else - return bfd_get_symcount (abfd); + return -1; + + return bfd_get_symcount (abfd); } asymbol * diff --git a/bfd/hp300hpux.c b/bfd/hp300hpux.c index 5be01e3..fded557 100644 --- a/bfd/hp300hpux.c +++ b/bfd/hp300hpux.c @@ -786,14 +786,14 @@ doit: /* call aout_32 versions if the input file was generated by gcc */ /************************************************************************/ -unsigned int aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location)); -unsigned int aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd)); +long aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location)); +long aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd)); -unsigned int aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section, - arelent ** relptr, - asymbol ** symbols)); +long aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section, + arelent ** relptr, + asymbol ** symbols)); -unsigned int +long MY (get_symtab) (abfd, location) bfd *abfd; asymbol **location; @@ -805,7 +805,7 @@ MY (get_symtab) (abfd, location) return aout_32_get_symtab (abfd, location); if (!MY (slurp_symbol_table) (abfd)) - return 0; + return -1; for (symbase = obj_aout_symbols (abfd); counter++ < bfd_get_symcount (abfd);) *(location++) = (asymbol *) (symbase++); @@ -813,14 +813,14 @@ MY (get_symtab) (abfd, location) return bfd_get_symcount (abfd); } -unsigned int +long MY (get_symtab_upper_bound) (abfd) bfd *abfd; { if (obj_aout_subformat (abfd) == gnu_encap_format) return aout_32_get_symtab_upper_bound (abfd); if (!MY (slurp_symbol_table) (abfd)) - return 0; + return -1; return (bfd_get_symcount (abfd) + 1) * (sizeof (aout_symbol_type *)); } @@ -828,7 +828,7 @@ MY (get_symtab_upper_bound) (abfd) -unsigned int +long MY (canonicalize_reloc) (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; @@ -841,7 +841,7 @@ MY (canonicalize_reloc) (abfd, section, relptr, symbols) return aout_32_canonicalize_reloc (abfd, section, relptr, symbols); if (!(tblptr || MY (slurp_reloc_table) (abfd, section, symbols))) - return 0; + return -1; if (section->flags & SEC_CONSTRUCTOR) { @@ -856,7 +856,7 @@ MY (canonicalize_reloc) (abfd, section, relptr, symbols) { tblptr = section->relocation; if (!tblptr) - return 0; + return -1; for (count = 0; count++ < section->reloc_count;) { diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c index 04ba4ba..70270ae 100644 --- a/bfd/hppabsd-core.c +++ b/bfd/hppabsd-core.c @@ -130,7 +130,7 @@ hppabsd_core_core_file_p (abfd) val = bfd_read ((void *) &u, 1, sizeof u, abfd); if (val != sizeof u) { - bfd_error = wrong_format; + bfd_set_error (bfd_error_wrong_format); return NULL; } @@ -145,19 +145,19 @@ hppabsd_core_core_file_p (abfd) struct stat statbuf; if (stream == NULL || fstat (fileno (stream), &statbuf) < 0) { - bfd_error = system_call_error; + bfd_set_error (bfd_error_system_call); return NULL; } if (NBPG * (UPAGES + u.u_dsize + u.u_ssize) > statbuf.st_size) { - bfd_error = file_truncated; + bfd_set_error (bfd_error_file_truncated); return NULL; } if (clicksz * (UPAGES + u.u_dsize + u.u_ssize) < statbuf.st_size) { /* The file is too big. Maybe it's not a core file or we otherwise have bad values for u_dsize and u_ssize). */ - bfd_error = wrong_format; + bfd_set_error (bfd_error_wrong_format); return NULL; } } @@ -168,7 +168,7 @@ hppabsd_core_core_file_p (abfd) bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct)); if (!coredata) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); return NULL; } @@ -245,13 +245,13 @@ hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd) bfd_generic_get_section_contents #define hppabsd_core_new_section_hook (boolean (*) PARAMS \ ((bfd *, sec_ptr))) bfd_true -#define hppabsd_core_get_symtab_upper_bound bfd_0u -#define hppabsd_core_get_symtab (unsigned int (*) PARAMS \ - ((bfd *, struct symbol_cache_entry **))) bfd_0u -#define hppabsd_core_get_reloc_upper_bound (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr))) bfd_0u -#define hppabsd_core_canonicalize_reloc (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define hppabsd_core_get_symtab_upper_bound bfd_0l +#define hppabsd_core_get_symtab (long (*) PARAMS \ + ((bfd *, struct symbol_cache_entry **))) bfd_0l +#define hppabsd_core_get_reloc_upper_bound (long (*) PARAMS \ + ((bfd *, sec_ptr))) bfd_0l +#define hppabsd_core_canonicalize_reloc (long (*) PARAMS \ + ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define hppabsd_core_print_symbol (void (*) PARAMS \ ((bfd *, PTR, struct symbol_cache_entry *, \ bfd_print_symbol_type))) bfd_false @@ -285,6 +285,12 @@ hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd) ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) #define hppabsd_core_bfd_final_link \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) +#define hppabsd_core_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_false) +#define hppabsd_core_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false) +#define hppabsd_core_bfd_is_local_label \ + ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false) /* If somebody calls any byte-swapping routines, shoot them. */ static void diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c index afda813..86555de 100644 --- a/bfd/hpux-core.c +++ b/bfd/hpux-core.c @@ -105,7 +105,8 @@ hpux_core_make_empty_symbol (abfd) bfd *abfd; { asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol)); - new->the_bfd = abfd; + if (new) + new->the_bfd = abfd; return new; } @@ -222,17 +223,17 @@ hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd) #define hpux_core_close_and_cleanup bfd_generic_close_and_cleanup #define hpux_core_set_section_contents (boolean (*) PARAMS \ ((bfd *abfd, asection *section, PTR data, file_ptr offset, \ - bfd_size_type count))) bfd_false + bfd_size_type count))) bfd_generic_set_section_contents #define hpux_core_get_section_contents bfd_generic_get_section_contents #define hpux_core_new_section_hook (boolean (*) PARAMS \ ((bfd *, sec_ptr))) bfd_true -#define hpux_core_get_symtab_upper_bound bfd_0u -#define hpux_core_get_symtab (unsigned int (*) PARAMS \ - ((bfd *, struct symbol_cache_entry **))) bfd_0u -#define hpux_core_get_reloc_upper_bound (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr))) bfd_0u -#define hpux_core_canonicalize_reloc (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define hpux_core_get_symtab_upper_bound bfd_0l +#define hpux_core_get_symtab (long (*) PARAMS \ + ((bfd *, struct symbol_cache_entry **))) bfd_0l +#define hpux_core_get_reloc_upper_bound (long (*) PARAMS \ + ((bfd *, sec_ptr))) bfd_0l +#define hpux_core_canonicalize_reloc (long (*) PARAMS \ + ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define hpux_core_print_symbol (void (*) PARAMS \ ((bfd *, PTR, struct symbol_cache_entry *, \ bfd_print_symbol_type))) bfd_false @@ -266,6 +267,12 @@ hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd) ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) #define hpux_core_bfd_final_link \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) +#define hpux_core_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_false) +#define hpux_core_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false) +#define hpux_core_bfd_is_local_label \ + ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false) /* If somebody calls any byte-swapping routines, shoot them. */ void @@ -273,9 +280,10 @@ swap_abort() { abort(); /* This way doesn't require any declaration for ANSI to fuck up */ } -#define NO_GET ((bfd_vma (*) PARAMS (( bfd_byte *))) swap_abort ) +#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort ) #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort ) -#define NO_SIGNED_GET ((bfd_signed_vma (*) PARAMS ((bfd_byte *))) swap_abort ) +#define NO_SIGNED_GET \ + ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort ) bfd_target hpux_core_vec = { diff --git a/bfd/i386lynx.c b/bfd/i386lynx.c index 9a47e00..fde6ad3 100644 --- a/bfd/i386lynx.c +++ b/bfd/i386lynx.c @@ -515,8 +515,8 @@ NAME (lynx, squirt_out_relocs) (abfd, section) } /* This is stupid. This function should be a boolean predicate */ -unsigned int -NAME (lynx, canonicalize_reloc) (abfd, section, relptr, symbols) +long +NAME(lynx,canonicalize_reloc) (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; arelent **relptr; @@ -526,7 +526,7 @@ NAME (lynx, canonicalize_reloc) (abfd, section, relptr, symbols) unsigned int count; if (!(tblptr || NAME (lynx, slurp_reloc_table) (abfd, section, symbols))) - return 0; + return -1; if (section->flags & SEC_CONSTRUCTOR) { @@ -541,7 +541,7 @@ NAME (lynx, canonicalize_reloc) (abfd, section, relptr, symbols) { tblptr = section->relocation; if (!tblptr) - return 0; + return -1; for (count = 0; count++ < section->reloc_count;) { @@ -586,7 +586,7 @@ get_symbol (abfd, return last_symbol; } -static void +static boolean ieee_slurp_external_symbols (abfd) bfd *abfd; { @@ -613,7 +613,8 @@ ieee_slurp_external_symbols (abfd) symbol = get_symbol (abfd, ieee, symbol, &symbol_count, &prev_symbols_ptr, &ieee->external_symbol_max_index, 'D'); - + if (symbol == NULL) + return false; symbol->symbol.the_bfd = abfd; symbol->symbol.name = read_id (&(ieee->h)); @@ -626,7 +627,8 @@ ieee_slurp_external_symbols (abfd) symbol = get_symbol (abfd, ieee, symbol, &symbol_count, &prev_symbols_ptr, &ieee->external_symbol_max_index, 'D'); - + if (symbol == NULL) + return false; BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index); @@ -710,7 +712,8 @@ ieee_slurp_external_symbols (abfd) symbol = get_symbol (abfd, ieee, symbol, &symbol_count, &prev_reference_ptr, &ieee->external_reference_max_index, 'X'); - + if (symbol == NULL) + return false; symbol->symbol.the_bfd = abfd; symbol->symbol.name = read_id (&(ieee->h)); @@ -760,24 +763,29 @@ ieee_slurp_external_symbols (abfd) *prev_symbols_ptr = (ieee_symbol_type *) NULL; *prev_reference_ptr = (ieee_symbol_type *) NULL; + + return true; } -static void +static boolean ieee_slurp_symbol_table (abfd) bfd *abfd; { if (IEEE_DATA (abfd)->read_symbols == false) { - ieee_slurp_external_symbols (abfd); + if (! ieee_slurp_external_symbols (abfd)) + return false; IEEE_DATA (abfd)->read_symbols = true; } + return true; } -unsigned int +long ieee_get_symtab_upper_bound (abfd) bfd *abfd; { - ieee_slurp_symbol_table (abfd); + if (! ieee_slurp_symbol_table (abfd)) + return -1; return (abfd->symcount != 0) ? (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0; @@ -790,7 +798,7 @@ symbol index order extern bfd_target ieee_vec; -unsigned int +long ieee_get_symtab (abfd, location) bfd *abfd; asymbol **location; @@ -805,7 +813,8 @@ ieee_get_symtab (abfd, location) { ieee_data_type *ieee = IEEE_DATA (abfd); dummy_bfd.xvec = &ieee_vec; - ieee_slurp_symbol_table (abfd); + if (! ieee_slurp_symbol_table (abfd)) + return -1; if (ieee->symbol_table_full == false) { @@ -1684,12 +1693,13 @@ ieee_new_section_hook (abfd, newsect) return true; } -unsigned int +long ieee_get_reloc_upper_bound (abfd, asect) bfd *abfd; sec_ptr asect; { - ieee_slurp_section_data (abfd); + if (! ieee_slurp_section_data (abfd)) + return -1; return (asect->reloc_count + 1) * sizeof (arelent *); } @@ -1707,7 +1717,7 @@ ieee_get_section_contents (abfd, section, location, offset, count) return true; } -unsigned int +long ieee_canonicalize_reloc (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; @@ -3310,6 +3320,11 @@ ieee_bfd_debug_info_accumulate (abfd, section) #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols #define ieee_bfd_final_link _bfd_generic_final_link +#define ieee_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true) +#define ieee_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true) +#define ieee_bfd_is_local_label bfd_generic_is_local_label /*SUPPRESS 460 */ bfd_target ieee_vec = diff --git a/bfd/irix-core.c b/bfd/irix-core.c index b0482a4..08f2a12 100644 --- a/bfd/irix-core.c +++ b/bfd/irix-core.c @@ -178,7 +178,8 @@ irix_core_make_empty_symbol (abfd) bfd *abfd; { asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol)); - new->the_bfd = abfd; + if (new) + new->the_bfd = abfd; return new; } @@ -194,17 +195,17 @@ irix_core_make_empty_symbol (abfd) #define irix_core_close_and_cleanup bfd_generic_close_and_cleanup #define irix_core_set_section_contents (boolean (*) PARAMS \ ((bfd *abfd, asection *section, PTR data, file_ptr offset, \ - bfd_size_type count))) bfd_false + bfd_size_type count))) bfd_generic_set_section_contents #define irix_core_get_section_contents bfd_generic_get_section_contents #define irix_core_new_section_hook (boolean (*) PARAMS \ ((bfd *, sec_ptr))) bfd_true -#define irix_core_get_symtab_upper_bound bfd_0u -#define irix_core_get_symtab (unsigned int (*) PARAMS \ - ((bfd *, struct symbol_cache_entry **))) bfd_0u -#define irix_core_get_reloc_upper_bound (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr))) bfd_0u -#define irix_core_canonicalize_reloc (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define irix_core_get_symtab_upper_bound bfd_0l +#define irix_core_get_symtab (long (*) PARAMS \ + ((bfd *, struct symbol_cache_entry **))) bfd_0l +#define irix_core_get_reloc_upper_bound (long (*) PARAMS \ + ((bfd *, sec_ptr))) bfd_0l +#define irix_core_canonicalize_reloc (long (*) PARAMS \ + ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define irix_core_print_symbol (void (*) PARAMS \ ((bfd *, PTR, struct symbol_cache_entry *, \ bfd_print_symbol_type))) bfd_false @@ -239,15 +240,23 @@ irix_core_make_empty_symbol (abfd) #define irix_core_bfd_final_link \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) +#define irix_core_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_false) +#define irix_core_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false) +#define irix_core_bfd_is_local_label \ + ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false) + /* If somebody calls any byte-swapping routines, shoot them. */ void swap_abort() { abort(); /* This way doesn't require any declaration for ANSI to fuck up */ } -#define NO_GET ((bfd_vma (*) PARAMS (( bfd_byte *))) swap_abort ) +#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort ) #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort ) -#define NO_SIGNED_GET ((bfd_signed_vma (*) PARAMS ((bfd_byte *))) swap_abort ) +#define NO_SIGNED_GET \ + ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort ) bfd_target irix_core_vec = { diff --git a/bfd/libaout.h b/bfd/libaout.h index 330f60e..c9793f8 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -44,9 +44,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define BYTES_IN_WORD 4 #endif /* ARCH_SIZE==32 */ -/* Declare at file level, since it isused in parameter lists, which - have weird scope. */ +/* Declare at file level, since used in parameter lists, which have + weird scope. */ struct external_exec; +struct external_nlist; /* Back-end information for various a.out targets. */ struct aout_backend_data @@ -76,6 +77,25 @@ struct aout_backend_data to the size of the text section in the file for alignment purposes but does *not* get counted in the length of the text section. */ unsigned char exec_header_not_counted; + + /* A callback function to read in the dynamic symbols of an object + which is dynamically linked. This returns the number of symbols + read (or -1 on error) and sets *SYMS to a buffer holding an array + of external_nlist structures and *STRS and *STRSIZE to the + associated string table. (This interface works for SunOS, but + can be changed if some other interface is better for some other + shared library implementation). */ + bfd_size_type (*read_dynamic_symbols) PARAMS ((bfd *, + struct external_nlist **syms, + char **strs, + bfd_size_type *strsize)); + + /* A callback function to read in the dynamic relocs of an object + which is dynamically linked. This returns the number of relocs + read (or -1 on error) and sets *RELOCS to a buffer holding an + array of external reloc structures (the type depends upon the + type of object file). */ + bfd_size_type (*read_dynamic_relocs) PARAMS ((bfd *, PTR *relocs)); }; #define aout_backend_info(abfd) \ ((CONST struct aout_backend_data *)((abfd)->xvec->backend_data)) @@ -133,7 +153,7 @@ enum machine_type { M_HPUX = (0x20c % 256)/* HP 200/300 HPUX binary */ }; -#define N_DYNAMIC(exec) ((exec).a_info & 0x8000000) +#define N_DYNAMIC(exec) ((exec).a_info & 0x80000000) #ifndef N_MAGIC # define N_MAGIC(exec) ((exec).a_info & 0xffff) @@ -154,6 +174,12 @@ enum machine_type { | (((flags) & 0xff) << 24)) #endif +#ifndef N_SET_DYNAMIC +# define N_SET_DYNAMIC(exec, dynamic) \ +((exec).a_info = (dynamic) ? ((exec).a_info | 0x80000000) : \ +((exec).a_info & 0x7fffffff)) +#endif + #ifndef N_SET_MAGIC # define N_SET_MAGIC(exec, magic) \ ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) @@ -227,6 +253,9 @@ struct aoutdata { bfd_size_type external_sym_count; char *external_strings; struct aout_link_hash_entry **sym_hashes; + + /* A pointer for shared library information. */ + PTR dynamic_info; }; struct aout_data_struct { @@ -249,6 +278,7 @@ struct aout_data_struct { #define obj_aout_external_sym_count(bfd) (adata(bfd).external_sym_count) #define obj_aout_external_strings(bfd) (adata(bfd).external_strings) #define obj_aout_sym_hashes(bfd) (adata(bfd).sym_hashes) +#define obj_aout_dynamic_info(bfd) (adata(bfd).dynamic_info) /* We take the address of the first element of an asymbol to ensure that the macro is only ever applied to an asymbol */ @@ -294,21 +324,21 @@ NAME(aout,write_syms) PARAMS ((bfd *abfd)); void NAME(aout,reclaim_symbol_table) PARAMS ((bfd *abfd)); -unsigned int +long NAME(aout,get_symtab_upper_bound) PARAMS ((bfd *abfd)); -unsigned int +long NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location)); boolean NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect, asymbol **symbols)); -unsigned int +long NAME(aout,canonicalize_reloc) PARAMS ((bfd *abfd, sec_ptr section, arelent **relptr, asymbol **symbols)); -unsigned int +long NAME(aout,get_reloc_upper_bound) PARAMS ((bfd *abfd, sec_ptr asect)); void @@ -375,6 +405,18 @@ aout_stab_name PARAMS ((int code)); #define NO_WRITE_HEADER_KLUDGE 0 #endif +#ifndef aout_32_bfd_copy_private_section_data +#define aout_32_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true) +#endif +#ifndef aout_32_bfd_copy_private_bfd_data +#define aout_32_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true) +#endif +#ifndef aout_32_bfd_is_local_label +#define aout_32_bfd_is_local_label bfd_generic_is_local_label +#endif + #ifndef WRITE_HEADERS #define WRITE_HEADERS(abfd, execp) \ { \ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index 6327bc5..b0a0f5f 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -117,6 +117,7 @@ boolean bfd_true PARAMS ((bfd *ignore)); PTR bfd_nullvoidptr PARAMS ((bfd *ignore)); int bfd_0 PARAMS ((bfd *ignore)); unsigned int bfd_0u PARAMS ((bfd *ignore)); +long bfd_0l PARAMS ((bfd *ignore)); void bfd_void PARAMS ((bfd *ignore)); bfd * _bfd_new_bfd_contained_in PARAMS ((bfd *)); @@ -178,6 +179,12 @@ extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create extern boolean _bfd_generic_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); +/* Generic add symbol routine. This version is used by targets for + which the linker must collect constructors and destructors by name, + as the collect2 program does. */ +extern boolean _bfd_generic_link_add_symbols_collect + PARAMS ((bfd *, struct bfd_link_info *)); + /* Generic archive add symbol routine. */ extern boolean _bfd_generic_link_add_archive_symbols PARAMS ((bfd *, struct bfd_link_info *, diff --git a/bfd/libbfd.c b/bfd/libbfd.c index fe441c8..da3460b 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -81,6 +81,14 @@ bfd_0u (ignore) return 0; } +/*ARGUSED*/ +long +bfd_0l (ignore) + bfd *ignore; +{ + return 0; +} + /*ARGSUSED*/ void bfd_void (ignore) diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 03f8043..a31db2e 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -117,6 +117,7 @@ boolean bfd_true PARAMS ((bfd *ignore)); PTR bfd_nullvoidptr PARAMS ((bfd *ignore)); int bfd_0 PARAMS ((bfd *ignore)); unsigned int bfd_0u PARAMS ((bfd *ignore)); +long bfd_0l PARAMS ((bfd *ignore)); void bfd_void PARAMS ((bfd *ignore)); bfd * _bfd_new_bfd_contained_in PARAMS ((bfd *)); @@ -307,7 +308,7 @@ bfd_generic_relax_section PARAMS ((bfd *abfd, asection *section, struct bfd_link_info *, - asymbol **symbols)); + boolean *)); bfd_byte * diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 05c0d1d..277080e 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -1,5 +1,5 @@ /* BFD COFF object file private structure. - Copyright (C) 1990-1991 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -28,6 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define obj_relocbase(bfd) (coff_data(bfd)->relocbase) #define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments) +#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 @@ -76,22 +77,25 @@ typedef struct coff_tdata /* Functions in coffgen.c. */ extern bfd_target *coff_object_p PARAMS ((bfd *)); extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int)); -extern unsigned int coff_get_symtab_upper_bound PARAMS ((bfd *)); -extern unsigned int coff_get_symtab PARAMS ((bfd *, asymbol **)); -extern void coff_count_linenumbers PARAMS ((bfd *)); +extern long coff_get_symtab_upper_bound PARAMS ((bfd *)); +extern long coff_get_symtab PARAMS ((bfd *, asymbol **)); +extern int coff_count_linenumbers PARAMS ((bfd *)); extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *)); -extern void coff_renumber_symbols PARAMS ((bfd *)); +extern boolean coff_renumber_symbols PARAMS ((bfd *)); extern void coff_mangle_symbols PARAMS ((bfd *)); extern void coff_write_symbols PARAMS ((bfd *)); -extern void coff_write_linenumbers 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 *)); extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *)); -extern unsigned int coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); +extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); extern asymbol *coff_make_empty_symbol PARAMS ((bfd *)); extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type how)); -extern asymbol *coff_make_debug_symbol PARAMS ((bfd *, PTR, unsigned long)); +extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *, + symbol_info *ret)); +extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR, + unsigned long)); extern boolean coff_find_nearest_line PARAMS ((bfd *, asection *, asymbol **, @@ -100,13 +104,17 @@ extern boolean coff_find_nearest_line PARAMS ((bfd *, CONST char **functionname_ptr, unsigned int *line_ptr)); extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc)); -extern boolean bfd_coff_reloc16_relax_section PARAMS ((bfd *, - asection *, - asymbol **)); +extern boolean bfd_coff_reloc16_relax_section + PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents - PARAMS ((bfd *, struct bfd_seclet *, bfd_byte *, boolean relocateable)); + PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, + bfd_byte *, boolean relocateable, asymbol **)); extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *, - struct bfd_seclet *)); + struct bfd_link_info *, + asection *)); +extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip, + asection *input_section, + bfd_vma val)); /* And more taken from the source .. */ diff --git a/bfd/libcoff.h b/bfd/libcoff.h index d657631..83d5468 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -1,5 +1,5 @@ /* BFD COFF object file private structure. - Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -77,18 +77,18 @@ typedef struct coff_tdata /* Functions in coffgen.c. */ extern bfd_target *coff_object_p PARAMS ((bfd *)); extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int)); -extern unsigned int coff_get_symtab_upper_bound PARAMS ((bfd *)); -extern unsigned int coff_get_symtab PARAMS ((bfd *, asymbol **)); +extern long coff_get_symtab_upper_bound PARAMS ((bfd *)); +extern long coff_get_symtab PARAMS ((bfd *, asymbol **)); extern int coff_count_linenumbers PARAMS ((bfd *)); extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *)); -extern void coff_renumber_symbols PARAMS ((bfd *)); +extern boolean coff_renumber_symbols PARAMS ((bfd *)); extern void coff_mangle_symbols PARAMS ((bfd *)); extern void coff_write_symbols PARAMS ((bfd *)); -extern void coff_write_linenumbers 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 *)); extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *)); -extern unsigned int coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); +extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); extern asymbol *coff_make_empty_symbol PARAMS ((bfd *)); extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type how)); @@ -104,23 +104,21 @@ extern boolean coff_find_nearest_line PARAMS ((bfd *, CONST char **functionname_ptr, unsigned int *line_ptr)); extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc)); -extern boolean bfd_coff_reloc16_relax_section PARAMS ((bfd *, - asection *, - struct bfd_link_info *, - asymbol **)); +extern boolean bfd_coff_reloc16_relax_section + PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *, boolean relocateable, asymbol **)); extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *, struct bfd_link_info *, asection *)); -extern void bfd_perform_slip PARAMS ((asymbol **s, unsigned int slip, +extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip, asection *input_section, - bfd_vma value)); + bfd_vma val)); /* And more taken from the source .. */ -typedef struct coff_ptr_struct +typedef struct coff_ptr_struct { /* Remembers the offset from the first symbol in the file for @@ -169,7 +167,7 @@ struct lineno_cache_entry *lineno; /* Have the line numbers been relocated yet ? */ boolean done_lineno; } coff_symbol_type; -typedef struct +typedef struct { void (*_bfd_coff_swap_aux_in) PARAMS (( bfd *abfd, @@ -282,8 +280,8 @@ typedef struct unsigned int *src_ptr, unsigned int *dst_ptr)); int (*_bfd_coff_reloc16_estimate) PARAMS (( + bfd *abfd, asection *input_section, - asymbol **symbols, arelent *r, unsigned int shrink, struct bfd_link_info *link_info)); @@ -365,7 +363,7 @@ typedef struct ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) -#define bfd_coff_reloc16_estimate(abfd, section, symbols, reloc, shrink, link_info)\ +#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ - (section, symbols, reloc, shrink, link_info)) - + (abfd, section, reloc, shrink, link_info)) + diff --git a/bfd/libecoff.h b/bfd/libecoff.h index f0f3a11..f413837 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -217,19 +217,18 @@ extern boolean ecoff_slurp_symbolic_info PARAMS ((bfd *)); /* Generic ECOFF BFD backend vectors. */ extern asymbol *ecoff_make_empty_symbol PARAMS ((bfd *abfd)); -extern unsigned int ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd)); -extern unsigned int ecoff_get_symtab PARAMS ((bfd *abfd, - asymbol **alocation)); +extern long ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd)); +extern long ecoff_get_symtab PARAMS ((bfd *abfd, asymbol **alocation)); extern void ecoff_get_symbol_info PARAMS ((bfd *abfd, asymbol *symbol, symbol_info *ret)); extern void ecoff_print_symbol PARAMS ((bfd *abfd, PTR filep, asymbol *symbol, bfd_print_symbol_type how)); -extern unsigned int ecoff_canonicalize_reloc PARAMS ((bfd *abfd, - asection *section, - arelent **relptr, - asymbol **symbols)); +extern long ecoff_canonicalize_reloc PARAMS ((bfd *abfd, + asection *section, + arelent **relptr, + asymbol **symbols)); extern boolean ecoff_find_nearest_line PARAMS ((bfd *abfd, asection *section, asymbol **symbols, diff --git a/bfd/libelf.h b/bfd/libelf.h index b0143a1..9eb93ec 100644 --- a/bfd/libelf.h +++ b/bfd/libelf.h @@ -259,12 +259,11 @@ extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); -extern unsigned int bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *)); -extern unsigned int bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **)); -extern unsigned int bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); -extern unsigned int bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr, - arelent **, - asymbol **)); +extern long bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *)); +extern long bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **)); +extern long bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); +extern long bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr, + arelent **, asymbol **)); extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *)); extern void bfd_elf32_print_symbol PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); @@ -296,12 +295,11 @@ extern boolean bfd_elf64_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); -extern unsigned int bfd_elf64_get_symtab_upper_bound PARAMS ((bfd *)); -extern unsigned int bfd_elf64_get_symtab PARAMS ((bfd *, asymbol **)); -extern unsigned int bfd_elf64_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); -extern unsigned int bfd_elf64_canonicalize_reloc PARAMS ((bfd *, sec_ptr, - arelent **, - asymbol **)); +extern long bfd_elf64_get_symtab_upper_bound PARAMS ((bfd *)); +extern long bfd_elf64_get_symtab PARAMS ((bfd *, asymbol **)); +extern long bfd_elf64_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); +extern long bfd_elf64_canonicalize_reloc PARAMS ((bfd *, sec_ptr, + arelent **, asymbol **)); extern asymbol *bfd_elf64_make_empty_symbol PARAMS ((bfd *)); extern void bfd_elf64_print_symbol PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); diff --git a/bfd/libnlm.h b/bfd/libnlm.h index 22d779d..cf6885d 100644 --- a/bfd/libnlm.h +++ b/bfd/libnlm.h @@ -58,17 +58,17 @@ extern boolean nlm_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, extern void nlmNAME(get_symbol_info) PARAMS ((bfd *, asymbol *, symbol_info *)); -extern unsigned int nlmNAME(get_symtab_upper_bound) +extern long nlmNAME(get_symtab_upper_bound) PARAMS ((bfd *)); -extern unsigned int nlmNAME(get_symtab) +extern long nlmNAME(get_symtab) PARAMS ((bfd *, asymbol **)); extern asymbol *nlmNAME(make_empty_symbol) PARAMS ((bfd *)); extern void nlmNAME(print_symbol) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); -extern unsigned int nlmNAME(get_reloc_upper_bound) +extern long nlmNAME(get_reloc_upper_bound) PARAMS ((bfd *, asection *)); -extern unsigned int nlmNAME(canonicalize_reloc) +extern long nlmNAME(canonicalize_reloc) PARAMS ((bfd *, asection *, arelent **, asymbol **)); extern bfd_target *nlmNAME(object_p) PARAMS ((bfd *)); @@ -99,6 +99,20 @@ struct nlm_obj_tdata /* Caches for data read from object file. */ arelent * nlm_reloc_fixups; asection ** nlm_reloc_fixup_secs; + /* Backend specific information. This should probably be a pointer, + but that would require yet another entry point to initialize the + structure. */ + union + { + struct /* Alpha backend information. */ + { + bfd_vma gp; /* GP value. */ + bfd_vma lita_address; /* .lita section address. */ + bfd_size_type lita_size; /* .lita section size. */ + } + alpha_backend_data; + } + backend_data; }; #define nlm_tdata(bfd) ((bfd) -> tdata.nlm_obj_data) @@ -117,6 +131,9 @@ struct nlm_obj_tdata #define nlm_relocation_fixups(bfd) (nlm_tdata(bfd) -> nlm_reloc_fixups) #define nlm_relocation_fixup_secs(bfd) (nlm_tdata(bfd)->nlm_reloc_fixup_secs) +#define nlm_alpha_backend_data(bfd) \ + (&nlm_tdata (bfd)->backend_data.alpha_backend_data) + /* This is used when writing out the external relocs. */ struct reloc_and_sec @@ -143,6 +160,10 @@ struct nlm_backend_data enum bfd_architecture arch; /* Machine. */ long mach; + /* Some NLM formats do not use the uninitialized data section, so + all uninitialized data must be put into the regular data section + instead. */ + boolean no_uninitialized_data; /* Some NLM formats have a prefix on the file. If this function is not NULL, it will be called by nlm_object_p. It should return true if this file could match this format, and it should leave @@ -188,42 +209,47 @@ struct nlm_backend_data boolean (*nlm_write_external) PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *)); + boolean (*nlm_write_export) PARAMS ((bfd *, asymbol *, bfd_vma)); }; #define nlm_backend(bfd) \ ((struct nlm_backend_data *)((bfd) -> xvec -> backend_data)) #define nlm_signature(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> signature : "") + (nlm_backend(bfd) -> signature) #define nlm_fixed_header_size(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> fixed_header_size : 0) + (nlm_backend(bfd) -> fixed_header_size) #define nlm_optional_prefix_size(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> optional_prefix_size : 0) + (nlm_backend(bfd) -> optional_prefix_size) #define nlm_architecture(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> arch : bfd_arch_unknown) + (nlm_backend(bfd) -> arch) #define nlm_machine(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> mach : 0) + (nlm_backend(bfd) -> mach) +#define nlm_no_uninitialized_data(bfd) \ + (nlm_backend(bfd) -> no_uninitialized_data) #define nlm_backend_object_p_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_backend_object_p : 0) + (nlm_backend(bfd) -> nlm_backend_object_p) #define nlm_write_prefix_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_write_prefix : 0) + (nlm_backend(bfd) -> nlm_write_prefix) #define nlm_read_reloc_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_read_reloc : 0) + (nlm_backend(bfd) -> nlm_read_reloc) #define nlm_mangle_relocs_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_mangle_relocs : 0) + (nlm_backend(bfd) -> nlm_mangle_relocs) #define nlm_read_import_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_read_import : 0) + (nlm_backend(bfd) -> nlm_read_import) #define nlm_write_import_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_write_import : 0) + (nlm_backend(bfd) -> nlm_write_import) #define nlm_set_public_section_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_set_public_section : 0) + (nlm_backend(bfd) -> nlm_set_public_section) #define nlm_get_public_offset_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_get_public_offset : 0) + (nlm_backend(bfd) -> nlm_get_public_offset) #define nlm_swap_fixed_header_in_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_swap_fhdr_in : 0) + (nlm_backend(bfd) -> nlm_swap_fhdr_in) #define nlm_swap_fixed_header_out_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_swap_fhdr_out : 0) + (nlm_backend(bfd) -> nlm_swap_fhdr_out) #define nlm_write_external_func(bfd) \ - (nlm_backend(bfd) ? nlm_backend(bfd) -> nlm_write_external : 0) + (nlm_backend(bfd) -> nlm_write_external) +#define nlm_write_export_func(bfd) \ + (nlm_backend(bfd) -> nlm_write_export) /* The NLM code, data, and uninitialized sections have no names defined in the NLM, but bfd wants to give them names, so use the traditional diff --git a/bfd/mipsbsd.c b/bfd/mipsbsd.c index 161e305..5d699aa 100644 --- a/bfd/mipsbsd.c +++ b/bfd/mipsbsd.c @@ -52,8 +52,14 @@ static void MY(choose_reloc_size) PARAMS ((bfd *abfd)); #define MY_write_object_contents MY(write_object_contents) static boolean MY(write_object_contents) PARAMS ((bfd *abfd)); -#define MY_reloc_howto_type_lookup MY(reloc_howto_type_lookup) -#define MY_canonicalize_reloc MY(canonicalize_reloc) +/* We can't use MY(x) here because it leads to a recursive call to CAT + when expanded inside JUMP_TABLE. */ +#define MY_bfd_reloc_type_lookup mipsbsd_reloc_howto_type_lookup +#define MY_canonicalize_reloc mipsbsd_canonicalize_reloc + +#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define MY_bfd_final_link _bfd_generic_final_link #define MY_backend_data &MY(backend_data) #define MY_BFD_TARGET @@ -177,14 +183,20 @@ MY(write_object_contents) (abfd) * 0x10000 and continue normally. This will compensate for the sign extension * when the low bits are added at run time. */ -bfd_reloc_status_type -mips_fix_hi16_s (abfd,reloc_entry,symbol,data,input_section,output_bfd) +static bfd_reloc_status_type +mips_fix_hi16_s PARAMS ((bfd *, arelent *, asymbol *, PTR, + asection *, bfd *, char **)); + +static bfd_reloc_status_type +mips_fix_hi16_s (abfd, reloc_entry, symbol, data, input_section, + output_bfd, error_message) bfd *abfd; arelent *reloc_entry; - struct symbol_cache_entry *symbol; + asymbol *symbol; PTR data; asection *input_section; bfd *output_bfd; + char **error_message; { bfd_vma relocation; @@ -212,21 +224,22 @@ mips_fix_hi16_s (abfd,reloc_entry,symbol,data,input_section,output_bfd) } static reloc_howto_type mips_howto_table_ext[] = { - {MIPS_RELOC_32, 0, 2, 32, false, 0, true, true, 0, + {MIPS_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", false, 0, 0xffffffff, false}, - {MIPS_RELOC_JMP, 2, 2, 26, false, 0, false, true, 0, + {MIPS_RELOC_JMP, 2, 2, 26, false, 0, complain_overflow_bitfield, 0, "MIPS_JMP", false, 0, 0x03ffffff, false}, - {MIPS_RELOC_WDISP16, 2, 1, 16, true, 0, false, true, 0, + {MIPS_RELOC_WDISP16, 2, 1, 16, true, 0, complain_overflow_signed, 0, "WDISP16", false, 0, 0x0000ffff, false}, - {MIPS_RELOC_HI16, 16, 1, 16, false, 0, false, true, 0, + {MIPS_RELOC_HI16, 16, 1, 16, false, 0, complain_overflow_bitfield, 0, "HI16", false, 0, 0x0000ffff, false}, - {MIPS_RELOC_HI16_S, 16, 1, 16, false, 0, false, true, mips_fix_hi16_s, - "HI16_S", false, 0, 0x0000ffff, false}, - {MIPS_RELOC_LO16, 0, 1, 16, false, 0, false, true, 0, + {MIPS_RELOC_HI16_S, 16, 1, 16, false, 0, complain_overflow_bitfield, + mips_fix_hi16_s, + "HI16_S", false, 0, 0x0000ffff, false}, + {MIPS_RELOC_LO16, 0, 1, 16, false, 0, complain_overflow_dont, 0, "LO16", false, 0, 0x0000ffff, false}, }; -static reloc_howto_type * +static const reloc_howto_type * MY(reloc_howto_type_lookup) (abfd, code) bfd *abfd; bfd_reloc_code_real_type code; @@ -258,7 +271,7 @@ MY(reloc_howto_type_lookup) (abfd, code) * This is just like the standard aoutx.h version but we need to do our * own mapping of external reloc type values to howto entries. */ -unsigned int +long MY(canonicalize_reloc)(abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; @@ -288,10 +301,10 @@ MY(canonicalize_reloc)(abfd, section, relptr, symbols) } if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols)) - return 0; + return -1; tblptr = section->relocation; if (!tblptr) - return 0; + return -1; /* fix up howto entries */ for (count = 0; count++ < section->reloc_count;) @@ -315,114 +328,60 @@ static CONST struct aout_backend_data MY(backend_data) = { bfd_target aout_mips_little_vec = { - "aout-mips-little", /* name */ + "a.out-mips-little", /* name */ bfd_target_aout_flavour, false, /* target byte order (little) */ false, /* target headers byte order (little) */ (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), + HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ MY_symbol_leading_char, ' ', /* ar_pad_char */ 15, /* ar_max_namelen */ 1, /* minimum alignment */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ + bfd_getl64, bfd_getl_signed_64, bfd_putl64, + bfd_getl32, bfd_getl_signed_32, bfd_putl32, + bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ + bfd_getl64, bfd_getl_signed_64, bfd_putl64, + bfd_getl32, bfd_getl_signed_32, bfd_putl32, + bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */ bfd_generic_archive_p, MY_core_file_p}, {bfd_false, MY_mkobject, /* bfd_set_format */ _bfd_generic_mkarchive, bfd_false}, {bfd_false, MY_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, - - MY_core_file_failing_command, - MY_core_file_failing_signal, - MY_core_file_matches_executable_p, - MY_slurp_armap, - MY_slurp_extended_name_table, - MY_truncate_arname, - MY_write_armap, - MY_close_and_cleanup, - MY_set_section_contents, - MY_get_section_contents, - MY_new_section_hook, - MY_get_symtab_upper_bound, - MY_get_symtab, - MY_get_reloc_upper_bound, - MY_canonicalize_reloc, - MY_make_empty_symbol, - MY_print_symbol, - MY_get_lineno, - MY_set_arch_mach, - MY_openr_next_archived_file, - MY_find_nearest_line, - MY_generic_stat_arch_elt, - MY_sizeof_headers, - MY_bfd_debug_info_start, - MY_bfd_debug_info_end, - MY_bfd_debug_info_accumulate, - bfd_generic_get_relocated_section_contents, - bfd_generic_relax_section, - bfd_generic_seclet_link, - MY_reloc_howto_type_lookup, - MY_make_debug_symbol, + JUMP_TABLE (MY), (PTR) MY_backend_data, }; bfd_target aout_mips_big_vec = { - "aout-mips-big", /* name */ + "a.out-mips-big", /* name */ bfd_target_aout_flavour, true, /* target byte order (big) */ true, /* target headers byte order (big) */ (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), + HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ MY_symbol_leading_char, ' ', /* ar_pad_char */ 15, /* ar_max_namelen */ 1, /* minimum alignment */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb32, bfd_getb_signed_32, bfd_putb32, + bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb32, bfd_getb_signed_32, bfd_putb32, + bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */ bfd_generic_archive_p, MY_core_file_p}, {bfd_false, MY_mkobject, /* bfd_set_format */ _bfd_generic_mkarchive, bfd_false}, {bfd_false, MY_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, - - MY_core_file_failing_command, - MY_core_file_failing_signal, - MY_core_file_matches_executable_p, - MY_slurp_armap, - MY_slurp_extended_name_table, - MY_truncate_arname, - MY_write_armap, - MY_close_and_cleanup, - MY_set_section_contents, - MY_get_section_contents, - MY_new_section_hook, - MY_get_symtab_upper_bound, - MY_get_symtab, - MY_get_reloc_upper_bound, - MY_canonicalize_reloc, - MY_make_empty_symbol, - MY_print_symbol, - MY_get_lineno, - MY_set_arch_mach, - MY_openr_next_archived_file, - MY_find_nearest_line, - MY_generic_stat_arch_elt, - MY_sizeof_headers, - MY_bfd_debug_info_start, - MY_bfd_debug_info_end, - MY_bfd_debug_info_accumulate, - bfd_generic_get_relocated_section_contents, - bfd_generic_relax_section, - bfd_generic_seclet_link, - MY_reloc_howto_type_lookup, - MY_make_debug_symbol, + JUMP_TABLE (MY), (PTR) MY_backend_data, }; diff --git a/bfd/nlm32-sparc.c b/bfd/nlm32-sparc.c index b7e5543..8c97cc5 100644 --- a/bfd/nlm32-sparc.c +++ b/bfd/nlm32-sparc.c @@ -122,9 +122,7 @@ nlm_sparc_read_reloc (abfd, sym, secp, rel) asection **secp; arelent *rel; { - bfd_byte temp[4]; bfd_vma val, addend; - const char *name; int index; unsigned int type; struct nlm32_sparc_reloc_ext tmp_reloc; diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h index eb07c9a..a05c5f1 100644 --- a/bfd/nlmcode.h +++ b/bfd/nlmcode.h @@ -91,7 +91,8 @@ static int nlm_external_reloc_compare #endif bfd_target * -DEFUN (nlm_object_p, (abfd), bfd * abfd) +nlm_object_p (abfd) + bfd *abfd; { struct nlm_obj_tdata *preserved_tdata = nlm_tdata (abfd); boolean (*backend_object_p) PARAMS ((bfd *)); @@ -105,7 +106,7 @@ DEFUN (nlm_object_p, (abfd), bfd * abfd) backend_object_p = nlm_backend_object_p_func (abfd); if (backend_object_p) { - if (! (*backend_object_p) (abfd)) + if (!(*backend_object_p) (abfd)) goto got_wrong_format_error; } @@ -165,18 +166,18 @@ DEFUN (nlm_object_p, (abfd), bfd * abfd) if (!nlm_swap_variable_header_in (abfd) || !nlm_swap_auxiliary_headers_in (abfd) || !add_bfd_section (abfd, NLM_CODE_NAME, - i_fxdhdrp -> codeImageOffset, - i_fxdhdrp -> codeImageSize, - (SEC_CODE | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_RELOC)) + i_fxdhdrp->codeImageOffset, + i_fxdhdrp->codeImageSize, + (SEC_CODE | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS + | SEC_RELOC)) || !add_bfd_section (abfd, NLM_INITIALIZED_DATA_NAME, - i_fxdhdrp -> dataImageOffset, - i_fxdhdrp -> dataImageSize, - (SEC_DATA | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_RELOC)) + i_fxdhdrp->dataImageOffset, + i_fxdhdrp->dataImageSize, + (SEC_DATA | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS + | SEC_RELOC)) || !add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME, (file_ptr) 0, - i_fxdhdrp -> uninitializedDataSize, + i_fxdhdrp->uninitializedDataSize, SEC_ALLOC)) goto got_wrong_format_error; @@ -194,11 +195,11 @@ DEFUN (nlm_object_p, (abfd), bfd * abfd) if (x_fxdhdr != NULL) free (x_fxdhdr); - return (abfd -> xvec); + return (abfd->xvec); - got_wrong_format_error: +got_wrong_format_error: bfd_set_error (bfd_error_wrong_format); - got_no_match: +got_no_match: nlm_tdata (abfd) = preserved_tdata; if (x_fxdhdr != NULL) free (x_fxdhdr); @@ -208,12 +209,12 @@ DEFUN (nlm_object_p, (abfd), bfd * abfd) /* Add a section to the bfd. */ static boolean -DEFUN (add_bfd_section, (abfd, name, offset, size, flags), - bfd *abfd AND - char *name AND - file_ptr offset AND - bfd_size_type size AND - flagword flags) +add_bfd_section (abfd, name, offset, size, flags) + bfd *abfd; + char *name; + file_ptr offset; + bfd_size_type size; + flagword flags; { asection *newsect; @@ -222,11 +223,11 @@ DEFUN (add_bfd_section, (abfd, name, offset, size, flags), { return (false); } - newsect -> vma = 0; /* NLM's are relocatable. */ - newsect -> _raw_size = size; - newsect -> filepos = offset; - newsect -> flags = flags; - newsect -> alignment_power = bfd_log2 (0); /* FIXME */ + newsect->vma = 0; /* NLM's are relocatable. */ + newsect->_raw_size = size; + newsect->filepos = offset; + newsect->flags = flags; + newsect->alignment_power = bfd_log2 (0); /* FIXME */ return (true); } @@ -234,25 +235,25 @@ DEFUN (add_bfd_section, (abfd, name, offset, size, flags), exist in the NLM, and must exist in the order they are read here. */ static boolean -DEFUN (nlm_swap_variable_header_in, (abfd), - bfd * abfd) +nlm_swap_variable_header_in (abfd) + bfd *abfd; { - unsigned char temp [NLM_TARGET_LONG_SIZE]; + unsigned char temp[NLM_TARGET_LONG_SIZE]; /* Read the description length and text members. */ - if (bfd_read ((PTR) &nlm_variable_header (abfd) -> descriptionLength, - sizeof (nlm_variable_header (abfd) -> descriptionLength), + if (bfd_read ((PTR) & nlm_variable_header (abfd)->descriptionLength, + sizeof (nlm_variable_header (abfd)->descriptionLength), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> descriptionLength)) + sizeof (nlm_variable_header (abfd)->descriptionLength)) { bfd_set_error (bfd_error_system_call); return (false); } - if (bfd_read ((PTR) nlm_variable_header (abfd) -> descriptionText, - nlm_variable_header (abfd) -> descriptionLength + 1, + if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText, + nlm_variable_header (abfd)->descriptionLength + 1, 1, abfd) != - nlm_variable_header (abfd) -> descriptionLength + 1) + nlm_variable_header (abfd)->descriptionLength + 1) { bfd_set_error (bfd_error_system_call); return (false); @@ -265,7 +266,7 @@ DEFUN (nlm_swap_variable_header_in, (abfd), bfd_set_error (bfd_error_system_call); return (false); } - nlm_variable_header (abfd) -> stackSize = get_word (abfd, (bfd_byte *) temp); + nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp); /* Read and convert the reserved field. */ @@ -274,14 +275,14 @@ DEFUN (nlm_swap_variable_header_in, (abfd), bfd_set_error (bfd_error_system_call); return (false); } - nlm_variable_header (abfd) -> reserved = get_word (abfd, (bfd_byte *) temp); + nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp); /* Read the oldThreadName field. This field is a fixed length string. */ - if (bfd_read ((PTR) nlm_variable_header (abfd) -> oldThreadName, - sizeof (nlm_variable_header (abfd) -> oldThreadName), + if (bfd_read ((PTR) nlm_variable_header (abfd)->oldThreadName, + sizeof (nlm_variable_header (abfd)->oldThreadName), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> oldThreadName)) + sizeof (nlm_variable_header (abfd)->oldThreadName)) { bfd_set_error (bfd_error_system_call); return (false); @@ -289,18 +290,18 @@ DEFUN (nlm_swap_variable_header_in, (abfd), /* Read the screen name length and text members. */ - if (bfd_read ((PTR) &nlm_variable_header (abfd) -> screenNameLength, - sizeof (nlm_variable_header (abfd) -> screenNameLength), + if (bfd_read ((PTR) & nlm_variable_header (abfd)->screenNameLength, + sizeof (nlm_variable_header (abfd)->screenNameLength), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> screenNameLength)) + sizeof (nlm_variable_header (abfd)->screenNameLength)) { bfd_set_error (bfd_error_system_call); return (false); } - if (bfd_read ((PTR) nlm_variable_header (abfd) -> screenName, - nlm_variable_header (abfd) -> screenNameLength + 1, + if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName, + nlm_variable_header (abfd)->screenNameLength + 1, 1, abfd) != - nlm_variable_header (abfd) -> screenNameLength + 1) + nlm_variable_header (abfd)->screenNameLength + 1) { bfd_set_error (bfd_error_system_call); return (false); @@ -308,18 +309,18 @@ DEFUN (nlm_swap_variable_header_in, (abfd), /* Read the thread name length and text members. */ - if (bfd_read ((PTR) &nlm_variable_header (abfd) -> threadNameLength, - sizeof (nlm_variable_header (abfd) -> threadNameLength), + if (bfd_read ((PTR) & nlm_variable_header (abfd)->threadNameLength, + sizeof (nlm_variable_header (abfd)->threadNameLength), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> threadNameLength)) + sizeof (nlm_variable_header (abfd)->threadNameLength)) { bfd_set_error (bfd_error_system_call); return (false); } - if (bfd_read ((PTR) nlm_variable_header (abfd) -> threadName, - nlm_variable_header (abfd) -> threadNameLength + 1, + if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName, + nlm_variable_header (abfd)->threadNameLength + 1, 1, abfd) != - nlm_variable_header (abfd) -> threadNameLength + 1) + nlm_variable_header (abfd)->threadNameLength + 1) { bfd_set_error (bfd_error_system_call); return (false); @@ -331,25 +332,25 @@ DEFUN (nlm_swap_variable_header_in, (abfd), exist in the NLM, and must exist in this order. */ static boolean -DEFUN (nlm_swap_variable_header_out, (abfd), - bfd * abfd) +nlm_swap_variable_header_out (abfd) + bfd *abfd; { - unsigned char temp [NLM_TARGET_LONG_SIZE]; + unsigned char temp[NLM_TARGET_LONG_SIZE]; /* Write the description length and text members. */ - if (bfd_write ((PTR) &nlm_variable_header (abfd) -> descriptionLength, - sizeof (nlm_variable_header (abfd) -> descriptionLength), + if (bfd_write ((PTR) & nlm_variable_header (abfd)->descriptionLength, + sizeof (nlm_variable_header (abfd)->descriptionLength), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> descriptionLength)) + sizeof (nlm_variable_header (abfd)->descriptionLength)) { bfd_set_error (bfd_error_system_call); return (false); } - if (bfd_write ((PTR) nlm_variable_header (abfd) -> descriptionText, - nlm_variable_header (abfd) -> descriptionLength + 1, + if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText, + nlm_variable_header (abfd)->descriptionLength + 1, 1, abfd) != - nlm_variable_header (abfd) -> descriptionLength + 1) + nlm_variable_header (abfd)->descriptionLength + 1) { bfd_set_error (bfd_error_system_call); return (false); @@ -357,7 +358,7 @@ DEFUN (nlm_swap_variable_header_out, (abfd), /* Convert and write the stackSize field. */ - put_word (abfd, (bfd_vma) nlm_variable_header (abfd) -> stackSize, + put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize, (bfd_byte *) temp); if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) { @@ -367,7 +368,7 @@ DEFUN (nlm_swap_variable_header_out, (abfd), /* Convert and write the reserved field. */ - put_word (abfd, (bfd_vma) nlm_variable_header (abfd) -> reserved, + put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved, (bfd_byte *) temp); if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) { @@ -377,10 +378,10 @@ DEFUN (nlm_swap_variable_header_out, (abfd), /* Write the oldThreadName field. This field is a fixed length string. */ - if (bfd_write ((PTR) nlm_variable_header (abfd) -> oldThreadName, - sizeof (nlm_variable_header (abfd) -> oldThreadName), + if (bfd_write ((PTR) nlm_variable_header (abfd)->oldThreadName, + sizeof (nlm_variable_header (abfd)->oldThreadName), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> oldThreadName)) + sizeof (nlm_variable_header (abfd)->oldThreadName)) { bfd_set_error (bfd_error_system_call); return (false); @@ -388,18 +389,18 @@ DEFUN (nlm_swap_variable_header_out, (abfd), /* Write the screen name length and text members. */ - if (bfd_write ((PTR) &nlm_variable_header (abfd) -> screenNameLength, - sizeof (nlm_variable_header (abfd) -> screenNameLength), + if (bfd_write ((PTR) & nlm_variable_header (abfd)->screenNameLength, + sizeof (nlm_variable_header (abfd)->screenNameLength), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> screenNameLength)) + sizeof (nlm_variable_header (abfd)->screenNameLength)) { bfd_set_error (bfd_error_system_call); return (false); } - if (bfd_write ((PTR) nlm_variable_header (abfd) -> screenName, - nlm_variable_header (abfd) -> screenNameLength + 1, + if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName, + nlm_variable_header (abfd)->screenNameLength + 1, 1, abfd) != - nlm_variable_header (abfd) -> screenNameLength + 1) + nlm_variable_header (abfd)->screenNameLength + 1) { bfd_set_error (bfd_error_system_call); return (false); @@ -407,18 +408,18 @@ DEFUN (nlm_swap_variable_header_out, (abfd), /* Write the thread name length and text members. */ - if (bfd_write ((PTR) &nlm_variable_header (abfd) -> threadNameLength, - sizeof (nlm_variable_header (abfd) -> threadNameLength), + if (bfd_write ((PTR) & nlm_variable_header (abfd)->threadNameLength, + sizeof (nlm_variable_header (abfd)->threadNameLength), 1, abfd) != - sizeof (nlm_variable_header (abfd) -> threadNameLength)) + sizeof (nlm_variable_header (abfd)->threadNameLength)) { bfd_set_error (bfd_error_system_call); return (false); } - if (bfd_write ((PTR) nlm_variable_header (abfd) -> threadName, - nlm_variable_header (abfd) -> threadNameLength + 1, + if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName, + nlm_variable_header (abfd)->threadNameLength + 1, 1, abfd) != - nlm_variable_header (abfd) -> threadNameLength + 1) + nlm_variable_header (abfd)->threadNameLength + 1) { bfd_set_error (bfd_error_system_call); return (false); @@ -436,10 +437,10 @@ DEFUN (nlm_swap_variable_header_out, (abfd), recognize it. */ static boolean -DEFUN (nlm_swap_auxiliary_headers_in, (abfd), - bfd * abfd) +nlm_swap_auxiliary_headers_in (abfd) + bfd *abfd; { - char tempstr [16]; + char tempstr[16]; long position; for (;;) @@ -459,110 +460,110 @@ DEFUN (nlm_swap_auxiliary_headers_in, (abfd), if (strncmp (tempstr, "VeRsIoN#", 8) == 0) { Nlm_External_Version_Header thdr; - if (bfd_read ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) + if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) { bfd_set_error (bfd_error_system_call); return (false); } - memcpy (nlm_version_header (abfd) -> stamp, thdr.stamp, + memcpy (nlm_version_header (abfd)->stamp, thdr.stamp, sizeof (thdr.stamp)); - nlm_version_header (abfd) -> majorVersion = + nlm_version_header (abfd)->majorVersion = get_word (abfd, (bfd_byte *) thdr.majorVersion); - nlm_version_header (abfd) -> minorVersion = + nlm_version_header (abfd)->minorVersion = get_word (abfd, (bfd_byte *) thdr.minorVersion); - nlm_version_header (abfd) -> revision = + nlm_version_header (abfd)->revision = get_word (abfd, (bfd_byte *) thdr.revision); - nlm_version_header (abfd) -> year = + nlm_version_header (abfd)->year = get_word (abfd, (bfd_byte *) thdr.year); - nlm_version_header (abfd) -> month = + nlm_version_header (abfd)->month = get_word (abfd, (bfd_byte *) thdr.month); - nlm_version_header (abfd) -> day = + nlm_version_header (abfd)->day = get_word (abfd, (bfd_byte *) thdr.day); } else if (strncmp (tempstr, "MeSsAgEs", 8) == 0) { Nlm_External_Extended_Header thdr; - if (bfd_read ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) + if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) { bfd_set_error (bfd_error_system_call); return (false); } - memcpy (nlm_extended_header (abfd) -> stamp, thdr.stamp, + memcpy (nlm_extended_header (abfd)->stamp, thdr.stamp, sizeof (thdr.stamp)); - nlm_extended_header (abfd) -> languageID = + nlm_extended_header (abfd)->languageID = get_word (abfd, (bfd_byte *) thdr.languageID); - nlm_extended_header (abfd) -> messageFileOffset = + nlm_extended_header (abfd)->messageFileOffset = get_word (abfd, (bfd_byte *) thdr.messageFileOffset); - nlm_extended_header (abfd) -> messageFileLength = + nlm_extended_header (abfd)->messageFileLength = get_word (abfd, (bfd_byte *) thdr.messageFileLength); - nlm_extended_header (abfd) -> messageCount = + nlm_extended_header (abfd)->messageCount = get_word (abfd, (bfd_byte *) thdr.messageCount); - nlm_extended_header (abfd) -> helpFileOffset = + nlm_extended_header (abfd)->helpFileOffset = get_word (abfd, (bfd_byte *) thdr.helpFileOffset); - nlm_extended_header (abfd) -> helpFileLength = + nlm_extended_header (abfd)->helpFileLength = get_word (abfd, (bfd_byte *) thdr.helpFileLength); - nlm_extended_header (abfd) -> RPCDataOffset = + nlm_extended_header (abfd)->RPCDataOffset = get_word (abfd, (bfd_byte *) thdr.RPCDataOffset); - nlm_extended_header (abfd) -> RPCDataLength = + nlm_extended_header (abfd)->RPCDataLength = get_word (abfd, (bfd_byte *) thdr.RPCDataLength); - nlm_extended_header (abfd) -> sharedCodeOffset = + nlm_extended_header (abfd)->sharedCodeOffset = get_word (abfd, (bfd_byte *) thdr.sharedCodeOffset); - nlm_extended_header (abfd) -> sharedCodeLength = + nlm_extended_header (abfd)->sharedCodeLength = get_word (abfd, (bfd_byte *) thdr.sharedCodeLength); - nlm_extended_header (abfd) -> sharedDataOffset = + nlm_extended_header (abfd)->sharedDataOffset = get_word (abfd, (bfd_byte *) thdr.sharedDataOffset); - nlm_extended_header (abfd) -> sharedDataLength = + nlm_extended_header (abfd)->sharedDataLength = get_word (abfd, (bfd_byte *) thdr.sharedDataLength); - nlm_extended_header (abfd) -> sharedRelocationFixupOffset = + nlm_extended_header (abfd)->sharedRelocationFixupOffset = get_word (abfd, (bfd_byte *) thdr.sharedRelocationFixupOffset); - nlm_extended_header (abfd) -> sharedRelocationFixupCount = + nlm_extended_header (abfd)->sharedRelocationFixupCount = get_word (abfd, (bfd_byte *) thdr.sharedRelocationFixupCount); - nlm_extended_header (abfd) -> sharedExternalReferenceOffset = + nlm_extended_header (abfd)->sharedExternalReferenceOffset = get_word (abfd, (bfd_byte *) thdr.sharedExternalReferenceOffset); - nlm_extended_header (abfd) -> sharedExternalReferenceCount = + nlm_extended_header (abfd)->sharedExternalReferenceCount = get_word (abfd, (bfd_byte *) thdr.sharedExternalReferenceCount); - nlm_extended_header (abfd) -> sharedPublicsOffset = + nlm_extended_header (abfd)->sharedPublicsOffset = get_word (abfd, (bfd_byte *) thdr.sharedPublicsOffset); - nlm_extended_header (abfd) -> sharedPublicsCount = + nlm_extended_header (abfd)->sharedPublicsCount = get_word (abfd, (bfd_byte *) thdr.sharedPublicsCount); - nlm_extended_header (abfd) -> sharedDebugRecordOffset = + nlm_extended_header (abfd)->sharedDebugRecordOffset = get_word (abfd, (bfd_byte *) thdr.sharedDebugRecordOffset); - nlm_extended_header (abfd) -> sharedDebugRecordCount = + nlm_extended_header (abfd)->sharedDebugRecordCount = get_word (abfd, (bfd_byte *) thdr.sharedDebugRecordCount); - nlm_extended_header (abfd) -> SharedInitializationOffset = + nlm_extended_header (abfd)->SharedInitializationOffset = get_word (abfd, (bfd_byte *) thdr.sharedInitializationOffset); - nlm_extended_header (abfd) -> SharedExitProcedureOffset = + nlm_extended_header (abfd)->SharedExitProcedureOffset = get_word (abfd, (bfd_byte *) thdr.SharedExitProcedureOffset); - nlm_extended_header (abfd) -> productID = + nlm_extended_header (abfd)->productID = get_word (abfd, (bfd_byte *) thdr.productID); - nlm_extended_header (abfd) -> reserved0 = + nlm_extended_header (abfd)->reserved0 = get_word (abfd, (bfd_byte *) thdr.reserved0); - nlm_extended_header (abfd) -> reserved1 = + nlm_extended_header (abfd)->reserved1 = get_word (abfd, (bfd_byte *) thdr.reserved1); - nlm_extended_header (abfd) -> reserved2 = + nlm_extended_header (abfd)->reserved2 = get_word (abfd, (bfd_byte *) thdr.reserved2); - nlm_extended_header (abfd) -> reserved3 = + nlm_extended_header (abfd)->reserved3 = get_word (abfd, (bfd_byte *) thdr.reserved3); - nlm_extended_header (abfd) -> reserved4 = + nlm_extended_header (abfd)->reserved4 = get_word (abfd, (bfd_byte *) thdr.reserved4); - nlm_extended_header (abfd) -> reserved5 = + nlm_extended_header (abfd)->reserved5 = get_word (abfd, (bfd_byte *) thdr.reserved5); } else if (strncmp (tempstr, "CuStHeAd", 8) == 0) { Nlm_External_Custom_Header thdr; - if (bfd_read ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) + if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) { bfd_set_error (bfd_error_system_call); return (false); } - memcpy (nlm_custom_header (abfd) -> stamp, thdr.stamp, + memcpy (nlm_custom_header (abfd)->stamp, thdr.stamp, sizeof (thdr.stamp)); - nlm_custom_header (abfd) -> dataLength = + nlm_custom_header (abfd)->dataLength = get_word (abfd, (bfd_byte *) thdr.dataLength); - nlm_custom_header (abfd) -> debugRecOffset = + nlm_custom_header (abfd)->debugRecOffset = get_word (abfd, (bfd_byte *) thdr.debugRecOffset); - nlm_custom_header (abfd) -> debugRecLength = + nlm_custom_header (abfd)->debugRecLength = get_word (abfd, (bfd_byte *) thdr.debugRecLength); } else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0) @@ -575,18 +576,18 @@ DEFUN (nlm_swap_auxiliary_headers_in, (abfd), bfd_set_error (bfd_error_system_call); return (false); } - if (bfd_read ((PTR) &(nlm_copyright_header (abfd) - ->copyrightMessageLength), + if (bfd_read ((PTR) & (nlm_copyright_header (abfd) + ->copyrightMessageLength), 1, 1, abfd) != 1) { bfd_set_error (bfd_error_system_call); return (false); } /* The copyright message is a variable length string. */ - if (bfd_read ((PTR) nlm_copyright_header (abfd) -> copyrightMessage, - nlm_copyright_header (abfd) -> copyrightMessageLength + 1, + if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage, + nlm_copyright_header (abfd)->copyrightMessageLength + 1, 1, abfd) != - nlm_copyright_header (abfd) -> copyrightMessageLength + 1) + nlm_copyright_header (abfd)->copyrightMessageLength + 1) { bfd_set_error (bfd_error_system_call); return (false); @@ -630,23 +631,23 @@ nlm_swap_auxiliary_headers_out (abfd) Nlm_External_Version_Header thdr; memcpy (thdr.stamp, "VeRsIoN#", 8); - put_word (abfd, (bfd_vma) nlm_version_header (abfd) -> majorVersion, + put_word (abfd, (bfd_vma) nlm_version_header (abfd)->majorVersion, (bfd_byte *) thdr.majorVersion); - put_word (abfd, (bfd_vma) nlm_version_header (abfd) -> minorVersion, + put_word (abfd, (bfd_vma) nlm_version_header (abfd)->minorVersion, (bfd_byte *) thdr.minorVersion); - put_word (abfd, (bfd_vma) nlm_version_header (abfd) -> revision, + put_word (abfd, (bfd_vma) nlm_version_header (abfd)->revision, (bfd_byte *) thdr.revision); - put_word (abfd, (bfd_vma) nlm_version_header (abfd) -> year, + put_word (abfd, (bfd_vma) nlm_version_header (abfd)->year, (bfd_byte *) thdr.year); - put_word (abfd, (bfd_vma) nlm_version_header (abfd) -> month, + put_word (abfd, (bfd_vma) nlm_version_header (abfd)->month, (bfd_byte *) thdr.month); - put_word (abfd, (bfd_vma) nlm_version_header (abfd) -> day, + put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day, (bfd_byte *) thdr.day); - if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) + { + bfd_set_error (bfd_error_system_call); + return false; + } } /* Write out the extended header if there is one. */ @@ -657,97 +658,97 @@ nlm_swap_auxiliary_headers_out (abfd) memcpy (thdr.stamp, "MeSsAgEs", 8); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> languageID, + (bfd_vma) nlm_extended_header (abfd)->languageID, (bfd_byte *) thdr.languageID); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> messageFileOffset, + (bfd_vma) nlm_extended_header (abfd)->messageFileOffset, (bfd_byte *) thdr.messageFileOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> messageFileLength, + (bfd_vma) nlm_extended_header (abfd)->messageFileLength, (bfd_byte *) thdr.messageFileLength); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> messageCount, + (bfd_vma) nlm_extended_header (abfd)->messageCount, (bfd_byte *) thdr.messageCount); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> helpFileOffset, + (bfd_vma) nlm_extended_header (abfd)->helpFileOffset, (bfd_byte *) thdr.helpFileOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> helpFileLength, + (bfd_vma) nlm_extended_header (abfd)->helpFileLength, (bfd_byte *) thdr.helpFileLength); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> RPCDataOffset, + (bfd_vma) nlm_extended_header (abfd)->RPCDataOffset, (bfd_byte *) thdr.RPCDataOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> RPCDataLength, + (bfd_vma) nlm_extended_header (abfd)->RPCDataLength, (bfd_byte *) thdr.RPCDataLength); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedCodeOffset, + (bfd_vma) nlm_extended_header (abfd)->sharedCodeOffset, (bfd_byte *) thdr.sharedCodeOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedCodeLength, + (bfd_vma) nlm_extended_header (abfd)->sharedCodeLength, (bfd_byte *) thdr.sharedCodeLength); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedDataOffset, + (bfd_vma) nlm_extended_header (abfd)->sharedDataOffset, (bfd_byte *) thdr.sharedDataOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedDataLength, + (bfd_vma) nlm_extended_header (abfd)->sharedDataLength, (bfd_byte *) thdr.sharedDataLength); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedRelocationFixupOffset, + (bfd_vma) nlm_extended_header (abfd)->sharedRelocationFixupOffset, (bfd_byte *) thdr.sharedRelocationFixupOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedRelocationFixupCount, + (bfd_vma) nlm_extended_header (abfd)->sharedRelocationFixupCount, (bfd_byte *) thdr.sharedRelocationFixupCount); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedExternalReferenceOffset, + (bfd_vma) nlm_extended_header (abfd)->sharedExternalReferenceOffset, (bfd_byte *) thdr.sharedExternalReferenceOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedExternalReferenceCount, + (bfd_vma) nlm_extended_header (abfd)->sharedExternalReferenceCount, (bfd_byte *) thdr.sharedExternalReferenceCount); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedPublicsOffset, + (bfd_vma) nlm_extended_header (abfd)->sharedPublicsOffset, (bfd_byte *) thdr.sharedPublicsOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedPublicsCount, + (bfd_vma) nlm_extended_header (abfd)->sharedPublicsCount, (bfd_byte *) thdr.sharedPublicsCount); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedDebugRecordOffset, + (bfd_vma) nlm_extended_header (abfd)->sharedDebugRecordOffset, (bfd_byte *) thdr.sharedDebugRecordOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> sharedDebugRecordCount, + (bfd_vma) nlm_extended_header (abfd)->sharedDebugRecordCount, (bfd_byte *) thdr.sharedDebugRecordCount); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> SharedInitializationOffset, + (bfd_vma) nlm_extended_header (abfd)->SharedInitializationOffset, (bfd_byte *) thdr.sharedInitializationOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> SharedExitProcedureOffset, + (bfd_vma) nlm_extended_header (abfd)->SharedExitProcedureOffset, (bfd_byte *) thdr.SharedExitProcedureOffset); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> productID, + (bfd_vma) nlm_extended_header (abfd)->productID, (bfd_byte *) thdr.productID); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> reserved0, + (bfd_vma) nlm_extended_header (abfd)->reserved0, (bfd_byte *) thdr.reserved0); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> reserved1, + (bfd_vma) nlm_extended_header (abfd)->reserved1, (bfd_byte *) thdr.reserved1); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> reserved2, + (bfd_vma) nlm_extended_header (abfd)->reserved2, (bfd_byte *) thdr.reserved2); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> reserved3, + (bfd_vma) nlm_extended_header (abfd)->reserved3, (bfd_byte *) thdr.reserved3); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> reserved4, + (bfd_vma) nlm_extended_header (abfd)->reserved4, (bfd_byte *) thdr.reserved4); put_word (abfd, - (bfd_vma) nlm_extended_header (abfd) -> reserved5, + (bfd_vma) nlm_extended_header (abfd)->reserved5, (bfd_byte *) thdr.reserved5); - if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) + { + bfd_set_error (bfd_error_system_call); + return false; + } } /* Write out the custom header if there is one. */ @@ -758,20 +759,20 @@ nlm_swap_auxiliary_headers_out (abfd) /* Right now we assume the custom header is always the suggested format for alternate debugging records. */ - BFD_ASSERT (nlm_custom_header (abfd) -> dataLength == 8); + BFD_ASSERT (nlm_custom_header (abfd)->dataLength == 8); memcpy (thdr.stamp, "CuStHeAd", 8); - put_word (abfd, (bfd_vma) nlm_custom_header (abfd) -> dataLength, + put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->dataLength, (bfd_byte *) thdr.dataLength); - put_word (abfd, (bfd_vma) nlm_custom_header (abfd) -> debugRecOffset, + put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->debugRecOffset, (bfd_byte *) thdr.debugRecOffset); - put_word (abfd, (bfd_vma) nlm_custom_header (abfd) -> debugRecLength, + put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->debugRecLength, (bfd_byte *) thdr.debugRecLength); - if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) - { - bfd_set_error (bfd_error_system_call); - return false; - } + if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr)) + { + bfd_set_error (bfd_error_system_call); + return false; + } } /* Write out the copyright header if there is one. */ @@ -795,10 +796,10 @@ nlm_swap_auxiliary_headers_out (abfd) return false; } /* The copyright message is a variable length string. */ - if (bfd_write ((PTR) nlm_copyright_header (abfd) -> copyrightMessage, - nlm_copyright_header (abfd) -> copyrightMessageLength + 1, + if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage, + nlm_copyright_header (abfd)->copyrightMessageLength + 1, 1, abfd) != - nlm_copyright_header (abfd) -> copyrightMessageLength + 1) + nlm_copyright_header (abfd)->copyrightMessageLength + 1) { bfd_set_error (bfd_error_system_call); return false; @@ -817,17 +818,18 @@ nlm_swap_auxiliary_headers_out (abfd) the count plus 1, since we will NULL terminate the vector allocated based on this size. */ -unsigned int -DEFUN (nlm_get_symtab_upper_bound, (abfd), bfd * abfd) +long +nlm_get_symtab_upper_bound (abfd) + bfd *abfd; { Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */ - unsigned int symcount; - unsigned int symtab_size = 0; + long symcount; + long symtab_size = 0; i_fxdhdrp = nlm_fixed_header (abfd); - symcount = (i_fxdhdrp -> numberOfPublics - + i_fxdhdrp -> numberOfDebugRecords - + i_fxdhdrp -> numberOfExternalReferences); + symcount = (i_fxdhdrp->numberOfPublics + + i_fxdhdrp->numberOfDebugRecords + + i_fxdhdrp->numberOfExternalReferences); symtab_size = (symcount + 1) * (sizeof (asymbol)); return (symtab_size); } @@ -835,7 +837,7 @@ DEFUN (nlm_get_symtab_upper_bound, (abfd), bfd * abfd) /* Note that bfd_get_symcount is guaranteed to be zero if slurping the symbol table fails. */ -unsigned int +long nlm_get_symtab (abfd, alocation) bfd *abfd; asymbol **alocation; @@ -844,7 +846,7 @@ nlm_get_symtab (abfd, alocation) bfd_size_type counter = 0; if (nlm_slurp_symbol_table (abfd) == false) - return 0; + return -1; symbase = nlm_get_symbols (abfd); while (counter < bfd_get_symcount (abfd)) { @@ -860,7 +862,7 @@ nlm_get_symtab (abfd, alocation) asymbol * nlm_make_empty_symbol (abfd) - bfd * abfd; + bfd *abfd; { nlm_symbol_type *new; @@ -874,9 +876,9 @@ nlm_make_empty_symbol (abfd) void nlm_get_symbol_info (ignore_abfd, symbol, ret) - bfd * ignore_abfd; - asymbol * symbol; - symbol_info * ret; + bfd *ignore_abfd; + asymbol *symbol; + symbol_info *ret; { bfd_symbol_info (symbol, ret); } @@ -897,13 +899,13 @@ nlm_print_symbol (abfd, afile, symbol, how) case bfd_print_symbol_name: case bfd_print_symbol_more: if (symbol->name) - fprintf (file,"%s", symbol->name); + fprintf (file, "%s", symbol->name); break; case bfd_print_symbol_all: bfd_print_symbol_vandf ((PTR) file, symbol); fprintf (file, " %-5s", symbol->section->name); if (symbol->name) - fprintf (file," %s", symbol->name); + fprintf (file, " %s", symbol->name); break; } } @@ -933,11 +935,11 @@ nlm_slurp_symbol_table (abfd) bfd *abfd; { Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */ - bfd_size_type totsymcount; /* Number of NLM symbols */ - bfd_size_type symcount; /* Counter of NLM symbols */ - nlm_symbol_type *sym; /* Pointer to current bfd symbol */ - unsigned char symlength; /* Symbol length read into here */ - unsigned char symtype; /* Type of debugging symbol */ + bfd_size_type totsymcount; /* Number of NLM symbols */ + bfd_size_type symcount; /* Counter of NLM symbols */ + nlm_symbol_type *sym; /* Pointer to current bfd symbol */ + unsigned char symlength; /* Symbol length read into here */ + unsigned char symtype; /* Type of debugging symbol */ bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Symbol offsets read into here */ boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *)); boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *)); @@ -953,17 +955,17 @@ nlm_slurp_symbol_table (abfd) use all the NLM symbols, so there will be no space left over at the end. When we have all the symbols, we build the caller's pointer vector. */ - abfd -> symcount = 0; + abfd->symcount = 0; i_fxdhdrp = nlm_fixed_header (abfd); - totsymcount = (i_fxdhdrp -> numberOfPublics - + i_fxdhdrp -> numberOfDebugRecords - + i_fxdhdrp -> numberOfExternalReferences); + totsymcount = (i_fxdhdrp->numberOfPublics + + i_fxdhdrp->numberOfDebugRecords + + i_fxdhdrp->numberOfExternalReferences); if (totsymcount == 0) { return (true); } - if (bfd_seek (abfd, i_fxdhdrp -> publicsOffset, SEEK_SET) == -1) + if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) == -1) { bfd_set_error (bfd_error_system_call); return (false); @@ -983,37 +985,37 @@ nlm_slurp_symbol_table (abfd) were read. */ set_public_section_func = nlm_set_public_section_func (abfd); - symcount = i_fxdhdrp -> numberOfPublics; - while (abfd -> symcount < symcount) + symcount = i_fxdhdrp->numberOfPublics; + while (abfd->symcount < symcount) { - if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd) + if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd) != sizeof (symlength)) { bfd_set_error (bfd_error_system_call); return (false); } - sym -> symbol.the_bfd = abfd; - sym -> symbol.name = bfd_alloc (abfd, symlength + 1); - if (!sym -> symbol.name) + sym->symbol.the_bfd = abfd; + sym->symbol.name = bfd_alloc (abfd, symlength + 1); + if (!sym->symbol.name) { bfd_set_error (bfd_error_no_memory); return false; } - if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd) + if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) != symlength) { bfd_set_error (bfd_error_system_call); return (false); } /* Cast away const. */ - ((char *) (sym -> symbol.name))[symlength] = '\0'; + ((char *) (sym->symbol.name))[symlength] = '\0'; if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)) { bfd_set_error (bfd_error_system_call); return (false); } - sym -> symbol.flags = BSF_GLOBAL | BSF_EXPORT; - sym -> symbol.value = get_word (abfd, temp); + sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT; + sym->symbol.value = get_word (abfd, temp); if (set_public_section_func) { /* Most backends can use the code below, but unfortunately @@ -1023,80 +1025,80 @@ nlm_slurp_symbol_table (abfd) } else { - if (sym -> symbol.value & NLM_HIBIT) + if (sym->symbol.value & NLM_HIBIT) { - sym -> symbol.value &= ~NLM_HIBIT; - sym -> symbol.flags |= BSF_FUNCTION; - sym -> symbol.section = + sym->symbol.value &= ~NLM_HIBIT; + sym->symbol.flags |= BSF_FUNCTION; + sym->symbol.section = bfd_get_section_by_name (abfd, NLM_CODE_NAME); } else { - sym -> symbol.section = + sym->symbol.section = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME); } } - sym -> rcnt = 0; - abfd -> symcount++; + sym->rcnt = 0; + abfd->symcount++; sym++; } /* Read the debugging records. */ - if (i_fxdhdrp -> numberOfDebugRecords > 0) + if (i_fxdhdrp->numberOfDebugRecords > 0) { - if (bfd_seek (abfd, i_fxdhdrp -> debugInfoOffset, SEEK_SET) == -1) + if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) == -1) { bfd_set_error (bfd_error_system_call); return (false); } - symcount += i_fxdhdrp -> numberOfDebugRecords; - while (abfd -> symcount < symcount) + symcount += i_fxdhdrp->numberOfDebugRecords; + while (abfd->symcount < symcount) { - if ((bfd_read ((PTR) &symtype, sizeof (symtype), 1, abfd) + if ((bfd_read ((PTR) & symtype, sizeof (symtype), 1, abfd) != sizeof (symtype)) - || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp) - || (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd) + || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp) + || (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd) != sizeof (symlength))) { bfd_set_error (bfd_error_system_call); return false; } - sym -> symbol.the_bfd = abfd; - sym -> symbol.name = bfd_alloc (abfd, symlength + 1); - if (!sym -> symbol.name) + sym->symbol.the_bfd = abfd; + sym->symbol.name = bfd_alloc (abfd, symlength + 1); + if (!sym->symbol.name) { bfd_set_error (bfd_error_no_memory); return false; } - if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd) + if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) != symlength) { bfd_set_error (bfd_error_system_call); return (false); } /* Cast away const. */ - ((char *) (sym -> symbol.name))[symlength] = '\0'; - sym -> symbol.flags = BSF_LOCAL; - sym -> symbol.value = get_word (abfd, temp); + ((char *) (sym->symbol.name))[symlength] = '\0'; + sym->symbol.flags = BSF_LOCAL; + sym->symbol.value = get_word (abfd, temp); if (symtype == 0) { - sym -> symbol.section = + sym->symbol.section = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME); } else if (symtype == 1) { - sym -> symbol.flags |= BSF_FUNCTION; - sym -> symbol.section = + sym->symbol.flags |= BSF_FUNCTION; + sym->symbol.section = bfd_get_section_by_name (abfd, NLM_CODE_NAME); } else { - sym -> symbol.section = &bfd_abs_section; + sym->symbol.section = &bfd_abs_section; } - sym -> rcnt = 0; - abfd -> symcount++; + sym->rcnt = 0; + abfd->symcount++; sym++; } } @@ -1107,15 +1109,15 @@ nlm_slurp_symbol_table (abfd) read_import_func = nlm_read_import_func (abfd); if (read_import_func != NULL) { - if (bfd_seek (abfd, i_fxdhdrp -> externalReferencesOffset, SEEK_SET) + if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET) == -1) { bfd_set_error (bfd_error_system_call); return (false); } - - symcount += i_fxdhdrp -> numberOfExternalReferences; - while (abfd -> symcount < symcount) + + symcount += i_fxdhdrp->numberOfExternalReferences; + while (abfd->symcount < symcount) { if ((*read_import_func) (abfd, sym) == false) return false; @@ -1195,7 +1197,7 @@ nlm_slurp_reloc_fixups (abfd) since it does not attempt to distinguish them based on the section. That will be handled when they are actually read. */ -unsigned int +long nlm_get_reloc_upper_bound (abfd, sec) bfd *abfd; asection *sec; @@ -1206,7 +1208,7 @@ nlm_get_reloc_upper_bound (abfd, sec) /* If we don't know how to read relocs, just return 0. */ if (nlm_read_reloc_func (abfd) == NULL) - return 0; + return -1; /* Make sure we have either the code or the data section. */ if ((bfd_get_section_flags (abfd, sec) & (SEC_CODE | SEC_DATA)) == 0) return 0; @@ -1215,7 +1217,7 @@ nlm_get_reloc_upper_bound (abfd, sec) if (syms == NULL) { if (nlm_slurp_symbol_table (abfd) == false) - return 0; + return -1; syms = nlm_get_symbols (abfd); } @@ -1233,7 +1235,7 @@ nlm_get_reloc_upper_bound (abfd, sec) /* Get the relocs themselves. */ -unsigned int +long nlm_canonicalize_reloc (abfd, sec, relptr, symbols) bfd *abfd; asection *sec; @@ -1250,10 +1252,10 @@ nlm_canonicalize_reloc (abfd, sec, relptr, symbols) if (rels == NULL) { if (nlm_slurp_reloc_fixups (abfd) == false) - return 0; + return -1; rels = nlm_relocation_fixups (abfd); if (rels == NULL) - return 0; + return -1; } secs = nlm_relocation_fixup_secs (abfd); @@ -1296,7 +1298,7 @@ nlm_canonicalize_reloc (abfd, sec, relptr, symbols) *relptr = NULL; - return ret; + return ret; } /* Compute the section file positions for an NLM file. All variable @@ -1335,9 +1337,9 @@ nlm_compute_section_file_positions (abfd) bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME); if (bss_sec == NULL) { - if (! add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME, - (file_ptr) 0, (bfd_size_type) 0, - SEC_ALLOC)) + if (!add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME, + (file_ptr) 0, (bfd_size_type) 0, + SEC_ALLOC)) return false; bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME); } @@ -1349,14 +1351,14 @@ nlm_compute_section_file_positions (abfd) /* The variable header. */ sofar += (sizeof (nlm_variable_header (abfd)->descriptionLength) - + nlm_variable_header (abfd) -> descriptionLength + 1 - + NLM_TARGET_LONG_SIZE /* stackSize */ - + NLM_TARGET_LONG_SIZE /* reserved */ - + sizeof (nlm_variable_header (abfd) -> oldThreadName) - + sizeof (nlm_variable_header (abfd) -> screenNameLength) - + nlm_variable_header (abfd) -> screenNameLength + 1 - + sizeof (nlm_variable_header (abfd) -> threadNameLength) - + nlm_variable_header (abfd) -> threadNameLength + 1); + + nlm_variable_header (abfd)->descriptionLength + 1 + + NLM_TARGET_LONG_SIZE /* stackSize */ + + NLM_TARGET_LONG_SIZE /* reserved */ + + sizeof (nlm_variable_header (abfd)->oldThreadName) + + sizeof (nlm_variable_header (abfd)->screenNameLength) + + nlm_variable_header (abfd)->screenNameLength + 1 + + sizeof (nlm_variable_header (abfd)->threadNameLength) + + nlm_variable_header (abfd)->threadNameLength + 1); /* The auxiliary headers. */ if (find_nonzero ((PTR) nlm_version_header (abfd), @@ -1371,7 +1373,7 @@ nlm_compute_section_file_positions (abfd) if (find_nonzero ((PTR) nlm_copyright_header (abfd), sizeof (Nlm_Internal_Copyright_Header))) sofar += (sizeof (Nlm_External_Copyright_Header) - + nlm_copyright_header (abfd) -> copyrightMessageLength + 1); + + nlm_copyright_header (abfd)->copyrightMessageLength + 1); /* Compute the section file positions in two passes. First get the sizes of the text and data sections, and then set the file @@ -1379,10 +1381,10 @@ nlm_compute_section_file_positions (abfd) same alignment restrictions that apply to the sections in memory; this may not be necessary. */ text = 0; - text_low = (bfd_vma) -1; + text_low = (bfd_vma) - 1; text_align = 0; data = 0; - data_low = (bfd_vma) -1; + data_low = (bfd_vma) - 1; data_align = 0; bss = 0; other_align = 0; @@ -1484,7 +1486,7 @@ nlm_compute_section_file_positions (abfd) sym = *sym_ptr_ptr; - if (! bfd_is_com_section (bfd_get_section (sym))) + if (!bfd_is_com_section (bfd_get_section (sym))) continue; /* Put the common symbol in the .bss section, and increase @@ -1544,8 +1546,8 @@ nlm_set_section_contents (abfd, section, location, offset, count) mangle_relocs_func = nlm_mangle_relocs_func (abfd); if (mangle_relocs_func != NULL) { - if (! (*mangle_relocs_func) (abfd, section, location, - (bfd_vma) offset, count)) + if (!(*mangle_relocs_func) (abfd, section, location, + (bfd_vma) offset, count)) return false; } } @@ -1637,7 +1639,7 @@ nlm_write_object_contents (abfd) /* Write out the variable length headers. */ if (bfd_seek (abfd, - nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd), + nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd), SEEK_SET) != 0) { bfd_set_error (bfd_error_system_call); @@ -1683,7 +1685,7 @@ nlm_write_object_contents (abfd) if (sec->reloc_count == 0) continue; - /* We can only represent relocs within a code or data + /* We can only represent relocs within a code or data section. We ignore them for a debugging section. */ if ((bfd_get_section_flags (abfd, sec) & (SEC_CODE | SEC_DATA)) == 0) continue; @@ -1800,7 +1802,7 @@ nlm_write_object_contents (abfd) if (sym_ptr_ptr != (asymbol **) NULL) { bfd_vma (*get_public_offset_func) PARAMS ((bfd *, asymbol *)); - boolean (*write_export_func) PARAMS ((bfd*, asymbol *, bfd_vma)); + boolean (*write_export_func) PARAMS ((bfd *, asymbol *, bfd_vma)); asymbol **sym_end; @@ -1868,14 +1870,14 @@ nlm_write_object_contents (abfd) bfd_set_error (bfd_error_system_call); goto error_return; } - + put_word (abfd, offset, temp); if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp)) { bfd_set_error (bfd_error_system_call); goto error_return; } - } + } } nlm_fixed_header (abfd)->numberOfPublics = c; @@ -1885,7 +1887,7 @@ nlm_write_object_contents (abfd) information. This can not be handled by fiddling with the symbol table, because exported symbols appear in both the exported symbol list and the debugging information. */ - if (nlm_fixed_header (abfd)->debugInfoOffset == (file_ptr) -1) + if (nlm_fixed_header (abfd)->debugInfoOffset == (file_ptr) - 1) { nlm_fixed_header (abfd)->debugInfoOffset = 0; nlm_fixed_header (abfd)->numberOfDebugRecords = 0; @@ -1954,7 +1956,7 @@ nlm_write_object_contents (abfd) bfd_set_error (bfd_error_system_call); goto error_return; } - } + } nlm_fixed_header (abfd)->numberOfDebugRecords = c; } } @@ -1998,7 +2000,7 @@ nlm_write_object_contents (abfd) if (bfd_seek (abfd, 0, SEEK_SET) != 0) goto error_return; - + write_prefix_func = nlm_write_prefix_func (abfd); if (write_prefix_func) { @@ -2020,7 +2022,7 @@ nlm_write_object_contents (abfd) free (fixed_header); return true; - error_return: +error_return: if (fixed_header != NULL) free (fixed_header); return false; diff --git a/bfd/oasys.c b/bfd/oasys.c index e392d17..a8f3bb8 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -201,11 +201,12 @@ oasys_slurp_symbol_table (abfd) return true; } -static unsigned int +static long oasys_get_symtab_upper_bound (abfd) bfd *CONST abfd; { - oasys_slurp_symbol_table (abfd); + if (! oasys_slurp_symbol_table (abfd)) + return -1; return (abfd->symcount + 1) * (sizeof (oasys_symbol_type *)); } @@ -215,7 +216,7 @@ oasys_get_symtab_upper_bound (abfd) extern bfd_target oasys_vec; -unsigned int +long oasys_get_symtab (abfd, location) bfd *abfd; asymbol **location; @@ -224,7 +225,7 @@ oasys_get_symtab (abfd, location) unsigned int counter; if (oasys_slurp_symbol_table (abfd) == false) { - return 0; + return -1; } symbase = OASYS_DATA (abfd)->symbols; for (counter = 0; counter < abfd->symcount; counter++) @@ -800,12 +801,13 @@ oasys_new_section_hook (abfd, newsect) } -static unsigned int +static long oasys_get_reloc_upper_bound (abfd, asect) bfd *abfd; sec_ptr asect; { - oasys_slurp_section_data (abfd); + if (! oasys_slurp_section_data (abfd)) + return -1; return (asect->reloc_count + 1) * sizeof (arelent *); } @@ -831,7 +833,7 @@ oasys_get_section_contents (abfd, section, location, offset, count) } -unsigned int +long oasys_canonicalize_reloc (ignore_abfd, section, relptr, symbols) bfd *ignore_abfd; sec_ptr section; @@ -1435,6 +1437,11 @@ oasys_sizeof_headers (abfd, exec) #define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols #define oasys_bfd_final_link _bfd_generic_final_link +#define oasys_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true) +#define oasys_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true) +#define oasys_bfd_is_local_label bfd_generic_is_local_label /*SUPPRESS 460 */ bfd_target oasys_vec = diff --git a/bfd/osf-core.c b/bfd/osf-core.c index 94a53bc..33e4d4a 100644 --- a/bfd/osf-core.c +++ b/bfd/osf-core.c @@ -142,7 +142,7 @@ osf_core_core_file_p (abfd) secname = bfd_alloc (abfd, 40); if (!secname) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); return NULL; } sprintf (secname, ".data%d", dseccnt++); @@ -212,13 +212,13 @@ osf_core_core_file_matches_executable_p (core_bfd, exec_bfd) #define osf_core_get_section_contents bfd_generic_get_section_contents #define osf_core_new_section_hook (boolean (*) PARAMS \ ((bfd *, sec_ptr))) bfd_true -#define osf_core_get_symtab_upper_bound bfd_0u -#define osf_core_get_symtab (unsigned int (*) PARAMS \ - ((bfd *, struct symbol_cache_entry **))) bfd_0u -#define osf_core_get_reloc_upper_bound (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr))) bfd_0u -#define osf_core_canonicalize_reloc (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define osf_core_get_symtab_upper_bound bfd_0l +#define osf_core_get_symtab (long (*) PARAMS \ + ((bfd *, struct symbol_cache_entry **))) bfd_0l +#define osf_core_get_reloc_upper_bound (long (*) PARAMS \ + ((bfd *, sec_ptr))) bfd_0l +#define osf_core_canonicalize_reloc (long (*) PARAMS \ + ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define osf_core_print_symbol (void (*) PARAMS \ ((bfd *, PTR, struct symbol_cache_entry *, \ bfd_print_symbol_type))) bfd_false @@ -252,6 +252,12 @@ osf_core_core_file_matches_executable_p (core_bfd, exec_bfd) ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) #define osf_core_bfd_final_link \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) +#define osf_core_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_false) +#define osf_core_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false) +#define osf_core_bfd_is_local_label \ + ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false) /* If somebody calls any byte-swapping routines, shoot them. */ static void diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c index 5b07ea1..bfc97e5 100644 --- a/bfd/ptrace-core.c +++ b/bfd/ptrace-core.c @@ -80,7 +80,7 @@ ptrace_unix_core_file_p (abfd) || u.pt_rev != _BCS_PTRACE_REV) { /* Too small to be a core file */ - bfd_error = wrong_format; + bfd_set_error (bfd_error_wrong_format); return 0; } @@ -92,7 +92,7 @@ ptrace_unix_core_file_p (abfd) bfd_zalloc (abfd, sizeof (struct trad_core_struct)); if (rawptr == NULL) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); return 0; } @@ -103,10 +103,10 @@ ptrace_unix_core_file_p (abfd) /* Create the sections. This is raunchy, but bfd_close wants to free them separately. */ - core_stacksec(abfd) = (asection *) zalloc (sizeof (asection)); + core_stacksec(abfd) = (asection *) bfd_zmalloc (sizeof (asection)); if (core_stacksec (abfd) == NULL) { loser: - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); free ((void *)rawptr); return 0; } @@ -203,17 +203,17 @@ ptrace_unix_core_file_matches_executable_p (core_bfd, exec_bfd) #define ptrace_unix_close_and_cleanup bfd_generic_close_and_cleanup #define ptrace_unix_set_section_contents (boolean (*) PARAMS \ ((bfd *abfd, asection *section, PTR data, file_ptr offset, \ - bfd_size_type count))) bfd_false + bfd_size_type count))) bfd_generic_set_section_contents #define ptrace_unix_get_section_contents bfd_generic_get_section_contents #define ptrace_unix_new_section_hook (boolean (*) PARAMS \ ((bfd *, sec_ptr))) bfd_true -#define ptrace_unix_get_symtab_upper_bound bfd_0u -#define ptrace_unix_get_symtab (unsigned int (*) PARAMS \ - ((bfd *, struct symbol_cache_entry **))) bfd_0u -#define ptrace_unix_get_reloc_upper_bound (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr))) bfd_0u -#define ptrace_unix_canonicalize_reloc (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define ptrace_unix_get_symtab_upper_bound bfd_0l +#define ptrace_unix_get_symtab (long (*) PARAMS \ + ((bfd *, struct symbol_cache_entry **))) bfd_0l +#define ptrace_unix_get_reloc_upper_bound (long (*) PARAMS \ + ((bfd *, sec_ptr))) bfd_0l +#define ptrace_unix_canonicalize_reloc (long (*) PARAMS \ + ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define ptrace_unix_make_empty_symbol (struct symbol_cache_entry * \ (*) PARAMS ((bfd *))) bfd_false #define ptrace_unix_print_symbol (void (*) PARAMS \ @@ -249,6 +249,12 @@ ptrace_unix_core_file_matches_executable_p (core_bfd, exec_bfd) ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) #define ptrace_unix_bfd_final_link \ ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false) +#define ptrace_unix_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_false) +#define ptrace_unix_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false) +#define ptrace_unix_bfd_is_local_label \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false) /* If somebody calls any byte-swapping routines, shoot them. */ void @@ -256,9 +262,10 @@ swap_abort() { abort(); /* This way doesn't require any declaration for ANSI to fuck up */ } -#define NO_GET ((bfd_vma (*) PARAMS (( bfd_byte *))) swap_abort ) +#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort ) #define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort ) -#define NO_SIGNED_GET ((bfd_signed_vma (*) PARAMS ((bfd_byte *))) swap_abort ) +#define NO_SIGNED_GET \ + ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort ) bfd_target ptrace_core_vec = { diff --git a/bfd/reloc.c b/bfd/reloc.c index 1c367cc..c5bd81b 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -57,7 +57,7 @@ SUBSECTION CODE_FRAGMENT . -.typedef enum bfd_reloc_status +.typedef enum bfd_reloc_status .{ . {* No errors detected *} . bfd_reloc_ok, @@ -89,7 +89,7 @@ CODE_FRAGMENT . bfd_reloc_status_type; . . -.typedef struct reloc_cache_entry +.typedef struct reloc_cache_entry .{ . {* A pointer into the canonical table of pointers *} . struct symbol_cache_entry **sym_ptr_ptr; @@ -98,7 +98,7 @@ CODE_FRAGMENT . bfd_size_type address; . . {* addend for relocation value *} -. bfd_vma addend; +. bfd_vma addend; . . {* Pointer to how to perform the required relocation *} . const struct reloc_howto_struct *howto; @@ -162,7 +162,7 @@ DESCRIPTION |RELOCATION RECORDS FOR [.text]: -|offset type value +|offset type value |00000006 32 _foo | |00000000 4e56 fffc ; linkw fp,#-4 @@ -187,7 +187,7 @@ DESCRIPTION |RELOCATION RECORDS FOR [.text]: -|offset type value +|offset type value |00000002 HVRT16 _foo+0x12340000 |00000006 LVRT16 _foo+0x12340000 | @@ -207,7 +207,7 @@ DESCRIPTION sparc the parts are created in odd sized lumps. The designers of the a.out format chose to not use the data within the section for storing part of the offset; all the offset is kept within - the reloc. Anything in the data should be ignored. + the reloc. Anything in the data should be ignored. | save %sp,-112,%sp | sethi %hi(_foo+0x12345678),%g2 @@ -220,7 +220,7 @@ DESCRIPTION |RELOCATION RECORDS FOR [.text]: -|offset type value +|offset type value |00000004 HI22 _foo+0x12345678 |00000008 LO10 _foo+0x12345678 | @@ -240,7 +240,7 @@ DESCRIPTION would normally have a relocation instruction set and turn relocations into pointers to the correct structure on input - but it would be possible to create each howto field on demand. - + */ /* @@ -273,7 +273,7 @@ CODE_FRAGMENT */ /* -SUBSUBSECTION +SUBSUBSECTION <<reloc_howto_type>> The <<reloc_howto_type>> is a structure which contains all the @@ -282,8 +282,8 @@ SUBSUBSECTION CODE_FRAGMENT .struct symbol_cache_entry; {* Forward declaration *} . -.typedef struct reloc_howto_struct -.{ +.typedef struct reloc_howto_struct +.{ . {* The type field has mainly a documetary use - the back end can . do what it wants with it, though normally the back end's . external idea of what a reloc number is stored @@ -323,12 +323,12 @@ CODE_FRAGMENT . called rather than the normal function. This allows really . strange relocation methods to be accomodated (e.g., i960 callj . instructions). *} -. bfd_reloc_status_type (*special_function) +. bfd_reloc_status_type (*special_function) . PARAMS ((bfd *abfd, . arelent *reloc_entry, . struct symbol_cache_entry *symbol, . PTR data, -. asection *input_section, +. asection *input_section, . bfd *output_bfd, . char **error_message)); . @@ -352,7 +352,7 @@ CODE_FRAGMENT . into the instruction. In most cases src_mask == dst_mask, . except in the above special case, where dst_mask would be . 0x000000ff, and src_mask would be 0x00000000. *} -. bfd_vma dst_mask; +. bfd_vma dst_mask; . . {* When some formats create PC relative instructions, they leave . the value of the pc of the place being relocated in the offset @@ -397,7 +397,7 @@ DESCRIPTION . relocation = symbol->value; \ . } \ . } \ -.} +.} */ @@ -417,15 +417,16 @@ int bfd_get_reloc_size (howto) const reloc_howto_type *howto; { - switch (howto->size) { - case 0: return 1; - case 1: return 2; - case 2: return 4; - case 3: return 0; - case 4: return 8; - case -2: return 4; - default: abort (); - } + switch (howto->size) + { + case 0: return 1; + case 1: return 2; + case 2: return 4; + case 3: return 0; + case 4: return 8; + case -2: return 4; + default: abort (); + } } /* @@ -448,7 +449,7 @@ DESCRIPTION /* -FUNCTION +FUNCTION bfd_perform_relocation SYNOPSIS @@ -492,15 +493,15 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, { bfd_vma relocation; bfd_reloc_status_type flag = bfd_reloc_ok; - bfd_size_type addr = reloc_entry->address ; + bfd_size_type addr = reloc_entry->address; bfd_vma output_base = 0; const reloc_howto_type *howto = reloc_entry->howto; asection *reloc_target_output_section; asymbol *symbol; symbol = *(reloc_entry->sym_ptr_ptr); - if ((symbol->section == &bfd_abs_section) - && output_bfd != (bfd *)NULL) + if ((symbol->section == &bfd_abs_section) + && output_bfd != (bfd *) NULL) { reloc_entry->address += input_section->output_offset; return bfd_reloc_ok; @@ -544,7 +545,7 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, reloc_target_output_section = symbol->section->output_section; /* Convert input-section-relative symbol value to absolute. */ - if (output_bfd && howto->partial_inplace==false) + if (output_bfd && howto->partial_inplace == false) output_base = 0; else output_base = reloc_target_output_section->vma; @@ -587,28 +588,28 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, actually does. I don't want to change it, because it seems far too likely that something will break. */ - relocation -= + relocation -= input_section->output_section->vma + input_section->output_offset; if (howto->pcrel_offset == true) relocation -= reloc_entry->address; } - if (output_bfd!= (bfd *)NULL) + if (output_bfd != (bfd *) NULL) { - if ( howto->partial_inplace == false) + if (howto->partial_inplace == false) { /* This is a partial relocation, and we want to apply the relocation to the reloc entry rather than the raw data. Modify the reloc inplace to reflect what we now know. */ reloc_entry->addend = relocation; - reloc_entry->address += input_section->output_offset; + reloc_entry->address += input_section->output_offset; return flag; } else { /* This is a partial relocation, but inplace, so modify the - reloc record a bit. + reloc record a bit. If we've relocated with a symbol with a section, change into a ref to the section belonging to the symbol. */ @@ -699,7 +700,7 @@ space consuming. For each target: } } } - else + else { reloc_entry->addend = 0; } @@ -727,14 +728,14 @@ space consuming. For each target: { /* Assumes two's complement. */ bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1; - bfd_signed_vma reloc_signed_min = ~ reloc_signed_max; + bfd_signed_vma reloc_signed_min = ~reloc_signed_max; /* The above right shift is incorrect for a signed value. Fix it up by forcing on the upper bits. */ if (howto->rightshift > howto->bitpos && (bfd_signed_vma) relocation < 0) - check |= ((bfd_vma) -1 - &~ ((bfd_vma) -1 + check |= ((bfd_vma) - 1 + & ~((bfd_vma) - 1 >> (howto->rightshift - howto->bitpos))); if ((bfd_signed_vma) check > reloc_signed_max || (bfd_signed_vma) check < reloc_signed_min) @@ -747,7 +748,7 @@ space consuming. For each target: overflow if howto->bitsize is the number of bits in bfd_vma. */ bfd_vma reloc_unsigned_max = - (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; + (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; if ((bfd_vma) check > reloc_unsigned_max) flag = bfd_reloc_overflow; @@ -760,8 +761,8 @@ space consuming. For each target: bfd_vma. */ bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; - if (((bfd_vma) check &~ reloc_bits) != 0 - && ((bfd_vma) check &~ reloc_bits) != (-1 &~ reloc_bits)) + if (((bfd_vma) check & ~reloc_bits) != 0 + && ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits)) { /* The above right shift is incorrect for a signed value. See if turning on the upper bits fixes the @@ -769,10 +770,10 @@ space consuming. For each target: if (howto->rightshift > howto->bitpos && (bfd_signed_vma) relocation < 0) { - check |= ((bfd_vma) -1 - &~ ((bfd_vma) -1 + check |= ((bfd_vma) - 1 + & ~((bfd_vma) - 1 >> (howto->rightshift - howto->bitpos))); - if (((bfd_vma) check &~ reloc_bits) != (-1 &~ reloc_bits)) + if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits)) flag = bfd_reloc_overflow; } else @@ -784,8 +785,8 @@ space consuming. For each target: abort (); } } - - /* + + /* Either we are relocating all the way, or we don't want to apply the relocation to the reloc entry (probably because there isn't any room in the output format to describe addends to relocs) @@ -817,7 +818,7 @@ space consuming. For each target: relocation >>= (bfd_vma) howto->rightshift; /* Shift everything up to where it's going to be used */ - + relocation <<= (bfd_vma) howto->bitpos; /* Wait for the day when all have the mask in them */ @@ -832,23 +833,23 @@ space consuming. For each target: A part 1 B part 2 R result - + Do this: i i i i i o o o o o from bfd_get<size> and S S S S S to get the size offset we want + r r r r r r r r r r to get the final value to place and D D D D D to chop to right size ----------------------- - A A A A A + A A A A A And this: ... i i i i i o o o o o from bfd_get<size> and N N N N N get instruction ----------------------- ... B B B B B - - And then: - B B B B B - or A A A A A + + And then: + B B B B B + or A A A A A ----------------------- R R R R R R R R R R put into bfd_put<size> */ @@ -856,60 +857,60 @@ space consuming. For each target: #define DOIT(x) \ x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)) - switch (howto->size) - { - case 0: - { - char x = bfd_get_8(abfd, (char *)data + addr); - DOIT(x); - bfd_put_8(abfd,x, (unsigned char *) data + addr); - } - break; - - case 1: - if (relocation) - { - short x = bfd_get_16(abfd, (bfd_byte *)data + addr); - DOIT(x); - bfd_put_16(abfd, x, (unsigned char *)data + addr); - } - break; - case 2: - if (relocation) - { - long x = bfd_get_32 (abfd, (bfd_byte *) data + addr); - DOIT (x); - bfd_put_32 (abfd, x, (bfd_byte *)data + addr); - } - break; - case -2: - { - long x = bfd_get_32(abfd, (bfd_byte *) data + addr); - relocation = -relocation; - DOIT(x); - bfd_put_32(abfd,x, (bfd_byte *)data + addr); - } - break; - - case 3: - /* Do nothing */ - break; - - case 4: + switch (howto->size) + { + case 0: + { + char x = bfd_get_8 (abfd, (char *) data + addr); + DOIT (x); + bfd_put_8 (abfd, x, (unsigned char *) data + addr); + } + break; + + case 1: + if (relocation) + { + short x = bfd_get_16 (abfd, (bfd_byte *) data + addr); + DOIT (x); + bfd_put_16 (abfd, x, (unsigned char *) data + addr); + } + break; + case 2: + if (relocation) + { + long x = bfd_get_32 (abfd, (bfd_byte *) data + addr); + DOIT (x); + bfd_put_32 (abfd, x, (bfd_byte *) data + addr); + } + break; + case -2: + { + long x = bfd_get_32 (abfd, (bfd_byte *) data + addr); + relocation = -relocation; + DOIT (x); + bfd_put_32 (abfd, x, (bfd_byte *) data + addr); + } + break; + + case 3: + /* Do nothing */ + break; + + case 4: #ifdef BFD64 - if (relocation) - { - bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + addr); - DOIT (x); - bfd_put_64 (abfd, x, (bfd_byte *) data + addr); - } + if (relocation) + { + bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + addr); + DOIT (x); + bfd_put_64 (abfd, x, (bfd_byte *) data + addr); + } #else - abort (); + abort (); #endif - break; - default: - return bfd_reloc_other; - } + break; + default: + return bfd_reloc_other; + } return flag; } @@ -937,7 +938,7 @@ space consuming. For each target: bfd_reloc_status_type _bfd_final_link_relocate (howto, input_bfd, input_section, contents, address, - value, addend) + value, addend) const reloc_howto_type *howto; bfd *input_bfd; asection *input_section; @@ -975,7 +976,7 @@ _bfd_final_link_relocate (howto, input_bfd, input_section, contents, address, if (howto->pcrel_offset) relocation -= address; } - + return _bfd_relocate_contents (howto, input_bfd, relocation, contents + address); } @@ -996,7 +997,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) /* If the size is negative, negate RELOCATION. This isn't very general. */ if (howto->size < 0) - relocation = - relocation; + relocation = -relocation; /* Get the value we are going to relocate. */ size = bfd_get_reloc_size (howto); @@ -1051,8 +1052,8 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) signed_check = check; else signed_check = (check - | ((bfd_vma) -1 - &~ ((bfd_vma) -1 >> howto->rightshift))); + | ((bfd_vma) - 1 + & ~((bfd_vma) - 1 >> howto->rightshift))); } /* Get the value from the object file. */ @@ -1067,8 +1068,8 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) signed_add needs no adjustment to become negative in that case. */ signed_add = add; - if ((add & (((~ howto->src_mask) >> 1) & howto->src_mask)) != 0) - signed_add -= (((~ howto->src_mask) >> 1) & howto->src_mask) << 1; + if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0) + signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1; /* Add the value from the object file, shifted so that it is a straight number. */ @@ -1088,8 +1089,8 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) signed_check += add >> howto->bitpos; else signed_check += ((add >> howto->bitpos) - | ((bfd_vma) -1 - &~ ((bfd_vma) -1 >> howto->bitpos))); + | ((bfd_vma) - 1 + & ~((bfd_vma) - 1 >> howto->bitpos))); } switch (howto->complain_on_overflow) @@ -1098,7 +1099,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) { /* Assumes two's complement. */ bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1; - bfd_signed_vma reloc_signed_min = ~ reloc_signed_max; + bfd_signed_vma reloc_signed_min = ~reloc_signed_max; if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) @@ -1111,7 +1112,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) overflow if howto->bitsize is the number of bits in bfd_vma. */ bfd_vma reloc_unsigned_max = - (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; + (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; if (check > reloc_unsigned_max) overflow = true; @@ -1124,9 +1125,9 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) bfd_vma. */ bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; - if ((check &~ reloc_bits) != 0 - && (((bfd_vma) signed_check &~ reloc_bits) - != (-1 &~ reloc_bits))) + if ((check & ~reloc_bits) != 0 + && (((bfd_vma) signed_check & ~reloc_bits) + != (-1 & ~reloc_bits))) overflow = true; } break; @@ -1140,7 +1141,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) relocation <<= (bfd_vma) howto->bitpos; /* Add RELOCATION to the right bits of X. */ - x = ((x &~ howto->dst_mask) + x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)); /* Put the relocated value back in the object file. */ @@ -1176,7 +1177,7 @@ INODE howto manager, , typedef arelent, Relocations SECTION - The howto manager + The howto manager When an application wants to create a relocation, but doesn't know what the target machine might call it, it can find out by @@ -1200,12 +1201,12 @@ DESCRIPTION CODE_FRAGMENT . -.typedef enum bfd_reloc_code_real +.typedef enum bfd_reloc_code_real .{ . {* Basic absolute relocations *} . BFD_RELOC_64, . BFD_RELOC_32, -. BFD_RELOC_16, +. BFD_RELOC_16, . BFD_RELOC_14, . BFD_RELOC_8, . @@ -1494,15 +1495,15 @@ DESCRIPTION const struct reloc_howto_struct * -DEFUN(bfd_reloc_type_lookup,(abfd, code), - bfd *abfd AND - bfd_reloc_code_real_type code) +bfd_reloc_type_lookup (abfd, code) + bfd *abfd; + bfd_reloc_code_real_type code; { return BFD_SEND (abfd, reloc_type_lookup, (abfd, code)); } static reloc_howto_type bfd_howto_32 = - HOWTO(0, 00,2,32,false,0,complain_overflow_bitfield,0,"VRT32", false,0xffffffff,0xffffffff,true); +HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield, 0, "VRT32", false, 0xffffffff, 0xffffffff, true); /* @@ -1511,8 +1512,7 @@ INTERNAL_FUNCTION SYNOPSIS const struct reloc_howto_struct *bfd_default_reloc_type_lookup - (bfd *abfd AND - bfd_reloc_code_real_type code); + (bfd *abfd, bfd_reloc_code_real_type code); DESCRIPTION Provides a default relocation lookup routine for any architecture. @@ -1521,29 +1521,30 @@ DESCRIPTION */ const struct reloc_howto_struct * -DEFUN(bfd_default_reloc_type_lookup, (abfd, code), - bfd *abfd AND - bfd_reloc_code_real_type code) +bfd_default_reloc_type_lookup (abfd, code) + bfd *abfd; + bfd_reloc_code_real_type code; { - switch (code) + switch (code) { case BFD_RELOC_CTOR: /* The type of reloc used in a ctor, which will be as wide as the address - so either a 64, 32, or 16 bitter. */ - switch (bfd_get_arch_info (abfd)->bits_per_address) { - case 64: - BFD_FAIL(); - case 32: - return &bfd_howto_32; - case 16: - BFD_FAIL(); - default: - BFD_FAIL(); - } + switch (bfd_get_arch_info (abfd)->bits_per_address) + { + case 64: + BFD_FAIL (); + case 32: + return &bfd_howto_32; + case 16: + BFD_FAIL (); + default: + BFD_FAIL (); + } default: - BFD_FAIL(); + BFD_FAIL (); } - return (const struct reloc_howto_struct *)NULL; + return (const struct reloc_howto_struct *) NULL; } @@ -1556,7 +1557,7 @@ SYNOPSIS (bfd *abfd, asection *section, struct bfd_link_info *, - asymbol **symbols); + boolean *); DESCRIPTION Provides default handling for relaxing for back ends which @@ -1565,15 +1566,16 @@ DESCRIPTION /*ARGSUSED*/ boolean -bfd_generic_relax_section (abfd, section, link_info, symbols) +bfd_generic_relax_section (abfd, section, link_info, again) bfd *abfd; asection *section; struct bfd_link_info *link_info; - asymbol **symbols; + boolean *again; { - return false; + *again = false; + return true; } - + /* INTERNAL_FUNCTION bfd_generic_get_relocated_section_contents @@ -1607,95 +1609,101 @@ bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data, bfd *input_bfd = link_order->u.indirect.section->owner; asection *input_section = link_order->u.indirect.section; - size_t reloc_size = bfd_get_reloc_upper_bound(input_bfd, input_section); + long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); arelent **reloc_vector = NULL; + long reloc_count; + + if (reloc_size < 0) + goto error_return; reloc_vector = (arelent **) malloc (reloc_size); - if (reloc_vector == NULL) + if (reloc_vector == NULL && reloc_size != 0) { bfd_set_error (bfd_error_no_memory); goto error_return; } - + /* read in the section */ - if (!bfd_get_section_contents(input_bfd, - input_section, - (PTR) data, - 0, - input_section->_raw_size)) + if (!bfd_get_section_contents (input_bfd, + input_section, + (PTR) data, + 0, + input_section->_raw_size)) goto error_return; /* We're not relaxing the section, so just copy the size info */ input_section->_cooked_size = input_section->_raw_size; input_section->reloc_done = true; - if (!bfd_canonicalize_reloc (input_bfd, - input_section, - reloc_vector, - symbols)) + reloc_count = bfd_canonicalize_reloc (input_bfd, + input_section, + reloc_vector, + symbols); + if (reloc_count < 0) goto error_return; - { - arelent **parent; - for (parent = reloc_vector; * parent != (arelent *)NULL; - parent++) - { - char *error_message = (char *) NULL; - bfd_reloc_status_type r= - bfd_perform_relocation(input_bfd, - *parent, - (PTR) data, - input_section, - relocateable ? abfd : (bfd *) NULL, - &error_message); - - if (relocateable) + if (reloc_count > 0) + { + arelent **parent; + for (parent = reloc_vector; *parent != (arelent *) NULL; + parent++) { - asection *os = input_section->output_section; + char *error_message = (char *) NULL; + bfd_reloc_status_type r = + bfd_perform_relocation (input_bfd, + *parent, + (PTR) data, + input_section, + relocateable ? abfd : (bfd *) NULL, + &error_message); + + if (relocateable) + { + asection *os = input_section->output_section; - /* A partial link, so keep the relocs */ - os->orelocation[os->reloc_count] = *parent; - os->reloc_count++; - } + /* A partial link, so keep the relocs */ + os->orelocation[os->reloc_count] = *parent; + os->reloc_count++; + } - if (r != bfd_reloc_ok) - { - switch (r) - { - case bfd_reloc_undefined: - if (! ((*link_info->callbacks->undefined_symbol) - (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), - input_bfd, input_section, (*parent)->address))) - goto error_return; - break; - case bfd_reloc_dangerous: - BFD_ASSERT (error_message != (char *) NULL); - if (! ((*link_info->callbacks->reloc_dangerous) - (link_info, error_message, input_bfd, input_section, - (*parent)->address))) - goto error_return; - break; - case bfd_reloc_overflow: - if (! ((*link_info->callbacks->reloc_overflow) - (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), - (*parent)->howto->name, (*parent)->addend, - input_bfd, input_section, (*parent)->address))) - goto error_return; - break; - case bfd_reloc_outofrange: - default: - abort(); - break; - } + if (r != bfd_reloc_ok) + { + switch (r) + { + case bfd_reloc_undefined: + if (!((*link_info->callbacks->undefined_symbol) + (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), + input_bfd, input_section, (*parent)->address))) + goto error_return; + break; + case bfd_reloc_dangerous: + BFD_ASSERT (error_message != (char *) NULL); + if (!((*link_info->callbacks->reloc_dangerous) + (link_info, error_message, input_bfd, input_section, + (*parent)->address))) + goto error_return; + break; + case bfd_reloc_overflow: + if (!((*link_info->callbacks->reloc_overflow) + (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), + (*parent)->howto->name, (*parent)->addend, + input_bfd, input_section, (*parent)->address))) + goto error_return; + break; + case bfd_reloc_outofrange: + default: + abort (); + break; + } - } - } - } + } + } + } if (reloc_vector != NULL) free (reloc_vector); return data; - error_return: +error_return: if (reloc_vector != NULL) free (reloc_vector); return NULL; @@ -138,16 +138,16 @@ static bfd_target * som_object_p PARAMS ((bfd *)); static boolean som_write_object_contents PARAMS ((bfd *)); static boolean som_slurp_string_table PARAMS ((bfd *)); static unsigned int som_slurp_symbol_table PARAMS ((bfd *)); -static unsigned int som_get_symtab_upper_bound PARAMS ((bfd *)); -static unsigned int som_canonicalize_reloc PARAMS ((bfd *, sec_ptr, - arelent **, asymbol **)); -static unsigned int som_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); +static long som_get_symtab_upper_bound PARAMS ((bfd *)); +static long som_canonicalize_reloc PARAMS ((bfd *, sec_ptr, + arelent **, asymbol **)); +static long som_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); static unsigned int som_set_reloc_info PARAMS ((unsigned char *, unsigned int, arelent *, asection *, asymbol **, boolean)); static boolean som_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **, boolean)); -static unsigned int som_get_symtab PARAMS ((bfd *, asymbol **)); +static long som_get_symtab PARAMS ((bfd *, asymbol **)); static asymbol * som_make_empty_symbol PARAMS ((bfd *)); static void som_print_symbol PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); @@ -3544,12 +3544,12 @@ som_slurp_string_table (abfd) /* Return the amount of data (in bytes) required to hold the symbol table for this object. */ -static unsigned int +static long som_get_symtab_upper_bound (abfd) bfd *abfd; { if (!som_slurp_symbol_table (abfd)) - return 0; + return -1; return (bfd_get_symcount (abfd) + 1) * (sizeof (asymbol *)); } @@ -3774,7 +3774,7 @@ som_slurp_symbol_table (abfd) /* Canonicalize a SOM symbol table. Return the number of entries in the symbol table. */ -static unsigned int +static long som_get_symtab (abfd, location) bfd *abfd; asymbol **location; @@ -3783,7 +3783,7 @@ som_get_symtab (abfd, location) som_symbol_type *symbase; if (!som_slurp_symbol_table (abfd)) - return 0; + return -1; i = bfd_get_symcount (abfd); symbase = obj_som_symtab (abfd); @@ -4169,7 +4169,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) /* Return the number of bytes required to store the relocation information associated with the given section. */ -static unsigned int +static long som_get_reloc_upper_bound (abfd, asect) bfd *abfd; sec_ptr asect; @@ -4178,18 +4178,18 @@ som_get_reloc_upper_bound (abfd, asect) and parse it to determine how many relocations exist. */ if (asect->flags & SEC_RELOC) { - if (som_slurp_reloc_table (abfd, asect, NULL, true)) - return (asect->reloc_count + 1) * sizeof (arelent); + if (! som_slurp_reloc_table (abfd, asect, NULL, true)) + return false; + return (asect->reloc_count + 1) * sizeof (arelent); } - /* Either there are no relocations or an error occurred while - reading and parsing the relocation stream. */ + /* There are no relocations. */ return 0; } /* Convert relocations from SOM (external) form into BFD internal form. Return the number of relocations. */ -static unsigned int +static long som_canonicalize_reloc (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; @@ -4200,12 +4200,12 @@ som_canonicalize_reloc (abfd, section, relptr, symbols) int count; if (som_slurp_reloc_table (abfd, section, symbols, false) == false) - return 0; + return -1; count = section->reloc_count; tblptr = section->relocation; if (tblptr == (arelent *) NULL) - return 0; + return -1; while (count--) *relptr++ = tblptr++; @@ -859,16 +859,17 @@ srec_make_empty_symbol (abfd) return new; } -static unsigned int +static long srec_get_symtab_upper_bound (abfd) bfd *abfd; { /* Read in all the info */ - srec_get_section_contents (abfd, abfd->sections, 0, 0, 0); + if (! srec_get_section_contents (abfd, abfd->sections, 0, 0, 0)) + return -1; return (bfd_get_symcount (abfd) + 1) * (sizeof (asymbol *)); } -static unsigned int +static long srec_get_symtab (abfd, alocation) bfd *abfd; asymbol **alocation; @@ -919,8 +920,8 @@ srec_print_symbol (ignore_abfd, afile, symbol, how) #define FOO PROTO #define srec_new_section_hook (FOO(boolean, (*), (bfd *, asection *)))bfd_true -#define srec_get_reloc_upper_bound (FOO(unsigned int, (*),(bfd*, asection *)))bfd_false -#define srec_canonicalize_reloc (FOO(unsigned int, (*),(bfd*,asection *, arelent **, asymbol **))) bfd_0 +#define srec_get_reloc_upper_bound (FOO(long, (*),(bfd*, asection *)))bfd_0l +#define srec_canonicalize_reloc (FOO(long, (*),(bfd*,asection *, arelent **, asymbol **))) bfd_0l @@ -951,6 +952,12 @@ srec_print_symbol (ignore_abfd, afile, symbol, how) #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols #define srec_bfd_final_link _bfd_generic_final_link +#define srec_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true) +#define srec_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true) +#define srec_bfd_is_local_label bfd_generic_is_local_label + bfd_target srec_vec = { "srec", /* name */ diff --git a/bfd/targets.c b/bfd/targets.c index d9775fe..0b45534 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -275,12 +275,12 @@ Standard stuff. Symbols and relocations. -. unsigned int (*_get_symtab_upper_bound) PARAMS ((bfd *)); -. unsigned int (*_bfd_canonicalize_symtab) PARAMS ((bfd *, -. struct symbol_cache_entry **)); -. unsigned int (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); -. unsigned int (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, -. struct symbol_cache_entry **)); +. long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *)); +. long (*_bfd_canonicalize_symtab) PARAMS ((bfd *, +. struct symbol_cache_entry **)); +. long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); +. long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, +. struct symbol_cache_entry **)); . struct symbol_cache_entry * . (*_bfd_make_empty_symbol) PARAMS ((bfd *)); . void (*_bfd_print_symbol) PARAMS ((bfd *, PTR, diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 9f2a50f..874a87e 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -358,7 +358,7 @@ find_chunk (abfd, vma) if (!sname || !d) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); return NULL; } @@ -422,7 +422,7 @@ first_phase (abfd, type, src) if (!n) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); abort(); /* FIXME */ } memcpy (n, sym, len + 1); @@ -456,7 +456,7 @@ first_phase (abfd, type, src) if (!new) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); abort(); /* FIXME */ } new->symbol.the_bfd = abfd; @@ -469,7 +469,7 @@ first_phase (abfd, type, src) new->symbol.name = bfd_alloc (abfd, len + 1); if (!new->symbol.name) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); abort(); /* FIXME */ } memcpy ((char *) (new->symbol.name), sym, len + 1); @@ -533,7 +533,7 @@ static void } -unsigned int +long tekhex_get_symtab (abfd, table) bfd *abfd; asymbol **table; @@ -552,7 +552,7 @@ tekhex_get_symtab (abfd, table) return bfd_get_symcount (abfd); } -unsigned int +long tekhex_get_symtab_upper_bound (abfd) bfd *abfd; { @@ -568,7 +568,7 @@ tekhex_mkobject (abfd) if (!tdata) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); return false; } abfd->tdata.tekhex_data = tdata; @@ -913,7 +913,7 @@ tekhex_write_object_contents (abfd) break; case 'C': case 'U': - bfd_error = wrong_format; + bfd_set_error (bfd_error_wrong_format); return false; } @@ -946,7 +946,7 @@ tekhex_make_empty_symbol (abfd) if (!new) { - bfd_error = no_memory; + bfd_set_error (bfd_error_no_memory); return NULL; } new->symbol.the_bfd = abfd; @@ -995,8 +995,8 @@ tekhex_print_symbol (ignore_abfd, filep, symbol, how) #define FOO PROTO #define tekhex_new_section_hook (FOO(boolean, (*), (bfd *, asection *)))bfd_true -#define tekhex_get_reloc_upper_bound (FOO(unsigned int, (*),(bfd*, asection *)))bfd_false -#define tekhex_canonicalize_reloc (FOO(unsigned int, (*),(bfd*,asection *, arelent **, asymbol **))) bfd_0 +#define tekhex_get_reloc_upper_bound (FOO(long, (*),(bfd*, asection *)))bfd_0l +#define tekhex_canonicalize_reloc (FOO(long, (*),(bfd*,asection *, arelent **, asymbol **))) bfd_0l #define tekhex_openr_next_archived_file (FOO(bfd *, (*), (bfd*,bfd*))) bfd_nullvoidptr #define tekhex_find_nearest_line (FOO(boolean, (*),(bfd*,asection*,asymbol**,bfd_vma, CONST char**, CONST char**, unsigned int *))) bfd_false @@ -1023,6 +1023,11 @@ tekhex_print_symbol (ignore_abfd, filep, symbol, how) #define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols #define tekhex_bfd_final_link _bfd_generic_final_link +#define tekhex_bfd_copy_private_section_data \ + ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true) +#define tekhex_bfd_copy_private_bfd_data \ + ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true) +#define tekhex_bfd_is_local_label bfd_generic_is_local_label bfd_target tekhex_vec = { diff --git a/bfd/trad-core.c b/bfd/trad-core.c index 8d06a92..6d57bbb 100644 --- a/bfd/trad-core.c +++ b/bfd/trad-core.c @@ -147,7 +147,7 @@ trad_unix_core_file_p (abfd) /* Allocate both the upage and the struct core_data at once, so a single free() will free them both. */ rawptr = (struct trad_core_struct *) - bfd_zmalloc (abfd, sizeof (struct trad_core_struct)); + bfd_zmalloc (sizeof (struct trad_core_struct)); if (rawptr == NULL) { bfd_set_error (bfd_error_no_memory); return 0; @@ -297,13 +297,13 @@ trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd) #define trad_unix_get_section_contents bfd_generic_get_section_contents #define trad_unix_new_section_hook (boolean (*) PARAMS \ ((bfd *, sec_ptr))) bfd_true -#define trad_unix_get_symtab_upper_bound bfd_0u -#define trad_unix_get_symtab (unsigned int (*) PARAMS \ - ((bfd *, struct symbol_cache_entry **))) bfd_0u -#define trad_unix_get_reloc_upper_bound (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr))) bfd_0u -#define trad_unix_canonicalize_reloc (unsigned int (*) PARAMS \ - ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define trad_unix_get_symtab_upper_bound bfd_0l +#define trad_unix_get_symtab (long (*) PARAMS \ + ((bfd *, struct symbol_cache_entry **))) bfd_0l +#define trad_unix_get_reloc_upper_bound (long (*) PARAMS \ + ((bfd *, sec_ptr))) bfd_0l +#define trad_unix_canonicalize_reloc (long (*) PARAMS \ + ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0l #define trad_unix_make_empty_symbol (struct symbol_cache_entry * \ (*) PARAMS ((bfd *))) bfd_false #define trad_unix_print_symbol (void (*) PARAMS \ |