From: Ian Lance Taylor Date: Tue, 12 Sep 1995 18:59:24 +0000 (+0000) Subject: * sunos.c (sunos_slurp_dynamic_symtab): New static function, X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=396aaeb2b690a3aeb287fc2c057d492379654944;p=binutils-gdb.git * sunos.c (sunos_slurp_dynamic_symtab): New static function, broken out of sunos_canonicalize_dynamic_symtab. (sunos_canonicalize_dynamic_symtab): Call new function sunos_slurp_dynamic_symtab. (sunos_add_dynamic_symbols): Add three new parameters. Return the dynamic symbol table to the caller. * aoutx.h (aout_link_add_symbols): Permit add_dynamic_symbols callback to override the symbols being read. * libaout.h (struct aout_backend_data): Add three new parameters to add_dynamic_symbols callback. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 17027a89bcf..589764cfcdb 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,16 @@ Tue Sep 12 12:14:33 1995 Ian Lance Taylor + * sunos.c (sunos_slurp_dynamic_symtab): New static function, + broken out of sunos_canonicalize_dynamic_symtab. + (sunos_canonicalize_dynamic_symtab): Call new function + sunos_slurp_dynamic_symtab. + (sunos_add_dynamic_symbols): Add three new parameters. Return the + dynamic symbol table to the caller. + * aoutx.h (aout_link_add_symbols): Permit add_dynamic_symbols + callback to override the symbols being read. + * libaout.h (struct aout_backend_data): Add three new parameters + to add_dynamic_symbols callback. + Extensive minor changes to avoid various gcc warnings. Also: * Makefile.in (BFD32_BACKENDS): Remove coff-arm.o. * archures.c (bfd_arch_info_type): Change mach field from long to diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 64b826e9c9a..2a44a1fb015 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -3126,6 +3126,7 @@ aout_link_add_symbols (abfd, info) bfd_vma, const char *, boolean, boolean, struct bfd_link_hash_entry **)); + struct external_nlist *syms; bfd_size_type sym_count; char *strings; boolean copy; @@ -3133,6 +3134,7 @@ aout_link_add_symbols (abfd, info) register struct external_nlist *p; struct external_nlist *pend; + syms = obj_aout_external_syms (abfd); sym_count = obj_aout_external_sym_count (abfd); strings = obj_aout_external_strings (abfd); if (info->keep_memory) @@ -3140,6 +3142,14 @@ aout_link_add_symbols (abfd, info) else copy = true; + if ((abfd->flags & DYNAMIC) != 0 + && aout_backend_info (abfd)->add_dynamic_symbols != NULL) + { + if (! ((*aout_backend_info (abfd)->add_dynamic_symbols) + (abfd, info, &syms, &sym_count, &strings))) + return false; + } + /* We keep a list of the linker hash table entries that correspond to particular symbols. We could just look them up in the hash table, but keeping the list is more efficient. Perhaps this @@ -3155,18 +3165,11 @@ aout_link_add_symbols (abfd, info) } obj_aout_sym_hashes (abfd) = sym_hash; - if ((abfd->flags & DYNAMIC) != 0 - && aout_backend_info (abfd)->add_dynamic_symbols != NULL) - { - if (! (*aout_backend_info (abfd)->add_dynamic_symbols) (abfd, info)) - return false; - } - add_one_symbol = aout_backend_info (abfd)->add_one_symbol; if (add_one_symbol == NULL) add_one_symbol = _bfd_generic_link_add_one_symbol; - p = obj_aout_external_syms (abfd); + p = syms; pend = p + sym_count; for (; p < pend; p++, sym_hash++) { diff --git a/bfd/libaout.h b/bfd/libaout.h index a40f3c07908..dd98d125cbe 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -16,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef LIBAOUT_H #define LIBAOUT_H @@ -127,7 +127,9 @@ struct aout_backend_data /* Callback from the add symbols phase of the linker code to handle a dynamic object. */ - boolean (*add_dynamic_symbols) PARAMS ((bfd *, struct bfd_link_info *)); + boolean (*add_dynamic_symbols) PARAMS ((bfd *, struct bfd_link_info *, + struct external_nlist **, + bfd_size_type *, char **)); /* Callback from the add symbols phase of the linker code to handle adding a single symbol to the global linker hash table. */ @@ -145,14 +147,17 @@ struct aout_backend_data boolean (*write_dynamic_symbol) PARAMS ((bfd *, struct bfd_link_info *, struct aout_link_hash_entry *)); - /* This callback is called by the linker for each reloc against an - external symbol. RELOC is a pointer to the unswapped reloc. If - *SKIP is set to true, the reloc will be skipped. */ + /* If this callback is not NULL, the linker calls it for each reloc. + RELOC is a pointer to the unswapped reloc. If *SKIP is set to + true, the reloc will be skipped. *RELOCATION may be changed to + change the effects of the relocation. */ boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *info, bfd *input_bfd, asection *input_section, struct aout_link_hash_entry *h, - PTR reloc, boolean *skip)); + PTR reloc, bfd_byte *contents, + boolean *skip, + bfd_vma *relocation)); /* Called at the end of a link to finish up any dynamic linking information. */ @@ -217,12 +222,12 @@ enum machine_type { M_SPARC_NETBSD = 138, /* NetBSD/sparc binary */ M_MIPS1 = 151, /* MIPS R2000/R3000 binary */ M_MIPS2 = 152, /* MIPS R4000/R6000 binary */ - M_HP200 = 200, /* HP 200 (68010) BSD binary */ - M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */ - M_HPUX = (0x20c % 256)/* HP 200/300 HPUX binary */ /* start-sanitize-rce */ M_RCE = 155, /* Motorola RCE binary */ /* end-sanitize-rce */ + M_HP200 = 200, /* HP 200 (68010) BSD binary */ + M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */ + M_HPUX = (0x20c % 256)/* HP 200/300 HPUX binary */ }; #define N_DYNAMIC(exec) ((exec).a_info & 0x80000000) @@ -340,6 +345,11 @@ struct aoutdata { /* A pointer for shared library information. */ PTR dynamic_info; + + /* A mapping from local symbols to offsets into the global offset + table, used when linking on SunOS. This is indexed by the symbol + index. */ + bfd_vma *local_got_offsets; }; struct aout_data_struct { @@ -381,6 +391,9 @@ struct aout_section_data_struct #define aout_section_data(s) \ ((struct aout_section_data_struct *) (s)->used_by_bfd) +#define set_aout_section_data(s,v) \ + ((s)->used_by_bfd = (PTR)&(v)->relocs) + /* Prototype declarations for functions defined in aoutx.h */ boolean @@ -440,10 +453,14 @@ NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location)); void NAME(aout,swap_ext_reloc_in) PARAMS ((bfd *, struct reloc_ext_external *, - arelent *, asymbol **)); + arelent *, asymbol **, bfd_size_type)); void NAME(aout,swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *, - arelent *, asymbol **)); + arelent *, asymbol **, bfd_size_type)); + +reloc_howto_type * +NAME(aout,reloc_type_lookup) PARAMS ((bfd *abfd, + bfd_reloc_code_real_type code)); boolean NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect, @@ -475,6 +492,13 @@ NAME(aout,find_nearest_line) PARAMS ((bfd *abfd, asection *section, asymbol **symbols, bfd_vma offset, CONST char **filename_ptr, CONST char **functionname_ptr, unsigned int *line_ptr)); +long +NAME(aout,read_minisymbols) PARAMS ((bfd *, boolean, PTR *, unsigned int *)); + +asymbol * +NAME(aout,minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR, + asymbol *)); + int NAME(aout,sizeof_headers) PARAMS ((bfd *abfd, boolean exec)); diff --git a/bfd/sunos.c b/bfd/sunos.c index e3d06999906..c2cf4537fd3 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ static boolean sunos_read_dynamic_info PARAMS ((bfd *)); static long sunos_get_dynamic_symtab_upper_bound PARAMS ((bfd *)); +static boolean sunos_slurp_dynamic_symtab PARAMS ((bfd *)); static long sunos_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **)); static long sunos_get_dynamic_reloc_upper_bound PARAMS ((bfd *)); static long sunos_canonicalize_dynamic_reloc @@ -40,7 +41,8 @@ static struct bfd_link_hash_table *sunos_link_hash_table_create static boolean sunos_create_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *, boolean)); static boolean sunos_add_dynamic_symbols - PARAMS ((bfd *, struct bfd_link_info *)); + PARAMS ((bfd *, struct bfd_link_info *, struct external_nlist **, + bfd_size_type *, char **)); static boolean sunos_add_one_symbol PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *, bfd_vma, const char *, boolean, boolean, @@ -243,28 +245,26 @@ sunos_get_dynamic_symtab_upper_bound (abfd) return (info->dynsym_count + 1) * sizeof (asymbol *); } -/* Read in the dynamic symbols. */ +/* Read the external dynamic symbols. */ -static long -sunos_canonicalize_dynamic_symtab (abfd, storage) +static boolean +sunos_slurp_dynamic_symtab (abfd) bfd *abfd; - asymbol **storage; { struct sunos_dynamic_info *info; - unsigned long i; /* Get the general dynamic information. */ if (obj_aout_dynamic_info (abfd) == NULL) { if (! sunos_read_dynamic_info (abfd)) - return -1; + return false; } info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd); if (! info->valid) { bfd_set_error (bfd_error_no_symbols); - return -1; + return false; } /* Get the dynamic nlist structures. */ @@ -277,7 +277,7 @@ sunos_canonicalize_dynamic_symtab (abfd, storage) if (info->dynsym == NULL && info->dynsym_count != 0) { bfd_set_error (bfd_error_no_memory); - return -1; + return false; } if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0 || (bfd_read ((PTR) info->dynsym, info->dynsym_count, @@ -289,7 +289,7 @@ sunos_canonicalize_dynamic_symtab (abfd, storage) bfd_release (abfd, info->dynsym); info->dynsym = NULL; } - return -1; + return false; } } @@ -300,7 +300,7 @@ sunos_canonicalize_dynamic_symtab (abfd, storage) if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0) { bfd_set_error (bfd_error_no_memory); - return -1; + return false; } if (bfd_seek (abfd, info->dyninfo.ld_symbols, SEEK_SET) != 0 || (bfd_read ((PTR) info->dynstr, 1, info->dyninfo.ld_symb_size, @@ -312,10 +312,28 @@ sunos_canonicalize_dynamic_symtab (abfd, storage) bfd_release (abfd, info->dynstr); info->dynstr = NULL; } - return -1; + return false; } } + return true; +} + +/* Read in the dynamic symbols. */ + +static long +sunos_canonicalize_dynamic_symtab (abfd, storage) + bfd *abfd; + asymbol **storage; +{ + struct sunos_dynamic_info *info; + unsigned long i; + + if (! sunos_slurp_dynamic_symtab (abfd)) + return -1; + + info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd); + #ifdef CHECK_DYNAMIC_HASH /* Check my understanding of the dynamic hash table by making sure that each symbol can be located in the hash table. */ @@ -828,12 +846,16 @@ sunos_create_dynamic_sections (abfd, info, needed) set. */ static boolean -sunos_add_dynamic_symbols (abfd, info) +sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) bfd *abfd; struct bfd_link_info *info; + struct external_nlist **symsp; + bfd_size_type *sym_countp; + char **stringsp; { asection *s; bfd *dynobj; + struct sunos_dynamic_info *dinfo; /* We do not want to include the sections in a dynamic object in the output file. We hack by simply clobbering the list of sections @@ -898,6 +920,15 @@ sunos_add_dynamic_symbols (abfd, info) return false; } + /* Pick up the dynamic symbols and return them to the caller. */ + if (! sunos_slurp_dynamic_symtab (abfd)) + return false; + + dinfo = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd); + *symsp = dinfo->dynsym; + *sym_countp = dinfo->dynsym_count; + *stringsp = dinfo->dynstr; + return true; }