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.
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.
do_globals arguments, always read symbol extension information for
globals and locals. All callers changed.
(elf32_hppa_size_stubs): Rework to only read symbol extension
information once for each input bfd. Another 10% improvement in
linker performance.
* 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.
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.
* 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.
Removed _bfd_debug_info_start, _bfd_debug_info_end and
_bfd_debug_info_accumulate, which were never used.
(BFD_JUMP_TABLE_GENERIC, BFD_JUMP_TABLE_COPY): Defined.
(BFD_JUMP_TABLE_CORE, BFD_JUMP_TABLE_ARCHIVE): Defined.
(BFD_JUMP_TABLE_SYMBOLS, BFD_JUMP_TABLE_RELOCS): Defined.
(BFD_JUMP_TABLE_WRITE, BFD_JUMP_TABLE_LINK): Defined.
* All backends: Changed to use the new BFD_JUMP_TABLE_* macros
rather than the single JUMP_TABLE macro. Removed many of the
weird macro definitions needed to support the monolithic
JUMP_TABLE.
* bfd-in.h (JUMP_TABLE): Removed.
* libbfd-in.h: Define a bunch of macros, and declare a few
functions, for use with the new BFD_JUMP_TABLE_* macros.
* libbfd.c (_bfd_dummy_new_section_hook): Removed.
(bfd_false): Set bfd_error_invalid_operation.
(bfd_nullvoidptr): Likewise.
(bfd_n1): New function.
(_bfd_nocore_core_file_matches_executable_p): Renamed from
_bfd_dummy_core_file_matches_executable_p.
(_bfd_nocore_core_file_failing_command): Similar rename. Set
bfd_error_invalid_operation.
(_bfd_nocore_core_file_failing_signal): Likewise.
(_bfd_generic_get_section_contents): Renamed from
bfd_generic_get_section_contents. Changed all callers.
(_bfd_generic_set_section_contents): Similar rename.
* ieee.c: #if 0 out ieee_bfd_debug_info_start,
ieee_bfd_debug_info_end, ieee_bfd_debug_info_accumulate. They
were never called.
* bfd-in2.h: Rebuilt.
* libbfd.h: Rebuilt.
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.
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.
field parameter.
(bfd_som_set_section_attributes): Use unsigned int rather than
unsigned char to avoid GNU-C extensions.
(bfd_som_attach_aux_hdr): Return a boolean to indicate success
or failure rather than aborting on failure.
* som.h (bfd_som_set_section_attributes): Fix prototype to match
som.c changes.
(bfd_som_attach_aux_hdr): Add prototype.
(hppa_som-gen_reloc_type): Likewise.
* elf32-hppa.c: Add a couple casts to make HP compiler happy.
(hppa_look_for_stubs_in_section): Do not return false on failure
until rest of code is ready to handle it. Abort for now.
action in case where caller specified no argument relocation.
(hppa_elf_build_linker_stub): Try again to get the sym_ptr_ptr
right in the original relocation and the stub's relocation.
unused symbols argument.
* elf32-hppa.c (hppa_elf_stub_reloc): Accept asymbol ** rather
than asymbol * for original target symbol. All callers changed.
Set reloc->sym_ptr_ptr appropriately.
(hppa_elf_build_linker_stub): Set reloc->sym_ptr_ptr correctly.
(hppa_elf_look_for_stubs_in_section): No longer need symbols
argument. Use the output symbols when canonicalizing the relocs,
creating them if necessary.
* linker.c (_bfd_generic_link_output_symbols): Do not rebuild/clobber
the output symbols if they already exist.
PARAMize and staticize rest of functions. Delete unused
functions. Delete unused/unnecessary arguments to some functions.
Group static vars together. Abort for bad errors until we have
error code propogation working. Work on spacing and indention.
Add FIXMEs for unresolved problems. Use enums rather than
#defines for lots of things. Merge two functions which build
linker stubs into a single function (so they can easily share a
ton of common code).
* elf32-hppa.h (elf_hppa_tc_symbol): Add new arguments.
(elf_hppa_tc_make_sections): Likewise.
(elf_hppa_final_processing): Add extern decl.
* elf32-hppa.c: First half of major cleanup. Add/cleanup lots of
comments. PARAMize some static functions. Delete unused functions.
Delete unused/unnecessary arguments to many functions. Group
static vars together. Collapse common case statements together
in many places. Use default case when possible instead of listing
each case separately. Abort for bad errors until we get error
code propogation working. Work on spacing and indention problems.
Add FIXMEs for some unresolved problems. Delete hopelessly broken
COMPLEX relocation support (it's never used anyway).
(hppa_elf_rebuild_insn): Delete. Moved into libhppa.h.
(elf_hppa_tc_symbol): Accept and use new arguments (symext chains).
(elf_hppa_tc_make_sections): Likewise.
of architectures, get the ELF EM_xxx code from the backend
information. Let the generic ELF target match any EM_xxx code not
matched by another ELF target. Call elf_backend_object_p to let
the backend do more checks and set global information.
* libelf.h (struct elf_backend_data): Added elf_machine_code and
elf_backend_object_p fields.
(struct bfd_elf_arch_map): Removed.
(bfd_elf_arch_map, bfd_elf_arch_map_size): Don't declare.
* elf32-target.h, elf64-target.h: Initialize elf_machine_code
field with ELF_MACHINE_CODE. Initialize elf_backend_object_p
field with elf_backend_object_p (if it is defined).
* elf32-gen.c, elf32-hppa.c, elf32-i386.c, elf32-i860.c,
elf32-m68k.c, elf32-m88k.c, elf32-mips.c, elf32-sparc.c,
elf64-gen.c (ELF_MACHINE_CODE): Defined.
* elf32-mips.c: Include ecoffswap.h to get ECOFF swapping
routines.
(mips_elf_object_p): Set the right machine number.
(mips_elf_ecoff_debug_swap): Defined.
(elf_backend_object_p): Defined to be mips_elf_object_p.
(elf_backend_ecoff_debug_swap): Defined to be
mips_elf_ecoff_debug_swap.
* elf.c (bfd_elf_arch_map, bfd_elf_arch_map_size): Removed.
* elf32-mips.c (elf_mips_howto_table): Don't complain on overflow
for R_MIPS_26. Correct overflow detection requires matching the
upper four bits of the destination against the PC. From Ted Lemon
<mellon@pepper.ncd.com>.
* elf32-hppa.c (elf_hppa_reloc_type_lookup): Return type
should point to const data.
* elf32-hppa.h (hppa_elf_stub_finish): Add prototype.
(ELF32_HPPA_R_ARG_RELOC): Renamed without the ELF32 prefix
and moved into libhppa.h. All references changed.
(ELF32_HPPA_R_CONSTANT, ELF32_HPPA_R_ADDEND): Likewise.
(get_opcode and opcode defines): Move into libhppa.h
* elf32-hppa.c (hppa_elf_insn2fmt): Rename and move info libhppa.h.
* libhppa.h (HPPA_R_*): Moved here. Reformatted slightly to make for easier
reading.
(get_opcode): Moved here. FIXME! this really should be a C function
inside the opcode library!
(bfd_hppa_insn2fmt): Likewise.
* targets.c (target_vector): Enable elf32-hppa vector.
* elf32-hppa.c (hppa_elf_get_section_contents): Add new comments and clarify
existing comments. Do not use DEFUN to declare this function. Fix numerous
indention problems. Correctly handle cases where symbol extension section may
need to be read from disk, read from memory, or built then read from memory.
* elf32-hppa.h: Reformat with gnu-indent and hand fix numerous
formatting and indention problems gnu-indent can not handle.
Clarify some comments about relocation types. Comment basic
relocation "classes". Group PARAM declarations together.
(HPPA_SXT_{NULL, SYMNDX, RG_RELOC}): Make members of a new
enumerated type rather than #defines.
These changes separate PA-SOM support from PA-ELF support.
A sun4-x-hppaosf assembler can now be built.
* elf32-hppa.c (elf_hppa_howto_table): Now static.
(symext_rootP, symext_lastP, global_value, GOT_value, global_symbol,
global_sym_defined, symextn_contents, symextn_contents_real_size,
elf_hppa_stub_rootP, elf32_hppa_symextn_map, elf32_hppa_symextn_map_size): Rely
on default initialization.
(hppa_elf_gen_reloc_type): Macro "UNDEFINED" doesn't need a trailing semicolon.
(hppa_look_for_stubs_in_section): Introduce temporaries to make code more
readable in 80 columns.
* libhppa.h (all functions): Now inline under GNU C.
* elf32-hppa.c (AR_WARN): Give argument which caused the invalid argument
relocation.
(AR_UNIMP): Delete unused macro.
(hppa_elf_set_section_contents): Always return a value.
(elf32_hppa_backend_table_processing): Likewise.
(elf32_hppa_backend_section_processing: Likewise.
* som.c: New file containing SOM specific code extracted from hppa.c
* som.h: New file containing SOM specific code extracted from libhppa.h
* hppa.c: Deleted.
* libhppa.h: Delete SOM specific code. Add generic PA code which can be shared
by both SOM and ELF backends.
* Makefile.in: Replace hppa.c with som.c. elf32-hppa.o depends on libhppa.h
now.
* configure.in (hppa_vec): Needs som.o module instead of hppa.o.
* elf32-hppa.c: Include libhppa.h. Do not define BYTES_IN_WORD.
* elf32-hppa.h (hppa_reloc_field_selector_type): Delete now lives in libhppa.h.
(hppa_reloc_field_selector_type_alt): Likewise.
* elf32-hppa.c (hppa_elf_relocate_unwind_table): Delete unused variables.
(elf_hppa_reloc_type_lookup): Likewise.
(elf_hppa_tc_make_sections): Likewise.
(hppa_elf_arg_reloc_needed_p): Likewise.
(hppa_elf_build_long_branch_stub): Likewise.
(elf_reloc_map): Delete, no longer used.
(elf_hppa_reloc_map): Likewise.
(elf32_hppa_symextn_map_max_size): Likewise.
(elf32_hppa_get_sym_extn): Abort if type is bogus.
* elf32-hppa.c (elf32_hppa_backend_fake_sections): Add processing
of the .hppa_unwind section.