Commit Graph

19 Commits

Author SHA1 Message Date
Ian Lance Taylor f5d6548535 * xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): Look through the
members of an archive for dynamic objects with no symbols, and
	pass them directly to check_archive_element.
	(xcoff_link_check_ar_symbols): Pass dynamic objects to
	xcoff_link_check_dynamic_ar_symbols.
	(xcoff_link_check_dynamic_ar_symbols): New static function.
The above is for PR 9520.

	* coff-rs6000.c (rs6000coff_vec): Change BFD_JUMP_TABLE_DYNAMIC
	from _bfd_nodynamic to _bfd_xcoff.
	* libcoff-in.h (_bfd_xcoff_get_dynamic_symtab_upper_bound):
	Declare.
	(_bfd_xcoff_canonicalize_dynamic_symtab): Declare.
	(_bfd_xcoff_get_dynamic_reloc_upper_bound): Declare.
	(_bfd_xcoff_canonicalize_dynamic_reloc): Declare.
	* libcoff.h: Rebuild.
	* xcofflink.c (xcoff_swap_ldrel_in): New static function.
	(xcoff_get_section_contents): New static function.
	(_bfd_xcoff_get_dynamic_symtab_upper_bound): New function.
	(_bfd_xcoff_canonicalize_dynamic_symtab): New function.
	(_bfd_xcoff_get_dynamic_reloc_upper_bound): New function.
	(xcoff_dynamic_reloc): New static variable.
	(_bfd_xcoff_canonicalize_dynamic_reloc): New function.
	(xcoff_link_add_dynamic_symbols): Use xcoff_get_section_contents.
1996-04-24 18:10:46 +00:00
Ian Lance Taylor d6e0e2f786 * libcoff-in.h (struct coff_final_link_info): Add last_bf_index
and last_bf fields.
	* libcoff.h: Rebuild.
	* coffswap.h (coff_swap_aux_in): Swap endndx field for C_FCN
	symbols.
	(coff_swap_aux_out): Likewise.
	* peicode.h (coff_swap_aux_in): Likewise.
	(coff_swap_aux_out): Likewise.
	* coffgen.c (coff_pointerize_aux): Check endndx field for C_FCN
	symbols.
	* cofflink.c (_bfd_coff_final_link): Initialize last_bf_index
	field.
	(_bfd_coff_link_input_bfd): Check endndx field for C_FCN symbols.
	Fix up .bf endndx link fields.
	* coff-ppc.c (ppc_bfd_coff_final_link): Initialize last_bf_index
	field.
	* xcofflink.c (xcoff_link_input_bfd): Check endndx field for C_FCN
	symbols.
PR 9467.
1996-04-18 22:55:54 +00:00
Kim Knuttila bdd2e7f179 Fixed exported names, removed a bad define 1996-01-29 19:31:34 +00:00
Kim Knuttila 13d1a4dda9 Removed a ppc hack from cofflink, promoted some types to libcoff-in.h 1996-01-29 17:44:41 +00:00
Ian Lance Taylor 86aac8eabe * syms.c: Include "bfdlink.h".
(struct stab_find_info): Define.
	(_bfd_stab_section_find_nearest_line): New function.
	* libbfd-in.h (_bfd_stab_section_find_nearest_line): Declare.
	* libbfd.h: Rebuild.
	* elf-bfd.h (struct elf_obj_tdata): Add line_info field.
	* elf.c (_bfd_elf_find_nearest_line): Try calling
	_bfd_stab_section_find_nearest_line before searching the ELF
	symbol table.  Find the closest STT_FUNC symbol, not the last one.
	* libcoff-in.h (coff_data_type): Add line_info field.
	* libcoff.h: Rebuild.
	* coffgen.c (coff_find_nearest_line): Try calling
	_bfd_stab_section_find_nearest_line before searching the COFF
	symbol table.
	* Makefile.in: Rebuild dependencies.
1996-01-26 23:42:58 +00:00
Kim Knuttila d6f41a7d3e First round ld support for PPC PE 1995-11-07 21:33:33 +00:00
Ken Raeburn 4fe6d901bd Changes for mmap; details in change log.
Added some new interfaces, and a new entry in the target vector.  Under the new
interfaces, mmap will be used if available, otherwise malloc/seek/read, as
before.  Old interfaces all still intact.

Most configurations (including all used by "--enable-targets=all") simply
changed to call the default routine for that entry in the target vector.  I
might've missed some targets only included in special configurations.

Support for a.out symbol and string table reading now goes through new
interfaces, and will use mmap when available.

Linker hooks (e.g., avoiding reallocation under malloc) not ready yet.
1995-11-06 10:08:03 +00:00
Ian Lance Taylor 867d923d18 * xcofflink.c: Numerous changes to get closer to a working XCOFF
linker.
	* libcoff-in.h (struct xcoff_tdata): Add full_aouthdr,
	toc_section, and entry_section fields.
	(struct xcoff_section_tdata): Remove ldrel_count field.
	* libcoff.h: Rebuild.
	* coffcode.h (coff_mkobject_hook): Initialize new xcoff_data
	fields.
	(coff_compute_section_file_positions): If RS6000COFF_C, generate
	full a.out header if full_aouthdr is set in xcoff_data.
	(coff_write_object_contents): Likewise.  Set o_snentry and o_sntoc
	based on sections stored in xcoff_data.
	* coff-rs6000.c (xcoff_copy_private_bfd_data): Copy new xcoff_data
	fields.
	* coffgen.c (coff_get_symbol_info): If fix_value is set, fix the
	value stored in ret rather than returning a pointer value.
1995-10-26 18:25:13 +00:00
Ian Lance Taylor b73322d9fd fix XCOFF line number handling 1995-10-25 20:33:38 +00:00
Ian Lance Taylor 28a0c10399 * xcofflink.c: Extensive changes to support linking shared objects
and generating a .loader section.
	* libcoff-in.h (struct xcoff_tdata): Add import_file_id field.
	(struct xcoff_section_tdata): Add first_symndx, last_symndx,
	and ldrel_count fields.
	* libcoff.h: Rebuild.
	* coff-rs6000.c (xcoff_howto_table): Correct reloc names.
	* coffcode.h (styp_to_sec_flags): Don't set any flags if STYP_PAD
	is set.
	* bfd-in.h (bfd_xcoff_import_symbol): Declare.
	(bfd_xcoff_export_symbol): Declare.
	(bfd_xcoff_size_dynamic_sections): Declare.
	* bfd-in2.h: Rebuild.
1995-10-25 15:37:47 +00:00
Steve Chamberlain c974e19ef4 * libcoff-in.h (pe_data_type.in_reloc_p): New. 1995-10-16 21:46:48 +00:00
Ian Lance Taylor 5f710a3a89 * libcoff-in.h (struct xcoff_tdata): Define.
(xcoff_data): Define.
	* bfd.c (struct _bfd): Add xcoff_obj_data field to tdata union.
	* bfd-in2.h, libcoff.h: Rebuild.
	* coff-rs6000.c (xcoff_mkobject): New static function.
	(coff_mkobject): Define.
	(xcoff_copy_private_bfd_data): New static function.
	(coff_bfd_copy_private_bfd_data): Define.
	(rs6000coff_howto_table): Change R_TOC complain_on_overflow from
	signed to bitfield.
	(rs6000coff_vec): Add DYNAMIC to object_flags.
	* coffcode.h (sec_to_styp_flags): If RS6000COFF_C, handle .pad and
	.loader sections specially.
	(coff_new_section_hook): If RS6000COFF_C, get the .text and .data
	section alignment from the XCOFF tdata information.
	(coff_mkobject_hook): If RS6000COFF_C, set DYNAMIC based on
	F_SHROBJ, and copy the extra a.out header information into the
	XCOFF tdata structure.
	(coff_write_object_contents): If RS6000COFF_C, set F_SHROBJ,
	F_DYNLOAD and the extra a.out header information.
	(coff_slurp_symbol_table): Set BSF_NOT_AT_END for a C_EXT or
	C_HIDEXT symbol with attached csect information.
	* coffswap.h (coff_swap_aouthdr_in): If RS6000COFF_C, swap
	in the o_maxdata field.
	(coff_swap_aouthdr_out): If RS6000COFF_C, swap extra XCOFF fields.
	* coffgen.c (coff_renumber_symbols): Don't move any symbol to the
	end if BSF_NOT_AT_END is set.
1995-10-09 21:19:53 +00:00
Ian Lance Taylor a208a70f7a Convert i960 COFF to use COFF backend linker.
* coff-i960.c (coff_i960_relocate): Use a coff_section_data
	structure to store the symbol being used.
	(coff_i960_start_final_link): New static function.
	(coff_i960_relocate_section): New static function.
	(coff_i960_adjust_symndx): New static function.
	(coff_start_final_link): Define.
	(coff_relocate_section): Define.
	(coff_adjust_symndx): Define.
	* coffcode.h (bfd_coff_backend_data): Add new callback function
	_bfd_coff_start_final_link.
	(bfd_coff_start_final_link): Define.
	(coff_start_final_link): Define if not defined.
	(bfd_coff_std_swap_table): Add coff_start_final_link.
	* cofflink.c (_bfd_coff_internal_syment_name): Make globally
	visible.
	(_bfd_coff_final_link): Call bfd_coff_start_final_link if the
	function callback is not NULL.
	* libcoff-in.h (struct coff_section_tdata): Add tdata field.
	(_bfd_coff_internal_syment_name): Declare.
	* libcoff.h: Rebuild.
	* configure.in (icoff_big_vec): Add cofflink.o.
	(icoff_little_vec): Likewise.
	* configure: Rebuild.
1995-09-14 19:03:21 +00:00
Steve Chamberlain beee31b1a2 Thu Sep 7 12:45:34 1995 steve chamberlain <sac@slash.cygnus.com>
* coffcode.h (coff_compute_section_file_positions): Keep the
	raw size safe.
	(coff_write_object_contents): Remember if it's a relocatable
	file.
	* libcoff-in.h (pe_data_type): New member 'has_reloc_section'
	* peicode.h (coff_swap_filehdr_out): Clear not-reloc flag
	if relocatable file. Swap out saved raw size.
1995-09-12 19:28:30 +00:00
Ian Lance Taylor 69645d10fb Add new style linker support to COFF backend. a29k only for now.
* cofflink.c: New file.
	* libcoff-in.h: Include bfdlink.h.
	(obj_coff_external_syms, obj_coff_strings): Define accessor macro.
	(obj_coff_sym_hashes): Define accessor macro.
	(struct coff_tdata): Add fields external_syms, strings, and
	sym_hashes.
	(struct coff_link_hash_entry): Define.
	(struct coff_link_hash_table): Define.
	(coff_link_hash_lookup, coff_link_hash_traverse): Define.
	(coff_hash_table): Define.
	(_bfd_coff_link_hash_table_create): Declare.
	(_bfd_coff_link_add_symbols, _bfd_coff_final_link): Declare.
	* coffcode.h (bfd_coff_backend_data): Add fields _bfd_relsz,
	_bfd_coff_swap_reloc_in, _bfd_coff_sym_is_global,
	_bfd_coff_compute_section_file_positions,
	_bfd_coff_relocate_section.
	(bfd_coff_relsz, bfd_coff_swap_reloc_in): Define.
	(bfd_coff_sym_is_global): Define.
	(bfd_coff_compute_section_file_positions): Define.
	(bfd_coff_relocate_section): Define.
	(coff_mkobject_hook): Initialize obj_raw_syment_count and
	obj_conv_table_size.
	(coff_compute_section_file_positions): Set target_index of all
	sections.  Set output_has_begun field.
	(coff_write_object_contents): Don't set target_index; now done by
	coff_compute_section_file_positions.  Remove obsolete handling of
	scn_base and data_base.  Don't bother to check that target_index
	is positive, since it always is.  Remove use of pad, which is
	always zero.  Check obj_raw_syment_count, not bfd_get_symcount,
	for the number of symbols, but only write them out if
	bfd_get_symcount is non-zero.
	(coff_slurp_symbol_table): Use obj_raw_syment_count, not
	bfd_get_symcount for the number of symbols.  Don't set
	obj_conv_table_size.
	(coff_sym_is_global): New static function or macro.
	(coff_slurp_reloc_table): Call coff_swap_reloc_in, not
	bfd_swap_reloc_in.
	(coff_bfd_link_hash_table_create): If coff_relocate_section is
	defined, define as _bfd_coff_link_hash_table_create.
	(coff_bfd_link_add_symbols): Similar change.
	(coff_bfd_final_link): Similar change.
	(coff_relocate_section): Define as NULL if not defined.
	(bfd_coff_std_swap_table): Initialize new fields.
	* coffgen.c (coff_real_object_p): Don't set obj_raw_syment_count
	and obj_conv_table_size here.
	(coff_count_linenumbers): Reindent.  If bfd_get_symcount is zero,
	add up the line numbers from the sections.
	(coff_write_symbols): Don't set bfd_get_symcount.
	(coff_pointerize_aux): Don't pointerize a nonpositive x_endndx
	field.
	(coff_get_normalized_symtab): Use obj_raw_syment_count, not
	bfd_get_symcount.
	(coff_print_symbol): If auxp->fix_end, print x_endndx value.
	* coffswap.h (coff_swap_reloc_in): Rename from bfd_swap_reloc_in.
	Reindent.  Change argument type to  PTR.
	* coff-a29k.c (coff_a29k_relocate_section): New static function.
	(coff_relocate_section): Define.
	* configure.in (a29kcoff_big_vec): Compile cofflink.o.
	* coff-alpha.c (alpha_ecoff_backend_data): Initialize new fields.
	* coff-mips.c (mips_ecoff_backend_data): Likewise.
	* libcoff.h: Rebuilt.
	* Makefile.in: Rebuilt dependencies.
	(BFD32_BACKENDS): Add cofflink.o.
	(CFILES): Add cofflink.c.
1994-09-06 19:28:55 +00:00
Ian Lance Taylor 326e32d7ce 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.
1994-03-30 22:15:07 +00:00
Ian Lance Taylor 0c2fae099a Mon Jan 11 18:32:22 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* targets.c (bfd_target): Added relocateable argument to
	_bfd_get_relocated_section_contents.  Added _bfd_seclet_link
	target vector for linker use.
	* bfd.c (bfd_seclet_link): New macro.
	* bfd-in.h (JUMP_TABLE): Added _bfd_seclet_link.
	* seclet.c (rel, seclet_dump_seclet): Added relocateable argument
	and boolean return value.  Made static.
	(bfd_generic_seclet_link): Renamed from seclet_dump.  Added
	relocateable argument.
	* reloc.c (bfd_generic_get_relocated_section_contents): Added
	relocateable argument (if relocateable, saves relocs).
	* bout.c (b_out_get_relocated_section_contents),
	reloc16.c (bfd_coff_reloc16_get_relocated_section_contents): Added
	relocateable argument (if relocateable, just calls
	bfd_generic_get_relocated_section_contents).
	* libcoff-in.h (bfd_coff_reloc16_get_value): Added relocateable
	argument to prototype.
	* All targets: Set new _bfd_seclet_link vector to
	bfd_generic_seclet_link.
1993-01-12 00:38:59 +00:00
Ian Lance Taylor 918356b902 Use struct bfd_seclet * rather than bfd_seclet_type in prototypes to
avoid requiring seclet.h before libcoff.h.
1993-01-10 20:35:41 +00:00
Ian Lance Taylor 075caafd65 These changes cut the size of libbfd.a on a Sun4 by about 11%.
Somewhat more could be done.

Fri Jan  8 15:47:53 1993  Ian Lance Taylor  (ian@tweedledumb.cygnus.com)

	* coffcode.h: Moved many generic functions into coffgen.c.  Moved
	swapping functions into coffswap.h for ECOFF use.  Moved
	relocation functions, only used by h8300 and z8k, into reloc16.c.
	Added hooks for coffgen.c functions to backend data structure, and
	added hook functions.  Still more could be done.
	* coffswap.h: New file to hold COFF swapping routines.
	* coffgen.c: New file to hold generic COFF functions.
	* reloc16.c: New file to hold h8300 and z8k specific relocation
	functions.
	* libcoff-in.h: Added declarations for functions in coffgen.c.
	* libcoff.h: Rebuilt to incorporate changes.
	* coff-h8300.c: Function name changes.
	* coff-z8k.c: Function name changes.  Use coff_reloc16_extra_cases
	hook rather than defining EXTRA_CASES.
	* Makefile.in: Build new files coffgen and reloc16.  Added
	dependencies of coff-*.o on coffswap.h and seclet.h.
1993-01-08 21:11:21 +00:00