Commit Graph

1130 Commits

Author SHA1 Message Date
Jean Marie Diaz 99dd775492 ELF linker patches from Eric Youngdale <ericy@cais.cais.com>.
* elfcode.h (elf_link_create_dynamic_sections): Set type of
	_DYNAMIC to STT_OBJECT.
	(NAME(bfd_elf,record_link_assignment)): Always create hash table
	entry.  Set type to STT_OBJECT.
	(elf_link_output_extsym): Don't set type of weak defined symbol to
	STB_WEAK if symbol was referenced.
	* elf32-i386.c (elf_i386_create_dynamic_sections): Set type of
	_GLOBAL_OFFSET_TABLE to STT_OBJECT.
	(elf_i386_check_relocs): Ignore local PLT32 relocs.
	(elf_i386_relocate_section): Treat local PLT32 relocs as PC32.
1994-08-01 23:11:18 +00:00
Jean Marie Diaz 287e3ce228 Mon Aug 1 17:55:53 1994 Fred Fish (fnf@cygnus.com)
* ptrace-core.c (ptrace_unix_core_file_p):  Convert zalloc usage
	to bfd_zalloc.
1994-08-01 22:00:19 +00:00
Ian Lance Taylor 30e5ad97e9 * elfcode.h (elf_adjust_dynamic_symbol): Correct weak symbol
handling again.
1994-08-01 20:53:48 +00:00
Ian Lance Taylor d510fd893a * elfcode.h (elf_slurp_reloc_table): Don't try to read the relocs
if there aren't any.
1994-08-01 16:34:09 +00:00
Ian Lance Taylor abc61566c0 * configure.host (sparc-*-solaris2*): Use sysv4, not solaris2.
* hosts/solaris2.h: Remove.
	* config/solaris2.mh: Remove.
1994-08-01 16:16:47 +00:00
Jeff Law 58bbba79a2 * elf32-hppa.c, elf32-hppa.h: Update comment reflecting which
HPPA ELF spec the code implements.
1994-07-31 20:29:19 +00:00
Ken Raeburn b5b056fc38 i960xl changes (sanitized) 1994-07-27 00:21:43 +00:00
Ian Lance Taylor 9a402d7ac5 * elfcode.h (elf_adjust_dynamic_symbol): When handling a weak
symbol, correct check to see whether the equivalent normal symbol
	was referenced.
1994-07-26 19:34:14 +00:00
Ian Lance Taylor 374d2ef905 Add support for creating shared libraries under i386 ELF and SPARC
ELF.  Based on patches by Eric Youngdale <ericy@cais.cais.com>.
	* libelf.h (struct elf_link_hash_entry): Remove copy_offset field.
	Add got_offset and plt_offset fields.
	(ELF_LINK_HASH_REF_DYNAMIC_MULTIPLE): Don't define.
	(ELF_LINK_HASH_DEF_DYNAMIC_MULTIPLE): Don't define.
	(ELF_LINK_HASH_NEEDS_COPY): Define.
	(struct elf_backend_data): Add check_relocs field.
	(struct bfd_elf_section_data): Change relocs from PTR to
	Elf_Internal_Rela *.
	(struct elf_obj_tdata): Add local_got_offsets field.
	(elf_local_got_offsets): Define accessor macro.
	(bfd_elf32_link_create_dynamic_sections): Declare.
	(bfd_elf32_link_record_dynamic_symbol): Declare.
	(bfd_elf64_link_create_dynamic_sections): Declare.
	(bfd_elf64_link_record_dynamic_symbol): Declare.
	* elfcode.h (elf_slurp_reloc_table): Don't use the section data
	relocs field.
	(elf_link_record_dynamic_symbol): Make globally visible.  Use
	macro to rename to NAME(bfd_elf,link_record_dynamic_symbol).
	(elf_link_add_object_symbols): If creating a shared library, put
	make all local symbols dynamic.  Don't bother with the
	DYNAMIC_MULTIPLE flags.  Call the check_relocs backend function if
	it is defined.
	(elf_link_create_dynamic_sections): Make globally visible.  Use
	macro to rename to NAME(bfd_elf,link_create_dynamic_sections).  If
	creating a shared library, make sure that _DYNAMIC is added as a
	dynamic symbol.
	(elf_link_read_relocs): New function.
	(NAME(bfd_elf,record_link_assignment)): If creating a shared
	library, always create symbols, and always make them dynamic.
	(elf_bfd_final_link): Permit creation of shared libraries.
	(elf_link_input_bfd): Use elf_link_read_relocs to get the relocs.
	* elf.c (_bfd_elf_link_hash_newfunc): Don't initialize
	copy_offset.  Initialize got_offset and plt_offset.
	* elf32-target.h (elf_backend_check_relocs): Define as 0 if not
	defined.
	(elf32_bed): Initialize check_relocs field.
	* elf64-target.h (elf_backend_check_relocs): Define as 0 if not
	defined.
	(elf64_bed): Initialize check_relocs field.
	* elf32-i386.c (elf_howto_table): Change R_386_PLT32 and
	R_386_GOTPC to be pc_relative and pcrel_offset.
	(elf_i386_pic_plt0_entry): Define.
	(elf_i386_pic_plt_entry): Define.
	(elf_i386_create_dynamic_sections): Create a .got.plt section, and
	define _GLOBAL_OFFSET_TABLE_ at the start of it.  If creating a
	shared library, make sure that _GLOBAL_OFFSET_TABLE_ is added as a
	dynamic symbol.  Don't create .rel.bss if creating a shared
	library.
	(elf_i386_check_relocs): New function.
	(elf_i386_adjust_dynamic_symbol): Don't make a PLT entry if the
	symbol already has one.  When making a PLT entry, set plt_offset.
	Don't create a copy reloc when creating a shared library.  Don't
	set copy_offset, just set ELF_LINK_HASH_NEEDS_COPY.
	(elf_i386_allocate_dynamic_section): Remove.
	(elf_i386_size_dynamic_sections): Look through all the sections
	rather than assuming we know their names.  Remove any empty reloc
	or plt sections.  Only add a DT_DEBUG entry if not creating a
	shared library.  Only add a DT_PLTGOT entry if there is a PLT.
	Add a DT_TEXTREL entry if required.
	(elf_i386_relocate_section): Permit undefined symbols when
	creating a shared library.  Handle the special relocation types
	specially.
	(elf_i386_finish_dynamic_symbol): Create a PLT entry if plt_offset
	is set.  If creating a shared library, produce a PIC PLT entry.
	Only mark a PLT symbol as undefined if it was not defined by a
	regular object file.  Create a GOT entry if got_offset is set.
	Create a copy reloc if ELF_LINK_HASH_NEEDS_COPY is set.
	(elf_i386_finish_dynamic_sections): Change the handling of
	DT_RELSZ to simply subtract out the size of .rel.plt.  If creating
	a shared library, produce PIC PLT code.
	(elf_backend_check_relocs): Define.
	* elf32-sparc.c (elf_sparc_howto_table): Change R_SPARC_GOT10,
	R_SPARC_GOT22, and R_SPARC_PC10 to not warn about reloc overflow.
	(elf32_sparc_create_dynamic_sections): If creating a shared
	library, make sure that _GLOBAL_OFFSET_TABLE_ is added as a
        dynamic symbol, and set the type to STT_OBJECT.  Likewise for
        _PROCEDURE_LINKAGE_TABLE_.  Don't create .rel.bss if creating a
        shared library.
	(elf32_sparc_check_relocs): New function.
	(elf32_sparc_adjust_dynamic_symbol): Don't make a PLT entry if the
	symbol already has one.  When making a PLT entry, set plt_offset.
	Don't create a copy reloc when creating a shared library.  Don't
	set copy_offset, just set ELF_LINK_HASH_NEEDS_COPY.
	(elf32_sparc_allocate_dynamic_section): Remove.
	(elf32_sparc_size_dynamic_sections): Look through all the sections
	rather than assuming we know their names.  Only add a DT_DEBUG
	entry if not creating a shared library.  Add a DT_TEXTREL entry if
	required.
	(elf32_sparc_relocate_section): Permit undefined symbols when
	creating a shared library.  Handle the special relocation types
	specially.
	(elf32_sparc_finish_dynamic_symbol): Create a PLT entry if plt_offset
	is set.  Only mark a PLT symbol as undefined if it was not defined
	by a regular object file.  Create a GOT entry if got_offset is
	set.  Create a copy reloc if ELF_LINK_HASH_NEEDS_COPY is set.
	(elf32_sparc_finish_dynamic_sections): Store dynobj in a local
	variable.
	(elf_backend_check_relocs): Define.
1994-07-26 17:18:37 +00:00
Stan Shebs caede51576 * configure.in (pc532mach_vec): Change to pc532machaout_vec.
* config.bfd (ns32k-*-netbsd*): Use ns32k-nbsd as bfd_name.
	* Makefile.in (ALL_MACHINES): Add cpu-ns32k.o.
	(BFD32_BACKENDS): Add aout-ns32k.o, netbsd532.o, m88kmach3.o,
	pc532-mach.o.
	* targets.c (pc532machaout_vec): Use instead of pc532mach_vec.
	* config/pc532-mach.mt (DEFAULT_VECTOR): Ditto.
	(SELECT_VECS): Remove.
	* config/ns32k-nbsd.mt: New file, was ns32k-netbsd.mt.
	* config/ns32k-netbsd.mt: Remove, name too long.
1994-07-25 20:00:10 +00:00
Ian Lance Taylor f2c2e75ce0 Forgot to save my buffer before last check in. 1994-07-22 23:50:35 +00:00
Ian Lance Taylor 2aaaab7ceb * aoutx.h (NAME(aout,some_aout_object_p)): Just check
STAT_FOR_EXEC, don't check MACH.
	* m88kmach3.c (MACH): Don't define.
	* config/i386-mach3.mt (TDEFINES): Define STAT_FOR_EXEC.
	* config/m88k-mach3.mt (TDEFINES): Likewise.
	* config/mips-mach3.mt (TDEFINES): Likewise.
1994-07-22 15:13:33 +00:00
Stan Shebs bb99a7328c * i386mach3.c: Reverted to version from before Jul 5 1994 changes.
Un-break gas/binutils/ld for FSF.
1994-07-22 00:28:17 +00:00
Ian Lance Taylor f42fe1599a * reloc.c (struct reloc_howto_struct): Remove special_function1.
It's the wrong way to do things.
	(HOWTO): Change accordingly.
	(HOWTO2): Remove.
	(_bfd_final_link_relocate): Remove references to
	special_function1.
	* bfd-in2.h: Rebuilt.
	* aoutx.h (aout_link_input_section_std): Remove references to
	special_function1.
	(aout_link_reloc_link_order): Likewise.
1994-07-21 16:34:59 +00:00
Ian Lance Taylor bf73e4f3fe * libelf.h (ELF_LINK_HASH_DEFINED_WEAK): Define.
* elfcode.h (elf_link_add_object_symbols): If symbol is defined as
	weak, set ELF_LINK_HASH_DEFINED_WEAK.
	(elf_link_output_extsym): If symbol is defined as weak, mark it
	STB_WEAK.
1994-07-17 02:15:24 +00:00
Ian Lance Taylor ea61717495 * libelf.h (struct bfd_elf_section_data): Add relocs field.
(shdr_name): Remove; unused.
	* elfcode.h (elf_slurp_reloc_table): Rewrote to handle both REL
	and RELA relocs.  Free up the unswapped relocs.  Permit the relocs
	to be cached in the section_data.  Correct the reloc address.
	(elf_slurp_reloca_table): Remove.
	(elf_canonicalize_reloc): Rewrote.
	(elf_link_input_bfd): Permit the relocs to be cached in the
	section data.
1994-07-17 01:15:42 +00:00
Stan Shebs d9840ab79e * config.bfd (m88*-harris-cxux*): Recognize.
* hosts/harris.h (POSIX_UTIME, HAVE_PROCFS): Define.
1994-07-16 21:08:41 +00:00
Stan Shebs ef8b133d8c * configure.host (m68*-atari-sysv4*): New host.
(m68*-cbm-sysv4*): Use m68kv4 instead of amix.
	* hosts/amix.h: Remove.
	* hosts/m68kv4.h: New file, was amix.h.
1994-07-16 21:02:53 +00:00
Ken Raeburn 1fb83be62b NS32K changes from Ian Dall.
Note: Some of the ns32k-specific files do require gcc to compile at present.
This will be fixed.
1994-07-14 21:35:54 +00:00
Stan Shebs a307efdfac * coff-sparc.c (sparccoff_vec): Have leading underscores. 1994-07-14 18:50:22 +00:00
Peter Schauer 57a814a93e * aix386-core.c, aoutf1.h, cisco-core.c, elfcode.h, hppabsd-core.c,
hpux-core.c, irix-core.c, lynx-core.c, osf-core.c, ptrace-core.c,
	rs6000-core.c, trad-core.c:  Remove SEC_ALLOC flag from .reg
	sections, .reg sections are not allocated and contain debug
	information only.
	* osf-core.c (make_bfd_asection, osf_core_core_file_p):  Use
	bfd_make_section_anyway instead of building unique section names.
1994-07-12 19:14:09 +00:00
Ian Lance Taylor 840846dac5 * libelf.h (bfd_elf32_swap_symbol_in): Declare.
(bfd_elf32_swap_symbol_out): Declare.
	(bfd_elf64_swap_symbol_in, bfd_elf64_swap_symbol_out): Declare.
	* elf32-hppa.c (elf32_hppa_args_hash_table_init): Correct cast.
1994-07-12 16:13:05 +00:00
Ian Lance Taylor 42ec46c361 * aout-encap.c (ARCH): Don't define. Obsolete.
* aout0.c, aoutx.h, gen-aout.c, hp300bsd.c, hp300hpux.c: Likewise.
	* i386aout.c, i386bsd.c, i386dynix.c, i386linux.c: Likewise.
	* i386lynx.c, m68klynx.c, mipsbsd.c, netbsd386.c: Likewise.
	* newsos3.c, sparclynx.c, sunos.c: Likewise.
1994-07-12 15:46:32 +00:00
Ian Lance Taylor 18938e4d3e * section.c (STD_SECTION): Make the sixth argument boolean, not
the seventh.  From gary@tuva.pacsemi.oz.au (gary kopff).
1994-07-12 00:12:19 +00:00
David Henkel-Wallace 4852416e2a Sun Jul 10 09:12:02 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
* aoutx.h (bfd_free_cached_info): Change name of FREE to BFCI_FREE
        in order not to collide with LynxOS's definition of FREE in
        /usr/include/sys/proc.h
1994-07-10 16:15:07 +00:00
Peter Schauer fd4913f196 * aoutx.h (howto_table_std): Add entry for GOT relocations
which are present in sun3 shared libraries, to avoid assertions
	when reading the dynamic relocations.
1994-07-07 17:11:58 +00:00
Jeff Law 48530c25d3 * som.h (R_HPPA_COMPLEX): Fix dumb typo. 1994-07-07 16:22:01 +00:00
Ian Lance Taylor 874a43273c * elfcode.h (elf_link_output_sym): Don't call output_symbol_hook
if it is NULL.
1994-07-06 23:33:02 +00:00
Peter Schauer 5fb54939a9 * coff-alpha.c (alpha_ecoff_mkobject_hook): New hook to
additionally copy object type information from the alpha file
	header to the BFD flags.
	(alpha_ecoff_backend_data):  Use it.
	(ecoffalpha_little_vec):  Add DYNAMIC to object_flags.
	* aout64.c:  Fix typo in conditional QMAGIC definition.
1994-07-06 07:53:31 +00:00
Jeff Law 2c0f3abc50 * hppabsd-core.c (hppabsd_core_core_file_p): Sanity check the
value of clicksz to help weed out non HPPA BSD core files.
1994-07-06 06:17:06 +00:00
Stan Shebs 11676adc14 Mach 3 support.
* config.bfd (m88*-*-mach3*, mips*-dec-mach3*, mips*-*-mach3*):
	New targets.
	* configure.host (i[34]86-*-mach3*, ns32k-*-mach3*): Recognize
	"mach3" instead of "mach".
	(m88*-*-mach3*, mips*-dec-mach3*, mips*-*-mach3*): New hosts.
	* targets.c (m88kmach3_vec): New target vector.
	(bfd_target_vector): Add i386mach3_vec and m88kmach3_vec, but
	inside #if 0.
	* aoutx.h (some_aout_object_p) [MACH]: Recognize executables by
	checking for execute permission, instead of looking at entry
	point.
	* i386mach3.c: Update, define MACH, N_TXTOFF, N_TXTADDR,
	N_SHARED_LIB, don't include aout/*.h files, etc.
	* m88kmach3.c: New file, m88k Mach 3 target.
	* config/m88k-mach3.mt,	config/mips-mach3.mt: New files, target
	makefile fragments.
	* config/i386mach3.mh, config/m88kmach3.mh, config/mipsmach3.mh:
	New files, host	makefile fragments.
	* hosts/m88kmach3.h, hosts/mipsmach3.h: New files, host definitions.
1994-07-05 21:50:43 +00:00
Ian Lance Taylor 71edd06df7 * elfcode.h (swap_out_syms): Get alignment of common symbol from
st_value field of saved ELF symbol information, if there is any.
1994-07-05 18:05:03 +00:00
Jeff Law edf7c1e4fe * som.h (R_HPPA_COMPLEX): Define.
* elf32-hppa.h (R_HPPA_COMPLEX): Define.
	(elf32_hppa_reloc_type): Delete R_PARISC_STUB_CALL_17.
1994-07-05 01:19:31 +00:00
Steve Chamberlain eeaed1957a * section.c (bfd_get_section_contents): Put in parens to get
precedence right.
1994-06-28 01:09:50 +00:00
Peter Schauer 5e16521ab7 Add Solaris BCP (the part of Solaris which allows it to run
SunOS4 a.out files) core file handling.
	* aoutf1.h (external_solaris_bcp_core, swapcore_solaris_bcp):
	New structure and its swap in function.
	(internal_sunos_core):  New member c_data_addr, to receive the
	start address of the data section in the core file.
	(swapcore_sun3, swapcore_sparc, sunos4_core_file_p):  Use it.
	(sunos4_core_file_p):  Recognize Solaris BCP core file.
	(sunos4_core_file_matches_executable_p):  Always indicate match
	for Solaris BCP core files.
1994-06-24 16:18:35 +00:00
Ian Lance Taylor 8af74670df Preliminary support for generating shared libraries, from Eric
Youngdale <ericy@cais.cais.com>.
	* elfcode.h (prep_headers): If DYNAMIC, set e_type to ET_DYN.
	(elf_link_add_object_symbols): If generating a shared library,
	create dynamic sections for first input BFD with the right format.
	(elf_link_create_dynamic_sections): Don't create .interp section
	if creating a shared library.
	(elf_link_input_bfd): Skip dynamic sections in input file.
	(elf_bfd_final_link): If creating a shared library, it's OK for
	dynobj to have sections which are not SEC_IN_MEMORY.
	* elf32-i386.c (elf_i386_size_dynamic_sections): Only set .interp
	section if not creating a shared library.
	* elf32-sparc.c (elf_sparc_size_dynamic_sections): Likewise.
1994-06-23 21:36:03 +00:00
Ian Lance Taylor 51fc377bab * elfcode.h (elf_object_p): Don't set DYNAMIC just because there
is an SHT_DYNAMIC section.
1994-06-23 20:14:58 +00:00
David MacKenzie 1f8b3b5746 Change --with-targets to --enable-targets, per GNU coding standards. 1994-06-23 20:08:57 +00:00
Ian Lance Taylor 135a68152c * linker.c (_bfd_generic_link_add_archive_symbols): Initialize
pass from abfd->archive_pass, and save it there as well.
1994-06-23 00:36:38 +00:00
Ken Raeburn 2e66a62730 linker.c (FAIL): Undefine macro before defining as enum. 1994-06-23 00:10:06 +00:00
Ken Raeburn 3bf36e67e2 config.bfd (powerpc-*-elf*): New target, like powerpc-*-sysv4*. 1994-06-22 23:40:17 +00:00
Ian Lance Taylor a537cb21bb * hash.c (bfd_hash_allocate): Don't call bfd_set_error if
obstack_alloc returns NULL unless the size is non-zero.

	* linker.c (archive_hash_allocate): Define.
	(_bfd_generic_link_add_archive_symbols): Use archive_hash_allocate
	rather than obstack_alloc, for clarity.
1994-06-22 22:37:54 +00:00
Ian Lance Taylor 66f2c66f93 * elfcode.h (elf_get_reloc_upper_bound): Correct. 1994-06-22 20:00:05 +00:00
Ian Lance Taylor d81843e864 * aout64.c (BMAGIC, QMAGIC): Define if not already defined. From
Peter Schauer <pes@regent.e-technik.tu-muenchen.de>.
1994-06-22 19:38:57 +00:00
Ian Lance Taylor 0630aba528 Linux ZMAGIC support from Eric Youngdale <ericy@cais.cais.com>.
* libaout.h (struct aoutdata): Add field zmagic_disk_block_size.
	* aout-target.h (MY(callback)): Only set alignment according to
	architecture if the section sizes are aligned to that alignment,
	for backward compatibility.
	(MY(set_sizes)): Initialize zmagic_disk_block_size field.
	* aoutx.h (adjust_z_magic): Set ztih if using q_magic_format.  Set
	text section filepos to zmagic_disk_block_size if not ztih.  Use a
	different padding algorithm if not ztih.
	* i386linux.c (MY_text_includes_header): Don't define.
1994-06-22 19:13:55 +00:00
Ian Lance Taylor 4587b57831 * aoutx.h (aout_link_check_ar_symbols): Just skip N_STAB and N_FN
symbols; don't look them up in the hash table.  From
        ralphc@pyramid.com (Ralph Campbell).
1994-06-22 14:55:58 +00:00
Ian Lance Taylor badd23e323 * section.c (bfd_abs_section): Make const.
(bfd_abs_section_ptr, bfd_is_abs_section): Define.
	(bfd_und_section): Make const.
	(bfd_und_section_ptr, bfd_is_und_section): Define.
	(bfd_com_section): Make const.
	(bfd_com_section_ptr): Define.
	(bfd_ind_section): Make const.
	(bfd_ind_section_ptr, bfd_is_ind_section): Define.
	(bfd_abs_symbol, bfd_com_symbol): Make const.
	(bfd_und_symbol, bfd_ind_symbol): Likewise.
	(global_syms): Cast initialization of section field.
	(STD_SECTION): Define as const, and cast initializations.
	* bfd-in2.h: Rebuilt.
	* Many files: Change uses of bfd_abs_section, etc., to use
	bfd_abs_section_ptr or bfd_is_abs_section, etc.
1994-06-21 16:47:07 +00:00
Ian Lance Taylor 2f3508ad05 * Many files: change all bfd_target vectors to be const. Change
all uses of bfd_target * to be const bfd_target *.  Change
	bfd_target_vector and bfd_default_vector arrays to be const
	bfd_target * const *.
1994-06-20 21:55:45 +00:00
Ian Lance Taylor 75f3ef7a63 * ecoff.c, libecoff.h, ecoffswap.h, coff-alpha.c, coff-mips.c,
elf32-mips.c: Renamed all externally visible ECOFF routines which
	are local to BFD to start with _bfd_ecoff instead of just ecoff.
1994-06-20 19:39:15 +00:00
Ian Lance Taylor aac6b32f31 * ecoff.c (ecoff_swap_tir_in): Change input argument to const.
(ecoff_swap_tir_out): Likewise.
	(ecoff_swap_rndx_in, ecoff_swap_rndx_out): Likewise.
	(ecoff_slurp_symbolic_info): Add new arguments to correspond to
	read_debug_info entry point in ecoff_debug_swap structure.
	Change all calls.
	* libecoff.h (ecoff_slurp_symbolic_info): Change declaration.
	* ecoffswap.h (ecoff_swap_tir_in, ecoff_swap_tir_out): Declare.
	(ecoff_swap_rndx_in, ecoff_swap_rndx_out): Declare.
	* coff-alpha.c (alpha_ecoff_backend_data): Initialize new
	ecoff_debug_swap fields.
	* coff-mips.c (mips_ecoff_backend_data): Likewise.
	* elf32-mips.c (mips_elf_read_ecoff_info): Undefine READ.
	(mips_elf_ecoff_debug_swap): Initialize new ecoff_debug_swap
	fields.
	* configure.in (bfd_elf32_bigmips_vec): Use ecoff.o and
	ecofflink.o.
	(bfd_elf32_littlemips_vec): Likewise.
	(ecoff_big_vec, ecoff_little_vec): Likewise.
	(ecoffalpha_little_vec): Likewise.
	* Makefile.in (BFD_LIBS): Remove ecoff.o and ecofflink.o.
	(BFD32_BACKENDS): Add ecoff.o and ecofflink.o.
1994-06-20 18:26:55 +00:00