Commit Graph

44 Commits

Author SHA1 Message Date
Ian Lance Taylor b2a05baf21 * xcofflink.c (xcoff_link_input_bfd): If we already called the
undefined_symbol callback for a symbol, then don't issue any more
	warnings about loader relocs.
	(_bfd_ppc_xcoff_relocate_section): Don't do any further processing
	after calling the undefined_symbol callback.
1996-08-08 21:15:32 +00:00
Ian Lance Taylor fbc4ed7ded * xcofflink.c (XCOFF_MULTIPLY_DEFINED): Define.
(xcoff_link_add_symbols): Permit multiple definitions of a symbol
	as the AIX linker seems to do.
PR 10304.
1996-08-08 20:33:39 +00:00
Ian Lance Taylor fb4dc1eb5f * xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): Do the regular
archive search before looking for stripped dynamic objects.
PR 10187.
1996-07-30 17:39:33 +00:00
Ian Lance Taylor b223f95038 * xcofflink.c (xcoff_build_ldsyms): Make exporting an undefined
symbol a warning rather than an error.
PR 10208.
1996-07-26 21:53:08 +00:00
Ian Lance Taylor a8a3d83af0 * xcofflink.c (xcoff_link_add_symbols): Don't check an XMC_TD
symbol for a magic name.
	(xcoff_link_input_bfd): Don't change the reloc symbol for an
	XMC_TD symbol.
	(_bfd_ppc_xcoff_relocate_section): Don't get the TOC offset for an
	XMC_TD symbol.
1996-07-18 19:41:35 +00:00
Ian Lance Taylor 4914478412 * xcofflink.c (_bfd_ppc_xcoff_relocate_section): Check explicitly
for _ptrgl, and treat it as global linkage code.
PR 9860.
1996-06-12 22:05:32 +00:00
Ian Lance Taylor a5c7acea2f * xcofflink.c (xcoff_build_ldsyms): Set XCOFF_DEF_REGULAR for a
common symbol defined by the linker.  Don't export function code
	even if export_defineds is set.
PR 9856.
1996-06-11 22:25:55 +00:00
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 f97fca7872 * xcofflink.c (xcoff_link_input_bfd): Check for TOC overflow. 1996-04-17 21:09:34 +00:00
Ian Lance Taylor ff0e4a9341 Remove SEC_LINKER_MARK, and add a linker_mark bitfield to the asection
structure instead.
1996-03-27 22:23:18 +00:00
Ian Lance Taylor 7ec49f9133 * section.c (SEC_LINKER_MARK): Define.
* bfd-in2.h: Rebuild.
	* aoutx.h (NAME(aout,final_link)): Mark sections included in the
	link.
	(aout_link_input_bfd): Don't link unmarked sections.
	* cofflink.c (_bfd_coff_final_link): Mark sections included in the
	link.
	(_bfd_coff_link_input_bfd): Don't link unmarked sections.
	* coff-ppc.c (ppc_bfd_coff_final_link): Mark sections included in
	the link.
	* elflink.h (elf_bfd_final_link): Mark sections included in the
	link.
	(elf_link_input_bfd): Don't link unmarked sections.
	* xcofflink.c (_bfd_xcoff_bfd_final_link): Mark sections included
	in the link.
	(xcoff_link_input_bfd): Don't link unmarked sections.
1996-03-27 19:21:19 +00:00
Ian Lance Taylor c3dffbd7cd * xcofflink.c (xcoff_link_input_bfd): Fix scan for C_BINCL/C_EINCL
symbols.
1996-03-22 19:59:20 +00:00
Ian Lance Taylor 6014cea70c update copyrights 1996-01-15 21:06:31 +00:00
Ian Lance Taylor c9746fb695 * xcofflink.c (xcoff_link_add_symbols): Create the special
sections if we see a DYNAMIC object, in case that is the only
	XCOFF input object we see.
PR 8788.
1996-01-12 04:29:59 +00:00
Ian Lance Taylor 58142f101d * libbfd.c (bfd_malloc, bfd_realloc): New functions.
(bfd_zmalloc): Return PTR, not char *.  Take size_t, not
	bfd_size_type.
	* libbfd-in.h (bfd_malloc, bfd_realloc): Declare.
	(bfd_zmalloc): Change declaration.
	* libbfd.h: Rebuild.
	* Many files: Use bfd_malloc and bfd_realloc rather than malloc
	and realloc.  Don't set bfd_error_no_memory if they fail.
1995-12-01 19:48:10 +00:00
Ian Lance Taylor a9713b91a7 * opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
obstack_alloc fails.
	(bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
	fails.
	* libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
	* Many files: don't set bfd_error_no_memory if one of the above
	routines fails.
1995-11-29 22:05:37 +00:00
Ian Lance Taylor 83dcdc6168 * xcofflink.c (bfd_xcoff_size_dynamic_sections): Clear
special_sections before returning when called with a non XCOFF
	BFD.
1995-11-21 21:25:35 +00:00
Ian Lance Taylor b5403ad754 * xcofflink.c (xcoff_link_input_bfd): Adjust the TOC anchor value
if it is not large enough to accomodate the entire TOC area with
	signed 16 bit offsets.
	(xcoff_write_global_symbol): Handle negative TOC offsets in global
	linkage code.
	(_bfd_ppc_xcoff_relocate_section): Adjust relocations against a
	TOC anchor to use the TOC value used in the output file.
1995-11-20 19:57:30 +00:00
Ian Lance Taylor 4a378b13e4 * coffcode.h (coff_set_alignment_hook): Write RS6000COFF_C version
which checks for STYP_OVRFLO sections.
	(coff_compute_section_file_positions): If RS6000COFF_C, handle
	reloc and lineno count overflows.
	(coff_write_object_contents): Call coff_count_linenumbers before
	coff_compute_section_file_positions.  If RS6000COFF_C, handle
	reloc and lineno count overflows.
	* xcofflink.c (_bfd_xcoff_bfd_final_link): Count line numbers and
	relocs before dealing with .pad sections.  Count overflow section
	headers when handling .pad sections.
1995-11-09 19:44:09 +00:00
Ian Lance Taylor ee17481566 * xcofflink.c (XCOFF_DESCRIPTOR): Define.
(struct xcoff_link_hash_table): Add descriptor_section and
	special_sections fields.
	(_bfd_xcoff_bfd_link_hash_table_create): Initialize new fields.
	(xcoff_link_add_symbols): Set linkage section alignment.  Create
	descriptor section.  Check for magic symbol names (_text, etc.),
	and record them in special_sections if found.  Set
	XCOFF_DESCRIPTOR flag for a function descriptor, and set its
	descriptor field to point back to the function code symbol.
	(xcoff_sweep): Always mark the special descriptor_section.
	(bfd_xcoff_export_symbol): Check whether the symbol might be a
	function descriptor, and mark it if it is.
	(bfd_xcoff_size_dynamic_sections): Add new special_sections
	parameter, and fill it in.  Allocate space for the descriptor
	section.
	(xcoff_build_ldsyms): Set XCOFF_DEF_REGULAR flag when defining
	global linkage code.  If an undefined function descriptor is
	exported, arrange to define it.  Warn about any other undefined
	exported symbol.
	(_bfd_xcoff_bfd_final_link): Write out the descriptor section.
	(xcoff_write_global_symbol): Create a function descriptor when
	necessary.
	* bfd-in.h (bfd_xcoff_size_dynamic_sections): Update declaration.
	* bfd-in2.h: Rebuild.
1995-11-09 18:08:56 +00:00
Ian Lance Taylor 7812bf9c25 * xcofflink.c (xcoff_find_reloc): Handle the case of a single
reloc correctly.
1995-11-08 19:26:19 +00:00
Ian Lance Taylor 417acf225f more XCOFF linker hackery 1995-11-08 19:08:18 +00:00
Ian Lance Taylor 0634a43142 * xcofflink.c (XCOFF_DEF_DYNAMIC): Rename from XCOFF_REF_DYNAMIC.
Change all uses.
	(xcoff_swap_ldhdr_in): New static function.
	(xcoff_swap_ldsym_in): New static function.
	(xcoff_link_add_symbols): If we just created a descriptor, pass it
	to _bfd_generic_link_add_one_symbol, to save a hash lookup.
	(xcoff_link_add_dynamic_symbols): Rewrite to read .loader symbols
	rather than normal symbol table.
	(xcoff_mark): When considering called symbols, check whether the
	descriptor is from a dynamic object, rather than the symbol
	itself.
	(xcoff_build_ldsyms): Likewise.
1995-11-08 18:17:44 +00:00
Ian Lance Taylor 83c23fca5b * xcofflink.c (xcoff_link_add_symbols): Set the alignment power of
the created .tc section to 2.
	(xcoff_mark): Don't keep a .loader reloc for a call to an
	undefined symbol when creating a shared library.
	(xcoff_build_ldsyms): When creating a shared library, generate
	global linkage code for a call to an undefined symbol.
1995-11-06 19:36:29 +00:00
Ian Lance Taylor 583db7a8e1 * xcofflink.c (xcoff_link_add_symbols): Rename local variable sub
to o.  Clobber and restore the list of new csects around the call
	to _bfd_generic_link_add_one_symbol, in case it wants to report a
	linker error and the linker wants to read the symbol table.  Reset
	the line number count of a real section even if it has no relocs.
	(_bfd_xcoff_bfd_final_link): If shared, set the DYNAMIC flag.
1995-11-03 21:20:41 +00:00
Ian Lance Taylor 18a9609c03 * xcofflink.c (_bfd_ppc_xcoff_relocate_section): Don't warn about
an undefined symbol in a shared link.
1995-11-03 04:18:55 +00:00
Ian Lance Taylor b2193cc594 * elf.c (bfd_elf_set_dt_needed_name): Don't do anything if the
BFD is not of the right type.
	(bfd_elf_get_needed_list): Likewise.
	* i386linux.c (bfd_linux_size_dynamic_sections): Likewise.
	* sunos.c (bfd_sunos_get_needed_list): Likewise.
	* xcofflink.c (XCOFF_XVECP): Define.
	(bfd_xcoff_link_record_set): Don't do anything if the BFD is not
	of the right type.
	(bfd_xcoff_import_symbol): Likewise.
	(bfd_xcoff_export_symbol): Likewise.
	(bfd_xcoff_link_count_reloc): Likewise.
	(bfd_xcoff_record_link_assignment): Likewise.
	(bfd_xcoff_size_dynamic_sections): Likewise.
1995-11-01 18:25:35 +00:00
Ian Lance Taylor 73246ff837 * coff-rs6000.c (_bfd_xcoff_sizeof_headers): Change from macro to
static function.
	* xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Set
	full_aouthdr flag here...
	(_bfd_xcoff_bfd_final_link): ...not here.
1995-11-01 16:47:14 +00:00
Ian Lance Taylor e608052057 * xcofflink.c (xcoff_mark_symbol): New static function, broken out
of xcoff_mark.
	(xcoff_mark): Call xcoff_mark_symbol.
	(bfd_xcoff_export_symbol): Call xcoff_mark_symbol.
	(bfd_xcoff_link_count_reloc): Call xcoff_mark_symbol rather than
	doing it by hand.
	(xcoff_build_ldsyms): Build a .loader symbol for an export symbol.
1995-10-31 17:36:12 +00:00
Ian Lance Taylor f630a0a41a * xcofflink.c (struct xcoff_final_link_info): Add new line_filepos
field.
	(xcoff_find_reloc): New static function.
	(xcoff_link_add_symbols): Use it.
	(_bfd_xcoff_bfd_final_link): Set finfo.line_filepos.
	(xcoff_link_input_bfd): Handle C_BINCL and C_EINCL.  Don't
	relocate the value of C_DECL.
1995-10-30 23:53:16 +00:00
Ian Lance Taylor 697a8fe872 * xcofflink.c (xcoff_link_add_symbols): Handle csects in the
absolute section.
1995-10-28 05:51:49 +00:00
Ian Lance Taylor 2d7de17d61 * xcofflink.c: More improvements, mostly to fix handling of
constructors and a few other special cases.
	* coff-rs6000.c (rs6000coff_vec): Set symbol_leading_char back to
	zero, reverting yesterday's change.
	* bfd-in.h (bfd_xcoff_link_record_set): Declare.
	(bfd_xcoff_link_count_reloc): Declare.
	(bfd_xcoff_record_link_assignment): Declare.
	* bfd-in2.h: Rebuild.
1995-10-27 22:20:19 +00:00
Ian Lance Taylor aad2c618d3 more XCOFF linker tweaks 1995-10-27 03:36:17 +00:00
Ian Lance Taylor 1d04caa1f9 fix output location of common symbols 1995-10-27 00:10:05 +00:00
Ian Lance Taylor bdaff47eb7 do not output symbols which need relocs until the end 1995-10-26 23:39:19 +00:00
Ian Lance Taylor 230de6b868 get symndx right for TOC relative relocs 1995-10-26 23:03:34 +00:00
Ian Lance Taylor e1371ad18c tweak .loader reloc counting 1995-10-26 18:42:46 +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 9c234e298d set l_stoff to 0 if there are no strings 1995-10-25 18:31:27 +00:00
Ian Lance Taylor afe0786271 only read the section relocs if there are some 1995-10-25 17:58:30 +00:00
Ian Lance Taylor f78195df56 tweak line number and gc handling 1995-10-25 17:45:33 +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
Stan Shebs aadf04f736 * configure.in: Add xcofflink.o to pmac_xcoff_vec.
* configure: Rebuild.
	* mpw-config.in: Add xcofflink.c.o to powerpc-apple-macos.
	* coff-pmac.c: Include coff-rs6000.c instead of duplicating its
	contents.
	(pmac_xcoff_vec): Update to use new xcoff support.
	* coff-rs6000.c (xcoff_generic_stat_arch_elt): Make static.
	(xcoff_write_armap): Declare buf as unsigned char.
	* xcofflink.c (xcoff_link_add_symbols): Declare a local as PTR.

	* mpw-make.sed: Generalize subdir_do edit.
1995-10-25 00:54:55 +00:00