Commit Graph

121 Commits

Author SHA1 Message Date
Steve Chamberlain d1ec549d7b * elfcode.h (elf_sort_hdrs): Rewrite to be symmetrical. 1995-06-09 19:21:47 +00:00
Ken Raeburn 0ef449dfad * elfcode.h (elf_fake_sections): Permit .scommon or COMMON sections as random
SHT_NOBITS sections, in case a linker script is strange.
1995-06-08 20:12:25 +00:00
Ian Lance Taylor d211786089 * elfcode.h (elf_sort_hdrs): Check SHT_NOBITS before checking
sh_size.
1995-03-07 17:25:07 +00:00
David Edelsohn df168c35f9 * elfcode.h (elf_sort_hdrs): Keep SHT_NOBITS sections after
!SHT_NOBITS ones.
1995-03-07 07:34:21 +00:00
Ian Lance Taylor 6581a70a9a * linker.c (generic_link_check_archive_element): Allocate common
symbol information structure.  Don't bother to check for common
	symbol size overflow.
	(_bfd_generic_link_add_one_symbol): Likewise.
	* aoutx.h (aout_link_check_ar_symbols): Likewise.
	* linker.c (generic_link_check_archive_element): Adjust references
	to common symbol information for new structure.
	(_bfd_generic_link_add_one_symbol): Likewise.
	* aoutx.h (aout_link_check_ar_symbols): Likewise.
	(aout_link_add_symbols): Likewise.
	* ecoff.c (ecoff_link_add_externals): Likewise.
	* elfcode.h (elf_link_add_object_symbols): Likewise.
	(elf_link_output_extsym): Likewise.
	* sunos.c (sunos_add_one_symbol): Likewise.
1995-02-08 22:57:48 +00:00
David Edelsohn 121a846514 elfcode.h (elf_sort_hdrs): Put SHT_NOBITS sections after !SHT_NOBITS. 1995-02-08 20:58:01 +00:00
Ian Lance Taylor 5947417403 * libelf.h (struct elf_link_hash_table): Add saw_needed field.
* elfcode.h (elf_link_add_object_symbols): Set saw_needed if
	DT_NEEDED seen in .dynamic section.
	(elf_link_output_extsym): Warn if an undefined symbol is
	only referenced from a dynamic object, and not making a shared
	object, and saw_needed is false.
	* elf.c (_bfd_elf_link_hash_table_init): Initialize saw_needed.
1995-02-06 23:23:37 +00:00
Ian Lance Taylor 0bef7f7266 * libelf.h (ELF_LINK_HASH_DEFINED_WEAK): Don't define.
* elfcode.h (elf_link_add_object_symbols): Don't clear or set
	ELF_LINK_HASH_DEFINED_WEAK.
	(elf_link_output_extsym): Don't check ELF_LINK_HASH_DEFINED_WEAK.
1995-02-06 21:34:44 +00:00
Ian Lance Taylor 6c97aedf26 Distinguish a weak defined symbol from a regular defined symbol.
* linker.c (enum link_action): Add DEFW.
	(link_action): Add bfd_link_hash_defweak column.
	(_bfd_generic_link_add_one_symbol): Add DEFW case.  Handle
	bfd_link_hash_defweak in a few other cases.
	* Many files (bfd_link_hash_undefweak): Renamed from
	bfd_link_hash_weak.
	* aoutx.h (aout_link_write_symbols): Handle bfd_link_hash_defweak.
	(aout_link_write_other_symbol): Likewise.
	(aout_link_input_section_std): Likewise.
	(aout_link_input_section_ext): Likewise.
	* bout.c (get_value): Likewise.
	* coff-a29k.c (coff_a29k_relocate_section): Likewise.
	* coff-alpha.c (alpha_convert_external_reloc): Likewise.
	(alpha_relocate_section): Likewise.
	* coff-mips.c (mips_relocate_section): Likewise.
	(mips_relax_section): Likewise.
	(bfd_mips_ecoff_create_embedded_relocs): Likewise.
	* cofflink.c (coff_write_global_sym): Likewise.
	(_bfd_coff_generic_relocate_section): Likewise.
	* ecoff.c (ecoff_link_add_externals): Likewise.
	(ecoff_link_write_external): LIkewise.
	* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
	(elf32_hppa_size_stubs): Likewise.
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	* elf32-mips.c (mips_elf_output_extsym): Likewise.
	(mips_elf_relocate_section): Likewise.
	* elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
	(elf32_sparc_relocate_section): Likewise.
	* elfcode.h (elf_link_add_object_symbols): Likewise.
	(elf_adjust_dynamic_symbol): Likewise.
	(elf_bfd_final_link): Likewise.
	(elf_link_output_extsym): Likewise.
	* i386linux.c (linux_add_one_symbol): Likewise.
	(linux_tally_symbols): Likewise.
	(linux_finish_dynamic_link): Likewise.
	* linker.c (_bfd_generic_link_output_symbols): Likewise.
	(set_symbol_from_hash): Likewise.
	* reloc16.c (bfd_coff_reloc16_get_value): Likewise.
	(bfd_perform_slip): Likewise.
	* sunos.c (sunos_add_one_symbol): Likewise.
	(sunos_scan_std_relocs): Likewise.
	(sunos_scan_ext_relocs): Likewise.
	(sunos_scan_dynamic_symbol): Likewise.
	(sunos_write_dynamic_symbol): Likewise.
1995-02-06 20:01:08 +00:00
Ian Lance Taylor 5945db2997 * elfcode.h (map_program_segments): Add sorted_hdrs parameter.
Search through it rather than through unsorted section headers.
	(assign_file_positions_except_relocs): Pass sorted_hdrs to
	map_program_segments.
1995-01-31 20:55:25 +00:00
Ian Lance Taylor cd9dba7b37 * elfcode.h (elf_link_add_object_symbols): Use *sym_hash instead
of h if we might not be doing an ELF link.
1995-01-28 05:17:04 +00:00
Ian Lance Taylor 6977046f0f * elfcode.h (elf_sort_hdrs): Correct SHF_ALLOC test.
(assign_file_positions_except_relocs): Free sorted_hdrs.
1995-01-27 21:24:28 +00:00
Ian Lance Taylor 4b412ed189 * elfcode.h (elf_link_add_object_symbols): Only examine weakdef if
we are using an ELF hash table.
1995-01-26 21:48:14 +00:00
Michael Meissner c6d729b375 Add new relocs for PowerPC Elf support.
Add eabi support.
1995-01-26 16:31:24 +00:00
Ian Lance Taylor 51fbf4548f update copyright dates 1995-01-24 19:48:50 +00:00
Ian Lance Taylor f78b396350 * elfcode.h (elf_link_add_object_symbols): It's reasonable for no
flags to be set, so don't insist otherwise.
1995-01-09 20:52:59 +00:00
Ian Lance Taylor 42cf6d7950 * elfcode.h (elf_slurp_symbol_table): Don't set BSF_GLOBAL for an
undefined or common symbol.
	(elf_link_add_object_symbols): Likewise.
1995-01-06 21:50:28 +00:00
Ken Raeburn 85200ebce9 * elfcode.h (assign_file_positions_except_relocs): In assertion, force all
values to the same type.
1994-12-20 20:31:36 +00:00
Ian Lance Taylor f5202354c3 * elfcode.h (elf_map_symbols): Only use section symbols whose
value is the start of the section.
1994-12-15 01:23:40 +00:00
Ian Lance Taylor 4c124191db * elfcode.h (elf_bfd_link_add_symbols): If the first object in the
archive is not an ELF object, pass the archive to the add_symbols
	entry point appropriate for the first object.  From Eric Youngdale
	<eric@aib.com>.
1994-12-09 17:57:47 +00:00
Ian Lance Taylor e6fb0df7c0 * elfcode.h (elf_export_symbol): Also export symbols which are
referenced by a regular file.
1994-11-13 04:51:53 +00:00
Ian Lance Taylor 11bb5591d6 * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add
export_dynamic argument, and handle it.
	(elf_export_symbol): New function.
	* bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration.
	(bfd_elf64_size_dynamic_sections): Update declaration.
	* bfd-in2.h: Rebuild.
1994-11-12 20:55:33 +00:00
Ian Lance Taylor 197e30e560 * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Create DT_INIT
and DT_FINI dynamic entries based on the existence of _init and
	_fini symbols, not on the .init and .fini sections.  This is
	compatible with some SVR4 linkers.
	(elf_bfd_final_link): Corresponding change.
1994-10-31 00:04:03 +00:00
Ian Lance Taylor 54f16fc4bb * linker.c (_bfd_generic_link_add_archive_symbols): It's not an
error if an empty archive has no symbol table.
	* ecoff.c (ecoff_link_add_archive_symbols): Likewise.
	* elfcode.h (elf_link_add_archive_symbols): Likewise.
1994-10-29 16:20:41 +00:00
Ian Lance Taylor 14cac507a8 * libelf.h (struct bfd_elf_section_data): Add field dynindx.
* elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Don't finalize
	the .dynsym, .dynstr or .hash sections until after the backend
	size_dynamic_sections routine, so that it can add dynamic symbols
	if it wants to.
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Don't define the
	symbol to be in the .plt section when generating a shared library
	if it is a defined symbol.
	* elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
	(elf32_sparc_size_dynamic_sections): When generating a shared
	library, allocate space for a dynamic symbol for each output
	section, storing the index in the dynindx field of the ELF section
	data.  Adjust the other dynindx fields to account for this.
	(elf32_sparc_adjust_dynindx): New static function.
	(elf32_sparc_relocate_section): When copying a reloc into a shared
	library, use the original addend as appropriate.  Convert an
	R_SPARC_32 reloc into an R_SPARC_RELATIVE reloc.  Use the dynamic
	symbol index of the output section, not the normal symbol index.
	(elf32_sparc_finish_dynamic_sections): Don't die if a section does
	not exist when setting the value of the dynamic tags.  Write out
	a dynamic symbol for each output section.
1994-10-27 21:25:31 +00:00
Ian Lance Taylor 12662be4fe Fix the ELF linker to not require an interpreter if no dynamic
objects were seen, even when linking PIC code.
	* libelf.h (ELF_LINK_HASH_NEEDS_PLT): Define.
	(struct elf_link_hash_table): Add field dynamic_sections_created.
	* elfcode.h (elf_link_record_dynamic_symbol): Create dynstr if it
	doesn't already exist.
	(elf_link_add_object_symbols): Create dynamic sections based on
	dynamic_sections_created field, not dynobj field.  Don't bother to
	set dynobj.
	(elf_link_create_dynamic_sections): If dynamic sections were
	already created, don't do anything.  If dynobj is already set, use
	it; otherwise, set it to the bfd argument.  Don't initialize
	dynsymcount.  Only create dynstr if it does not exist.  Set
	dynamic_sections_created to true.
	(NAME(bfd_elf,size_dynamic_sections)): Skip most of this function
	if no dynamic objects were seen.
	(elf_adjust_dynamic_symbol): If a symbol has the
	ELF_LINK_HASH_NEEDS_PLT flag set, let the backend adjust it.
	(elf_bfd_final_link): Change most decisions based on dynobj to
	check dynamic_sections_created instead.
	(elf_link_output_extsym): Only handle dynamic symbols if a dynamic
	object was seen.
	* elf.c (_bfd_elf_link_hash_table_init): Initialize new field
	dynamic_sections_created.  Set dynsymcount to 1, not 0.
	* elf32-i386.c (elf_i386_create_dynamic_sections): Call
	elf_i386_create_got_section rather than creating the .got and
	.got.plt sections.
	(elf_i386_create_got_section): New static function.
	(elf_i386_check_relocs): Just call elf_i386_create_got_section if
	a GOT table is needed, not bfd_elf32_link_create_dynamic_sections.
	Only create the .rel.got section, and only make space for a reloc,
	for a global symbol or when generating a shared object.  For a
	R_386_PLT32 reloc, just set the	ELF_LINK_HASH_NEEDS_PLT flag.
	(elf_i386_adjust_dynamic_symbol): Rework initial assertion to
	permit ELF_LINK_HASH_NEEDS_PLT non dynamic symbols.  Create a
	procedure linkage table entry for such symbols.  But, if no
	dynamic objects were seen, never create a PLT entry.
	(elf_i386_size_dynamic_sections): If no dynamic objects were seen,
	skip most of this function, and force the size of the .rel.got
	section to zero.
	(elf_i386_relocate_section): For a R_386_GOT32 reloc against a global
	symbol when no dynamic object was seen, initialize the contents of
	the .got section.  For a R_386_GOT32 against a local symbol, only
	create a R_386_RELATIVE reloc when generating a shared object.
	Treat a R_386_PLT32 reloc against a symbol for which we did not
	create a PLT entry as a R_386_PC32 reloc.
	(elf_i386_finish_dynamic_sections): Only fiddle with the dynamic
	entries and the PLT if we saw a dynamic object.
	* elf32-sparc.c (elf_sparc_howto_table): Fix R_SPARC_PC22 by
	setting rightshift to 10.  Fix R_SPARC_WPLT20 by setting
	rightshift to 2, size to 2, bitsize to 30, and dst_mask to
	0x3fffffff.
	(elf32_sparc_create_dynamic_sections): Don't set the size of the
	.plt section.  Call elf32_sparc_create_got_section rather than
	creating the .got section.
	(elf32_sparc_check_relocs): Call elf32_sparc_create_got_section if
	a GOT table is needed, not bfd_elf32_link_create_dynamic_sections.
	Only create the .rela.got section, and only make space for a
	reloc, for a global symbol or when generating a shared object.
	Set the alignment of the .rela.got section to 2.  For a
	R_SPARC_WPLT30 reloc, just set the ELF_LINK_HASH_NEEDS_PLT flag.
	(elf32_sparc_adjust_dynamic_symbol): Rework initial assertion to
	permit ELF_LINK_HASH_NEDS_PLT non dynamic symbols.  Create a
	procedure linkage table for such symbols.  But, if no dynamic
	objects were seen, never create a PLT entry.  Initialize the size
	of the .plt section.
	(elf32_sparc_size_dynamic_sections): If no dynamic objects were
	seen, skip most of this function, and force the size of the
	.rela.got section to zero.  Strip empty reloc sections, and strip
	an empty .plt section.
	(elf32_sparc_relocate_section): For a GOT reloc against a global
	symbol when no dynamic object was seen, initialize the contents of
	the .got section.  For a GOT reloc against a local symbol, only
	create a R_SPARC_RELATIVE reloc when generating a shared object.
	Treat a R_SPARC_WPLT30 reloc against a symbol for which we did not
	create a PLT entry as a R_SPARC_WDISP30 reloc.
	(elf32_sparc_finish_dynamic_sections): Only fiddle with the
	dynamic entries and the PLT if we saw a dynamic object.
1994-10-21 22:00:18 +00:00
Ian Lance Taylor e4a4da62ab * elfcode.h (elf_map_symbols): Don't worry about section symbols
in a section not owned by any BFD.
	(elf_section_from_bfd_section): Separate out loop which calls
	backend routine.  Check bfd_section and call the backend routine
	even for a section not owned by any BFD.
	* elf32-mips.c (mips_elf_section_from_bfd_section): Handle
	.acommon section.
1994-10-20 17:32:33 +00:00
Ian Lance Taylor eb4267a3f9 Use a hash table when writing out ELF symbol names.
* elfcode.h (elf_stringtab_init): New static function.
	(bfd_new_strtab, bfd_add_to_strtab, bfd_add_2_to_strtab): Remove.
	Change all callers to use elf_stringtab_init or
	_bfd_stringtab_add, and get stringtab lengths using
	_bfd_stringtab_size.
	(elf_fake_sections): Change ignored argument to pointer to
	boolean, and set the boolean to true if an error occurs.  If an
	error has already occurred, don't do anything.
	(assign_section_numbers): Just set sh_size, not contents.
	(elf_compute_section_file_positions): Pass the address of a
	boolean to elf_fake_sections.  Pass the address of a
	bfd_strtab_hash to swap_out_syms.  Write out the .strtab section.
	(prep_headers): Change shstrtab to bfd_strtab_hash.
	(swap_out_syms): Take a pointer to a bfd_strtab_hash as an
	argument.  Set it to the symbol names.
	(NAME(bfd_elf,write_object_contents)): Write out the section
	header names using _bfd_stringtab_emit.
	(elf_debug_section): Remove first argument; get the section name
	via the bfd_section pointer.  Change caller.
	(elf_bfd_final_link): Write out the symbol names using
	_bfd_stringtab_emit.  Likewise for the .dynstr section contents.
	Free the symbol names at the end of the function.
	(elf_link_input_bfd): Remove the last argument, output_names,
	from relocate_section.  Save the old symbol contents before
	calling elf_link_output_sym, and restore them afterward.
	* libelf.h (struct elf_link_hash_table): Change dynstr field to
	struct bfd_strtab_hash.
	(struct elf_backend_data): Remove last argument, output_names,
	from elf_backend_relocate_section field.
	(struct strtab): Don't define.
	(struct elf_obj_tdata): Change strtab_ptr field to struct
	bfd_strtab_hash.
	* elf32-hppa.c (elf32_hppa_relocate_section): Remove last
	argument, output_names.
	* elf32-i386.c (elf_i386_relocate_section): Likewise.
	* elf32-mips.c (mips_elf_relocate_section): Likewise.
	* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
1994-10-17 22:03:14 +00:00
Ian Lance Taylor 24f13b0331 * elfcode.h (elf_swap_shdr_in): Use rawdata, not bfd_section.
Clear contents field.
	(bfd_section_from_shdr): In SHT_STRTAB case, check bfd_section,
	not rawdata.  Don't set rawdata if e_shstrndx.  Use bfd_section
	rather than rawdata in commented out code.  In SHT_REL[A] case,
	don't bother to check elf_section_data of section returned by
	section_from_elf_index.
	(elf_fake_sections): Set bfd_section, not rawdata.  Don't set
	size.
	(elf_map_symbols): Don't set elf_num_section_syms.  Don't create
	section symbols that already exist.
	(assign_file_position_for_section): Use bfd_section, not rawdata.
	(section_from_elf_index): Just check bfd_section field.
	(elf_section_from_bfd_section): Likewise.
	(elf_debug_section): Don't print rawdata, contents, or size.
	(elf_link_add_object_symbols): Don't error out if
	section_from_elf_index returns NULL.
	(elf_bfd_final_link): Check return value from
	section_from_elf_index against NULL, not bfd_is_abs_section.
	(elf_link_input_bfd): Don't check section_from_elf_index return
	value.
	* libelf.h (struct elf_obj_tdata): Remove num_section_syms field.
	(elf_num_section_syms): Don't define.
	* elf.c (elf_get_str_section): Store section contents in contents
	field rather than rawdata field.
	(elf_string_from_elf_section): Likewise.
	(_bfd_elf_make_section_from_shdr): Store BFD section pointer in
	bfd_section field rather than rawdata field.
	* elf32-hppa.c (elf32_hppa_read_symext_info): Use bfd_section
	rather than rawdata.
	(elf32_hppa_size_stubs): Likewise.
	* elf32-mips.c (mips_elf_final_write_processing): Use bfd_section
	rathern than rawdata.
	(mips_elf_section_from_shdr): Likewise.
	(mips_elf_section_processing): Likewise.
	(mips_elf_section_from_bfd_section): Remove rawdata check.
1994-10-17 18:27:40 +00:00
Ken Raeburn ef4b8f6687 * opncls.c (bfd_realloc): Deleted, since it's broken and fixing it would make
it slow.  Besides, it isn't used much.
* elfcode.h (elf_map_symbols): Always allocate new storage for the symbol table.
1994-10-12 21:39:54 +00:00
Ken Raeburn 4c0322704f * cofflink.c (_bfd_coff_final_link): Cast argument to bfd_h_put_32 to correct
type.
(coff_read_string_table): Cast argument to bfd_h_get_32 to correct type.
* elfcode.h (elf_link_output_extsym): Cast argument to bfd_elf_hash to correct
type.
1994-10-10 20:38:06 +00:00
Ian Lance Taylor fb562be02f * elfcode.h (elf_bfd_final_link): Remove assertion when a non
SEC_IN_MEMORY section is found in dynobj.  This can happen when
	linking PIC compiled code.
1994-09-30 17:13:08 +00:00
Ken Raeburn 64e21e0fd7 * elf.c (bfd_elf_print_symbol): Moved here from elf_print_symbol in elfcode.h.
(case bfd_print_symbol_all): Print symbol's size field, except for common
symbols; print their alignment.
* elfcode.h (elf_print_symbol): Deleted.
* libelf.h (bfd_elf_print_symbol): Declare.
(bfd_elf{32,64}_print_symbol): Replace declarations with macros.
1994-09-29 20:36:24 +00:00
Ian Lance Taylor 0d9e139762 tipo 1994-09-26 02:48:36 +00:00
Ian Lance Taylor 57b400818d * elfcode.h (map_program_segments): Don't abort if we allocated
too much space for the program header, only if we allocated too
	little.
1994-09-23 19:19:41 +00:00
Ian Lance Taylor 3c9832f89f * elfcode.h (swap_out_syms): Set the type of an undefined symbol
to STT_FUNC if the BSF_FUNCTION flag is set.
1994-09-12 22:16:27 +00:00
Ian Lance Taylor 0822b56d66 * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add soname
argument, and use it to set DT_SONAME dynamic entry.
	* bfd-in.h (bfd_elf32_size_dynamic_sections): Update prototype.
	(bfd_elf64_size_dynamic_sections): Update prototype.
	* bfd-in2.h: Rebuilt.
1994-08-30 16:04:40 +00:00
Ian Lance Taylor 823609fe90 * elfcode.h (bfd_section_from_shdr): If a SHT_SYMTAB section in a
shared object has SHF_ALLOC set, create a BFD section for it.
	(elf_section_from_bfd_section): There may be a BFD section for a
	SHT_SYMTAB section.
1994-08-15 18:08:13 +00:00
Ian Lance Taylor e9227b4255 * elfcode.h (section_from_elf_index): Correct check for invalid
section index.
1994-08-12 23:25:23 +00:00
Ian Lance Taylor 1c640609d8 * elfcode.h (elf_link_add_object_symbols): If there is no symbol
table, try using the dynamic symbol table.  From Eric Youngdale
	<ericy@cais.cais.com>.
1994-08-12 15:51:09 +00:00
Jean Marie Diaz df9e066f4b * elfcode.h (map_program_segments): Check DYNAMIC as well as EXEC_P.
(assign_file_positions_except_relocs): Likewise.
1994-08-01 23:37:22 +00:00
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
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 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
Ian Lance Taylor 7c6da9cade * aoutx.h (aout_link_check_ar_symbols): When changing a symbol to
common, set the alignment.
	(aout_link_add_symbols): Restrict the alignment of a common symbol
	to the alignment power given by the architecture.
	* elf.c (_bfd_elf_link_hash_newfunc): Don't initialize align.  Do
	initialize copy_offset.
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Use copy_offset
	field rather than align field.  Get alignment using bfd_log2
	rather than switch.
	* elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Use copy_offset,
	not align.
	* elf32-sparc.c (elf32_sparc_finish_dynamic_symbol): Likewise.
1994-07-22 18:53:23 +00:00
Ian Lance Taylor f9779aad5a * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add rpath
argument.  If it is not NULL, use it to set DT_RPATH.
	* bfd-in.h (bfd_elf32_size_dynamic_sections): Update prototype.
	(bfd_elf64_size_dynamic_sections): Likewise.
	* bfd-in2.h: Rebuilt.
1994-07-20 19:51:18 +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
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