Commit Graph

139 Commits

Author SHA1 Message Date
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
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
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
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 6c8fa8e62c * aoutx.h (NAME(aout,final_link)): Check flavour of sub, not abfd,
when computing reloc sizes.  From Eric Youngdale
	<ericy@cais.cais.com>.
	* elfcode.h (elf_bfd_final_link): Don't try to compute maximum
	reloc count or size for a non-ELF file.
1994-06-20 15:51:28 +00:00
Jeff Law c46b8ed7e6 * elfcode.h (elf_link_input_bfd): Don't try to read local symbols
if there aren't any in the input file.
1994-06-17 05:39:55 +00:00
Ian Lance Taylor 0ff5d3a69a * elfcode.h (elf_bfd_final_link): If trying to generate a shared
object, warn and return false.
1994-06-16 19:30:49 +00:00
Ian Lance Taylor c1f84521bf * libelf.h (struct elf_obj_tdata): New field dt_needed_name.
(elf_dt_needed_name): New accessor macro.
	* elfcode.h (elf_link_add_object_symbols): If elf_dt_needed_name
	is set, use that instead of the filename for the DT_NEEDED dynamic
	entry.
	* elf.c (bfd_elf_set_dt_needed_name): New function.
	* bfd-in.h (bfd_elf_set_dt_needed_name): Declare.
	* bfd-in2.h: Rebuilt.
1994-06-16 00:01:32 +00:00
Ken Raeburn 5546cc7eb6 Tweak v9 support to ready it for release. 1994-06-15 22:05:40 +00:00
Ian Lance Taylor 7c726b6625 * elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Add sinterpptr
argument, and set it to the .interp section.
	* bfd-in.h (bfd_elf32_size_dynamic_sections): Update prototype.
	(bfd_elf64_size_dynamic_sections): Likewise.
	* bfd-in2.h: Rebuilt.
1994-06-15 19:58:59 +00:00
Ian Lance Taylor e6667b2bc3 * elfcode.h (bfd_section_from_shdr): Don't turn a reloc section
into a BFD section just because SHF_ALLOC is set; require that it
	not use the normal symbol table.
	(elf_section_from_bfd_section): Corresponding change.
1994-06-06 23:59:27 +00:00
Ian Lance Taylor fa15568ac1 Changes to support ELF strip and objcopy on dynamically linked
files.
	* elfcode.h (elf_fake_sections): Add prototype.
	(bfd_section_from_shdr): Make a BFD section from an SHT_HASH
	section, and from an SHT_DYNSYM section, and from the dynamic
	string table section.
	(elf_object_p): Set D_PAGED if there is a program header.
	(elf_make_sections): Remove.
	(fix_up_strtabs): Remove.
	(elf_fake_sections): Rewrite.  Now sets sh_entsize.
	(assign_section_numbers): Rewrite.  Now sets sh_link and sh_info
	for all sections.
	(elf_compute_section_file_positions):  Don't call obsolete
	functions elf_make_sections or fix_up_strtabs.
	(swap_out_syms): Set sh_addralign to FILE_ALIGN rather than 4.
	(NAME(bfd_elf,write_object_contents)): Permit writing DYNAMIC
	objects.
	(elf_section_from_bfd_section): Treat SHT_DYNSYM like other normal
	sections.  If an SHT_REL or SHT_RELA section is allocated or uses
	an unusual symbol table, permit a BFD section to map to it.
	Permit most SHT_STRTAB sections to have a BFD section mapped to
	them.
	(elf_bfd_final_link): Don't set sh_link, sh_info or sh_entsize
	fields of dynamic sections here; do it in assign_section_numbers.
	* elf32-target.h, elf64-target.h: Add D_PAGED to permitted object
	flags.
1994-06-05 20:00:42 +00:00
Ian Lance Taylor 5315c42827 Make MIPS ELF use new ELF backend linker. No shared library
support yet.
	* elf32-mips.c (bfd_mips_elf32_swap_gptab_in): New function.
	(bfd_mips_elf32_swap_gptab_out): New function.
	(mips_elf_object_p): If last symbol is LOCAL, set elf_bad_symtab.
	(mips_elf_final_write_processing): Set sh_info field for .gptab.*
	sections.
	(mips_elf_fake_sections): Set sh_entsize for .gptab.* sections.
	(mips_elf_read_ecoff_info): Read and free external symbols last,
	not first, for clarity.
	(struct mips_elf_link_hash_entry): Define new structure.
	(struct mips_elf_link_hash_table): Define new structure.
	(mips_elf_link_hash_lookup): Define new macro.
	(mips_elf_link_hash_traverse): Define new macro.
	(mips_elf_hash_table): Define new macro.
	(mips_elf_link_hash_newfunc): New static function.
	(mips_elf_link_hash_table_create): New static function.
	(mips_elf_add_symbol_hook): New static function.
	(struct extsym_info): Define new structure.
	(mips_elf_get_extr, mips_elf_set_index): Remove.
	(mips_elf_output_extsym): New static function.
	(gptab_compare): New static function.
	(mips_elf_final_link): Rewrite to use ELF backend linker, and to
	merge gptab information in input files.
	(mips_elf_relocate_hi16): New static function.
	(mips_elf_relocate_section): New static function.
	(bfd_elf32_bfd_link_hash_table_create): Define as macro before
	including elf32-target.h.
	(elf_backend_relocate_section): Likewise.
	(elf_backend_add_symbol_hook): Likewise.
	* elf.c (_bfd_elf_link_hash_newfunc): Rename from
	elf_link_hash_newfunc and make globally visible.  Change caller.
	(_bfd_elf_link_hash_table_init): New function, broken out of
	_bfd_elf_link_hash_table_create.
	(_bfd_elf_link_hash_table_create): Use
	_bfd_elf_link_hash_table_init.
	* libelf.h (struct elf_obj_tdata): Add new field bad_symtab.
	(elf_bad_symtab): Define new accessor macro.
	(_bfd_elf_link_hash_newfunc): Declare.
	(_bew_elf_link_hash_table_init): Declare.
	* elfcode.h (elf_object_p): Call backend object_p hook after
	swapping in all the section headers.
	(map_program_segments): Correct typo: Internal for External.
	(elf_link_add_object_symbols): If elf_bad_symtab is set, read all
	the symbols.  Skip STB_LOCAL symbols rather than giving an error.
	(elf_bfd_final_link): If elf_bad_symtab is set, allocate space for
	all symbols, not just locals.
	(elf_link_output_extsym): Only skip a symbol not mentioned by a
	regular file if it is mentioned by a dynamic object.
	(elf_link_input_bfd): If elf_bad_symtab is set, read all the
	symbols.
1994-05-24 20:44:50 +00:00
Ian Lance Taylor 497c543457 * elf.c (_bfd_elf_make_section_from_shdr): New function, based on
code repeated three times in bfd_section_from_shdr in elfcode.h.
	* libelf.h (_bfd_elf_make_section_from_shdr): Declare.
	* elfcode.h (bfd_section_from_shdr): Use new function
	_bfd_elf_make_section_from_shdr to create BFD sections.  If a
	reloc section does not use the main symbol table, or it is part of
	the process image, treat it as a normal section, not relocs.
	* elf32-mips.c (mips_elf_section_from_shdr): Use new function
	_bfd_elf_make_section_from_shdr.
1994-05-20 16:04:59 +00:00
Ian Lance Taylor 6731b89c4b Make map_program_segments tend to call abort rather than trash the
stack in unhandled cases.  Still covered by previous ChangeLog entry.
1994-05-19 21:58:45 +00:00
Ian Lance Taylor 013dec1ad9 Add support for ELF shared libraries. Loosely based on work by
Eric Youngdale <ericy@cais.com>.
	* libelf.h (struct elf_backend_data): Add new fields for dynamic
	linking: elf_backend_create_dynamic_sections,
	elf_backend_adjust_dynamic_symbol,
	elf_backend_size_dynamic_sections,
	elf_backend_finish_dynamic_symbol,
	elf_backend_finish_dynamic_sections.
	(struct elf_link_hash_entry): Change type of align field to
	bfd_size_type.  Add fields dynindx, dynstr_index, weakdef,
	elf_link_hash_flags.
	(struct elf_link_hash_table): Add fields dynobj, dynsymcount,
	dynstr, bucketcount.
	(bfd_elf32_swap_reloc_in, bfd_elf32_swap_reloc_out): Declare.
	(bfd_elf32_swap_reloca_in, bfd_elf32_swap_reloca_out): Declare.
	(bfd_elf32_swap_dyn_in, bfd_elf32_swap_dyn_out): Declare.
	(bfd_elf32_add_dynamic_entry): Declare.
	(bfd_elf64_swap_reloc_in, bfd_elf64_swap_reloc_out): Declare.
	(bfd_elf64_swap_reloca_in, bfd_elf64_swap_reloca_out): Declare.
	(bfd_elf64_swap_dyn_in, bfd_elf64_swap_dyn_out): Declare.
	(bfd_elf64_add_dynamic_entry): Declare.
	* elfcode.h (Elf_External_Dyn): Define.
	(elf_swap_reloc_in): Define as macro using NAME.  Make externally
	visible.
	(elf_swap_reloc_out): Likewise.
	(elf_swap_reloca_in, elf_swap_reloca_out): Likewise.
	(elf_swap_dyn_in, elf_swap_dyn_out): Define as macro using NAME
	and as new externally visible function.
	(elf_fake_sections): Set section type of dynamic sections based on
	section names.
	(elf_write_phdrs): Remove.
	(assign_file_position_for_section): Add new align argument.
	Change all callers.
	(get_program_header_size): New static function.
	(struct seg_info): Remove.
	(map_program_segments): Completely rewrite.
	(assign_file_positions_except_relocs): Completely rewrite.
	(assign_file_positions_for_relocs): Don't set a file position for
	sections which already have one.  Don't bother to align the file
	position here.
	(section_from_elf_index): Handle SHT_HASH and SHT_DYNAMIC
	section types.
	(elf_section_from_bfd_section): Likewise.
	(elf_slurp_symbol_table): If section_from_elf_index fails, just
	use bfd_abs_section rather than returning an error.
	(elf_sizeof_headers): Make useful.
	(elf_link_record_dynamic_symbol): New static function.
	(elf_link_add_object_symbols): Handle dynamic objects.
	(elf_link_create_dynamic_sections): New static function.
	(elf_add_dynamic_entry): Define as macro using NAME and as new
	externally visible function.
	(NAME(bfd_elf,record_link_assignment)): New function.
	(elf_buckets): New static variable.
	(NAME(bfd_elf,size_dynamic_sections)): New function.
	(struct elf_final_link_info): Add dynsym_sec and hash_sec fields.
	(elf_bfd_final_link): Handle dynamic linking.  Create a section
	symbol for all ELF sections, not all BFD sections.  Store section
	symbol index in target_index field, not index field.  Traverse
	over global symbols even if stripping.
	(elf_link_output_extsym): Output dynamic symbols.  Mark symbols
	defined by dynamic objects as undefined.
	(elf_link_input_bfd): Ignore dynamic objects.  Use target_index
	field for section relocs, and make sure it is set.
	(elf_reloc_link_order): Use target_index field for section relocs,
	and make sure it is set.
	* elf.c (elf_link_hash_newfunc): Initialize dynindx, dynstr_index,
	weakdef and elf_link_hash_flags fields.
	(_bfd_elf_link_hash_table_create): Initialize dynobj, dynsymcount,
	dynstr and bucketcount fields.
	* elf32-target.h: Initialize new dynamic linking fields.
	* elf64-target.h: Likewise.
	* elf32-i386.c: New functions for dynamic linking support.
	* elf32-sparc.c: Likewise.
	* bfd-in.h (bfd_elf32_record_link_assignment): Declare.
	(bfd_elf64_record_link_assignment): Declare.
	(bfd_elf32_size_dynamic_sections): Declare.
	(bfd_elf64_size_dynamic_sections): Declare.
	* bfd-in2.h: Rebuilt.
1994-05-19 18:23:40 +00:00
Jeff Law 459ae909b9 * bfd-in2.h: Rebuilt.
* elf32-hppa.c: Change .hppa_linker_stubs to .PARISC.stubs,
	likewise for other PA specific sections.
	(hppa_elf_relocate_unwind_table): Delete unused
	function.
	(elf_hppa_howto_table): Completely new table based on 94-02-02
	draft PA ELF spec.  Change relocation tags appropriately
	throughout elf32-hppa.c
	(hppa_elf_gen_reloc_type): Rewrite and simplify based on 94-02-02
	spec.
	(hppa_elf_reloc): Likewise.
	(hppa_look_for_stubs_in_section): Likewise
	(ELF_MACHINE_CODE): Change to EM_PARISC.
	* elf32-hppa.h: Include "elf/hppa.h".  Change relocation tags
	appropriately throughout elf32-hppa.h.
	(elf32_hppa_reloc_type): New table based on 94-02-02 draft PA ELF
	spec.
	(R_HPPA_ABS_CALL, R_HPPA_COMPLEX*, R_HPPA_UNWIND): Delete definitions.
	* elfcode.h (prep_headers): Use EM_PARISC instead of EM_HPPA.
	* reloc.c (bfd_reloc_code_real): Delete unused HPPA relocations.
	* som.h (R_HPPA_ABS_CALL, R_HPPA_COMPLEX): Delete definitions.

	* libhppa.h (hppa_field_adjust): Avoid adding constant_value into
	the final value twice for LR and RR field selectors.
1994-05-16 19:34:13 +00:00
Ian Lance Taylor 6ec3bb6a75 * elfcode.h: Include bfdlink.h. Added several new functions to do
linking.
	(ELF_R_TYPE): Define.
	(bfd_add_to_strtab): Return unsigned long.  Change check for
	realloc failure.
	(elf_fake_sections): Check return value of bfd_add_to_strtab.
	(elf_compute_section_file_positions): Add link_info argument.
	Call elf_backend_begin_write_processing hook and prep_headers
	here.  Only call swap_out_syms if link_info is NULL.  Set up
	.shstrtab section here.  Pass dosyms argument to
	assign_file_positions_except_relocs.  Set output_has_begun flag.
	(assign_file_positions_for_symtab_and_strtabs): Add dosyms
	argument, and use it to control setting .symtab and .strtab file
	positions.
	(assign_file_positions_except_relocs): Add dosyms argument, and
	pass it on.
	(prep_headers): Check return value of bfd_add_to_strtab.
	(swap_out_syms): Likewise.  Also, don't set up .shstrtab here.
	(NAME(bfd_elf,write_object_contents)): Some calls moved into
	elf_compute_section_file_positions.
	(elf_set_section_contents): Likewise.
	(elf_slurp_symbol_table): SHN_LORESERV corrected to SHN_LORESERVE.
	* libelf.h: Include bfdlink.h.
	(struct elf_backend_data): Add fields collect,
	elf_add_symbol_hook, elf_backend_relocate_section.
	(struct bfd_elf_section_data): Add field rel_hashes.
	(struct elf_obj_tdata): Remove fields internal_syms and symbols.
	Add field sym_hashes.
	(obj_symbols, obj_internal_syms): Remove definitions.
	(elf_sym_hashes): Define.
	(struct elf_link_hash_entry): Define.
	(struct elf_link_hash_table): Define.
	(elf_link_hash_lookup): Define.
	(elf_link_hash_traverse): Define.
	(elf_hash_table): Define.
	(_bfd_elf_link_hash_table_create): Declare.
	(bfd_elf32_bfd_link_add_symbols): Declare.
	(bfd_elf32_bfd_final_link): Declare.
	(bfd_elf64_bfd_link_add_symbols): Declare.
	(bfd_elf64_bfd_final_link): Declare.
	* elf.c: Include bfdlink.h.
	(elf_link_hash_newfunc): New function.
	(_bfd_elf_link_hash_table_create): New function.
	* elf32-target.h (elf_backend_relocate_section): If not defined,
	define as 0 and use generic linker.  Otherwise, use ELF backend
	linker.
	(elf_backend_collect): If not defined, define as false.
	(elf_backend_add_symbol_hook): If not defined, define as 0.
	(elf32_bed): Initialize new fields.
	* elf64-target.h: Same changes as elf32-target.h.
	* elf32-i386.c: Include bfdlink.h.
	(elf_i386_relocate_section): New function.
	(elf_backend_relocate_section): Define.
	* elf32-sparc.c: Include bfdlink.h.
	(elf_info_to_howto): Change type of dst from Elf32_Internal_Rela
	to Elf_Internal_Rela (they're the same type anyhow).
	(elf_sparc_relocate_section): New function.
	(elf_backend_relocate_section): Define.
	* elf32-mips.c (elf_backend_collect): Define.
1994-05-09 16:58:36 +00:00
Ian Lance Taylor ba436e33cd * elfcode.h (write_relocs): Undo patch of Apr 10; breaks Solaris. 1994-04-25 19:52:15 +00:00
Ian Lance Taylor 2e03ce1861 * elfcode.h (bfd_section_from_shdr): Use bfd_make_section_anyway
to create sections.  Check return value of recursive calls.
	(bfd_section_from_phdr): Check return value of bfd_make_section.
	(elf_symbol_from_bfd_symbol): Likewise.
	(elf_object_p): Check return value of bfd_section_from_shdr.
	(section_from_elf_index): Likewise.
	(elf_slurp_symbol_table): Check return value of
	section_from_elf_index.
	(bfd_prstatus): Return boolean value.  Check return value of
	bfd_make_section.
	(bfd_fpregset): Likewise.
	(bfd_prpsinfo): Return boolean value.
	(elf_corefile_note): Check return values of bfd_prstatus,
	bfd_fpregset, and bfd_prpsinfo.
	(elf_core_file_p): Check return value of elf_corefile_note.
1994-04-25 19:36:51 +00:00
Ian Lance Taylor 80a903c960 * aout-adobe.c (aout_adobe_set_arch_mach): Check return value of
bfd_default_set_arch_mach.  Accept bfd_arch_m68k as well as
	bfd_arch_unknown.
	* elfcode.h (elf_set_arch_mach): Don't check a list of ELF
	architectures, just see if the desired architecture matches what
	the ELF backend permits.
1994-04-22 17:11:37 +00:00
Peter Schauer cb71adf12b * libelf.h (elf_obj_tdata): Add members for dynamic symbol table
handling.
	* elfcode.h (bfd_section_from_shdr):  Handle dynamic symbol table.
	* elfcode.h (elf_slurp_symbol_table):  Take additional parameter
	to select static or dynamic symbol table and return number of
	symbols slurped or -1 on error.
	* elfcode.h (elf_get_symtab):  Set bfd symcount from
	elf_slurp_symbol_table result.
	* elfcode.h (elf_get_dynamic_symtab_upper_bound,
	elf_canonicalize_dynamic_symtab):  New functions to handle dynamic
	symbol table.
	* elf32-target.h, elf64-target.h (BFD_JUMP_TABLE_DYNAMIC):
	Change to handle dynamic symbol table, provide default definitions
	for dynamic relocs.
	* aoutx.h (howto_table_std, NAME(aout,swap_std_reloc_out),
	NAME(aout,swap_std_reloc_in), aout_link_input_section_std,
	aout_link_reloc_link_order):  Handle r_jmptable and r_relative
	relocations.
1994-04-21 17:01:12 +00:00
Ian Lance Taylor bf08d1e266 * elfcode.h (assign_file_positions_except_relocs): Don't require
the file alignment to correspond to the page size when linking
	with -N.
1994-04-11 18:43:15 +00:00
Jeff Law 9a5334e590 * elfcode.h (write_relocs): For rela relocations, adjust the
addend for relocations involving section symbols to account
        for the lossage of 1:1 mapping from input section symbols to
        output section symbols.
1994-04-10 08:12:33 +00:00
Jeff Law 99a6c7613c * elfcode.h (elf_set_section_contents): Support calling the backend
function elf_backend_begin_write_processing when just beginning to
	write an object file.

	* libelf.h (elf_backend_begin_write_processing): Declare.

	* elf{32,64}-target.h (elf_backend_begin_write_processing): Provide
	a default definition.
	(elf{32,64}_bed): Add elf_backend_begin_write_processing.

	* elf32-hppa.h (elf_hppa_tc_symbol): Delete extern declaration.
	(elf_hppa_tc_make_sections): Likewise.

	* elf32-hppa.c (symext_chain_built): Delete.
	(symext_chain_size): Renamed from symextn_contents_real_size.
	(elf32_hppa_backend_{begin,final}_write_processing): New functions.
	(add_entry_to_symext_chain): New function.
	(hppa_elf_set_section_contents): Ignore writes to the symbol extension
	section until it's been rebuilt internally.
	(hppa_elf_get_section_contents): Symbol extension section is no
	longer special.
	(elf_backend_{begin,final}_write_processing): Define.
	(elf_hppa_tc_make_sections): Simplify now that much code has
	migrated into elf32_hppa_backend_{being,final}_write_processing.
1994-04-07 18:12:25 +00:00
Ian Lance Taylor d909628bb7 * elfcode.h (write_shdrs_and_ehdr): Correct bfd_write check. 1994-04-05 16:27:36 +00:00
Ian Lance Taylor b3cee0a981 * aoutx.h (NAME(aout,canonicalize_reloc)): Don't error out if
section->relocation is NULL; malloc might have returned NULL when
	given a zero size if there were no relocations.
	* bout.c (b_out_canonicalize_reloc): Likewise.
	* coffcode.h (coff_canonicalize_reloc): Likewise.
	* ecoff.c (ecoff_canonicalize_reloc): Likewise.
	* elfcode.h (elf_canonicalize_reloc): Likewise.
	* mipsbsd.c (MY(canonicalize_reloc)): Likewise.
	* i386lynx.c (NAME(lynx,canonicalize_reloc)): Likewise.
	* nlmcode.h (nlm_canonicalize_reloc): Likewise.
	* som.c (som_canonicalize_reloc): Likewise.
	* hp300hpux.c (MY(slurp_reloc_table)): Likewise.  Also, if malloc
	returns NULL, don't report an error if we asked for zero bytes.
	* i386lynx.c (NAME(lynx,slurp_reloc_table)): If malloc returns
	NULL, don't report an error if we asked for zero bytes.
	* nlmcode.h (nlm_slurp_reloc_fixups): Likewise.
1994-04-05 15:32:49 +00:00
Ian Lance Taylor 4002f18a05 Made sure that every call to bfd_read, bfd_write, and bfd_seek
checks the return value and handled bfd_error correctly.  These
	changes are not itemised.
1994-04-04 22:49:04 +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
Jeff Law 250578363e * libbfd.c (bfd_read): Set bfd_error as appropriate for a short
read. (bfd_error_system_call or bfd_error_file_truncated).

        * som.c: Do not blindly set bfd_error_system_call after a
        failing bfd_read, bfd_write, or bfd_seek.  In a few places
        (like som_object_p) override the error status set by bfd_read.

        * aix386-core.c, aout-encap,c archive.c, bout.c: Likewise.
        * coff-rs6000.c, coffgen.c ecoff.c, elf.c: Likewise.
        * elf32-hppa.c, elfcode.h, hp300hpux.c, i386lynx.c: Likewise.
        * nlm32-alpha.c, nlm32-i386.c, nlm32-sparc.c: Likewise.

        * som.c: Check return values from several bfd_{seek,read,write}
        calls that we just assumed were not failing.
1994-03-26 18:28:29 +00:00
Ian Lance Taylor 1c6042ee10 * elfcode.h (NAME(bfd_elf,write_object_contents)): Don't use space
after NAME, since SunOS /bin/cc can't handle it.
1994-03-17 16:47:01 +00:00
Jim Kingdon 80425e6c82 * libbfd-in.h: Remove alloca cruft. It was missing some necessary
cruft (like the #pragma alloca for AIX).
	In addition to that problem, the C alloca calls xmalloc, which
	means checking for being out of memory can't work right.  The
	following changes remove all uses of alloca from BFD.
	* hosts/solaris2.h: Remove alloca cruft.
	* som.c: Replace alloca with a fixed size auto array.
	* aoutx.h, elfcode.h, nlmcode.h, bout.c, coff-alpha.c, ecoff.c,
	ecofflink.c, elf32-hppa.c, elf32-mips.c, linker.c, reloc.c, som.c:
	Replace alloca with malloc and appropriate error checking and
	freeing.
	* linker.c: Replace alloca with obstack_alloc.
	* libbfd.h: Rebuilt.
1994-03-10 02:09:10 +00:00
Peter Schauer 25677b5b30 * elf32-hppa.h, elfcode.h: Replace uses of Elf*_Half, Elf*_Word,
Elf*_Off typedefs by their expansion, the typedefs have been
	removed from include/elf/internal.h.
1994-03-05 22:41:41 +00:00
Ian Lance Taylor 68241b2b3f * aoutx.h, archive.c: Add casts to avoid warnings from SVR4 cc.
* ecoff.c, ecofflink.c, ecoffswap.h, srec.c: Likewise.
	* elf32-i386.c: Likewise.
	* elfcode.h (bfd_section_from_shdr): Make i unsigned; remove old
	#if 0 code.
	(elf_write_phdrs): Make i unsigned.
	(map_program_segments): Make i and n_left unsigned.
	(assign_file_positions_except_relocs): Make i unsigned.
	(write_shdrs_and_ehdr): Make count unsigned.
	(assign_file_positions_for_relocs): Make i unsigned.
	(NAME(bfd,elf_write_object_contents)): Make count unsigned.
	(section_from_elf_index): Make index argument unsigned.
1994-02-26 18:25:23 +00:00
Ian Lance Taylor 850584adbe * elfcode.h: Don't include assert.h.
(swap_out_syms): Use BFD_ASSERT rather than assert.
1994-02-26 05:37:24 +00:00
Jeff Law 43ebdfcf4e * format.c (bfd_check_format_matches): Initialize matching_vector
to keep gcc -Wall quiet.

        * elfcode.h (elf_slurp_reloca_table): Fix typo.
1994-02-26 03:41:36 +00:00
Jeff Law d643978558 * som.c (som_get_symtab_upper_bound): Use "sizeof (asymbol *)"
not "sizeof (som_symbol_type *)".

        * elfcode.h (elf_get_symtab_upper_bound): Use "sizeof (asymbol *)"
        not "sizeof (asymbol").  Opps.
1994-02-26 00:39:03 +00:00
Jeff Law 2e7b92cfa9 * elfcode.h (alloca): Delete declaration. 1994-02-24 04:00:30 +00:00
Ian Lance Taylor 99ec1f66c1 start-sanitize-powerpc-netware
Support for PowerPC NetWare.
	* config.bfd (powerpc-*-netware*): New target; use ppc-nlm.
	* config/ppc-nlm.mt: New file.
	* configure.in (nlm32_powerpc_vec): New target vector; use
	nlm32-powerpc.o, nlm32.o, nlm.o.
	* targets.c (nlm32_powerpc_vec): Declare.
	* Makefile.in (BFD32_BACKENDS): Add nlm32-powerpc.o.
	(CFILES): Should add nlm32-powerpc.c, but didn't, because the
	dependencies can't be sanitized.
	end-sanitize-powerpc-netware

	Initial support for PowerPC ELF.  Done without an ABI, and
	probably to be changed when I get an ABI.
	* config.bfd (powerpc-*-sysv4*): New target; use ppc-elf.
	* config/ppc-elf.mt: New file.
	* configure.in (bfd_elf32_powerpc_vec): New target vector; use
	elf32-powerpc.o, elf32.o, elf.o.
	* elf32-powerpc.c: New file.
	* elfcode.h (prep_headers): Add bfd_arch_powerpc case.
	(elf_set_arch_mach): Likewise.
	* targets.c (bfd_elf32_powerpc_vec): Declare.
	* Makefile.in (BFD32_BACKENDS): Add elf32-powerpc.o.
	(CFILES): Add elf32-powerpc.c.
	Rebuilt dependencies.
1994-02-18 17:09:13 +00:00
Ian Lance Taylor a243926667 Use bfd_set_error in last patch. 1994-02-17 21:50:39 +00:00
Ian Lance Taylor 7d8aaf368f * elfcode.h (elf_slurp_symbol_table): Handle zero symbols
reasonably.  Allocate x_symp using alloca.

Also fixed up indentation a bit in elf_set_arch_mach.
1994-02-17 20:45:06 +00:00
Ian Lance Taylor 2f3189e737 * elfcode.h (map_program_segments): ELF program header entries
must be sorted by load address.  This used to generate the entries
	in reverse order.
1994-02-17 20:39:58 +00:00
David MacKenzie d1ad85a6e6 * bfd.c (bfd_get_error, bfd_set_error): New functions.
(bfd_error): Make static.
	(bfd_error_type): Renamed from bfd_ec.  Prepend "bfd_error_" to
	all values.
	* bfd-in2.h: Regenerated.
	* aix386-core.c, aout-adobe.c, aout-encap.c, aout-target.h,
	aoutf1.h, aoutx.h, archive.c, archures.c,
	bfd.c, bout.c, cache.c, coff-alpha.c, coff-mips.c,
	coff-rs6000.c, coffcode.h, coffgen.c, core.c, ctor.c,
	ecoff.c, ecofflink.c, elf.c, elf32-hppa.c, elf32-mips.c,
	elfcode.h, format.c, hash.c, hp300hpux.c, hppabsd-core.c,
	i386lynx.c, ieee.c, libbfd.c, libelf.h, linker.c,
	lynx-core.c, nlm.c, nlm32-alpha.c, nlm32-i386.c,
	nlm32-sparc.c, nlmcode.h, oasys.c, opncls.c, osf-core.c,
	ptrace-core.c, reloc16.c, rs6000-core.c, section.c, som.c,
	srec.c, sunos.c, syms.c, targets.c, tekhex.c,
	trad-core.c: Change callers.
1994-02-17 18:08:41 +00:00
Jeff Law 5e829a3440 * elfcode.h (elf_map_symbols): Fix typo.
(write_object_contents): Check return values from prep_headers and
        elf_compute_section_file_positions.
        (set_section_contents): Likewise.
1994-02-13 06:36:41 +00:00
David MacKenzie 9783e04a64 Make all callers of malloc or realloc (including via obstacks)
check the result for NULL.  Most set bfd_error to no_memory and
	return in that case; a few are harder to fix, and are marked
	with "FIXME <return type>".

	* elf32-hppa.c (hppa_elf_build_arg_reloc_stub
	hppa_elf_build_long_branch_stub):  Check bfd_make_empty_symbol return.
	* linker.c (_bfd_generic_link_output_symbols
	_bfd_generic_link_write_global_symbol): Ditto
	* section.c (bfd_make_section_anyway): Ditto.

	* tekhex.c (find_chunk tekhex_mkobject): Check bfd_alloc.
	(first_phase): Ditto.  FIXME void
	(tekhex_make_empty_symbol): Check bfd_zalloc.

	* sunos.c (sunos_read_dynamic_info): Check bfd_zalloc.
	(MY(read_dynamic_symbols) MY(read_dynamic_relocs)): Check bfd_alloc.

	* stringhash.c (_bfd_stringtab_hash_newfunc): Check bfd_hash_allocate.

	* srec.c: Indent.
	(fillup_symbols): Check bfd_alloc.  FIXME void
	(srec_mkobject srec_get_section_contents
	srec_set_section_contents): Check bfd_alloc.
	(srec_make_empty_symbol): Check bfd_zalloc.

	* som.c (hppa_som_gen_reloc_type): Check bfd_alloc_by_size_t.
	(make_unique_section): Check bfd_alloc.
	(som_new_section_hook): Check bfd_zalloc.
	(bfd_som_attach_aux_hdr): Ditto.  FIXME void

	* rs6000-core.c (rs6000coff_core_p): Check bfd_zalloc.

	* osf-core.c (osf_core_make_empty_symbol): Check bfd_zalloc.
	(osf_core_core_file_p): Check bfd_alloc.

	* oasys.c (oasys_slurp_symbol_table oasys_archive_p
	oasys_mkobject oasys_object_p oasys_new_section_hook
	oasys_set_section_contents): Check bfd_alloc.
	(oasys_slurp_section_data): Check bfd_zalloc and bfd_alloc.
	(oasys_make_empty_symbol): Check bfd_zalloc.

	* nlmcode.h (nlm_make_empty_symbol): Check bfd_zalloc.
	(nlm_slurp_symbol_table): Check bfd_zalloc and bfd_alloc.

	* nlm32-sparc.c (nlm_sparc_read_import): Check bfd_alloc.

	* nlm32-i386.c (nlm_i386_read_import): Check bfd_alloc.

	* nlm32-alpha.c (nlm_alpha_read_import): Check bfd_alloc.

	* linker.c (_bfd_link_hash_newfunc
	(generic_link_hash_newfunc
	(archive_hash_newfunc
	(_bfd_generic_link_add_one_symbol): Check bfd_hash_allocate.
	(_bfd_generic_final_link
	(_bfd_generic_link_output_symbols
	(default_indirect_link_order): Check bfd_alloc.
	(bfd_new_link_order): Check bfd_alloc_by_size_t.

	* irix-core.c (irix_core_make_empty_symbol): Check bfd_zalloc.

	* ieee.c: Indent.
	(read_id get_symbol get_section_entry ieee_archive_p ieee_object_p
	ieee_slurp_section_data ieee_new_section_hook): Check bfd_alloc.
	(do_one): Check bfd_alloc.  Return a boolean.
	(ieee_slurp_section_data): Check it.
	(init_for_output): Check bfd_alloc.  Return a boolean.
	(ieee_set_section_contents): Check it.
	(do_with_relocs):  Check bfd_alloc.  Return a boolean.
	(ieee_bfd_debug_info_accumulate): Ditto.  FIXME void.
	(ieee_mkobject): Check bfd_zalloc.
	(ieee_make_empty_symbol): Check bfd_zmalloc.

	* hpux-core.c (hpux_core_make_empty_symbol): Check
	bfd_zalloc.

	* hppabsd-core.c (hppabsd_core_make_empty_symbol): Check
	bfd_zalloc.
	(hppabsd_core_core_file_p): Check bfd_zalloc.

	* hp300hpux.c (MY(slurp_symbol_table)): Check bfd_alloc.

	* elfcode.h (elf_new_section_hook): Check bfd_alloc.
	(bfd_section_from_phdr): Ditto.
	(write_relocs): Ditto.  FIXME void
	(elf_map_symbols assign_section_numbers map_program_segments):
	Ditto.  Return a boolean.
	(swap_out_syms): Ditto.  Check elf_map_symbols.
	(elf_slurp_symbol_table): Check bfd_zalloc.
	(elf_slurp_reloca_table): Check bfd_alloc.
	(elf_slurp_reloc_table): Ditto.
	(elf_compute_section_file_positions): Check assign_section_numbers.
	(assign_file_positions_except_relocs): Return a boolean.
	Check map_program_segments.
	(elf_compute_section_file_positions): Check it.

	* elf32-mips.c (mips_elf_final_link): Check bfd_alloc.

	* elf32-hppa.c (hppa_elf_stub_branch_reloc): Check bfd_zmalloc and
	realloc.
	(hppa_elf_stub_reloc): Ditto.
	(hppa_elf_build_arg_reloc_stub): Check bfd_zalloc.
	(hppa_elf_build_long_branch_stub): Ditto.
	(elf32_hppa_backend_symbol_table_processing): Ditto.

	* ecoff.c (ecoff_set_symbol_info): Check bfd_alloc.  Return a boolean.
	(ecoff_slurp_symbol_table): Check it.
	(ecoff_slurp_armap): Check bfd_alloc.
	(ecoff_write_armap): Check bfd_zalloc.
	(ecoff_link_hash_newfunc): Check bfd_hash_allocate and
	_bfd_link_hash_newfunc.
	(ecoff_link_add_externals): Check bfd_alloc.

	* ctor.c (bfd_constructor_entry): Check bfd_alloc.

	* coffgen.c (coff_real_object_p): Check bfd_alloc.
	(coff_renumber_symbols): Check bfd_alloc_by_size_t.  Return a boolean.
	(coff_write_symbol): Check bfd_alloc.  FIXME int
	(coff_write_linenumbers): Check bfd_alloc.  Return a boolean.
	(coff_section_symbol): Check bfd_alloc_by_size_t.
	(coff_get_normalized_symtab): Check bfd_alloc.
	(coff_bfd_make_debug_symbol): Check bfd_zalloc.
	* libcoff-in.h: Change decls of coff_renumber_symbols,
	coff_write_linenumbers.
	* libcoff.h: Rebuilt.
	* coffcode.h (coff_write_object_contents): Check
	coff_renumber_symbols, coff_write_linenumbers.

	* coffcode.h: Indent.
	(coff_add_missing_symbols): Check bfd_alloc_by_size_t.  Return a
	boolean.
	(coff_write_object_contents): Check it.

	* coff-alpha.c (alpha_relocate_section): Check bfd_alloc.
	* coff-mips.c (mips_relocate_section): Ditto.

	* archive.c (bfd_slurp_bsd_armap_f2): Check bfd_alloc value.
	(do_slurp_bsd_armap): Ditto.
	(compute_and_write_armap): Check bfd_realloc value.

	* aoutx.h (translate_from_native_sym_flags): Check bfd_alloc
	return value.  Return boolean value.
	(NAME(aout,make_empty_symbol)): Check bfd_zalloc return value.
	(NAME(aout,slurp_symbol_table)): Check bf_alloc and bfd_zalloc
	return value.
	(add_to_stringtab): Ditto.  FIXME void
	(aout_link_hash_newfunc): Check bfd_hash_allocate return value.
	(aout_link_add_symbols): Check bfd_alloc value.
	(translate_symbol_table): Check translate_from_native_sym_flags.
	* hp300hpux.c (MY(slurp_symbol_table)): Ditto.
	* aoutx.h (aout_link_hash_newfunc): Check _bfd_link_hash_newfunc.

	* opncls.c (bfd_zalloc bfd_realloc): Check result of bfd_alloc.

	* opncls.c (obstack_chunk_alloc): Define as malloc, not
	bfd_xmalloc_by_size_t.
	(_bfd_new_bfd): Check obstack_begin for 0 return.

	* ieee.c (obstack_chunk_alloc): Define as malloc, not
	bfd_xmalloc_by_size_t.
	(ieee_archive_p): Check obstack_begin for 0 return and
	obstack_finish for NULL return.

	* hash.c (obstack_chunk_alloc): Define as malloc, not
	bfd_xmalloc_by_size_t.
	(bfd_hash_table_init_n): Check obstack_begin for 0 return and
	obstack_finish for NULL return.
	(bfd_hash_lookup): Check obstack_alloc for NULL return.

	* ecofflink.c (obstack_chunk_alloc): Define as malloc, not
	bfd_xmalloc_by_size_t.
	bfd_ecoff_debug_accumulate
	bfd_ecoff_debug_accumulate_other): Check obstack_alloc.
	(add_file_shuffle add_memory_shuffle): Check obstack_alloc for
	NULL return.  Return boolean, not void.
	(bfd_ecoff_debug_init): Check obstack_begin for 0 return.
	(bfd_ecoff_debug_accumulate): Check add_file_shuffle
	and add_memory_shuffle return.
	(string_hash_newfunc): Check bfd_hash_allocate and bfd_hash_newfunc.
	(bfd_ecoff_debug_accumulate): Check bfd_alloc.
	(ecoff_add_string): Check add_memory_shuffle return.

	* libbfd-in.h (xmalloc, bfd_xmalloc, bfd_xmalloc_by_size_t):
	Remove decls.
	* libbfd.h: Rebuilt.
1994-02-12 00:45:54 +00:00
David MacKenzie b9d5cdf003 * elfcode.h (prep_headers, swap_out_syms): Check for NULL return
from bfd_new_strtab.
	(elf_compute_section_file_positions): Check for false return from
	swap_out_syms.

	* linker.c (default_indirect_link_order): Check for NULL return
	from bfd_get_relocated_section_contents.

	* syms.c: Make example application in doc call xmalloc, not
	bfd_xmalloc.

	* aoutx.h (NAME(aout,slurp_symbol_table),
	aout_link_get_symbols, NAME(aout,link_hash_table_create)):
	* bout.c (b_out_slurp_reloc_table, b_out_squirt_out_relocs):
	* ecoff.c (ecoff_bfd_link_hash_table_create):
	* ecofflink.c (bfd_ecoff_debug_init):
	* format.c (bfd_check_format_matches):
	* linker.c (_bfd_generic_link_hash_table_create):
	(_bfd_generic_final_link):
	* reloc16.c (bfd_coff_reloc16_relax_section):
	(bfd_coff_reloc16_get_relocated_section_contents):
	* elf32-hppa.c (hppa_elf_build_arg_reloc_stub):
	* elf32-mips.c (mips_elf_final_link):
	* elfcode.h (bfd_new_strtab):
	(bfd_add_2_to_strtab):
	(elf_slurp_symbol_table):
	(elf_corefile_note):
	* libbfd.c (bfd_zmalloc):
	Use malloc and check the result, instead of bfd_xmalloc.
1994-02-07 05:17:21 +00:00
David MacKenzie f4bd7a8f0e * opncls.c (_bfd_new_bfd, _bfd_new_bfd_contained_in): Add
"_bfd_" to function names.
	* archive.c (_bfd_create_empty_archive_element_shell),
	libbfd-in.h: Change callers.

	* libbfd.c (bfd_zmalloc): Renamed from zalloc.
	* libbfd.c (bfd_add_to_string_table),
	trad-core.c (trad_unix_core_file_p),
	targets.c (bfd_target_list),
	ptrace-core.c (ptrace_unix_core_file_p),
	opncls.c (new_bfd), libbfd-in.h,
	ieee.c (ieee_make_empty_symbol),
	elf32-hppa.c (hppa_elf_stub_branch_reloc),
	(hppa_elf_stub_reloc): Change callers.
	* libbfd.h: Regenerated.

	* archive.c (_bfd_look_for_bfd_in_cache): Add "_bfd_" to name.
	(_bfd_get_elt_at_filepos),
	coff-rs6000.c (rs6000coff_get_elt_at_filepos), libbfd-in.h:
	Change callers.

	* format.c (bfd_check_format_matches), libbfd-in.h, targets.c,
	elfcode.h (elf_object_p): Rename target_vector to bfd_target_vector
	and default_vector to bfd_default_vector.
	* libbfd.h: Regenerated.
1994-01-25 13:25:26 +00:00
Ian Lance Taylor d4fb8fced1 * elfcode.h (swap_out_syms): Use elf_section_from_bfd_section to
get the index of a common section, rather than always using
	SHN_COMMON (MIPS has multiple common sections).
1994-01-24 23:54:51 +00:00
Ian Lance Taylor 38a5f510bc * elfcode.h (elf_object_p): If there is a SHT_DYNAMIC section, set
the DYNAMIC flag for the BFD.
	(NAME(bfd_elf,write_object_contents)): Don't try to write out a
	BFD with the DYNAMIC flag set, since we don't generate the program
	header table correctly.
1994-01-14 22:35:41 +00:00
Ian Lance Taylor 6c35a16d6a * elfcode.h (map_program_segments): Restore check of file_size !=
mem_size, but only if SHT_PROGBITS.
1993-11-24 07:31:02 +00:00
Ian Lance Taylor 062189c6ea * elfcode.h (bfd_section_from_shdr): Don't dump core if target
section has no ELF section data.
	(elf_make_sections): Set addralign of reloc section to 4.
	(elf_fake_sections): Likewise.
	(map_program_segments):	Don't consider section 0.
	(assign_file_positions_except_relocs): Don't consider section 0.
	In the main loop, skip the symtab and strtab sections, since their
	positions are set elsewhere.
	(swap_out_syms): Set addralign of symtab section to 4.  Set
	addralign of strtab sections to 1.
	(assign_file_positions_for_relocs): Don't consider section 0.
	(write_object_contents): Don't write out section 0.
	(sym_is_global): Take abfd argument.  Call
	elf_backend_sym_is_global if it is not NULL.
	(elf_map_symbols): Pass abfd to sym_is_global.
	(write_object_contents): Call elf_backend_final_write_processing
	if it is defined.
1993-11-18 17:12:47 +00:00
Ian Lance Taylor 7b8106b484 * elfcode.h (bfd_section_from_shdr): Remove duplicate assignment
to filepos in SHT_STRTAB case.
	(assign_file_position_for_section): Set BFD section filepos as
	well as ELF section sh_offset.
1993-11-08 23:33:56 +00:00
Ian Lance Taylor f035cc474f * elfcode.h (assign_file_position_for_section): Align sh_offset to
sh_addralign (this is what UnixWare does, and it shouldn't hurt).
1993-10-26 20:58:54 +00:00
Ken Raeburn 01383fb458 elfcode.h (EALIGN): Define, dependent on ARCH_SIZE.
(align_file_position): New function.
(elf_locate_sh): Disabled function deleted.
(assign_file_positions_for_symtab_and_strtabs): Align position, then place
symtab, then do other sections.
(map_program_segments): Align program header.
(assign_file_positions_except_relocs): Align section headers.
(assign_file_positions_for_relocs): Align relocation sections.

Fixes ld/3584.
1993-10-07 18:34:59 +00:00
Ian Lance Taylor d6e5f95000 * section.c (SEC_DEBUGGING): New section flag.
* elfcode.h (bfd_section_from_shdr): If section is SHT_PROGBITS,
	and the name starts with .debug, .line or .stab, set
	SEC_DEBUGGING.
	* elf32-target.h (TARGET_BIG_SYM, TARGET_LITTLE_SYM): Added
	SEC_DEBUGGING to section_flags.
	* elf64-target.h (TARGET_BIG_SYM, TARGET_LITTLE_SYM): Added
	SEC_DEBUGGING and SEC_CODE to section_flags.
	* bfd-in2.h: Updated.
1993-09-23 15:14:12 +00:00
Ian Lance Taylor 36d541b1c7 * elfcode.h (bfd_section_from_shdr): Only set SEC_DATA for a
SHF_PROGBITS or SHT_STRTAB section if SEC_ALLOC is set.  Never set
	SEC_DATA for a SHF_NOBITS section.

	* nlm32-i386.c (nlm_i386_mangle_relocs): Check SEC_LOAD rather
	than SEC_CODE | SEC_DATA.  Add some casts to avoid warnings.
	* nlmcode.h: Add some casts to avoid warnings.
	(nlm_write_object_contents): Ignore relocs for sections that are
	neither code nor data.  Just use the symbol value for debugging
	symbols; don't offset by the section vma.
1993-09-20 23:25:52 +00:00
Ian Lance Taylor e621c5cc37 * elfcode.h (elf_map_symbols): Create section symbols for all
sections, not just allocated sections; debugging sections can have
	relocs.
	(elf_symbol_from_bfd_symbol): If there is an output section, use
	the section index from that rather than the input section.
1993-09-16 22:24:33 +00:00
Ken Raeburn d24928c05b * elfcode.h (elf_build_phdrs): Unused function deleted.
(bfd_shdr_from_section): Ditto.
(write_relocs): Don't change section contents for addend.
(elf_locate_sh): Return type is now always elf_internal_shdr, since the other
types were really aliases for this type anyways.  Don't compile this function,
since it is static and doesn't appear to be used in this file.
(sym_is_global): Return non-zero for weak symbols.  Abort if sec ptr is null.
(swap_out_syms): Reorder tests so function symbols can be weak.
(elf_slurp_symbol_table): Don't use BSF_EXPORT.
(elf_slurp_reloca_table): Make RELOC_PROCESSING section smaller by
extracting out some common code.  Abort if BFD section symbol has null name.
(elf_slurp_reloc_table): Translate ELF section symbols into BFD section
symbols.  Don't read section contents to fill in addend field.

* Merged from OSF:

Tue Jun 15 14:38:32 1993  Michael Meissner  (meissner@osf.org)

* libelf.h (struct Elf_Sym_Extra): New structure to contain ELF
specific information for a symbol.  Put in elf_sym_num, which
gives the external symbol number in the elf object file, since
local symbols must come before global symbols.
(elf_sym_extra): New macro.
(elf_symtab_map): Delete, in favor of using Elf_Sym_Extra.
* elfcode.h (elf_map_symbols): Use Elf_Sym_Extra to map internal
symbol number to external number.  Store the address of the
Elf_Sym_Extra field for the symbol in the udata field.
(elf_write_object_contents): Use Elf_Sym_Extra to map out symbols.

Sun Jun 20 16:30:11 1993  Michael Meissner  (meissner@osf.org)

* elfcode.h (elf_obj_tdata): Add field to count the size of the
array of pointers to section symbols.
(elf_map_symbols): Bump the max index of the section symbols so
that we don't overwrite memory.  Store the max index into the
elf_obj_tdata field.

Sat Jun 19 10:12:27 1993  Michael Meissner  (meissner@osf.org)

* elfcode.h (elf_obj_tdata): Add pointer to an array of pointers
to the section symbols we created.  Remove unused field internal_syms.
(elf_map_symbols): Fill in array of pointers to section symbols.  Only create
section symbols for sections that have SEC_ALLOC set, and have non-zero size.
(elf_symbol_from_bfd_symbol): If udata is NULL, and this is a section symbol,
look up the section in the list of section symbols, and set the udata pointer
appropriately.  Otherwise, if udata is still NULL, fail an assertion, and use
0, instead of dropping core.
1993-08-20 22:21:49 +00:00
Ken Raeburn e74034d81a Wed Jun 23 06:05:58 1993 Michael Meissner (meissner@osf.org)
* elfcode.h (elf_write_object_contents): Don't drop core if
	elf_symbol_from returns a NULL pointer when processing a non-elf
	symbol, use a 0 size instead.

Tue Jun 15 14:38:32 1993  Michael Meissner  (meissner@osf.org)

	* elfcode.h (elf_hash): Delete macro mapping elf_hash to
	bfd_elf32_hash, since the hash table is independent of the 32/64
	bit system.
1993-08-05 18:32:50 +00:00
Ken Raeburn 300adb3110 Reimplement segment writing.
(elf_write_phdrs): Use precomputed e_phoff rather than making assumptions.
(elf_build_phdrs): Disabled, for now.
(assign_file_position_for_section): Don't change file offset for SHT_NOBITS.
(assign_file_positions_for_symtab_and_strtabs): New function.
(struct seg_info): New type.
(map_program_segments): New function.
(assign_file_positions_except_relocs): For executables, leave section headers
&c for last, and properly align all sections with flag SHF_ALLOC set.
(prep_headers): No longer abort when EXEC_P is set.
(write_shdrs_and_ehdr): Deleted all code relating to program segments.

(various): Deleted some unused code, and debugging "malloc(0)" calls.
(write_relocs): Cache value of last symbol looked up, to save
time if the symbol is referred to repeatedly.
(elf_fake_sections): Check only SEC_RELOC flag, not number of relocs.
(assign_section_numbers): Likewise.
1993-07-26 19:27:56 +00:00
Fred Fish c3e964b955 * configure.in (*-*-netware, i[34]86-*-netware): New configs.
* Makefile.in (BFD32_BACKENDS):  Add nlm.o, nlm32.o, nlm32-gen.o.
	* Makefile.in (BFD64_BACKENDS):  Add nlm64.o, nlm64-gen.o.
	* Makefile.in (CFILES):  Add nlm{32,64}.c, nlm{32,64}-gen.c.
	* Makefile.in (nlm.o, nlm{32,64}.o, nlm{32,64}-gen.o:  New targets.
	* bfd-in2.h (INLINE):  Defines moved here.
	* {aoutx.h, elf.c, elfcode.h}:  Move INLINE defines to bfd-in2.h.
	* libelf.h (CAT4):  Move define to bfd-in2.h.
	* bfd-in2.h (CAT4):  Merge CAT4 macro with other CAT macros.
	* bfd-in2.h (union tdata):  Add nlm_obj_data.
	* bfd-in2.h (enum target_flavour):  Add bfd_target_nlm_flavour.
	* targets.c (bfd_nlm{32,64}_{big,little}_vec):  Add prototypes.
	* targets.c (target_vector):  Add bfd_nlm{32,64}_{big,little}_vec.
	* (libnlm.h, nlm.c, nlmcode.h, nlm{32,64}-gen.c,
	nlm{32,64}-target.h, nlm{32,64}.c, config/i386-nlm.mt):  New files
	for NLM support.
1993-07-20 04:45:13 +00:00
Ken Raeburn 32090b8e4f * elf.c, elfcode.h, libelf.h: Serious reorganization.
Deleted `thunk' structure, merged into tdata, duplicate data eliminated.
Rearranged functions, grouping by function.
Broke up many functions in elfcode.h, re-ordered many parts of file writing
to handle unpredictable state of section relocation table as provided by
various applications.
Still needs cleanup: Merge functions back together, split out data structure
with only data that is used only when writing out object file.

* elf.c (bfd_elf_generic_reloc): New function, taken from coff-mips.c.
* elf32-sparc.c (elf_sparc_howto_table): Use it, to work around
bfd_perform_relocation lossage.
1993-07-19 19:12:59 +00:00
Ken Raeburn 42b9004e46 make sanitize dtrt wrt v9 1993-07-13 18:39:22 +00:00
Jim Kingdon 4d09e8acfb * elfcode.h: Use memset not bzero.
* trad-core.c: Don't include <sys/file.h>.
	* i386linux.h: Include <sys/file.h>.
	* coff-m68k-un.c: new file to handle names with underscores on
	svr3 machines.
	* coff-m68k.c (m68k_rtype2howto): added #ifdef ONLY_DECLARE_RELOCS
	to not duplicate the function in the executable.
	(TARGET_SYM, TARGET_NAME, NAMES_HAVE_UNDERSCORE): new macros needed
	by coff-m68k-un.c.
	* coffcode.h (MC68KBCSMAGIC): case added.
	* targets.c: Add m68kcoffun_vec.
	* configure.host: added support for Bull dpx/2.
	* config/dpx2.mh, hosts/dpx2.h: new files.
	* Makefile.in: added target coff-m68k-un.
1993-07-11 23:23:20 +00:00
Ken Raeburn 6a3eb9b606 * elfcode.h (elf_read): Delete static declaration, since function has moved.
(elf_map_symbols): Write out section symbols for all sections, for now.
(elf_symbol_from_bfd_symbol): Allow match if both symbols are section symbols
for the same section.
(elf_find_nearest_line): Don't print message, just return false.
1993-07-06 20:43:42 +00:00
Ken Raeburn 15012ad131 Sigh. Null pointer return might be right in some cases; don't abort. 1993-06-22 21:39:40 +00:00
Ken Raeburn 94dbb655ba More get_word/put_word changes.
(bfd_section_from_shdr, case SHT_PROGBITS): If section already exists, still
use its address to fill in the rawdata slot.
(section_from_elf_index): Abort if section pointer is null.
1993-06-22 21:38:10 +00:00
Ken Raeburn 238ac6ecd2 Use new size-independent elf internal data structures.
(put_word, get_word): Define as appropriate for architecture word size.
Structure swapping functions changed to use them as appropriate.
(bfd_add_to_strtab): Now static.
(sym_is_global): New function.
(elf_map_symbols): Call it.  Now returns void.  Removed unused local variable.
(bfd_section_from_shdr): Mark string tables other than for section and symbol
names as normal sections having contents.
(fix_up_strtabs): New function; fixes up ELF header fields for stab sections
with string tables associated.
(elf_write_object_contents): Map fix_up_strtabs over all BFD sections.
Reordered condition tests for symbol flags; default to local-object value
instead of global-object.
(elf_symbol_from_bfd_symbol): Hid conditionally-used variable inside condition
test.
(elf_print_symbol): Use fprintf_vma.
(elf_idx_of_sym, bfd_shdr_from_section): Unused functions commented out.
1993-06-22 03:21:12 +00:00
Ken Raeburn fce361373d * elfcode.h (bfd_add_to_strtab): Now static.
(sym_is_global): New function.
(bfd_section_from_shdr): Makr stirng tables other than for section and symbol
names as normal sections having contents.
(fix_up_strtabs): New function; fixes up ELF header fields for stab sections
with string tables associated.
(elf_write_object_contents): Map fix_up_strtabs over all BFD sections.
Reordered condition tests for symbol flags; default to local-object value
instead of global-object.

* elfcode.h (new_section_hook): Define here.
1993-06-21 00:53:45 +00:00
Jim Kingdon 244ffee7f1 * Makefile.in: Add elf32-{mips,m88k,generic}.
elf32-{mips,m88k,generic}.c: New files.
	targets.c (target_vector): Include bfd_elf32_{mips,m88k,generic}_vec.
	elfcode.h (elf_object_p): Match elf32-generic for all machines which
	don't match a different target.
1993-06-18 17:45:41 +00:00