Commit Graph

1247 Commits

Author SHA1 Message Date
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
Jim Kingdon dab0844122 * coffgen.c (coff_print_symbol): Make names for section number and
storage class slightly more verbose.  It's not clear how many
	characters I can justify using up, but before this change they
	both were abbreviated "sc" which is (IMHO) clearly unacceptable.
1994-10-19 20:49:03 +00:00
Ian Lance Taylor 8b65c39307 * binary.c (binary_set_section_contents): Set the base file
position from the lowest section VMA, not the start address.
1994-10-19 18:08:42 +00:00
Ian Lance Taylor 7494246592 * aoutx.h (NAME(aout,slurp_symbol_table)): Don't return an error
if there are no symbols.
	* coffgen.c (coff_get_normalized_symtab): Likewise.
	* hp300hpux.c (MY(slurp_symbol_table)): Likewise.
1994-10-19 05:30:15 +00:00
Ian Lance Taylor c768bd3f2d * binary.c: New file for raw binary output format.
* Makefile.in (BFD_LIBS): Add binary.o.
	(CFILES): Add binary.c.
	* targets.c (binary_vec): Declare.
	(bfd_target_vector): Include binary_vec.
1994-10-18 18:51:01 +00:00
Ian Lance Taylor d4d166835f * srec.c (tdata_type): Add field tail.
(srec_mkobject): Initialize tail.
	(srec_set_section_contents): Sort S record list by address.
1994-10-18 16:58:24 +00:00
Ian Lance Taylor b7881f82ee * oasys.c (oasys_slurp_symbol_table): Use udata.p rather than just
udata.
1994-10-17 23:59:36 +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
Jim Kingdon a3377a658c Fix thinko in ian's ChangeLog entry 1994-10-17 21:41:20 +00:00
Ian Lance Taylor cb066aa98a * libbfd-in.h (DEFAULT_STRING_SPACE_SIZE): Don't define.
(bfd_add_to_string_table): Don't declare.
	* libbfd.h: Rebuild.
	* libbfd.c (bfd_add_to_string_table): Remove.
1994-10-17 19:31:23 +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
Ian Lance Taylor 5e643795a3 * srec.c (pass_over): Set the start address for S7, S8 or S9. 1994-10-17 15:39:37 +00:00
Ken Raeburn f10abb42eb update to version 2.5 1994-10-14 23:17:15 +00:00
Ian Lance Taylor 61c94e5e64 * bfd.c (bfd_scan_vma): Cast end to be non const before passing it
to strtoul.
1994-10-14 15:09:07 +00:00
Ian Lance Taylor 82735983df * bfd.c (bfd_scan_vma): Pass end argument on to strtoul. 1994-10-13 18:41:39 +00:00
Ian Lance Taylor 7b18561f3b * ecoff.c (ecoff_set_symbol_info): Mark local stProc or stLabel
symbols as BSF_DEBUGGING.
PR 5769.
1994-10-12 21:51:04 +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
Ian Lance Taylor 17d9e20376 * rs6000-core.c (rs6000coff_core_file_matches_executable_p): Make
str1 and str2 const pointers.
1994-10-12 16:19:33 +00:00
Ian Lance Taylor bf42caf32c * Makefile.in (INSTALL): Use top level install.sh script.
* config/README (INSTALL): Remove.
	* config/delta88.mh (INSTALL): Remove.
	* config/i386v4.mh (INSTALL): Remove.
	* config/irix4.mh (INSTALL): Remove.
	* config/irix5.mh (INSTALL): Remove.
	* config/ncrt3000.mh (INSTALL): Remove.
1994-10-12 15:57:28 +00:00
Ian Lance Taylor b2bcf39ca2 Tue Oct 11 13:57:56 1994 Eric Youngdale (eric@andante.aib.com)
* elf32-i386.c (elf_i386_check_relocs): Make sure that a symbol
	with a global offset table entry or a procedure linkage table
	entry is added to the dynamic symbol table.
	* elf32-sparc.c (elf32_sparc_check_relocs): Likewise.
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): If a symbol has
	already gotten a procedure linkage table entry, change the
	definition to the PLT entry.
	* elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
1994-10-11 21:40:54 +00:00
Ian Lance Taylor 9a406d86e9 * lynx-core.c (lynx_core_file_p): SPARC Lynx appears to start
dumping the .data section in a core file at a page boundary.
1994-10-11 21:13:45 +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
Ken Raeburn 4fbc96adc8 * elf32-sparc.c (elf_sparc_howto_table): The PC10, PC22, and WPLT30 relocations
are PC-relative.
1994-10-10 20:30:32 +00:00
Ian Lance Taylor 66e4e64904 * archive.c (bfd_construct_extended_name_table): SVR4 uses slash
newline at the end of the file name, not just newline.
1994-10-05 18:43:30 +00:00
Ian Lance Taylor ea4849d5b7 * ecoff.c (_bfd_ecoff_new_section_hook): Default section alignment
power to 4, rather than using align_power_min.
1994-10-04 21:30:45 +00:00
Ian Lance Taylor 28d19d0321 * coffcode.h (coff_new_section_hook): Don't use align_power_min;
use COFF_DEFAULT_SECTION_ALIGNMENT_POWER instead.  Force the .stab
	and .stabstr sections to be aligned to no more than 2.  Remove
	COFF_SPARC special cases.
	* coff-a29k.c: Define COFF_DEFAULT_SECTION_ALIGNMENT_POWER.
	* coff-apollo.c, coff-go32.c, coff-h8300.c: Likewise.
	* coff-h8500.c, coff-i386.c, coff-i960.c, coff-m68k.c: Likewise.
	* coff-m88k.c, coff-rs6000.c, coff-sh.c, coff-sparc.c: Likewise.
	* coff-we32k.c, coff-z8k.c: Likewise.
PR 5706.
1994-10-04 21:13:51 +00:00
Ian Lance Taylor 995b0d3ff3 * configure.in: Use ${config_shell} when running config.bfd. 1994-10-04 16:18:19 +00:00
Ian Lance Taylor a297d42c27 * cofflink.c (coff_link_input_bfd): Don't try to convert a long
filename if the offset field is zero.
1994-10-04 15:54:27 +00:00
Ian Lance Taylor dfaf9ef608 * elfcode.h (swap_out_syms): If the alignment of a common symbol
was not set, use a sensible default rather than zero.
PR 5751.
1994-10-04 15:25:02 +00:00
Peter Schauer 7a6c910ea1 * rs6000-core.c (rs6000coff_core_p): Set SEC_HAS_CONTENTS flag
for .stack and .ldinfo sections. Cast coredata.c_tab to a
	file_ptr to avoid warnings from gcc.
1994-10-03 11:47:38 +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 12cf5d98c7 fix typu 1994-09-29 20:51:57 +00:00
Ken Raeburn 85f340909d * reloc.c (bfd_install_relocation): Change type of data to bfd_byte *, to go
along with yesterday's change.
1994-09-29 20:39:27 +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
Ken Raeburn 9afa408e4f * syms.c (bfd_print_symbol_vandf): Show BSF_LOCAL and BSF_GLOBAL in one column.
Use the column freed up to show BSF_FUNCTION and BSF_FILE.
1994-09-29 20:29:54 +00:00
Ian Lance Taylor ec591fcf45 * syms.c (stt): Add .rdata and .rodata.
PR 5714.
1994-09-29 16:30:12 +00:00
Ian Lance Taylor 094e8be303 * reloc.c (bfd_install_relocation): Cast data_start to bfd_byte *
before trying to add values to it.
1994-09-28 17:36:42 +00:00
Ian Lance Taylor 5ea9089194 * elfcode.h (assign_file_positions_except_relocs): Align the
section VMA and the file position even if D_PAGED is not set.
1994-09-26 15:40:12 +00:00
Ian Lance Taylor d80ebaacea * bfd-in.h (bfd_seek): Change declaration to not mark fp const.
* bfd-in2.h: Rebuild.
	* libbfd.c (bfd_seek): Don't mark parameters const, to avoid
	conflicts with declaration.
1994-09-26 15:01:59 +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
J.T. Conklin 237402b49b * libaout.h: Fix comment.
* ns32knbsd.h: Changed M_NS32K_NETBSD to M_532_NETBSD to match
  libaout.h.
1994-09-20 20:20:12 +00:00
Ian Lance Taylor f90a2cdcb0 * coff-sh.c (rtype2howto): Remove; unused.
(coff_sh_relocate_section): Remove unused local variable rstat.
	(reloc_processing): Comment out; unused.
1994-09-20 19:24:50 +00:00
Ian Lance Taylor fb9a219279 * aoutx.h (aout_link_write_other_symbol): If h->indx is -2, then
always write it out even if it would normally be stripped.
	(aout_link_input_section_std): If we find a reloc against a
	stripped global symbol, force it to be written out rather than
	merely calling unattached_reloc.
	(aout_link_input_section_ext): Likewise.
	(aout_link_reloc_link_order): Likewise.
1994-09-16 16:14:51 +00:00
Ian Lance Taylor ab0434c26d * aoutx.h (aout_link_write_symbols): Rename skip_indirect to
skip_next.  If we find an N_WARNING symbol which has already been
	written out, set skip_next.
PR 5634.
1994-09-14 23:28:25 +00:00
Jeff Law a8d0866480 * som.h (struct somdata): New field sorted_syms.
(obj_som_sorted_syms): Accessor macro.
	* som.c (som_object_setup): Initialize sorted_syms to NULL.
	(som_prep_for_fixups): Sort a copy of the BFD's symbol table;
	store the sorted symbol table in sorted_syms.
	(som_write_fixups): Initalize tmp_reloc to NULL to make GCC happy.
	(som_begin_writing): Similarly for exec_header.  Pass the sorted
	symbol table to som_write_symbol_strings.
	(som_build_and_write_symbol_table): Use the sorted symbols rather
	than the canonical symbol table.
1994-09-14 22:24:56 +00:00
Jeff Law 8a2cdc6278 * som.h (som_symbol_type): Add "stringtab_offset" field.
* som.c (som_write_symbol_strings): Use "stringtab_offset"
	rather than destroying the "name" field in the BFD symbol.
	(som_build_and_write_symbol_table): Likewise.
1994-09-14 21:44:35 +00:00
Ian Lance Taylor 9be909aef7 * libecoff.h (struct ecoff_tdata): Add field find_buffer.
* ecoff.c: Include aout/stab_gnu.h.
	(ecoff_find_nearest_line): Handle stabs debugging information.
PR 3954.
1994-09-14 20:19:09 +00:00
Ian Lance Taylor 8c62064a26 * elfcode.h (elf_link_output_extsym): Keep a symbol marked as weak
even if it is referenced by another object.
1994-09-14 19:08:26 +00:00
Jeff Law ae880afc1b * som.c (som_fixup_formats): Case R_ENTRY (0xb3), set both
'T' and 'U' to grab all the unwind information.
	(som_set_reloc_info): Make 'U' unwind bits persist across
	multiple SOM relocations.  Set the addend field of an R_ENTRY
	relocation to the value in 'T'; set the addend field on an
	R_EXIT relocation to the value in 'U'.
1994-09-14 03:03:15 +00:00