* elf.c (_bfd_elf_link_hash_newfunc): Set elf_link_hash_flags to
ELF_LINK_NON_ELF.
* elflink.h (elf_link_add_object_symbols): Reset ELF_LINK_NON_ELF
flag for a newly defined symbol.
(NAME(bfd_elf,record_link_assignment)): Likewise.
(elf_adjust_dynamic_symbol): If ELF_LINK_NON_ELF is set, try to
set the DEF or REF_REGULAR flags correctly.
* syms.c (BSF_OBJECT): Define.
(bfd_print_symbol_vandf): Print 'O' for BSF_OBJECT.
* bfd-in2.h: Rebuild.
* elfcode.h (elf_slurp_symbol_table): Set BSF_OBJECT for an
STT_OBJECT symbol.
* elf.c (swap_out_syms): Only set type to STT_OBJECT if BSF_OBJECT
is set.
dynamic section, if there is one.
* elf-bfd.h (struct elf_size_info): Add swap_dyn_in field.
(bfd_elf32_swap_dyn_in): Change type of second parameter to PTR.
(bfd_elf64_swap_dyn_in): Likewise.
* elfcode.h (elf_swap_dyn_in): Change type of second parameter to
PTR.
(NAME(_bfd_elf,size_info)): Initialize swap_dyn_in field.
support, from Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
* elf-bfd.h (struct elf_backend_data): Add type_change_ok field.
(struct elf_backend_data): Remove
elf_backend_create_program_headers field. Add
elf_backend_additional_program_headers and
elf_backend_modify_segment_map fields.
* elfxx-target.h (elf_backend_type_change_ok): Define if not
defined.
(elf_backend_additional_program_headers): Likewise.
(elf_backend_modify_segment_map): Likewise.
(elf_backend_create_program_headers): Don't define.
(elfNN_bed): Change to account for field changes.
* elf.c (assign_file_positions_for_segments): Call new
modify_segment_map backend function. Don't call old
create_program_headers backend function.
(get_program_header_size): Call additional_program_headers rather
than create_program_headers.
* elflink.h (elf_link_add_object_symbols): Initialize
type_change_ok from new backend field.
(elf_link_output_extsym): Don't warn if _rld_new_interface is
defined.
(elf_reloc_link_order): Treat a reloc against a defined symbol as
a reloc against the appropriate section.
(bfd_zmalloc): Return PTR, not char *. Take size_t, not
bfd_size_type.
* libbfd-in.h (bfd_malloc, bfd_realloc): Declare.
(bfd_zmalloc): Change declaration.
* libbfd.h: Rebuild.
* Many files: Use bfd_malloc and bfd_realloc rather than malloc
and realloc. Don't set bfd_error_no_memory if they fail.
p_paddr if p_paddr is zero.
(make_mapping): Set includes_filehdr and includes_phdrs for first
PT_LOAD segment.
(map_sections_to_segments): Set includes_phdrs for PT_PHDR
segment.
(assign_file_positions_for_segments): Handle includes_filehdr and
includes_phdrs. Remove special handling of PT_PHDR and first
PT_LOAD segments.
(copy_private_bfd_data): Set includes_filehdr and includes_phdr
when appropriate. Remove special handling of PT_PHDR segment.
Use a more complex condition for when a section is included in a
segment to handle Solaris linker oddities.
obstack_alloc fails.
(bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
fails.
* libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
* Many files: don't set bfd_error_no_memory if one of the above
routines fails.
* elf.c (make_mapping): New static function.
(map_sections_to_segments): New static function.
(elf_sort_sections): New static function.
(assign_file_positions_for_segments): New static function.
(map_program_segments): Remove.
(get_program_header_size): Remove sorted_hdrs, count, and
maxpagesize parameters. Simplify.
(assign_file_positions_except_relocs): When generating an
executable, use assign_file_positions_for_segments.
(elf_sort_hdrs): Remove.
(_bfd_elf_sizeof_headers): Remove eliminated parameters from call
to get_program_header_size.
BFD is not of the right type.
(bfd_elf_get_needed_list): Likewise.
* i386linux.c (bfd_linux_size_dynamic_sections): Likewise.
* sunos.c (bfd_sunos_get_needed_list): Likewise.
* xcofflink.c (XCOFF_XVECP): Define.
(bfd_xcoff_link_record_set): Don't do anything if the BFD is not
of the right type.
(bfd_xcoff_import_symbol): Likewise.
(bfd_xcoff_export_symbol): Likewise.
(bfd_xcoff_link_count_reloc): Likewise.
(bfd_xcoff_record_link_assignment): Likewise.
(bfd_xcoff_size_dynamic_sections): Likewise.
systems that have a system <libelf.h>.
* Makefile.in: Globally replace libelf.h with elf-bfd.h.
* bfd.c, elf.c, elf32-arc.c, elf32-gen.c, elf32-hppa.c,
elf32-hppa.h, elf32-i386.c, elf32-i860.c, elf32-m68k.c,
elf32-m88k.c, elf32-mips.c, elf32-ppc.c, elf32-sparc.c,
elf64-gen.c, elf64-sparc.c, elfcode.h, elflink.c,
elfxx-target.h: Include elf-bfd.h rather than libelf.h.
* elfxx-target.h: Change libelf.h reference to elf-bfd.h.
align to the section's alignment. "align" argument removed;
all callers changed.
Loosely based on a patch from dupuy@smarts.com; keeps dbx from losing
when debugging programs that have been objcopy'd.
* Makefile.in (BFD32_BACKENDS): Remove coff-arm.o.
* archures.c (bfd_arch_info_type): Change mach field from long to
unsigned long.
(bfd_lookup_arch): Change machine parameter from long to unsigned
long.
Moved some mostly size-independent stuff from elfcode.h to elf.c, adding a data
structure to elfcode.h with some misc data and callback functions. Added a
pointer to that structure to the target back end data. More work can be done
here.
Renamed generic elf routines (not cpu-specific stuff) to start with bfd_elf or
_bfd_elf. Updated most call sites, sometimes defined some macros.
Moved some dynamic linking support code from m68k, sparc, i386 to common files,
using target back end flags to control behavior. More work can probably be
done here too.
Moved core- and linker-support code out of elfcode.h to elf.c, elfcore.h,
elflink.h, or elflink.c. Now elfcode.h contains only .o and executable
support, plus #includes of elfcore.h and elflink.h. Much of the contents of
these other header files can probably still be moved from the .h files to the
.c files, to get compiled only once.
Cleaned up some "gcc -Wall" warnings regarding unused or uninitialized
variables, in generic and cpu-specific code.
saw_needed field.
* elfcode.h (elf_link_add_object_symbols): If elf_dt_needed_name
is an empty string, don't make a DT_NEEDED entry in the output
file. Record all DT_NEEDED entries found in input dynamic
objects.
(elf_link_output_extsym): Don't check saw_needed when issuing
warnings.
* elf.c (_bfd_elf_link_hash_table_init): Initialize needed, not
saw_needed.
(bfd_elf_get_needed_list): New function.
* bfd-in.h (struct bfd_elf_link_needed_list): Define.
(bfd_elf_get_needed_list): Define.
* bfd-in2.h: Rebuild.
PR 7083.
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.
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.
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.
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.
more efficient backend code can be written for specific object
files. Only existing efficient backend is a.out.
* seclet.c, seclet.h: Removed.
* hash.c, linker.c, genlink.h: New files.
* bfd-in.h: Removed bfd_error_vector. Declared hash table
structures and functions.
(JUMP_TABLE): Removed bfd_seclet_link, added
bfd_link_hash_table_create, bfd_link_add_symbols and
bfd_final_link.
* All backends: Changed accordingly.
* bfd-in2.h: Rebuilt.
* bfd.c (struct _bfd): Added link_next and archive_pass fields.
Removed ld_symbols field.
(bfd_nonrepresentable_section, bfd_undefined_symbol,
bfd_reloc_value_truncated, bfd_reloc_is_dangerous,
bfd_error_vector): Removed.
(bfd_default_error_trap, bfd_error_trap,
bfd_error_nonrepresentabltrap): Removed.
(bfd_get_relocated_section_contents): Pass link_info. Pass
link_order instead of seclet. Pass symbols.
(bfd_relax_section): Pass link_info.
(bfd_seclet_link): Removed.
(bfd_link_hash_table_create, bfd_link_add_symbols,
bfd_final_link): New macros.
* libbfd-in.h: If __GNUC__ is defined and alloca is not, define
alloca as __builtin_alloca. Declare internal linking functions.
* libbfd.h: Rebuilt.
* libbfd.c (bfd_seek): Comment out fseek assertion. It's worked
for months.
* reloc.c (reloc_howto_type): Added error_message argument to
special_function field. Changed all callers and all definitions.
(bfd_get_reloc_size): Make argument a const pointer.
(bfd_perform_relocation): Add error_message argument to hold
string set if return value if bfd_reloc_dangerous. Changed all
callers.
(_bfd_final_link_relocate, _bfd_relocate_contents): New functions.
* section.c (asection): Renamed seclets_head and seclets_tail to
link_order_head and link_order_tail.
* targets.c (bfd_target): Replaced seclet argument with link_info
and link_order and symbols arguments in
bfd_get_relocated_section_contents. Added symbols argument to
bfd_relax_section. Removed bfd_seclet_link. Added
bfd_link_hash_table_create, bfd_link_add_symbols and
bfd_final_link.
* libaout.h (struct aoutdata): Added external_syms,
external_sym_count, external_strings, sym_hashes fields.
(obj_aout_external_syms, obj_aout_external_sym_count,
obj_aout_external_strings, obj_aout_sym_hashes): New accessor
macros.
(WRITE_HEADERS): Only output symbols if outsymbols is not NULL.
* aoutx.h: Wrote new back end linker routines.
(translate_to_native_sym_flags): Return boolean value. Don't use
bfd_error_vector.
(NAME(aout,write_syms)): Return boolean value. Check return value
of translate_to_native_sym_flags and bfd_write.
* aout-target.h (final_link_callback): New function.
(MY_bfd_final_link): New function.
* aout-adobe.c (aout_adobe_write_object_contents): Check return
value of aout_32_write_syms.
* hp300hpux.c (MY(write_object_contents)): Likewise.
* i386lynx.c (WRITE_HEADERS): Likewise.
* libaout.h (WRITE_HEADERS): Likewise.
* bout.c: Changed functions to use link_info->callbacks rather
than bfd_error_vector, and link_orders rather than seclets.
* coff-alpha.c: Likewise.
* coff-h8300.c: Likewise.
* coff-h8500.c: Likewise.
* coff-sh.c: Likewise.
* coff-z8k.c: Likewise.
* elf32-hppa.c: Likewise.
* reloc16.c: Likewise.
* coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Look
up _gp in the hash table rather than in outsymbols.
* coff-a29k.c (a29k_reloc): Pass errors back in new error_message
argument rather than printing them.
* coffcode.h (bfd_coff_reloc16_extra_cases): Take link_info and
link_order arguments rather than seclet. Changed all uses and
definitions.
(bfd_coff_reloc16_estimate): Pass link_info arguments. Changed
all uses and definitions.
* libcoff.h: Rebuilt.
* ecoff.c (ecoff_get_extr): If symbol is defined by linker, but
not by ECOFF, make it scAbs.
(ecoff_bfd_final_link): Renamed from ecoff_bfd_seclet_link and
rewritten.
* elf32-mips.c (mips_elf_final_link): Renamed from
mips_elf_seclet_link and rewritten.
* elf32-hppa.c (elf32_hppa_stub_description): Added link_info
field.
(new_stub, add_stub_by_name, hppa_elf_build_arg_reloc_stub,
hppa_elf_build_long_branch_stub, hppa_look_for_stubs_in_section):
Added link_info arguments. Changed all callers.
* elfcode.h (elf_slurp_symbol_table): Don't quit if outsymbols is
not NULL.
* oasys.c (oasys_write_sections): Return boolean value rather than
using bfd_error_vector.
(oasys_write_object_contents): Check return value of
oasys_write_sections.
* hosts/std-host.h: Don't declare qsort or strtol.
* Makefile.in: Rebuild dependencies.
(BFD_LIBS): Removed seclet.o. Added hash.o and linker.o.
(CFILES): Removed seclet.c. Added hash.c and linker.c.
(HFILES): Removed seclet.h. Added genlink.h.
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.
bfd_make_debug_symbol; they were already in the target structure.
* Adjusted all uses of JUMP_TABLE.
* coffgen.c, libcoff-in.h (coff_bfd_make_debug_symbol): Renamed
from coff_make_debug_symbol.
* libcoff.h: Updated accordingly.
on the possible size of any object in a bfd.
* elf.c (bfd_elf_find_section, elf_get_str_section,
elf_get_symtab_upper_bound): Rewrite to avoid NULL pointer
dereferences.
* elf.c (elf_big_vec, elf_little_vec): Document last three
members initialized to NULL.
coffcode.h, elf.c, ieee.c, libaout.h, libbfd.c, oasys.c,
sco-core.c: Lint: Second argument of bfd_seek is always file_ptr.
Third argument is SEEK_SET or SEEK_CUR. Result is always 0 or -1.
Thu Oct 8 08:52:48 1992 Steve Chamberlain (sac@thepub.cygnus.com)
Now a bfd knows whether underscores are normally prepended
to symbols in its file format. Helps with error messages.
* aout-adobe.c, aout-target.h, bout.c, coff-a29k.c, coff-h8300.c,
coff-z8k.c: targets set so they have leading underscore
* coff-i386.c, coff-i960.c, coff-m68k.c, coff-mips.c, coff-m88k.c,
coff-rs6000.c, coff-we32k.c, elf.c, ieee.c, srec.c: targets set
without leading underscore flag
* targets.c: add symbol leading char to xvec description
* bfd-in.h (bfd_get_symbol_leading_char): new macro.
* elf.c (bfd_section_from_shdr, elf_section_from_bfd_section,
section_from_elf_index): Add SHT_BEPROGBITS case for i860 in
big endian mode.
* elf.c (bfd_section_from_shdr): Test for the possibility that
section_from_elf_index returns NULL and don't dereference it.
its prototype will be included in libbfd.h. Change result type
to struct * (rather than equivalent typedef) so it can be used in
the prototype, where they typedef won't be known.
* libbfd.h: Updated version.