1999-05-03 15:29:11 +08:00
|
|
|
|
/* POWER/PowerPC XCOFF linker support.
|
2006-03-16 20:20:16 +08:00
|
|
|
|
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
2008-02-15 11:35:53 +08:00
|
|
|
|
2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
|
|
|
|
|
|
2002-03-18 20:46:27 +08:00
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-03-18 20:46:27 +08:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-03 22:26:43 +08:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-03-18 20:46:27 +08:00
|
|
|
|
(at your option) any later version.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-03-18 20:46:27 +08:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-03-18 20:46:27 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
2007-07-03 22:26:43 +08:00
|
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
|
MA 02110-1301, USA. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
#include "sysdep.h"
|
2007-04-26 22:47:00 +08:00
|
|
|
|
#include "bfd.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#include "bfdlink.h"
|
|
|
|
|
#include "libbfd.h"
|
|
|
|
|
#include "coff/internal.h"
|
2001-05-25 04:50:50 +08:00
|
|
|
|
#include "coff/xcoff.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#include "libcoff.h"
|
2001-05-25 04:50:50 +08:00
|
|
|
|
#include "libxcoff.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* This file holds the XCOFF linker code. */
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
#undef STRING_SIZE_SIZE
|
|
|
|
|
#define STRING_SIZE_SIZE 4
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* We reuse the SEC_ROM flag as a mark flag for garbage collection.
|
|
|
|
|
This flag will only be used on input sections. */
|
|
|
|
|
|
|
|
|
|
#define SEC_MARK (SEC_ROM)
|
|
|
|
|
|
|
|
|
|
/* The list of import files. */
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
struct xcoff_import_file
|
|
|
|
|
{
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* The next entry in the list. */
|
|
|
|
|
struct xcoff_import_file *next;
|
|
|
|
|
/* The path. */
|
|
|
|
|
const char *path;
|
|
|
|
|
/* The file name. */
|
|
|
|
|
const char *file;
|
|
|
|
|
/* The member name. */
|
|
|
|
|
const char *member;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Information we keep for each section in the output file during the
|
|
|
|
|
final link phase. */
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
struct xcoff_link_section_info
|
|
|
|
|
{
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* The relocs to be output. */
|
|
|
|
|
struct internal_reloc *relocs;
|
|
|
|
|
/* For each reloc against a global symbol whose index was not known
|
|
|
|
|
when the reloc was handled, the global hash table entry. */
|
|
|
|
|
struct xcoff_link_hash_entry **rel_hashes;
|
|
|
|
|
/* If there is a TOC relative reloc against a global symbol, and the
|
|
|
|
|
index of the TOC symbol is not known when the reloc was handled,
|
|
|
|
|
an entry is added to this linked list. This is not an array,
|
|
|
|
|
like rel_hashes, because this case is quite uncommon. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct xcoff_toc_rel_hash
|
|
|
|
|
{
|
2000-11-30 16:04:42 +08:00
|
|
|
|
struct xcoff_toc_rel_hash *next;
|
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
struct internal_reloc *rel;
|
|
|
|
|
} *toc_rel_hashes;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Information that we pass around while doing the final link step. */
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
struct xcoff_final_link_info
|
|
|
|
|
{
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* General link information. */
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
/* Output BFD. */
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
/* Hash table for long symbol names. */
|
|
|
|
|
struct bfd_strtab_hash *strtab;
|
|
|
|
|
/* Array of information kept for each output section, indexed by the
|
|
|
|
|
target_index field. */
|
|
|
|
|
struct xcoff_link_section_info *section_info;
|
|
|
|
|
/* Symbol index of last C_FILE symbol (-1 if none). */
|
|
|
|
|
long last_file_index;
|
|
|
|
|
/* Contents of last C_FILE symbol. */
|
|
|
|
|
struct internal_syment last_file;
|
|
|
|
|
/* Symbol index of TOC symbol. */
|
|
|
|
|
long toc_symindx;
|
|
|
|
|
/* Start of .loader symbols. */
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_byte *ldsym;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* Next .loader reloc to swap out. */
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_byte *ldrel;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* File position of start of line numbers. */
|
|
|
|
|
file_ptr line_filepos;
|
|
|
|
|
/* Buffer large enough to hold swapped symbols of any input file. */
|
|
|
|
|
struct internal_syment *internal_syms;
|
|
|
|
|
/* Buffer large enough to hold output indices of symbols of any
|
|
|
|
|
input file. */
|
|
|
|
|
long *sym_indices;
|
|
|
|
|
/* Buffer large enough to hold output symbols for any input file. */
|
|
|
|
|
bfd_byte *outsyms;
|
|
|
|
|
/* Buffer large enough to hold external line numbers for any input
|
|
|
|
|
section. */
|
|
|
|
|
bfd_byte *linenos;
|
|
|
|
|
/* Buffer large enough to hold any input section. */
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
/* Buffer large enough to hold external relocs of any input section. */
|
|
|
|
|
bfd_byte *external_relocs;
|
|
|
|
|
};
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
static bfd_boolean xcoff_mark (struct bfd_link_info *, asection *);
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines to read XCOFF dynamic information. This don't really
|
|
|
|
|
belong here, but we already have the ldsym manipulation routines
|
|
|
|
|
here. */
|
|
|
|
|
|
|
|
|
|
/* Read the contents of a section. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_get_section_contents (bfd *abfd, asection *sec)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
if (coff_section_data (abfd, sec) == NULL)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_size_type amt = sizeof (struct coff_section_tdata);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
sec->used_by_bfd = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (sec->used_by_bfd == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (coff_section_data (abfd, sec)->contents == NULL)
|
|
|
|
|
{
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
bfd_byte *contents;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
if (! bfd_malloc_and_get_section (abfd, sec, &contents))
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
{
|
|
|
|
|
if (contents != NULL)
|
|
|
|
|
free (contents);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
coff_section_data (abfd, sec)->contents = contents;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the size required to hold the dynamic symbols. */
|
|
|
|
|
|
|
|
|
|
long
|
2005-04-11 16:23:05 +08:00
|
|
|
|
_bfd_xcoff_get_dynamic_symtab_upper_bound (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
struct internal_ldhdr ldhdr;
|
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) == 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lsec = bfd_get_section_by_name (abfd, ".loader");
|
|
|
|
|
if (lsec == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_no_symbols);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! xcoff_get_section_contents (abfd, lsec))
|
|
|
|
|
return -1;
|
|
|
|
|
contents = coff_section_data (abfd, lsec)->contents;
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_swap_ldhdr_in (abfd, (void *) contents, &ldhdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
return (ldhdr.l_nsyms + 1) * sizeof (asymbol *);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the dynamic symbols. */
|
|
|
|
|
|
|
|
|
|
long
|
2005-04-11 16:23:05 +08:00
|
|
|
|
_bfd_xcoff_canonicalize_dynamic_symtab (bfd *abfd, asymbol **psyms)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
struct internal_ldhdr ldhdr;
|
|
|
|
|
const char *strings;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_byte *elsym, *elsymend;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
coff_symbol_type *symbuf;
|
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) == 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lsec = bfd_get_section_by_name (abfd, ".loader");
|
|
|
|
|
if (lsec == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_no_symbols);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! xcoff_get_section_contents (abfd, lsec))
|
|
|
|
|
return -1;
|
|
|
|
|
contents = coff_section_data (abfd, lsec)->contents;
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
coff_section_data (abfd, lsec)->keep_contents = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
strings = (char *) contents + ldhdr.l_stoff;
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
symbuf = bfd_zalloc (abfd, ldhdr.l_nsyms * sizeof (* symbuf));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (symbuf == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
elsym = contents + bfd_xcoff_loader_symbol_offset(abfd, &ldhdr);
|
|
|
|
|
|
|
|
|
|
elsymend = elsym + ldhdr.l_nsyms * bfd_xcoff_ldsymsz(abfd);
|
|
|
|
|
for (; elsym < elsymend; elsym += bfd_xcoff_ldsymsz(abfd), symbuf++, psyms++)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct internal_ldsym ldsym;
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldsym_in (abfd, elsym, &ldsym);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
symbuf->symbol.the_bfd = abfd;
|
|
|
|
|
|
|
|
|
|
if (ldsym._l._l_l._l_zeroes == 0)
|
|
|
|
|
symbuf->symbol.name = strings + ldsym._l._l_l._l_offset;
|
|
|
|
|
else
|
|
|
|
|
{
|
2001-05-25 04:50:50 +08:00
|
|
|
|
char *c;
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
c = bfd_alloc (abfd, (bfd_size_type) SYMNMLEN + 1);
|
2001-05-25 04:50:50 +08:00
|
|
|
|
if (c == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
memcpy (c, ldsym._l._l_name, SYMNMLEN);
|
|
|
|
|
c[SYMNMLEN] = '\0';
|
|
|
|
|
symbuf->symbol.name = c;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ldsym.l_smclas == XMC_XO)
|
|
|
|
|
symbuf->symbol.section = bfd_abs_section_ptr;
|
|
|
|
|
else
|
|
|
|
|
symbuf->symbol.section = coff_section_from_bfd_index (abfd,
|
|
|
|
|
ldsym.l_scnum);
|
|
|
|
|
symbuf->symbol.value = ldsym.l_value - symbuf->symbol.section->vma;
|
|
|
|
|
|
|
|
|
|
symbuf->symbol.flags = BSF_NO_FLAGS;
|
|
|
|
|
if ((ldsym.l_smtype & L_EXPORT) != 0)
|
|
|
|
|
symbuf->symbol.flags |= BSF_GLOBAL;
|
|
|
|
|
|
|
|
|
|
/* FIXME: We have no way to record the other information stored
|
2002-11-30 16:39:46 +08:00
|
|
|
|
with the loader symbol. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
*psyms = (asymbol *) symbuf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*psyms = NULL;
|
|
|
|
|
|
|
|
|
|
return ldhdr.l_nsyms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the size required to hold the dynamic relocs. */
|
|
|
|
|
|
|
|
|
|
long
|
2005-04-11 16:23:05 +08:00
|
|
|
|
_bfd_xcoff_get_dynamic_reloc_upper_bound (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
struct internal_ldhdr ldhdr;
|
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) == 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lsec = bfd_get_section_by_name (abfd, ".loader");
|
|
|
|
|
if (lsec == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_no_symbols);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! xcoff_get_section_contents (abfd, lsec))
|
|
|
|
|
return -1;
|
|
|
|
|
contents = coff_section_data (abfd, lsec)->contents;
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
return (ldhdr.l_nreloc + 1) * sizeof (arelent *);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the dynamic relocs. */
|
|
|
|
|
|
|
|
|
|
long
|
2005-04-11 16:23:05 +08:00
|
|
|
|
_bfd_xcoff_canonicalize_dynamic_reloc (bfd *abfd,
|
|
|
|
|
arelent **prelocs,
|
|
|
|
|
asymbol **syms)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
struct internal_ldhdr ldhdr;
|
|
|
|
|
arelent *relbuf;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_byte *elrel, *elrelend;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) == 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lsec = bfd_get_section_by_name (abfd, ".loader");
|
|
|
|
|
if (lsec == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_no_symbols);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! xcoff_get_section_contents (abfd, lsec))
|
|
|
|
|
return -1;
|
|
|
|
|
contents = coff_section_data (abfd, lsec)->contents;
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
relbuf = bfd_alloc (abfd, ldhdr.l_nreloc * sizeof (arelent));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (relbuf == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
elrel = contents + bfd_xcoff_loader_reloc_offset(abfd, &ldhdr);
|
|
|
|
|
|
|
|
|
|
elrelend = elrel + ldhdr.l_nreloc * bfd_xcoff_ldrelsz(abfd);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
for (; elrel < elrelend; elrel += bfd_xcoff_ldrelsz(abfd), relbuf++,
|
|
|
|
|
prelocs++)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct internal_ldrel ldrel;
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldrel_in (abfd, elrel, &ldrel);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if (ldrel.l_symndx >= 3)
|
|
|
|
|
relbuf->sym_ptr_ptr = syms + (ldrel.l_symndx - 3);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
asection *sec;
|
|
|
|
|
|
|
|
|
|
switch (ldrel.l_symndx)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
name = ".text";
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
name = ".data";
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
name = ".bss";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sec = bfd_get_section_by_name (abfd, name);
|
|
|
|
|
if (sec == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
relbuf->sym_ptr_ptr = sec->symbol_ptr_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
relbuf->address = ldrel.l_vaddr;
|
|
|
|
|
relbuf->addend = 0;
|
|
|
|
|
|
|
|
|
|
/* Most dynamic relocs have the same type. FIXME: This is only
|
2002-11-30 16:39:46 +08:00
|
|
|
|
correct if ldrel.l_rtype == 0. In other cases, we should use
|
|
|
|
|
a different howto. */
|
2001-05-25 04:50:50 +08:00
|
|
|
|
relbuf->howto = bfd_xcoff_dynamic_reloc_howto(abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* FIXME: We have no way to record the l_rsecnm field. */
|
|
|
|
|
|
|
|
|
|
*prelocs = relbuf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*prelocs = NULL;
|
|
|
|
|
|
|
|
|
|
return ldhdr.l_nreloc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Routine to create an entry in an XCOFF link hash table. */
|
|
|
|
|
|
|
|
|
|
static struct bfd_hash_entry *
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_link_hash_newfunc (struct bfd_hash_entry *entry,
|
|
|
|
|
struct bfd_hash_table *table,
|
|
|
|
|
const char *string)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *ret = (struct xcoff_link_hash_entry *) entry;
|
|
|
|
|
|
|
|
|
|
/* Allocate the structure if it has not already been allocated by a
|
|
|
|
|
subclass. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (ret == NULL)
|
|
|
|
|
ret = bfd_hash_allocate (table, sizeof (* ret));
|
|
|
|
|
if (ret == NULL)
|
|
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Call the allocation method of the superclass. */
|
|
|
|
|
ret = ((struct xcoff_link_hash_entry *)
|
|
|
|
|
_bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
|
|
|
|
|
table, string));
|
|
|
|
|
if (ret != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Set local fields. */
|
|
|
|
|
ret->indx = -1;
|
|
|
|
|
ret->toc_section = NULL;
|
|
|
|
|
ret->u.toc_indx = -1;
|
|
|
|
|
ret->descriptor = NULL;
|
|
|
|
|
ret->ldsym = NULL;
|
|
|
|
|
ret->ldindx = -1;
|
|
|
|
|
ret->flags = 0;
|
|
|
|
|
ret->smclas = XMC_UA;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (struct bfd_hash_entry *) ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a XCOFF link hash table. */
|
|
|
|
|
|
|
|
|
|
struct bfd_link_hash_table *
|
2005-04-11 16:23:05 +08:00
|
|
|
|
_bfd_xcoff_bfd_link_hash_table_create (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_table *ret;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_size_type amt = sizeof (* ret);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ret = bfd_malloc (amt);
|
|
|
|
|
if (ret == NULL)
|
|
|
|
|
return NULL;
|
2006-03-16 20:20:16 +08:00
|
|
|
|
if (!_bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc,
|
|
|
|
|
sizeof (struct xcoff_link_hash_entry)))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2002-04-05 03:53:38 +08:00
|
|
|
|
free (ret);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret->debug_strtab = _bfd_xcoff_stringtab_init ();
|
|
|
|
|
ret->debug_section = NULL;
|
|
|
|
|
ret->loader_section = NULL;
|
|
|
|
|
ret->ldrel_count = 0;
|
|
|
|
|
memset (&ret->ldhdr, 0, sizeof (struct internal_ldhdr));
|
|
|
|
|
ret->linkage_section = NULL;
|
|
|
|
|
ret->toc_section = NULL;
|
|
|
|
|
ret->descriptor_section = NULL;
|
|
|
|
|
ret->imports = NULL;
|
|
|
|
|
ret->file_align = 0;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
ret->textro = FALSE;
|
|
|
|
|
ret->gc = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
memset (ret->special_sections, 0, sizeof ret->special_sections);
|
|
|
|
|
|
|
|
|
|
/* The linker will always generate a full a.out header. We need to
|
|
|
|
|
record that fact now, before the sizeof_headers routine could be
|
|
|
|
|
called. */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
xcoff_data (abfd)->full_aouthdr = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
return &ret->root;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-05 03:53:38 +08:00
|
|
|
|
/* Free a XCOFF link hash table. */
|
|
|
|
|
|
|
|
|
|
void
|
2005-04-11 16:23:05 +08:00
|
|
|
|
_bfd_xcoff_bfd_link_hash_table_free (struct bfd_link_hash_table *hash)
|
2002-04-05 03:53:38 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_table *ret = (struct xcoff_link_hash_table *) hash;
|
|
|
|
|
|
|
|
|
|
_bfd_stringtab_free (ret->debug_strtab);
|
|
|
|
|
bfd_hash_table_free (&ret->root.table);
|
|
|
|
|
free (ret);
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Read internal relocs for an XCOFF csect. This is a wrapper around
|
|
|
|
|
_bfd_coff_read_internal_relocs which tries to take advantage of any
|
|
|
|
|
relocs which may have been cached for the enclosing section. */
|
|
|
|
|
|
|
|
|
|
static struct internal_reloc *
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_read_internal_relocs (bfd *abfd,
|
|
|
|
|
asection *sec,
|
|
|
|
|
bfd_boolean cache,
|
|
|
|
|
bfd_byte *external_relocs,
|
|
|
|
|
bfd_boolean require_internal,
|
|
|
|
|
struct internal_reloc *internal_relocs)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
if (coff_section_data (abfd, sec) != NULL
|
|
|
|
|
&& coff_section_data (abfd, sec)->relocs == NULL
|
|
|
|
|
&& xcoff_section_data (abfd, sec) != NULL)
|
|
|
|
|
{
|
|
|
|
|
asection *enclosing;
|
|
|
|
|
|
|
|
|
|
enclosing = xcoff_section_data (abfd, sec)->enclosing;
|
|
|
|
|
|
|
|
|
|
if (enclosing != NULL
|
|
|
|
|
&& (coff_section_data (abfd, enclosing) == NULL
|
|
|
|
|
|| coff_section_data (abfd, enclosing)->relocs == NULL)
|
|
|
|
|
&& cache
|
|
|
|
|
&& enclosing->reloc_count > 0)
|
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
if (_bfd_coff_read_internal_relocs (abfd, enclosing, TRUE,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
external_relocs, FALSE, NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
== NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enclosing != NULL
|
|
|
|
|
&& coff_section_data (abfd, enclosing) != NULL
|
|
|
|
|
&& coff_section_data (abfd, enclosing)->relocs != NULL)
|
|
|
|
|
{
|
|
|
|
|
size_t off;
|
|
|
|
|
|
|
|
|
|
off = ((sec->rel_filepos - enclosing->rel_filepos)
|
|
|
|
|
/ bfd_coff_relsz (abfd));
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (! require_internal)
|
|
|
|
|
return coff_section_data (abfd, enclosing)->relocs + off;
|
|
|
|
|
memcpy (internal_relocs,
|
|
|
|
|
coff_section_data (abfd, enclosing)->relocs + off,
|
|
|
|
|
sec->reloc_count * sizeof (struct internal_reloc));
|
|
|
|
|
return internal_relocs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
|
|
|
|
|
require_internal, internal_relocs);
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This function is used to add symbols from a dynamic object to the
|
|
|
|
|
global symbol table. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_byte *contents;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
struct internal_ldhdr ldhdr;
|
|
|
|
|
const char *strings;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_byte *elsym, *elsymend;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct xcoff_import_file *n;
|
|
|
|
|
const char *bname;
|
|
|
|
|
const char *mname;
|
|
|
|
|
const char *s;
|
|
|
|
|
unsigned int c;
|
|
|
|
|
struct xcoff_import_file **pp;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We can only handle a dynamic object if we are generating an XCOFF
|
|
|
|
|
output file. */
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (info->output_bfd->xvec != abfd->xvec)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: XCOFF shared object when not producing XCOFF output"),
|
|
|
|
|
bfd_get_filename (abfd));
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* The symbols we use from a dynamic object are not the symbols in
|
|
|
|
|
the normal symbol table, but, rather, the symbols in the export
|
|
|
|
|
table. If there is a global symbol in a dynamic object which is
|
|
|
|
|
not in the export table, the loader will not be able to find it,
|
|
|
|
|
so we don't want to find it either. Also, on AIX 4.1.3, shr.o in
|
|
|
|
|
libc.a has symbols in the export table which are not in the
|
|
|
|
|
symbol table. */
|
|
|
|
|
|
|
|
|
|
/* Read in the .loader section. FIXME: We should really use the
|
|
|
|
|
o_snloader field in the a.out header, rather than grabbing the
|
|
|
|
|
section by name. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
lsec = bfd_get_section_by_name (abfd, ".loader");
|
|
|
|
|
if (lsec == NULL)
|
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: dynamic object with no .loader section"),
|
|
|
|
|
bfd_get_filename (abfd));
|
|
|
|
|
bfd_set_error (bfd_error_no_symbols);
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! xcoff_get_section_contents (abfd, lsec))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
contents = coff_section_data (abfd, lsec)->contents;
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Remove the sections from this object, so that they do not get
|
|
|
|
|
included in the link. */
|
|
|
|
|
bfd_section_list_clear (abfd);
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
strings = (char *) contents + ldhdr.l_stoff;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
elsym = contents + bfd_xcoff_loader_symbol_offset(abfd, &ldhdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
elsymend = elsym + ldhdr.l_nsyms * bfd_xcoff_ldsymsz(abfd);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
for (; elsym < elsymend; elsym += bfd_xcoff_ldsymsz(abfd))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct internal_ldsym ldsym;
|
|
|
|
|
char nambuf[SYMNMLEN + 1];
|
|
|
|
|
const char *name;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct xcoff_link_hash_entry *h;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldsym_in (abfd, elsym, &ldsym);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* We are only interested in exported symbols. */
|
|
|
|
|
if ((ldsym.l_smtype & L_EXPORT) == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (ldsym._l._l_l._l_zeroes == 0)
|
|
|
|
|
name = strings + ldsym._l._l_l._l_offset;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
memcpy (nambuf, ldsym._l._l_name, SYMNMLEN);
|
|
|
|
|
nambuf[SYMNMLEN] = '\0';
|
|
|
|
|
name = nambuf;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Normally we could not call xcoff_link_hash_lookup in an add
|
|
|
|
|
symbols routine, since we might not be using an XCOFF hash
|
|
|
|
|
table. However, we verified above that we are using an XCOFF
|
2002-11-30 16:39:46 +08:00
|
|
|
|
hash table. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, TRUE,
|
|
|
|
|
TRUE, TRUE);
|
|
|
|
|
if (h == NULL)
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h->flags |= XCOFF_DEF_DYNAMIC;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If the symbol is undefined, and the BFD it was found in is
|
|
|
|
|
not a dynamic object, change the BFD to this dynamic object,
|
|
|
|
|
so that we can get the correct import file ID. */
|
|
|
|
|
if ((h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak)
|
|
|
|
|
&& (h->root.u.undef.abfd == NULL
|
|
|
|
|
|| (h->root.u.undef.abfd->flags & DYNAMIC) == 0))
|
|
|
|
|
h->root.u.undef.abfd = abfd;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_new)
|
|
|
|
|
{
|
|
|
|
|
h->root.type = bfd_link_hash_undefined;
|
|
|
|
|
h->root.u.undef.abfd = abfd;
|
|
|
|
|
/* We do not want to add this to the undefined symbol list. */
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->smclas == XMC_UA
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak)
|
|
|
|
|
h->smclas = ldsym.l_smclas;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Unless this is an XMC_XO symbol, we don't bother to actually
|
|
|
|
|
define it, since we don't have a section to put it in anyhow.
|
|
|
|
|
Instead, the relocation routines handle the DEF_DYNAMIC flag
|
|
|
|
|
correctly. */
|
|
|
|
|
|
|
|
|
|
if (h->smclas == XMC_XO
|
|
|
|
|
&& (h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak))
|
|
|
|
|
{
|
|
|
|
|
/* This symbol has an absolute value. */
|
|
|
|
|
h->root.type = bfd_link_hash_defined;
|
|
|
|
|
h->root.u.def.section = bfd_abs_section_ptr;
|
|
|
|
|
h->root.u.def.value = ldsym.l_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this symbol defines a function descriptor, then it
|
|
|
|
|
implicitly defines the function code as well. */
|
|
|
|
|
if (h->smclas == XMC_DS
|
|
|
|
|
|| (h->smclas == XMC_XO && name[0] != '.'))
|
|
|
|
|
h->flags |= XCOFF_DESCRIPTOR;
|
|
|
|
|
if ((h->flags & XCOFF_DESCRIPTOR) != 0)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *hds;
|
|
|
|
|
|
|
|
|
|
hds = h->descriptor;
|
|
|
|
|
if (hds == NULL)
|
|
|
|
|
{
|
|
|
|
|
char *dsnm;
|
|
|
|
|
|
|
|
|
|
dsnm = bfd_malloc ((bfd_size_type) strlen (name) + 2);
|
|
|
|
|
if (dsnm == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
dsnm[0] = '.';
|
|
|
|
|
strcpy (dsnm + 1, name);
|
|
|
|
|
hds = xcoff_link_hash_lookup (xcoff_hash_table (info), dsnm,
|
|
|
|
|
TRUE, TRUE, TRUE);
|
|
|
|
|
free (dsnm);
|
|
|
|
|
if (hds == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (hds->root.type == bfd_link_hash_new)
|
|
|
|
|
{
|
|
|
|
|
hds->root.type = bfd_link_hash_undefined;
|
|
|
|
|
hds->root.u.undef.abfd = abfd;
|
|
|
|
|
/* We do not want to add this to the undefined
|
|
|
|
|
symbol list. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hds->descriptor = h;
|
|
|
|
|
h->descriptor = hds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hds->flags |= XCOFF_DEF_DYNAMIC;
|
|
|
|
|
if (hds->smclas == XMC_UA)
|
|
|
|
|
hds->smclas = XMC_PR;
|
|
|
|
|
|
|
|
|
|
/* An absolute symbol appears to actually define code, not a
|
|
|
|
|
function descriptor. This is how some math functions are
|
|
|
|
|
implemented on AIX 4.1. */
|
|
|
|
|
if (h->smclas == XMC_XO
|
|
|
|
|
&& (hds->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| hds->root.type == bfd_link_hash_undefweak))
|
|
|
|
|
{
|
|
|
|
|
hds->smclas = XMC_XO;
|
|
|
|
|
hds->root.type = bfd_link_hash_defined;
|
|
|
|
|
hds->root.u.def.section = bfd_abs_section_ptr;
|
|
|
|
|
hds->root.u.def.value = ldsym.l_value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (contents != NULL && ! coff_section_data (abfd, lsec)->keep_contents)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
free (coff_section_data (abfd, lsec)->contents);
|
|
|
|
|
coff_section_data (abfd, lsec)->contents = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Record this file in the import files. */
|
|
|
|
|
n = bfd_alloc (abfd, (bfd_size_type) sizeof (struct xcoff_import_file));
|
|
|
|
|
if (n == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
n->next = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* For some reason, the path entry in the import file list for a
|
|
|
|
|
shared object appears to always be empty. The file name is the
|
|
|
|
|
base name. */
|
|
|
|
|
n->path = "";
|
|
|
|
|
if (abfd->my_archive == NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bname = bfd_get_filename (abfd);
|
|
|
|
|
mname = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bname = bfd_get_filename (abfd->my_archive);
|
|
|
|
|
mname = bfd_get_filename (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
s = strrchr (bname, '/');
|
|
|
|
|
if (s != NULL)
|
|
|
|
|
bname = s + 1;
|
|
|
|
|
n->file = bname;
|
|
|
|
|
n->member = mname;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We start c at 1 because the first import file number is reserved
|
|
|
|
|
for LIBPATH. */
|
|
|
|
|
for (pp = &xcoff_hash_table (info)->imports, c = 1;
|
|
|
|
|
*pp != NULL;
|
|
|
|
|
pp = &(*pp)->next, ++c)
|
|
|
|
|
;
|
|
|
|
|
*pp = n;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_data (abfd)->import_file_id = c;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
/* xcoff_link_create_extra_sections
|
|
|
|
|
|
|
|
|
|
Takes care of creating the .loader, .gl, .ds, .debug and sections. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean return_value = FALSE;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (info->output_bfd->xvec == abfd->xvec)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2001-05-25 04:50:50 +08:00
|
|
|
|
/* We need to build a .loader section, so we do it here. This
|
|
|
|
|
won't work if we're producing an XCOFF output file with no
|
|
|
|
|
XCOFF input files. FIXME. */
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (xcoff_hash_table (info)->loader_section == NULL)
|
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
2006-06-01 11:45:58 +08:00
|
|
|
|
flagword flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2006-06-01 11:45:58 +08:00
|
|
|
|
lsec = bfd_make_section_anyway_with_flags (abfd, ".loader", flags);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (lsec == NULL)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
goto end_return;
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
xcoff_hash_table (info)->loader_section = lsec;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Likewise for the linkage section. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (xcoff_hash_table (info)->linkage_section == NULL)
|
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
2006-06-01 11:45:58 +08:00
|
|
|
|
flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
|
|
|
|
|
| SEC_IN_MEMORY);
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2006-06-01 11:45:58 +08:00
|
|
|
|
lsec = bfd_make_section_anyway_with_flags (abfd, ".gl", flags);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (lsec == NULL)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
goto end_return;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
xcoff_hash_table (info)->linkage_section = lsec;
|
|
|
|
|
lsec->alignment_power = 2;
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
|
|
|
|
/* Likewise for the TOC section. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (xcoff_hash_table (info)->toc_section == NULL)
|
|
|
|
|
{
|
|
|
|
|
asection *tsec;
|
2006-06-01 11:45:58 +08:00
|
|
|
|
flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
|
|
|
|
|
| SEC_IN_MEMORY);
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2006-06-01 11:45:58 +08:00
|
|
|
|
tsec = bfd_make_section_anyway_with_flags (abfd, ".tc", flags);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (tsec == NULL)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
goto end_return;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
xcoff_hash_table (info)->toc_section = tsec;
|
|
|
|
|
tsec->alignment_power = 2;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
/* Likewise for the descriptor section. */
|
|
|
|
|
if (xcoff_hash_table (info)->descriptor_section == NULL)
|
|
|
|
|
{
|
|
|
|
|
asection *dsec;
|
2006-06-01 11:45:58 +08:00
|
|
|
|
flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
|
|
|
|
|
| SEC_IN_MEMORY);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2006-06-01 11:45:58 +08:00
|
|
|
|
dsec = bfd_make_section_anyway_with_flags (abfd, ".ds", flags);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (dsec == NULL)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
goto end_return;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
|
|
|
|
xcoff_hash_table (info)->descriptor_section = dsec;
|
|
|
|
|
dsec->alignment_power = 2;
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
|
|
|
|
/* Likewise for the .debug section. */
|
|
|
|
|
if (xcoff_hash_table (info)->debug_section == NULL
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
&& info->strip != strip_all)
|
|
|
|
|
{
|
|
|
|
|
asection *dsec;
|
2006-06-01 11:45:58 +08:00
|
|
|
|
flagword flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2006-06-01 11:45:58 +08:00
|
|
|
|
dsec = bfd_make_section_anyway_with_flags (abfd, ".debug", flags);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (dsec == NULL)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
goto end_return;
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
xcoff_hash_table (info)->debug_section = dsec;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return_value = TRUE;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
|
|
|
|
end_return:
|
|
|
|
|
|
|
|
|
|
return return_value;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Returns the index of reloc in RELOCS with the least address greater
|
|
|
|
|
than or equal to ADDRESS. The relocs are sorted by address. */
|
|
|
|
|
|
|
|
|
|
static bfd_size_type
|
|
|
|
|
xcoff_find_reloc (struct internal_reloc *relocs,
|
|
|
|
|
bfd_size_type count,
|
|
|
|
|
bfd_vma address)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type min, max, this;
|
|
|
|
|
|
|
|
|
|
if (count < 2)
|
|
|
|
|
{
|
|
|
|
|
if (count == 1 && relocs[0].r_vaddr < address)
|
|
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
min = 0;
|
|
|
|
|
max = count;
|
|
|
|
|
|
|
|
|
|
/* Do a binary search over (min,max]. */
|
|
|
|
|
while (min + 1 < max)
|
|
|
|
|
{
|
|
|
|
|
bfd_vma raddr;
|
|
|
|
|
|
|
|
|
|
this = (max + min) / 2;
|
|
|
|
|
raddr = relocs[this].r_vaddr;
|
|
|
|
|
if (raddr > address)
|
|
|
|
|
max = this;
|
|
|
|
|
else if (raddr < address)
|
|
|
|
|
min = this;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
min = this;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (relocs[min].r_vaddr < address)
|
|
|
|
|
return min + 1;
|
|
|
|
|
|
|
|
|
|
while (min > 0
|
|
|
|
|
&& relocs[min - 1].r_vaddr == address)
|
|
|
|
|
--min;
|
|
|
|
|
|
|
|
|
|
return min;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* Add all the symbols from an object file to the hash table.
|
|
|
|
|
|
|
|
|
|
XCOFF is a weird format. A normal XCOFF .o files will have three
|
|
|
|
|
COFF sections--.text, .data, and .bss--but each COFF section will
|
|
|
|
|
contain many csects. These csects are described in the symbol
|
|
|
|
|
table. From the linker's point of view, each csect must be
|
|
|
|
|
considered a section in its own right. For example, a TOC entry is
|
|
|
|
|
handled as a small XMC_TC csect. The linker must be able to merge
|
|
|
|
|
different TOC entries together, which means that it must be able to
|
|
|
|
|
extract the XMC_TC csects from the .data section of the input .o
|
|
|
|
|
file.
|
|
|
|
|
|
|
|
|
|
From the point of view of our linker, this is, of course, a hideous
|
|
|
|
|
nightmare. We cope by actually creating sections for each csect,
|
|
|
|
|
and discarding the original sections. We then have to handle the
|
|
|
|
|
relocation entries carefully, since the only way to tell which
|
|
|
|
|
csect they belong to is to examine the address. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
unsigned int n_tmask;
|
|
|
|
|
unsigned int n_btshft;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean default_copy;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
bfd_size_type symcount;
|
|
|
|
|
struct xcoff_link_hash_entry **sym_hash;
|
|
|
|
|
asection **csect_cache;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
unsigned int *lineno_counts;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
bfd_size_type linesz;
|
|
|
|
|
asection *o;
|
|
|
|
|
asection *last_real;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean keep_syms;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
asection *csect;
|
|
|
|
|
unsigned int csect_index;
|
|
|
|
|
asection *first_csect;
|
|
|
|
|
bfd_size_type symesz;
|
|
|
|
|
bfd_byte *esym;
|
|
|
|
|
bfd_byte *esym_end;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
struct reloc_info_struct
|
2001-05-25 04:50:50 +08:00
|
|
|
|
{
|
|
|
|
|
struct internal_reloc *relocs;
|
|
|
|
|
asection **csects;
|
|
|
|
|
bfd_byte *linenos;
|
|
|
|
|
} *reloc_info = NULL;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_size_type amt;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
keep_syms = obj_coff_keep_syms (abfd);
|
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) != 0
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
&& ! info->static_link)
|
|
|
|
|
{
|
|
|
|
|
if (! xcoff_link_add_dynamic_symbols (abfd, info))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Create the loader, toc, gl, ds and debug sections, if needed. */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
if (! xcoff_link_create_extra_sections (abfd, info))
|
2002-02-19 13:01:40 +08:00
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) != 0
|
|
|
|
|
&& ! info->static_link)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
n_tmask = coff_data (abfd)->local_n_tmask;
|
|
|
|
|
n_btshft = coff_data (abfd)->local_n_btshft;
|
|
|
|
|
|
|
|
|
|
/* Define macros so that ISFCN, et. al., macros work correctly. */
|
|
|
|
|
#define N_TMASK n_tmask
|
|
|
|
|
#define N_BTSHFT n_btshft
|
|
|
|
|
|
|
|
|
|
if (info->keep_memory)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
default_copy = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
else
|
2002-11-30 16:39:46 +08:00
|
|
|
|
default_copy = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
symcount = obj_raw_syment_count (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* We keep a list of the linker hash table entries that correspond
|
|
|
|
|
to each external symbol. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = symcount * sizeof (struct xcoff_link_hash_entry *);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
sym_hash = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (sym_hash == NULL && symcount != 0)
|
|
|
|
|
goto error_return;
|
|
|
|
|
coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
|
|
|
|
|
|
|
|
|
|
/* Because of the weird stuff we are doing with XCOFF csects, we can
|
|
|
|
|
not easily determine which section a symbol is in, so we store
|
|
|
|
|
the information in the tdata for the input file. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = symcount * sizeof (asection *);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
csect_cache = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (csect_cache == NULL && symcount != 0)
|
|
|
|
|
goto error_return;
|
|
|
|
|
xcoff_data (abfd)->csects = csect_cache;
|
|
|
|
|
|
2009-03-14 17:32:33 +08:00
|
|
|
|
/* We garbage-collect line-number information on a symbol-by-symbol
|
|
|
|
|
basis, so we need to have quick access to the number of entries
|
|
|
|
|
per symbol. */
|
|
|
|
|
amt = symcount * sizeof (unsigned int);
|
|
|
|
|
lineno_counts = bfd_zalloc (abfd, amt);
|
|
|
|
|
if (lineno_counts == NULL && symcount != 0)
|
|
|
|
|
goto error_return;
|
|
|
|
|
xcoff_data (abfd)->lineno_counts = lineno_counts;
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* While splitting sections into csects, we need to assign the
|
|
|
|
|
relocs correctly. The relocs and the csects must both be in
|
|
|
|
|
order by VMA within a given section, so we handle this by
|
|
|
|
|
scanning along the relocs as we process the csects. We index
|
|
|
|
|
into reloc_info using the section target_index. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = abfd->section_count + 1;
|
|
|
|
|
amt *= sizeof (struct reloc_info_struct);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
reloc_info = bfd_zmalloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (reloc_info == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* Read in the relocs and line numbers for each section. */
|
|
|
|
|
linesz = bfd_coff_linesz (abfd);
|
|
|
|
|
last_real = NULL;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
last_real = o;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if ((o->flags & SEC_RELOC) != 0)
|
|
|
|
|
{
|
|
|
|
|
reloc_info[o->target_index].relocs =
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_read_internal_relocs (abfd, o, TRUE, NULL, FALSE, NULL);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = o->reloc_count;
|
|
|
|
|
amt *= sizeof (asection *);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
reloc_info[o->target_index].csects = bfd_zmalloc (amt);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (reloc_info[o->target_index].csects == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if ((info->strip == strip_none || info->strip == strip_some)
|
|
|
|
|
&& o->lineno_count > 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_byte *linenos;
|
|
|
|
|
|
|
|
|
|
amt = linesz * o->lineno_count;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
linenos = bfd_malloc (amt);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (linenos == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
reloc_info[o->target_index].linenos = linenos;
|
|
|
|
|
if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bread (linenos, amt, abfd) != amt)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* Don't let the linker relocation routines discard the symbols. */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
obj_coff_keep_syms (abfd) = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
csect = NULL;
|
|
|
|
|
csect_index = 0;
|
|
|
|
|
first_csect = NULL;
|
|
|
|
|
|
|
|
|
|
symesz = bfd_coff_symesz (abfd);
|
|
|
|
|
BFD_ASSERT (symesz == bfd_coff_auxesz (abfd));
|
|
|
|
|
esym = (bfd_byte *) obj_coff_external_syms (abfd);
|
|
|
|
|
esym_end = esym + symcount * symesz;
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
while (esym < esym_end)
|
|
|
|
|
{
|
|
|
|
|
struct internal_syment sym;
|
|
|
|
|
union internal_auxent aux;
|
|
|
|
|
const char *name;
|
|
|
|
|
char buf[SYMNMLEN + 1];
|
|
|
|
|
int smtyp;
|
|
|
|
|
flagword flags;
|
|
|
|
|
asection *section;
|
|
|
|
|
bfd_vma value;
|
|
|
|
|
struct xcoff_link_hash_entry *set_toc;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_sym_in (abfd, (void *) esym, (void *) &sym);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
|
|
|
|
/* In this pass we are only interested in symbols with csect
|
|
|
|
|
information. */
|
|
|
|
|
if (sym.n_sclass != C_EXT && sym.n_sclass != C_HIDEXT)
|
|
|
|
|
{
|
|
|
|
|
/* Set csect_cache,
|
|
|
|
|
Normally csect is a .pr, .rw etc. created in the loop
|
|
|
|
|
If C_FILE or first time, handle special
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:17:56 +08:00
|
|
|
|
Advance esym, sym_hash, csect_hash ptrs. */
|
|
|
|
|
if (sym.n_sclass == C_FILE)
|
|
|
|
|
csect = NULL;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (csect != NULL)
|
|
|
|
|
*csect_cache = csect;
|
|
|
|
|
else if (first_csect == NULL || sym.n_sclass == C_FILE)
|
|
|
|
|
*csect_cache = coff_section_from_bfd_index (abfd, sym.n_scnum);
|
|
|
|
|
else
|
|
|
|
|
*csect_cache = NULL;
|
|
|
|
|
esym += (sym.n_numaux + 1) * symesz;
|
|
|
|
|
sym_hash += sym.n_numaux + 1;
|
|
|
|
|
csect_cache += sym.n_numaux + 1;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
lineno_counts += sym.n_numaux + 1;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* If this symbol has line number information attached to it,
|
2002-11-30 16:39:46 +08:00
|
|
|
|
and we're not stripping it, count the number of entries and
|
|
|
|
|
add them to the count for this csect. In the final link pass
|
|
|
|
|
we are going to attach line number information by symbol,
|
|
|
|
|
rather than by section, in order to more easily handle
|
|
|
|
|
garbage collection. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if ((info->strip == strip_none || info->strip == strip_some)
|
|
|
|
|
&& sym.n_numaux > 1
|
|
|
|
|
&& csect != NULL
|
|
|
|
|
&& ISFCN (sym.n_type))
|
|
|
|
|
{
|
|
|
|
|
union internal_auxent auxlin;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_aux_in (abfd, (void *) (esym + symesz),
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
sym.n_type, sym.n_sclass,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
0, sym.n_numaux, (void *) &auxlin);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
|
|
|
|
if (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0)
|
|
|
|
|
{
|
|
|
|
|
asection *enclosing;
|
|
|
|
|
bfd_signed_vma linoff;
|
|
|
|
|
|
|
|
|
|
enclosing = xcoff_section_data (abfd, csect)->enclosing;
|
|
|
|
|
if (enclosing == NULL)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: `%s' has line numbers but no enclosing section"),
|
|
|
|
|
abfd, name);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
linoff = (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr
|
|
|
|
|
- enclosing->line_filepos);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Explicit cast to bfd_signed_vma for compiler. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (linoff < (bfd_signed_vma) (enclosing->lineno_count * linesz))
|
|
|
|
|
{
|
|
|
|
|
struct internal_lineno lin;
|
|
|
|
|
bfd_byte *linpstart;
|
|
|
|
|
|
|
|
|
|
linpstart = (reloc_info[enclosing->target_index].linenos
|
|
|
|
|
+ linoff);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_lineno_in (abfd, (void *) linpstart, (void *) &lin);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (lin.l_lnno == 0
|
|
|
|
|
&& ((bfd_size_type) lin.l_addr.l_symndx
|
|
|
|
|
== ((esym
|
|
|
|
|
- (bfd_byte *) obj_coff_external_syms (abfd))
|
|
|
|
|
/ symesz)))
|
|
|
|
|
{
|
|
|
|
|
bfd_byte *linpend, *linp;
|
|
|
|
|
|
|
|
|
|
linpend = (reloc_info[enclosing->target_index].linenos
|
|
|
|
|
+ enclosing->lineno_count * linesz);
|
|
|
|
|
for (linp = linpstart + linesz;
|
|
|
|
|
linp < linpend;
|
|
|
|
|
linp += linesz)
|
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_lineno_in (abfd, (void *) linp,
|
|
|
|
|
(void *) &lin);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (lin.l_lnno == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-03-14 17:32:33 +08:00
|
|
|
|
*lineno_counts = (linp - linpstart) / linesz;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
/* The setting of line_filepos will only be
|
|
|
|
|
useful if all the line number entries for a
|
|
|
|
|
csect are contiguous; this only matters for
|
|
|
|
|
error reporting. */
|
|
|
|
|
if (csect->line_filepos == 0)
|
|
|
|
|
csect->line_filepos =
|
|
|
|
|
auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
/* Pick up the csect auxiliary information. */
|
|
|
|
|
if (sym.n_numaux == 0)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: class %d symbol `%s' has no aux entries"),
|
|
|
|
|
abfd, sym.n_sclass, name);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_coff_swap_aux_in (abfd,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(void *) (esym + symesz * sym.n_numaux),
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
sym.n_type, sym.n_sclass,
|
1999-05-03 15:29:11 +08:00
|
|
|
|
sym.n_numaux - 1, sym.n_numaux,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(void *) &aux);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
smtyp = SMTYP_SMTYP (aux.x_csect.x_smtyp);
|
|
|
|
|
|
|
|
|
|
flags = BSF_GLOBAL;
|
|
|
|
|
section = NULL;
|
|
|
|
|
value = 0;
|
|
|
|
|
set_toc = NULL;
|
|
|
|
|
|
|
|
|
|
switch (smtyp)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: symbol `%s' has unrecognized csect type %d"),
|
|
|
|
|
abfd, name, smtyp);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
case XTY_ER:
|
|
|
|
|
/* This is an external reference. */
|
|
|
|
|
if (sym.n_sclass == C_HIDEXT
|
|
|
|
|
|| sym.n_scnum != N_UNDEF
|
|
|
|
|
|| aux.x_csect.x_scnlen.l != 0)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d"),
|
|
|
|
|
abfd, name, sym.n_sclass, sym.n_scnum,
|
1999-05-03 15:29:11 +08:00
|
|
|
|
aux.x_csect.x_scnlen.l);
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* An XMC_XO external reference is actually a reference to
|
2002-11-30 16:39:46 +08:00
|
|
|
|
an absolute location. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (aux.x_csect.x_smclas != XMC_XO)
|
|
|
|
|
section = bfd_und_section_ptr;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
section = bfd_abs_section_ptr;
|
|
|
|
|
value = sym.n_value;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XTY_SD:
|
|
|
|
|
csect = NULL;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
csect_index = -(unsigned) 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* When we see a TOC anchor, we record the TOC value. */
|
|
|
|
|
if (aux.x_csect.x_smclas == XMC_TC0)
|
|
|
|
|
{
|
|
|
|
|
if (sym.n_sclass != C_HIDEXT
|
|
|
|
|
|| aux.x_csect.x_scnlen.l != 0)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: XMC_TC0 symbol `%s' is class %d scnlen %d"),
|
|
|
|
|
abfd, name, sym.n_sclass, aux.x_csect.x_scnlen.l);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
xcoff_data (abfd)->toc = sym.n_value;
|
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
/* We must merge TOC entries for the same symbol. We can
|
|
|
|
|
merge two TOC entries if they are both C_HIDEXT, they
|
|
|
|
|
both have the same name, they are both 4 or 8 bytes long, and
|
|
|
|
|
they both have a relocation table entry for an external
|
|
|
|
|
symbol with the same name. Unfortunately, this means
|
|
|
|
|
that we must look through the relocations. Ick.
|
|
|
|
|
|
|
|
|
|
Logic for 32 bit vs 64 bit.
|
|
|
|
|
32 bit has a csect length of 4 for TOC
|
|
|
|
|
64 bit has a csect length of 8 for TOC
|
|
|
|
|
|
|
|
|
|
The conditions to get past the if-check are not that bad.
|
|
|
|
|
They are what is used to create the TOC csects in the first
|
|
|
|
|
place. */
|
|
|
|
|
if (aux.x_csect.x_smclas == XMC_TC
|
|
|
|
|
&& sym.n_sclass == C_HIDEXT
|
2008-02-15 11:35:53 +08:00
|
|
|
|
&& info->output_bfd->xvec == abfd->xvec
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
&& ((bfd_xcoff_is_xcoff32 (abfd)
|
|
|
|
|
&& aux.x_csect.x_scnlen.l == 4)
|
|
|
|
|
|| (bfd_xcoff_is_xcoff64 (abfd)
|
|
|
|
|
&& aux.x_csect.x_scnlen.l == 8)))
|
|
|
|
|
{
|
|
|
|
|
asection *enclosing;
|
|
|
|
|
struct internal_reloc *relocs;
|
|
|
|
|
bfd_size_type relindx;
|
|
|
|
|
struct internal_reloc *rel;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
|
|
|
|
|
if (enclosing == NULL)
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
relocs = reloc_info[enclosing->target_index].relocs;
|
|
|
|
|
amt = enclosing->reloc_count;
|
|
|
|
|
relindx = xcoff_find_reloc (relocs, amt, sym.n_value);
|
|
|
|
|
rel = relocs + relindx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
/* 32 bit R_POS r_size is 31
|
|
|
|
|
64 bit R_POS r_size is 63 */
|
|
|
|
|
if (relindx < enclosing->reloc_count
|
|
|
|
|
&& rel->r_vaddr == (bfd_vma) sym.n_value
|
|
|
|
|
&& rel->r_type == R_POS
|
|
|
|
|
&& ((bfd_xcoff_is_xcoff32 (abfd)
|
|
|
|
|
&& rel->r_size == 31)
|
|
|
|
|
|| (bfd_xcoff_is_xcoff64 (abfd)
|
|
|
|
|
&& rel->r_size == 63)))
|
|
|
|
|
{
|
|
|
|
|
bfd_byte *erelsym;
|
|
|
|
|
|
|
|
|
|
struct internal_syment relsym;
|
|
|
|
|
|
|
|
|
|
erelsym = ((bfd_byte *) obj_coff_external_syms (abfd)
|
|
|
|
|
+ rel->r_symndx * symesz);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_sym_in (abfd, (void *) erelsym, (void *) &relsym);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (relsym.n_sclass == C_EXT)
|
|
|
|
|
{
|
|
|
|
|
const char *relname;
|
|
|
|
|
char relbuf[SYMNMLEN + 1];
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean copy;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
/* At this point we know that the TOC entry is
|
|
|
|
|
for an externally visible symbol. */
|
|
|
|
|
relname = _bfd_coff_internal_syment_name (abfd, &relsym,
|
|
|
|
|
relbuf);
|
|
|
|
|
if (relname == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* We only merge TOC entries if the TC name is
|
|
|
|
|
the same as the symbol name. This handles
|
|
|
|
|
the normal case, but not common cases like
|
|
|
|
|
SYM.P4 which gcc generates to store SYM + 4
|
|
|
|
|
in the TOC. FIXME. */
|
|
|
|
|
if (strcmp (name, relname) == 0)
|
|
|
|
|
{
|
|
|
|
|
copy = (! info->keep_memory
|
|
|
|
|
|| relsym._n._n_n._n_zeroes != 0
|
|
|
|
|
|| relsym._n._n_n._n_offset == 0);
|
|
|
|
|
h = xcoff_link_hash_lookup (xcoff_hash_table (info),
|
2002-11-30 16:39:46 +08:00
|
|
|
|
relname, TRUE, copy,
|
|
|
|
|
FALSE);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (h == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* At this point h->root.type could be
|
|
|
|
|
bfd_link_hash_new. That should be OK,
|
|
|
|
|
since we know for sure that we will come
|
|
|
|
|
across this symbol as we step through the
|
|
|
|
|
file. */
|
|
|
|
|
|
|
|
|
|
/* We store h in *sym_hash for the
|
|
|
|
|
convenience of the relocate_section
|
|
|
|
|
function. */
|
|
|
|
|
*sym_hash = h;
|
|
|
|
|
|
|
|
|
|
if (h->toc_section != NULL)
|
|
|
|
|
{
|
|
|
|
|
asection **rel_csects;
|
|
|
|
|
|
|
|
|
|
/* We already have a TOC entry for this
|
|
|
|
|
symbol, so we can just ignore this
|
|
|
|
|
one. */
|
|
|
|
|
rel_csects =
|
|
|
|
|
reloc_info[enclosing->target_index].csects;
|
|
|
|
|
rel_csects[relindx] = bfd_und_section_ptr;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We are about to create a TOC entry for
|
|
|
|
|
this symbol. */
|
|
|
|
|
set_toc = h;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
asection *enclosing;
|
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
/* We need to create a new section. We get the name from
|
|
|
|
|
the csect storage mapping class, so that the linker can
|
|
|
|
|
accumulate similar csects together. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
csect = bfd_xcoff_create_csect_from_smclas(abfd, &aux, name);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (NULL == csect)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
goto error_return;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
/* The enclosing section is the main section : .data, .text
|
|
|
|
|
or .bss that the csect is coming from. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
|
|
|
|
|
if (enclosing == NULL)
|
|
|
|
|
goto error_return;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (! bfd_is_abs_section (enclosing)
|
|
|
|
|
&& ((bfd_vma) sym.n_value < enclosing->vma
|
|
|
|
|
|| ((bfd_vma) sym.n_value + aux.x_csect.x_scnlen.l
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
> enclosing->vma + enclosing->size)))
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: csect `%s' not in enclosing section"),
|
|
|
|
|
abfd, name);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
csect->vma = sym.n_value;
|
|
|
|
|
csect->filepos = (enclosing->filepos
|
|
|
|
|
+ sym.n_value
|
|
|
|
|
- enclosing->vma);
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
csect->size = aux.x_csect.x_scnlen.l;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
csect->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
|
|
|
|
csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
|
|
|
|
|
|
|
|
|
|
/* Record the enclosing section in the tdata for this new
|
|
|
|
|
section. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = sizeof (struct coff_section_tdata);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
csect->used_by_bfd = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (csect->used_by_bfd == NULL)
|
|
|
|
|
goto error_return;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = sizeof (struct xcoff_section_tdata);
|
|
|
|
|
coff_section_data (abfd, csect)->tdata = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (coff_section_data (abfd, csect)->tdata == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
xcoff_section_data (abfd, csect)->enclosing = enclosing;
|
|
|
|
|
xcoff_section_data (abfd, csect)->lineno_count =
|
|
|
|
|
enclosing->lineno_count;
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (enclosing->owner == abfd)
|
|
|
|
|
{
|
|
|
|
|
struct internal_reloc *relocs;
|
|
|
|
|
bfd_size_type relindx;
|
|
|
|
|
struct internal_reloc *rel;
|
|
|
|
|
asection **rel_csect;
|
|
|
|
|
|
|
|
|
|
relocs = reloc_info[enclosing->target_index].relocs;
|
|
|
|
|
amt = enclosing->reloc_count;
|
|
|
|
|
relindx = xcoff_find_reloc (relocs, amt, csect->vma);
|
|
|
|
|
|
|
|
|
|
rel = relocs + relindx;
|
|
|
|
|
rel_csect = (reloc_info[enclosing->target_index].csects
|
|
|
|
|
+ relindx);
|
|
|
|
|
|
|
|
|
|
csect->rel_filepos = (enclosing->rel_filepos
|
|
|
|
|
+ relindx * bfd_coff_relsz (abfd));
|
|
|
|
|
while (relindx < enclosing->reloc_count
|
|
|
|
|
&& *rel_csect == NULL
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
&& rel->r_vaddr < csect->vma + csect->size)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
*rel_csect = csect;
|
|
|
|
|
csect->flags |= SEC_RELOC;
|
|
|
|
|
++csect->reloc_count;
|
|
|
|
|
++relindx;
|
|
|
|
|
++rel;
|
|
|
|
|
++rel_csect;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There are a number of other fields and section flags
|
|
|
|
|
which we do not bother to set. */
|
|
|
|
|
|
|
|
|
|
csect_index = ((esym
|
|
|
|
|
- (bfd_byte *) obj_coff_external_syms (abfd))
|
|
|
|
|
/ symesz);
|
|
|
|
|
|
|
|
|
|
xcoff_section_data (abfd, csect)->first_symndx = csect_index;
|
|
|
|
|
|
|
|
|
|
if (first_csect == NULL)
|
|
|
|
|
first_csect = csect;
|
|
|
|
|
|
|
|
|
|
/* If this symbol is C_EXT, we treat it as starting at the
|
|
|
|
|
beginning of the newly created section. */
|
|
|
|
|
if (sym.n_sclass == C_EXT)
|
|
|
|
|
{
|
|
|
|
|
section = csect;
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is a TOC section for a symbol, record it. */
|
|
|
|
|
if (set_toc != NULL)
|
|
|
|
|
set_toc->toc_section = csect;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XTY_LD:
|
|
|
|
|
/* This is a label definition. The x_scnlen field is the
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
symbol index of the csect. Usually the XTY_LD symbol will
|
2001-08-30 20:48:35 +08:00
|
|
|
|
follow its appropriate XTY_SD symbol. The .set pseudo op can
|
|
|
|
|
cause the XTY_LD to not follow the XTY_SD symbol. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean bad;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bad = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (aux.x_csect.x_scnlen.l < 0
|
|
|
|
|
|| (aux.x_csect.x_scnlen.l
|
|
|
|
|
>= esym - (bfd_byte *) obj_coff_external_syms (abfd)))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bad = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (! bad)
|
|
|
|
|
{
|
|
|
|
|
section = xcoff_data (abfd)->csects[aux.x_csect.x_scnlen.l];
|
|
|
|
|
if (section == NULL
|
|
|
|
|
|| (section->flags & SEC_HAS_CONTENTS) == 0)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bad = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
if (bad)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: misplaced XTY_LD `%s'"),
|
|
|
|
|
abfd, name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
2001-08-30 20:48:35 +08:00
|
|
|
|
csect = section;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
value = sym.n_value - csect->vma;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XTY_CM:
|
|
|
|
|
/* This is an unitialized csect. We could base the name on
|
2002-11-30 16:39:46 +08:00
|
|
|
|
the storage mapping class, but we don't bother except for
|
|
|
|
|
an XMC_TD symbol. If this csect is externally visible,
|
|
|
|
|
it is a common symbol. We put XMC_TD symbols in sections
|
|
|
|
|
named .tocbss, and rely on the linker script to put that
|
|
|
|
|
in the TOC area. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if (aux.x_csect.x_smclas == XMC_TD)
|
|
|
|
|
{
|
|
|
|
|
/* The linker script puts the .td section in the data
|
|
|
|
|
section after the .tc section. */
|
2006-06-01 11:45:58 +08:00
|
|
|
|
csect = bfd_make_section_anyway_with_flags (abfd, ".td",
|
|
|
|
|
SEC_ALLOC);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
2006-06-01 11:45:58 +08:00
|
|
|
|
csect = bfd_make_section_anyway_with_flags (abfd, ".bss",
|
|
|
|
|
SEC_ALLOC);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (csect == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
csect->vma = sym.n_value;
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
csect->size = aux.x_csect.x_scnlen.l;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
|
|
|
|
|
/* There are a number of other fields and section flags
|
|
|
|
|
which we do not bother to set. */
|
|
|
|
|
|
|
|
|
|
csect_index = ((esym
|
|
|
|
|
- (bfd_byte *) obj_coff_external_syms (abfd))
|
|
|
|
|
/ symesz);
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = sizeof (struct coff_section_tdata);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
csect->used_by_bfd = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (csect->used_by_bfd == NULL)
|
|
|
|
|
goto error_return;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
amt = sizeof (struct xcoff_section_tdata);
|
|
|
|
|
coff_section_data (abfd, csect)->tdata = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (coff_section_data (abfd, csect)->tdata == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
xcoff_section_data (abfd, csect)->first_symndx = csect_index;
|
|
|
|
|
|
|
|
|
|
if (first_csect == NULL)
|
|
|
|
|
first_csect = csect;
|
|
|
|
|
|
|
|
|
|
if (sym.n_sclass == C_EXT)
|
|
|
|
|
{
|
|
|
|
|
csect->flags |= SEC_IS_COMMON;
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
csect->size = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
section = csect;
|
|
|
|
|
value = aux.x_csect.x_scnlen.l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check for magic symbol names. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
if ((smtyp == XTY_SD || smtyp == XTY_CM)
|
|
|
|
|
&& aux.x_csect.x_smclas != XMC_TC
|
|
|
|
|
&& aux.x_csect.x_smclas != XMC_TD)
|
|
|
|
|
{
|
|
|
|
|
int i = -1;
|
|
|
|
|
|
|
|
|
|
if (name[0] == '_')
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (name, "_text") == 0)
|
|
|
|
|
i = XCOFF_SPECIAL_SECTION_TEXT;
|
|
|
|
|
else if (strcmp (name, "_etext") == 0)
|
|
|
|
|
i = XCOFF_SPECIAL_SECTION_ETEXT;
|
|
|
|
|
else if (strcmp (name, "_data") == 0)
|
|
|
|
|
i = XCOFF_SPECIAL_SECTION_DATA;
|
|
|
|
|
else if (strcmp (name, "_edata") == 0)
|
|
|
|
|
i = XCOFF_SPECIAL_SECTION_EDATA;
|
|
|
|
|
else if (strcmp (name, "_end") == 0)
|
|
|
|
|
i = XCOFF_SPECIAL_SECTION_END;
|
|
|
|
|
}
|
|
|
|
|
else if (name[0] == 'e' && strcmp (name, "end") == 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
i = XCOFF_SPECIAL_SECTION_END2;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
|
|
|
|
if (i != -1)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_hash_table (info)->special_sections[i] = csect;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Now we have enough information to add the symbol to the
|
2002-11-30 16:39:46 +08:00
|
|
|
|
linker hash table. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if (sym.n_sclass == C_EXT)
|
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean copy;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (section != NULL);
|
|
|
|
|
|
|
|
|
|
/* We must copy the name into memory if we got it from the
|
2002-11-30 16:39:46 +08:00
|
|
|
|
syment itself, rather than the string table. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
copy = default_copy;
|
|
|
|
|
if (sym._n._n_n._n_zeroes != 0
|
|
|
|
|
|| sym._n._n_n._n_offset == 0)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
copy = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* The AIX linker appears to only detect multiple symbol
|
|
|
|
|
definitions when there is a reference to the symbol. If
|
|
|
|
|
a symbol is defined multiple times, and the only
|
|
|
|
|
references are from the same object file, the AIX linker
|
|
|
|
|
appears to permit it. It does not merge the different
|
|
|
|
|
definitions, but handles them independently. On the
|
|
|
|
|
other hand, if there is a reference, the linker reports
|
|
|
|
|
an error.
|
|
|
|
|
|
|
|
|
|
This matters because the AIX <net/net_globals.h> header
|
|
|
|
|
file actually defines an initialized array, so we have to
|
|
|
|
|
actually permit that to work.
|
|
|
|
|
|
|
|
|
|
Just to make matters even more confusing, the AIX linker
|
|
|
|
|
appears to permit multiple symbol definitions whenever
|
|
|
|
|
the second definition is in an archive rather than an
|
|
|
|
|
object file. This may be a consequence of the manner in
|
|
|
|
|
which it handles archives: I think it may load the entire
|
|
|
|
|
archive in as separate csects, and then let garbage
|
|
|
|
|
collection discard symbols.
|
|
|
|
|
|
|
|
|
|
We also have to handle the case of statically linking a
|
|
|
|
|
shared object, which will cause symbol redefinitions,
|
|
|
|
|
although this is an easier case to detect. */
|
|
|
|
|
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (info->output_bfd->xvec == abfd->xvec)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
if (! bfd_is_und_section (section))
|
2005-04-11 16:23:05 +08:00
|
|
|
|
*sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
|
|
|
|
|
name, TRUE, copy, FALSE);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
else
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Make a copy of the symbol name to prevent problems with
|
|
|
|
|
merging symbols. */
|
|
|
|
|
*sym_hash = ((struct xcoff_link_hash_entry *)
|
|
|
|
|
bfd_wrapped_link_hash_lookup (abfd, info, name,
|
|
|
|
|
TRUE, TRUE, FALSE));
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (*sym_hash == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
if (((*sym_hash)->root.type == bfd_link_hash_defined
|
|
|
|
|
|| (*sym_hash)->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& ! bfd_is_und_section (section)
|
|
|
|
|
&& ! bfd_is_com_section (section))
|
|
|
|
|
{
|
|
|
|
|
/* This is a second definition of a defined symbol. */
|
|
|
|
|
if ((abfd->flags & DYNAMIC) != 0
|
|
|
|
|
&& ((*sym_hash)->smclas != XMC_GL
|
|
|
|
|
|| aux.x_csect.x_smclas == XMC_GL
|
|
|
|
|
|| ((*sym_hash)->root.u.def.section->owner->flags
|
|
|
|
|
& DYNAMIC) == 0))
|
|
|
|
|
{
|
|
|
|
|
/* The new symbol is from a shared library, and
|
2002-11-30 16:39:46 +08:00
|
|
|
|
either the existing symbol is not global
|
|
|
|
|
linkage code or this symbol is global linkage
|
|
|
|
|
code. If the existing symbol is global
|
|
|
|
|
linkage code and the new symbol is not, then
|
|
|
|
|
we want to use the new symbol. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
section = bfd_und_section_ptr;
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (((*sym_hash)->root.u.def.section->owner->flags
|
|
|
|
|
& DYNAMIC) != 0)
|
|
|
|
|
{
|
|
|
|
|
/* The existing symbol is from a shared library.
|
2002-11-30 16:39:46 +08:00
|
|
|
|
Replace it. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
(*sym_hash)->root.type = bfd_link_hash_undefined;
|
|
|
|
|
(*sym_hash)->root.u.undef.abfd =
|
|
|
|
|
(*sym_hash)->root.u.def.section->owner;
|
|
|
|
|
}
|
|
|
|
|
else if (abfd->my_archive != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* This is a redefinition in an object contained
|
2002-11-30 16:39:46 +08:00
|
|
|
|
in an archive. Just ignore it. See the
|
|
|
|
|
comment above. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
section = bfd_und_section_ptr;
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
2004-09-17 15:14:33 +08:00
|
|
|
|
else if ((*sym_hash)->root.u.undef.next != NULL
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|| info->hash->undefs_tail == &(*sym_hash)->root)
|
|
|
|
|
{
|
|
|
|
|
/* This symbol has been referenced. In this
|
2002-11-30 16:39:46 +08:00
|
|
|
|
case, we just continue and permit the
|
|
|
|
|
multiple definition error. See the comment
|
|
|
|
|
above about the behaviour of the AIX linker. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
else if ((*sym_hash)->smclas == aux.x_csect.x_smclas)
|
|
|
|
|
{
|
|
|
|
|
/* The symbols are both csects of the same
|
2002-11-30 16:39:46 +08:00
|
|
|
|
class. There is at least a chance that this
|
|
|
|
|
is a semi-legitimate redefinition. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
section = bfd_und_section_ptr;
|
|
|
|
|
value = 0;
|
|
|
|
|
(*sym_hash)->flags |= XCOFF_MULTIPLY_DEFINED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (((*sym_hash)->flags & XCOFF_MULTIPLY_DEFINED) != 0
|
|
|
|
|
&& ((*sym_hash)->root.type == bfd_link_hash_defined
|
|
|
|
|
|| (*sym_hash)->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& (bfd_is_und_section (section)
|
|
|
|
|
|| bfd_is_com_section (section)))
|
|
|
|
|
{
|
|
|
|
|
/* This is a reference to a multiply defined symbol.
|
|
|
|
|
Report the error now. See the comment above
|
|
|
|
|
about the behaviour of the AIX linker. We could
|
|
|
|
|
also do this with warning symbols, but I'm not
|
|
|
|
|
sure the XCOFF linker is wholly prepared to
|
|
|
|
|
handle them, and that would only be a warning,
|
|
|
|
|
not an error. */
|
|
|
|
|
if (! ((*info->callbacks->multiple_definition)
|
|
|
|
|
(info, (*sym_hash)->root.root.string,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
NULL, NULL, (bfd_vma) 0,
|
1999-05-03 15:29:11 +08:00
|
|
|
|
(*sym_hash)->root.u.def.section->owner,
|
|
|
|
|
(*sym_hash)->root.u.def.section,
|
|
|
|
|
(*sym_hash)->root.u.def.value)))
|
|
|
|
|
goto error_return;
|
|
|
|
|
/* Try not to give this error too many times. */
|
|
|
|
|
(*sym_hash)->flags &= ~XCOFF_MULTIPLY_DEFINED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* _bfd_generic_link_add_one_symbol may call the linker to
|
|
|
|
|
generate an error message, and the linker may try to read
|
|
|
|
|
the symbol table to give a good error. Right now, the
|
|
|
|
|
line numbers are in an inconsistent state, since they are
|
|
|
|
|
counted both in the real sections and in the new csects.
|
|
|
|
|
We need to leave the count in the real sections so that
|
|
|
|
|
the linker can report the line number of the error
|
|
|
|
|
correctly, so temporarily clobber the link to the csects
|
|
|
|
|
so that the linker will not try to read the line numbers
|
|
|
|
|
a second time from the csects. */
|
|
|
|
|
BFD_ASSERT (last_real->next == first_csect);
|
|
|
|
|
last_real->next = NULL;
|
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, abfd, name, flags, section, value,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
NULL, copy, TRUE,
|
1999-05-03 15:29:11 +08:00
|
|
|
|
(struct bfd_link_hash_entry **) sym_hash)))
|
|
|
|
|
goto error_return;
|
|
|
|
|
last_real->next = first_csect;
|
|
|
|
|
|
|
|
|
|
if (smtyp == XTY_CM)
|
|
|
|
|
{
|
|
|
|
|
if ((*sym_hash)->root.type != bfd_link_hash_common
|
|
|
|
|
|| (*sym_hash)->root.u.c.p->section != csect)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We don't need the common csect we just created. */
|
|
|
|
|
csect->size = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
else
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(*sym_hash)->root.u.c.p->alignment_power
|
|
|
|
|
= csect->alignment_power;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (info->output_bfd->xvec == abfd->xvec)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
|
|
if (smtyp == XTY_ER || smtyp == XTY_CM)
|
|
|
|
|
flag = XCOFF_REF_REGULAR;
|
|
|
|
|
else
|
|
|
|
|
flag = XCOFF_DEF_REGULAR;
|
|
|
|
|
(*sym_hash)->flags |= flag;
|
|
|
|
|
|
|
|
|
|
if ((*sym_hash)->smclas == XMC_UA
|
|
|
|
|
|| flag == XCOFF_DEF_REGULAR)
|
|
|
|
|
(*sym_hash)->smclas = aux.x_csect.x_smclas;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-14 17:17:56 +08:00
|
|
|
|
if (smtyp == XTY_ER)
|
|
|
|
|
*csect_cache = section;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*csect_cache = csect;
|
|
|
|
|
if (csect != NULL)
|
|
|
|
|
xcoff_section_data (abfd, csect)->last_symndx
|
|
|
|
|
= (esym - (bfd_byte *) obj_coff_external_syms (abfd)) / symesz;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
esym += (sym.n_numaux + 1) * symesz;
|
|
|
|
|
sym_hash += sym.n_numaux + 1;
|
|
|
|
|
csect_cache += sym.n_numaux + 1;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
lineno_counts += sym.n_numaux + 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (last_real == NULL || last_real->next == first_csect);
|
|
|
|
|
|
|
|
|
|
/* Make sure that we have seen all the relocs. */
|
|
|
|
|
for (o = abfd->sections; o != first_csect; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
/* Reset the section size and the line number count, since the
|
|
|
|
|
data is now attached to the csects. Don't reset the size of
|
|
|
|
|
the .debug section, since we need to read it below in
|
|
|
|
|
bfd_xcoff_size_dynamic_sections. */
|
|
|
|
|
if (strcmp (bfd_get_section_name (abfd, o), ".debug") != 0)
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
o->size = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
o->lineno_count = 0;
|
|
|
|
|
|
|
|
|
|
if ((o->flags & SEC_RELOC) != 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type i;
|
|
|
|
|
struct internal_reloc *rel;
|
|
|
|
|
asection **rel_csect;
|
|
|
|
|
|
|
|
|
|
rel = reloc_info[o->target_index].relocs;
|
|
|
|
|
rel_csect = reloc_info[o->target_index].csects;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
for (i = 0; i < o->reloc_count; i++, rel++, rel_csect++)
|
|
|
|
|
{
|
|
|
|
|
if (*rel_csect == NULL)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
(_("%B: reloc %s:%d not in csect"),
|
|
|
|
|
abfd, o->name, i);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
/* We identify all function symbols that are the target
|
|
|
|
|
of a relocation, so that we can create glue code for
|
|
|
|
|
functions imported from dynamic objects. */
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (info->output_bfd->xvec == abfd->xvec
|
1999-05-03 15:29:11 +08:00
|
|
|
|
&& *rel_csect != bfd_und_section_ptr
|
|
|
|
|
&& obj_xcoff_sym_hashes (abfd)[rel->r_symndx] != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
h = obj_xcoff_sym_hashes (abfd)[rel->r_symndx];
|
|
|
|
|
/* If the symbol name starts with a period, it is
|
2002-11-30 16:39:46 +08:00
|
|
|
|
the code of a function. If the symbol is
|
|
|
|
|
currently undefined, then add an undefined symbol
|
|
|
|
|
for the function descriptor. This should do no
|
|
|
|
|
harm, because any regular object that defines the
|
|
|
|
|
function should also define the function
|
|
|
|
|
descriptor. It helps, because it means that we
|
|
|
|
|
will identify the function descriptor with a
|
|
|
|
|
dynamic object if a dynamic object defines it. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (h->root.root.string[0] == '.'
|
|
|
|
|
&& h->descriptor == NULL)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *hds;
|
2002-10-11 16:33:11 +08:00
|
|
|
|
struct bfd_link_hash_entry *bh;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
hds = xcoff_link_hash_lookup (xcoff_hash_table (info),
|
|
|
|
|
h->root.root.string + 1,
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, FALSE, TRUE);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (hds == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
if (hds->root.type == bfd_link_hash_new)
|
|
|
|
|
{
|
2002-10-11 16:33:11 +08:00
|
|
|
|
bh = &hds->root;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, abfd, hds->root.root.string,
|
|
|
|
|
(flagword) 0, bfd_und_section_ptr,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(bfd_vma) 0, NULL, FALSE,
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, &bh)))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
goto error_return;
|
2002-10-11 16:33:11 +08:00
|
|
|
|
hds = (struct xcoff_link_hash_entry *) bh;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
hds->flags |= XCOFF_DESCRIPTOR;
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
BFD_ASSERT ((h->flags & XCOFF_DESCRIPTOR) == 0);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
hds->descriptor = h;
|
|
|
|
|
h->descriptor = hds;
|
|
|
|
|
}
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
if (h->root.root.string[0] == '.')
|
|
|
|
|
h->flags |= XCOFF_CALLED;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (reloc_info[o->target_index].csects);
|
|
|
|
|
reloc_info[o->target_index].csects = NULL;
|
|
|
|
|
|
|
|
|
|
/* Reset SEC_RELOC and the reloc_count, since the reloc
|
|
|
|
|
information is now attached to the csects. */
|
2001-05-25 04:50:50 +08:00
|
|
|
|
o->flags &=~ SEC_RELOC;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
o->reloc_count = 0;
|
|
|
|
|
|
|
|
|
|
/* If we are not keeping memory, free the reloc information. */
|
|
|
|
|
if (! info->keep_memory
|
|
|
|
|
&& coff_section_data (abfd, o) != NULL
|
|
|
|
|
&& coff_section_data (abfd, o)->relocs != NULL
|
|
|
|
|
&& ! coff_section_data (abfd, o)->keep_relocs)
|
|
|
|
|
{
|
|
|
|
|
free (coff_section_data (abfd, o)->relocs);
|
|
|
|
|
coff_section_data (abfd, o)->relocs = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free up the line numbers. FIXME: We could cache these
|
2002-11-30 16:39:46 +08:00
|
|
|
|
somewhere for the final link, to avoid reading them again. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (reloc_info[o->target_index].linenos != NULL)
|
|
|
|
|
{
|
|
|
|
|
free (reloc_info[o->target_index].linenos);
|
|
|
|
|
reloc_info[o->target_index].linenos = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (reloc_info);
|
|
|
|
|
|
|
|
|
|
obj_coff_keep_syms (abfd) = keep_syms;
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
error_return:
|
|
|
|
|
if (reloc_info != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if (reloc_info[o->target_index].csects != NULL)
|
|
|
|
|
free (reloc_info[o->target_index].csects);
|
|
|
|
|
if (reloc_info[o->target_index].linenos != NULL)
|
|
|
|
|
free (reloc_info[o->target_index].linenos);
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
free (reloc_info);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
obj_coff_keep_syms (abfd) = keep_syms;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef N_TMASK
|
|
|
|
|
#undef N_BTSHFT
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Add symbols from an XCOFF object file. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! _bfd_coff_get_external_symbols (abfd))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (! xcoff_link_add_symbols (abfd, info))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (! info->keep_memory)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! _bfd_coff_free_symbols (abfd))
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Look through the loader symbols to see if this dynamic object
|
|
|
|
|
should be included in the link. The native linker uses the loader
|
|
|
|
|
symbols, not the normal symbol table, so we do too. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_link_check_dynamic_ar_symbols (bfd *abfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
bfd_boolean *pneeded)
|
|
|
|
|
{
|
|
|
|
|
asection *lsec;
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
struct internal_ldhdr ldhdr;
|
|
|
|
|
const char *strings;
|
|
|
|
|
bfd_byte *elsym, *elsymend;
|
|
|
|
|
|
|
|
|
|
*pneeded = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
lsec = bfd_get_section_by_name (abfd, ".loader");
|
|
|
|
|
if (lsec == NULL)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* There are no symbols, so don't try to include it. */
|
|
|
|
|
return TRUE;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (! xcoff_get_section_contents (abfd, lsec))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
contents = coff_section_data (abfd, lsec)->contents;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
|
|
|
|
|
|
|
|
|
|
strings = (char *) contents + ldhdr.l_stoff;
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
elsym = contents + bfd_xcoff_loader_symbol_offset (abfd, &ldhdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
elsymend = elsym + ldhdr.l_nsyms * bfd_xcoff_ldsymsz (abfd);
|
|
|
|
|
for (; elsym < elsymend; elsym += bfd_xcoff_ldsymsz (abfd))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct internal_ldsym ldsym;
|
|
|
|
|
char nambuf[SYMNMLEN + 1];
|
|
|
|
|
const char *name;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct bfd_link_hash_entry *h;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-05-25 04:50:50 +08:00
|
|
|
|
bfd_xcoff_swap_ldsym_in (abfd, elsym, &ldsym);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* We are only interested in exported symbols. */
|
|
|
|
|
if ((ldsym.l_smtype & L_EXPORT) == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (ldsym._l._l_l._l_zeroes == 0)
|
|
|
|
|
name = strings + ldsym._l._l_l._l_offset;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
memcpy (nambuf, ldsym._l._l_name, SYMNMLEN);
|
|
|
|
|
nambuf[SYMNMLEN] = '\0';
|
|
|
|
|
name = nambuf;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We are only interested in symbols that are currently
|
|
|
|
|
undefined. At this point we know that we are using an XCOFF
|
|
|
|
|
hash table. */
|
|
|
|
|
if (h != NULL
|
|
|
|
|
&& h->type == bfd_link_hash_undefined
|
|
|
|
|
&& (((struct xcoff_link_hash_entry *) h)->flags
|
|
|
|
|
& XCOFF_DEF_DYNAMIC) == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! (*info->callbacks->add_archive_element) (info, abfd, name))
|
|
|
|
|
return FALSE;
|
|
|
|
|
*pneeded = TRUE;
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We do not need this shared object. */
|
|
|
|
|
if (contents != NULL && ! coff_section_data (abfd, lsec)->keep_contents)
|
|
|
|
|
{
|
|
|
|
|
free (coff_section_data (abfd, lsec)->contents);
|
|
|
|
|
coff_section_data (abfd, lsec)->contents = NULL;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Look through the symbols to see if this object file should be
|
|
|
|
|
included in the link. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_link_check_ar_symbols (bfd *abfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
bfd_boolean *pneeded)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type symesz;
|
|
|
|
|
bfd_byte *esym;
|
|
|
|
|
bfd_byte *esym_end;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
*pneeded = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((abfd->flags & DYNAMIC) != 0
|
|
|
|
|
&& ! info->static_link
|
2008-02-15 11:35:53 +08:00
|
|
|
|
&& info->output_bfd->xvec == abfd->xvec)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return xcoff_link_check_dynamic_ar_symbols (abfd, info, pneeded);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
symesz = bfd_coff_symesz (abfd);
|
|
|
|
|
esym = (bfd_byte *) obj_coff_external_syms (abfd);
|
|
|
|
|
esym_end = esym + obj_raw_syment_count (abfd) * symesz;
|
|
|
|
|
while (esym < esym_end)
|
|
|
|
|
{
|
|
|
|
|
struct internal_syment sym;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_sym_in (abfd, (void *) esym, (void *) &sym);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (sym.n_sclass == C_EXT && sym.n_scnum != N_UNDEF)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
char buf[SYMNMLEN + 1];
|
|
|
|
|
struct bfd_link_hash_entry *h;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This symbol is externally visible, and is defined by this
|
|
|
|
|
object file. */
|
|
|
|
|
name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
|
|
|
|
|
|
|
|
|
|
/* We are only interested in symbols that are currently
|
|
|
|
|
undefined. If a symbol is currently known to be common,
|
|
|
|
|
XCOFF linkers do not bring in an object file which
|
|
|
|
|
defines it. We also don't bring in symbols to satisfy
|
|
|
|
|
undefined references in shared objects. */
|
|
|
|
|
if (h != NULL
|
|
|
|
|
&& h->type == bfd_link_hash_undefined
|
2008-02-15 11:35:53 +08:00
|
|
|
|
&& (info->output_bfd->xvec != abfd->xvec
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|| (((struct xcoff_link_hash_entry *) h)->flags
|
|
|
|
|
& XCOFF_DEF_DYNAMIC) == 0))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! (*info->callbacks->add_archive_element) (info, abfd, name))
|
|
|
|
|
return FALSE;
|
|
|
|
|
*pneeded = TRUE;
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
esym += (sym.n_numaux + 1) * symesz;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We do not need this object file. */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Check a single archive element to see if we need to include it in
|
|
|
|
|
the link. *PNEEDED is set according to whether this element is
|
|
|
|
|
needed in the link or not. This is called via
|
|
|
|
|
_bfd_generic_link_add_archive_symbols. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_link_check_archive_element (bfd *abfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
bfd_boolean *pneeded)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_coff_get_external_symbols (abfd))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! xcoff_link_check_ar_symbols (abfd, info, pneeded))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (*pneeded)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! xcoff_link_add_symbols (abfd, info))
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
if (! info->keep_memory || ! *pneeded)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! _bfd_coff_free_symbols (abfd))
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Given an XCOFF BFD, add symbols to the global hash table as
|
|
|
|
|
appropriate. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_boolean
|
|
|
|
|
_bfd_xcoff_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
|
|
|
|
|
{
|
|
|
|
|
switch (bfd_get_format (abfd))
|
|
|
|
|
{
|
|
|
|
|
case bfd_object:
|
|
|
|
|
return xcoff_link_add_object_symbols (abfd, info);
|
|
|
|
|
|
|
|
|
|
case bfd_archive:
|
|
|
|
|
/* If the archive has a map, do the usual search. We then need
|
|
|
|
|
to check the archive for dynamic objects, because they may not
|
|
|
|
|
appear in the archive map even though they should, perhaps, be
|
|
|
|
|
included. If the archive has no map, we just consider each object
|
|
|
|
|
file in turn, since that apparently is what the AIX native linker
|
|
|
|
|
does. */
|
|
|
|
|
if (bfd_has_map (abfd))
|
|
|
|
|
{
|
|
|
|
|
if (! (_bfd_generic_link_add_archive_symbols
|
|
|
|
|
(abfd, info, xcoff_link_check_archive_element)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
bfd *member;
|
|
|
|
|
|
|
|
|
|
member = bfd_openr_next_archived_file (abfd, NULL);
|
|
|
|
|
while (member != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (bfd_check_format (member, bfd_object)
|
2008-02-15 11:35:53 +08:00
|
|
|
|
&& (info->output_bfd->xvec == member->xvec)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
&& (! bfd_has_map (abfd) || (member->flags & DYNAMIC) != 0))
|
|
|
|
|
{
|
|
|
|
|
bfd_boolean needed;
|
|
|
|
|
|
|
|
|
|
if (! xcoff_link_check_archive_element (member, info,
|
|
|
|
|
&needed))
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (needed)
|
|
|
|
|
member->archive_pass = -1;
|
|
|
|
|
}
|
|
|
|
|
member = bfd_openr_next_archived_file (abfd, member);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
bfd_set_error (bfd_error_wrong_format);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
/* If symbol H has not been interpreted as a function descriptor,
|
|
|
|
|
see whether it should be. Set up its descriptor information if so. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_find_function (struct bfd_link_info *info,
|
|
|
|
|
struct xcoff_link_hash_entry *h)
|
|
|
|
|
{
|
|
|
|
|
if ((h->flags & XCOFF_DESCRIPTOR) == 0
|
|
|
|
|
&& h->root.root.string[0] != '.')
|
|
|
|
|
{
|
|
|
|
|
char *fnname;
|
|
|
|
|
struct xcoff_link_hash_entry *hfn;
|
|
|
|
|
bfd_size_type amt;
|
|
|
|
|
|
|
|
|
|
amt = strlen (h->root.root.string) + 2;
|
|
|
|
|
fnname = bfd_malloc (amt);
|
|
|
|
|
if (fnname == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
fnname[0] = '.';
|
|
|
|
|
strcpy (fnname + 1, h->root.root.string);
|
|
|
|
|
hfn = xcoff_link_hash_lookup (xcoff_hash_table (info),
|
|
|
|
|
fnname, FALSE, FALSE, TRUE);
|
|
|
|
|
free (fnname);
|
|
|
|
|
if (hfn != NULL
|
|
|
|
|
&& hfn->smclas == XMC_PR
|
|
|
|
|
&& (hfn->root.type == bfd_link_hash_defined
|
|
|
|
|
|| hfn->root.type == bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
h->flags |= XCOFF_DESCRIPTOR;
|
|
|
|
|
h->descriptor = hfn;
|
|
|
|
|
hfn->descriptor = h;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* H is an imported symbol. Set the import module's path, file and member
|
|
|
|
|
to IMPATH, IMPFILE and IMPMEMBER respectively. All three are null if
|
|
|
|
|
no specific import module is specified. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_set_import_path (struct bfd_link_info *info,
|
|
|
|
|
struct xcoff_link_hash_entry *h,
|
|
|
|
|
const char *imppath, const char *impfile,
|
|
|
|
|
const char *impmember)
|
|
|
|
|
{
|
|
|
|
|
unsigned int c;
|
|
|
|
|
struct xcoff_import_file **pp;
|
|
|
|
|
|
|
|
|
|
/* We overload the ldindx field to hold the l_ifile value for this
|
|
|
|
|
symbol. */
|
|
|
|
|
BFD_ASSERT (h->ldsym == NULL);
|
|
|
|
|
BFD_ASSERT ((h->flags & XCOFF_BUILT_LDSYM) == 0);
|
|
|
|
|
if (imppath == NULL)
|
|
|
|
|
h->ldindx = -1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We start c at 1 because the first entry in the import list is
|
|
|
|
|
reserved for the library search path. */
|
|
|
|
|
for (pp = &xcoff_hash_table (info)->imports, c = 1;
|
|
|
|
|
*pp != NULL;
|
|
|
|
|
pp = &(*pp)->next, ++c)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp ((*pp)->path, imppath) == 0
|
|
|
|
|
&& strcmp ((*pp)->file, impfile) == 0
|
|
|
|
|
&& strcmp ((*pp)->member, impmember) == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*pp == NULL)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_import_file *n;
|
|
|
|
|
bfd_size_type amt = sizeof (* n);
|
|
|
|
|
|
|
|
|
|
n = bfd_alloc (info->output_bfd, amt);
|
|
|
|
|
if (n == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
n->next = NULL;
|
|
|
|
|
n->path = imppath;
|
|
|
|
|
n->file = impfile;
|
|
|
|
|
n->member = impmember;
|
|
|
|
|
*pp = n;
|
|
|
|
|
}
|
|
|
|
|
h->ldindx = c;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* Mark a symbol as not being garbage, including the section in which
|
|
|
|
|
it is defined. */
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
static inline bfd_boolean
|
|
|
|
|
xcoff_mark_symbol (struct bfd_link_info *info, struct xcoff_link_hash_entry *h)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
if ((h->flags & XCOFF_MARK) != 0)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
h->flags |= XCOFF_MARK;
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
|
|
|
|
|
/* If we're marking an undefined symbol, try find some way of
|
|
|
|
|
defining it. */
|
|
|
|
|
if (!info->relocatable
|
|
|
|
|
&& (h->flags & XCOFF_IMPORT) == 0
|
|
|
|
|
&& (h->flags & XCOFF_DEF_REGULAR) == 0
|
|
|
|
|
&& (h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak))
|
|
|
|
|
{
|
|
|
|
|
/* First check whether this symbol can be interpreted as an
|
|
|
|
|
undefined function descriptor for a defined function symbol. */
|
|
|
|
|
if (!xcoff_find_function (info, h))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if ((h->flags & XCOFF_DESCRIPTOR) != 0
|
|
|
|
|
&& (h->descriptor->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->descriptor->root.type == bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
/* This is a descriptor for a defined symbol, but the input
|
|
|
|
|
objects have not defined the descriptor itself. Fill in
|
|
|
|
|
the definition automatically.
|
|
|
|
|
|
|
|
|
|
Note that we do this even if we found a dynamic definition
|
|
|
|
|
of H. The local function definition logically overrides
|
|
|
|
|
the dynamic one. */
|
|
|
|
|
asection *sec;
|
|
|
|
|
|
|
|
|
|
sec = xcoff_hash_table (info)->descriptor_section;
|
|
|
|
|
h->root.type = bfd_link_hash_defined;
|
|
|
|
|
h->root.u.def.section = sec;
|
|
|
|
|
h->root.u.def.value = sec->size;
|
|
|
|
|
h->smclas = XMC_DS;
|
|
|
|
|
h->flags |= XCOFF_DEF_REGULAR;
|
|
|
|
|
|
|
|
|
|
/* The size of the function descriptor depends on whether this
|
|
|
|
|
is xcoff32 (12) or xcoff64 (24). */
|
|
|
|
|
sec->size += bfd_xcoff_function_descriptor_size (sec->owner);
|
|
|
|
|
|
|
|
|
|
/* A function descriptor uses two relocs: one for the
|
|
|
|
|
associated code, and one for the TOC address. */
|
|
|
|
|
xcoff_hash_table (info)->ldrel_count += 2;
|
|
|
|
|
sec->reloc_count += 2;
|
|
|
|
|
|
|
|
|
|
/* Mark the function itself. */
|
|
|
|
|
if (!xcoff_mark_symbol (info, h->descriptor))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2009-03-14 17:18:22 +08:00
|
|
|
|
/* Mark the TOC section, so that we get an anchor
|
|
|
|
|
to relocate against. */
|
|
|
|
|
if (!xcoff_mark (info, xcoff_hash_table (info)->toc_section))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
/* We handle writing out the contents of the descriptor in
|
|
|
|
|
xcoff_write_global_symbol. */
|
|
|
|
|
}
|
|
|
|
|
else if ((h->flags & XCOFF_CALLED) != 0)
|
|
|
|
|
{
|
|
|
|
|
/* This is a function symbol for which we need to create
|
|
|
|
|
linkage code. */
|
|
|
|
|
asection *sec;
|
|
|
|
|
struct xcoff_link_hash_entry *hds;
|
|
|
|
|
|
|
|
|
|
/* Mark the descriptor (and its TOC section). */
|
|
|
|
|
hds = h->descriptor;
|
|
|
|
|
BFD_ASSERT ((hds->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| hds->root.type == bfd_link_hash_undefweak)
|
|
|
|
|
&& (hds->flags & XCOFF_DEF_REGULAR) == 0);
|
|
|
|
|
if (!xcoff_mark_symbol (info, hds))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Treat this symbol as undefined if the descriptor was. */
|
|
|
|
|
if ((hds->flags & XCOFF_WAS_UNDEFINED) != 0)
|
|
|
|
|
h->flags |= XCOFF_WAS_UNDEFINED;
|
|
|
|
|
|
|
|
|
|
/* Allocate room for the global linkage code itself. */
|
|
|
|
|
sec = xcoff_hash_table (info)->linkage_section;
|
|
|
|
|
h->root.type = bfd_link_hash_defined;
|
|
|
|
|
h->root.u.def.section = sec;
|
|
|
|
|
h->root.u.def.value = sec->size;
|
|
|
|
|
h->smclas = XMC_GL;
|
|
|
|
|
h->flags |= XCOFF_DEF_REGULAR;
|
|
|
|
|
sec->size += bfd_xcoff_glink_code_size (info->output_bfd);
|
|
|
|
|
|
|
|
|
|
/* The global linkage code requires a TOC entry for the
|
|
|
|
|
descriptor. */
|
|
|
|
|
if (hds->toc_section == NULL)
|
|
|
|
|
{
|
|
|
|
|
int byte_size;
|
|
|
|
|
|
|
|
|
|
/* 32 vs 64
|
|
|
|
|
xcoff32 uses 4 bytes in the toc.
|
|
|
|
|
xcoff64 uses 8 bytes in the toc. */
|
|
|
|
|
if (bfd_xcoff_is_xcoff64 (info->output_bfd))
|
|
|
|
|
byte_size = 8;
|
|
|
|
|
else if (bfd_xcoff_is_xcoff32 (info->output_bfd))
|
|
|
|
|
byte_size = 4;
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Allocate room in the fallback TOC section. */
|
|
|
|
|
hds->toc_section = xcoff_hash_table (info)->toc_section;
|
|
|
|
|
hds->u.toc_offset = hds->toc_section->size;
|
|
|
|
|
hds->toc_section->size += byte_size;
|
|
|
|
|
if (!xcoff_mark (info, hds->toc_section))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Allocate room for a static and dynamic R_TOC
|
|
|
|
|
relocation. */
|
|
|
|
|
++xcoff_hash_table (info)->ldrel_count;
|
|
|
|
|
++hds->toc_section->reloc_count;
|
|
|
|
|
|
|
|
|
|
/* Set the index to -2 to force this symbol to
|
|
|
|
|
get written out. */
|
|
|
|
|
hds->indx = -2;
|
|
|
|
|
hds->flags |= XCOFF_SET_TOC | XCOFF_LDREL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((h->flags & XCOFF_DEF_DYNAMIC) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Record that the symbol was undefined, then import it.
|
|
|
|
|
-brtl links use a special fake import file. */
|
|
|
|
|
h->flags |= XCOFF_WAS_UNDEFINED | XCOFF_IMPORT;
|
|
|
|
|
if (xcoff_hash_table (info)->rtld)
|
|
|
|
|
{
|
|
|
|
|
if (!xcoff_set_import_path (info, h, "", "..", ""))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!xcoff_set_import_path (info, h, NULL, NULL, NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
{
|
|
|
|
|
asection *hsec;
|
|
|
|
|
|
|
|
|
|
hsec = h->root.u.def.section;
|
|
|
|
|
if (! bfd_is_abs_section (hsec)
|
|
|
|
|
&& (hsec->flags & SEC_MARK) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (! xcoff_mark (info, hsec))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (h->toc_section != NULL
|
|
|
|
|
&& (h->toc_section->flags & SEC_MARK) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (! xcoff_mark (info, h->toc_section))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The mark phase of garbage collection. For a given section, mark
|
|
|
|
|
it, and all the sections which define symbols to which it refers.
|
|
|
|
|
Because this function needs to look at the relocs, we also count
|
|
|
|
|
the number of relocs which need to be copied into the .loader
|
|
|
|
|
section. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_mark (struct bfd_link_info *info, asection *sec)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
if (bfd_is_abs_section (sec)
|
|
|
|
|
|| (sec->flags & SEC_MARK) != 0)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
sec->flags |= SEC_MARK;
|
|
|
|
|
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (sec->owner->xvec == info->output_bfd->xvec
|
1999-05-03 15:29:11 +08:00
|
|
|
|
&& coff_section_data (sec->owner, sec) != NULL
|
|
|
|
|
&& xcoff_section_data (sec->owner, sec) != NULL)
|
|
|
|
|
{
|
2009-03-14 17:17:56 +08:00
|
|
|
|
struct xcoff_link_hash_entry **syms;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
struct internal_reloc *rel, *relend;
|
2009-03-14 17:17:56 +08:00
|
|
|
|
asection **csects;
|
|
|
|
|
unsigned long i, first, last;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Mark all the symbols in this section. */
|
2009-03-14 17:17:56 +08:00
|
|
|
|
syms = obj_xcoff_sym_hashes (sec->owner);
|
|
|
|
|
csects = xcoff_data (sec->owner)->csects;
|
|
|
|
|
first = xcoff_section_data (sec->owner, sec)->first_symndx;
|
|
|
|
|
last = xcoff_section_data (sec->owner, sec)->last_symndx;
|
|
|
|
|
for (i = first; i <= last; i++)
|
|
|
|
|
if (csects[i] == sec
|
|
|
|
|
&& syms[i] != NULL
|
|
|
|
|
&& (syms[i]->flags & XCOFF_MARK) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!xcoff_mark_symbol (info, syms[i]))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Look through the section relocs. */
|
|
|
|
|
if ((sec->flags & SEC_RELOC) != 0
|
|
|
|
|
&& sec->reloc_count > 0)
|
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
rel = xcoff_read_internal_relocs (sec->owner, sec, TRUE,
|
2005-04-11 16:23:05 +08:00
|
|
|
|
NULL, FALSE, NULL);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (rel == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
relend = rel + sec->reloc_count;
|
|
|
|
|
for (; rel < relend; rel++)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
if ((unsigned int) rel->r_symndx
|
|
|
|
|
> obj_raw_syment_count (sec->owner))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
h = obj_xcoff_sym_hashes (sec->owner)[rel->r_symndx];
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
if (h != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
if ((h->flags & XCOFF_MARK) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!xcoff_mark_symbol (info, h))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
asection *rsec;
|
|
|
|
|
|
|
|
|
|
rsec = xcoff_data (sec->owner)->csects[rel->r_symndx];
|
|
|
|
|
if (rsec != NULL
|
|
|
|
|
&& (rsec->flags & SEC_MARK) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!xcoff_mark (info, rsec))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See if this reloc needs to be copied into the .loader
|
2002-11-30 16:39:46 +08:00
|
|
|
|
section. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (rel->r_type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
if (h == NULL
|
|
|
|
|
|| h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak
|
|
|
|
|
|| h->root.type == bfd_link_hash_common
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
/* We will always provide a local definition of
|
|
|
|
|
function symbols. */
|
|
|
|
|
|| (h->flags & XCOFF_CALLED) != 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
/* Fall through. */
|
|
|
|
|
case R_POS:
|
|
|
|
|
case R_NEG:
|
|
|
|
|
case R_RL:
|
|
|
|
|
case R_RLA:
|
2009-03-14 17:15:34 +08:00
|
|
|
|
if (h != NULL
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& bfd_is_abs_section (h->root.u.def.section))
|
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
++xcoff_hash_table (info)->ldrel_count;
|
|
|
|
|
if (h != NULL)
|
|
|
|
|
h->flags |= XCOFF_LDREL;
|
|
|
|
|
break;
|
|
|
|
|
case R_TOC:
|
|
|
|
|
case R_GL:
|
|
|
|
|
case R_TCL:
|
|
|
|
|
case R_TRL:
|
|
|
|
|
case R_TRLA:
|
|
|
|
|
/* We should never need a .loader reloc for a TOC
|
|
|
|
|
relative reloc. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! info->keep_memory
|
|
|
|
|
&& coff_section_data (sec->owner, sec) != NULL
|
|
|
|
|
&& coff_section_data (sec->owner, sec)->relocs != NULL
|
|
|
|
|
&& ! coff_section_data (sec->owner, sec)->keep_relocs)
|
|
|
|
|
{
|
|
|
|
|
free (coff_section_data (sec->owner, sec)->relocs);
|
|
|
|
|
coff_section_data (sec->owner, sec)->relocs = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Routines that are called after all the input files have been
|
|
|
|
|
handled, but before the sections are laid out in memory. */
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* The sweep phase of garbage collection. Remove all garbage
|
|
|
|
|
sections. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_sweep (struct bfd_link_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
bfd *sub;
|
|
|
|
|
|
|
|
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
|
|
|
|
{
|
|
|
|
|
asection *o;
|
|
|
|
|
|
|
|
|
|
for (o = sub->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_MARK) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Keep all sections from non-XCOFF input files. Keep
|
2002-11-30 16:39:46 +08:00
|
|
|
|
special sections. Keep .debug sections for the
|
|
|
|
|
moment. */
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (sub->xvec != info->output_bfd->xvec
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|| o == xcoff_hash_table (info)->debug_section
|
|
|
|
|
|| o == xcoff_hash_table (info)->loader_section
|
|
|
|
|
|| o == xcoff_hash_table (info)->linkage_section
|
|
|
|
|
|| o == xcoff_hash_table (info)->descriptor_section
|
|
|
|
|
|| strcmp (o->name, ".debug") == 0)
|
|
|
|
|
o->flags |= SEC_MARK;
|
|
|
|
|
else
|
|
|
|
|
{
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 12:46:28 +08:00
|
|
|
|
o->size = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
o->reloc_count = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Record the number of elements in a set. This is used to output the
|
|
|
|
|
correct csect length. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_link_record_set (bfd *output_bfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
struct bfd_link_hash_entry *harg,
|
|
|
|
|
bfd_size_type size)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
|
|
|
|
|
struct xcoff_link_size_list *n;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_size_type amt;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-06-17 04:35:08 +08:00
|
|
|
|
if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* This will hardly ever be called. I don't want to burn four bytes
|
|
|
|
|
per global symbol, so instead the size is kept on a linked list
|
|
|
|
|
attached to the hash table. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
amt = sizeof (* n);
|
|
|
|
|
n = bfd_alloc (output_bfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (n == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
n->next = xcoff_hash_table (info)->size_list;
|
|
|
|
|
n->h = h;
|
|
|
|
|
n->size = size;
|
|
|
|
|
xcoff_hash_table (info)->size_list = n;
|
|
|
|
|
|
|
|
|
|
h->flags |= XCOFF_HAS_SIZE;
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Import a symbol. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_import_symbol (bfd *output_bfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
struct bfd_link_hash_entry *harg,
|
|
|
|
|
bfd_vma val,
|
|
|
|
|
const char *imppath,
|
|
|
|
|
const char *impfile,
|
|
|
|
|
const char *impmember,
|
|
|
|
|
unsigned int syscall_flag)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
|
|
|
|
|
|
2000-06-17 04:35:08 +08:00
|
|
|
|
if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* A symbol name which starts with a period is the code for a
|
|
|
|
|
function. If the symbol is undefined, then add an undefined
|
|
|
|
|
symbol for the function descriptor, and import that instead. */
|
|
|
|
|
if (h->root.root.string[0] == '.'
|
|
|
|
|
&& h->root.type == bfd_link_hash_undefined
|
|
|
|
|
&& val == (bfd_vma) -1)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *hds;
|
|
|
|
|
|
|
|
|
|
hds = h->descriptor;
|
|
|
|
|
if (hds == NULL)
|
|
|
|
|
{
|
|
|
|
|
hds = xcoff_link_hash_lookup (xcoff_hash_table (info),
|
|
|
|
|
h->root.root.string + 1,
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, FALSE, TRUE);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (hds == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (hds->root.type == bfd_link_hash_new)
|
|
|
|
|
{
|
|
|
|
|
hds->root.type = bfd_link_hash_undefined;
|
|
|
|
|
hds->root.u.undef.abfd = h->root.u.undef.abfd;
|
|
|
|
|
}
|
|
|
|
|
hds->flags |= XCOFF_DESCRIPTOR;
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
BFD_ASSERT ((h->flags & XCOFF_DESCRIPTOR) == 0);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
hds->descriptor = h;
|
|
|
|
|
h->descriptor = hds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now, if the descriptor is undefined, import the descriptor
|
2002-11-30 16:39:46 +08:00
|
|
|
|
rather than the symbol we were told to import. FIXME: Is
|
|
|
|
|
this correct in all cases? */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (hds->root.type == bfd_link_hash_undefined)
|
|
|
|
|
h = hds;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-06 23:20:01 +08:00
|
|
|
|
h->flags |= (XCOFF_IMPORT | syscall_flag);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
if (val != (bfd_vma) -1)
|
|
|
|
|
{
|
|
|
|
|
if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
&& (! bfd_is_abs_section (h->root.u.def.section)
|
|
|
|
|
|| h->root.u.def.value != val))
|
|
|
|
|
{
|
|
|
|
|
if (! ((*info->callbacks->multiple_definition)
|
|
|
|
|
(info, h->root.root.string, h->root.u.def.section->owner,
|
|
|
|
|
h->root.u.def.section, h->root.u.def.value,
|
|
|
|
|
output_bfd, bfd_abs_section_ptr, val)))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h->root.type = bfd_link_hash_defined;
|
|
|
|
|
h->root.u.def.section = bfd_abs_section_ptr;
|
|
|
|
|
h->root.u.def.value = val;
|
2009-03-14 17:32:56 +08:00
|
|
|
|
h->smclas = XMC_XO;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
if (!xcoff_set_import_path (info, h, imppath, impfile, impmember))
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Export a symbol. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_export_symbol (bfd *output_bfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
struct bfd_link_hash_entry *harg)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
|
|
|
|
|
|
2000-06-17 04:35:08 +08:00
|
|
|
|
if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
h->flags |= XCOFF_EXPORT;
|
|
|
|
|
|
|
|
|
|
/* FIXME: I'm not at all sure what syscall is supposed to mean, so
|
|
|
|
|
I'm just going to ignore it until somebody explains it. */
|
|
|
|
|
|
|
|
|
|
/* Make sure we don't garbage collect this symbol. */
|
|
|
|
|
if (! xcoff_mark_symbol (info, h))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* If this is a function descriptor, make sure we don't garbage
|
|
|
|
|
collect the associated function code. We normally don't have to
|
|
|
|
|
worry about this, because the descriptor will be attached to a
|
|
|
|
|
section with relocs, but if we are creating the descriptor
|
|
|
|
|
ourselves those relocs will not be visible to the mark code. */
|
|
|
|
|
if ((h->flags & XCOFF_DESCRIPTOR) != 0)
|
|
|
|
|
{
|
|
|
|
|
if (! xcoff_mark_symbol (info, h->descriptor))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Count a reloc against a symbol. This is called for relocs
|
|
|
|
|
generated by the linker script, typically for global constructors
|
|
|
|
|
and destructors. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_link_count_reloc (bfd *output_bfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
const char *name)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
|
2000-06-17 04:35:08 +08:00
|
|
|
|
if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
h = ((struct xcoff_link_hash_entry *)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_wrapped_link_hash_lookup (output_bfd, info, name, FALSE, FALSE,
|
|
|
|
|
FALSE));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (h == NULL)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler) (_("%s: no such symbol"), name);
|
|
|
|
|
bfd_set_error (bfd_error_no_symbols);
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h->flags |= XCOFF_REF_REGULAR | XCOFF_LDREL;
|
|
|
|
|
++xcoff_hash_table (info)->ldrel_count;
|
2000-11-30 16:04:42 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* Mark the symbol to avoid garbage collection. */
|
|
|
|
|
if (! xcoff_mark_symbol (info, h))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function is called for each symbol to which the linker script
|
|
|
|
|
assigns a value. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_record_link_assignment (bfd *output_bfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
const char *name)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
|
2000-06-17 04:35:08 +08:00
|
|
|
|
if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, TRUE, TRUE,
|
|
|
|
|
FALSE);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (h == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
h->flags |= XCOFF_DEF_REGULAR;
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Add a symbol to the .loader symbols, if necessary. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
/* INPUT_BFD has an external symbol associated with hash table entry H
|
|
|
|
|
and csect CSECT. Return true if INPUT_BFD defines H. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_final_definition_p (bfd *input_bfd, struct xcoff_link_hash_entry *h,
|
|
|
|
|
asection *csect)
|
|
|
|
|
{
|
|
|
|
|
switch (h->root.type)
|
|
|
|
|
{
|
|
|
|
|
case bfd_link_hash_defined:
|
|
|
|
|
case bfd_link_hash_defweak:
|
|
|
|
|
/* No input bfd owns absolute symbols. They are written by
|
|
|
|
|
xcoff_write_global_symbol instead. */
|
|
|
|
|
return (!bfd_is_abs_section (csect)
|
|
|
|
|
&& h->root.u.def.section == csect);
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_common:
|
|
|
|
|
return h->root.u.c.p->section->owner == input_bfd;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_undefined:
|
|
|
|
|
case bfd_link_hash_undefweak:
|
|
|
|
|
/* We can't treat undef.abfd as the owner because that bfd
|
|
|
|
|
might be a dynamic object. Allow any bfd to claim it. */
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_build_ldsyms (struct xcoff_link_hash_entry *h, void * p)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct xcoff_loader_info *ldinfo = (struct xcoff_loader_info *) p;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_size_type amt;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct xcoff_link_hash_entry *) h->root.u.i.link;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* __rtinit, this symbol has special handling. */
|
|
|
|
|
if (h->flags & XCOFF_RTINIT)
|
|
|
|
|
return TRUE;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If this is a final link, and the symbol was defined as a common
|
|
|
|
|
symbol in a regular object file, and there was no definition in
|
|
|
|
|
any dynamic object, then the linker will have allocated space for
|
|
|
|
|
the symbol in a common section but the XCOFF_DEF_REGULAR flag
|
|
|
|
|
will not have been set. */
|
|
|
|
|
if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
&& (h->flags & XCOFF_DEF_REGULAR) == 0
|
|
|
|
|
&& (h->flags & XCOFF_REF_REGULAR) != 0
|
|
|
|
|
&& (h->flags & XCOFF_DEF_DYNAMIC) == 0
|
|
|
|
|
&& (bfd_is_abs_section (h->root.u.def.section)
|
|
|
|
|
|| (h->root.u.def.section->owner->flags & DYNAMIC) == 0))
|
|
|
|
|
h->flags |= XCOFF_DEF_REGULAR;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If all defined symbols should be exported, mark them now. We
|
|
|
|
|
don't want to export the actual functions, just the function
|
|
|
|
|
descriptors. */
|
|
|
|
|
if (ldinfo->export_defineds
|
|
|
|
|
&& (h->flags & XCOFF_DEF_REGULAR) != 0
|
|
|
|
|
&& h->root.root.string[0] != '.')
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_boolean export;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We don't export a symbol which is being defined by an object
|
|
|
|
|
included from an archive which contains a shared object. The
|
|
|
|
|
rationale is that if an archive contains both an unshared and
|
|
|
|
|
a shared object, then there must be some reason that the
|
|
|
|
|
unshared object is unshared, and we don't want to start
|
|
|
|
|
providing a shared version of it. In particular, this solves
|
|
|
|
|
a bug involving the _savefNN set of functions. gcc will call
|
|
|
|
|
those functions without providing a slot to restore the TOC,
|
|
|
|
|
so it is essential that these functions be linked in directly
|
|
|
|
|
and not from a shared object, which means that a shared
|
|
|
|
|
object which also happens to link them in must not export
|
|
|
|
|
them. This is confusing, but I haven't been able to think of
|
|
|
|
|
a different approach. Note that the symbols can, of course,
|
|
|
|
|
be exported explicitly. */
|
|
|
|
|
export = TRUE;
|
|
|
|
|
if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& h->root.u.def.section->owner != NULL
|
|
|
|
|
&& h->root.u.def.section->owner->my_archive != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd *arbfd, *member;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
arbfd = h->root.u.def.section->owner->my_archive;
|
|
|
|
|
member = bfd_openr_next_archived_file (arbfd, NULL);
|
|
|
|
|
while (member != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((member->flags & DYNAMIC) != 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
export = FALSE;
|
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
member = bfd_openr_next_archived_file (arbfd, member);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
if (export)
|
|
|
|
|
h->flags |= XCOFF_EXPORT;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We don't want to garbage collect symbols which are not defined in
|
|
|
|
|
XCOFF files. This is a convenient place to mark them. */
|
|
|
|
|
if (xcoff_hash_table (ldinfo->info)->gc
|
|
|
|
|
&& (h->flags & XCOFF_MARK) == 0
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& (h->root.u.def.section->owner == NULL
|
|
|
|
|
|| (h->root.u.def.section->owner->xvec
|
2008-02-15 11:35:53 +08:00
|
|
|
|
!= ldinfo->info->output_bfd->xvec)))
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h->flags |= XCOFF_MARK;
|
|
|
|
|
|
|
|
|
|
/* If this symbol is exported, but not defined, we need to try to
|
|
|
|
|
define it. */
|
|
|
|
|
if ((h->flags & XCOFF_EXPORT) != 0
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
&& (h->flags & XCOFF_WAS_UNDEFINED) != 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("warning: attempt to export undefined symbol `%s'"),
|
|
|
|
|
h->root.root.string);
|
|
|
|
|
h->ldsym = NULL;
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If this is still a common symbol, and it wasn't garbage
|
|
|
|
|
collected, we need to actually allocate space for it in the .bss
|
|
|
|
|
section. */
|
|
|
|
|
if (h->root.type == bfd_link_hash_common
|
|
|
|
|
&& (! xcoff_hash_table (ldinfo->info)->gc
|
|
|
|
|
|| (h->flags & XCOFF_MARK) != 0)
|
|
|
|
|
&& h->root.u.c.p->section->size == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT (bfd_is_com_section (h->root.u.c.p->section));
|
|
|
|
|
h->root.u.c.p->section->size = h->root.u.c.size;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We need to add a symbol to the .loader section if it is mentioned
|
|
|
|
|
in a reloc which we are copying to the .loader section and it was
|
|
|
|
|
not defined or common, or if it is the entry point, or if it is
|
|
|
|
|
being exported. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (((h->flags & XCOFF_LDREL) == 0
|
|
|
|
|
|| h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak
|
|
|
|
|
|| h->root.type == bfd_link_hash_common)
|
|
|
|
|
&& (h->flags & XCOFF_ENTRY) == 0
|
|
|
|
|
&& (h->flags & XCOFF_EXPORT) == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h->ldsym = NULL;
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
/* We don't need to add this symbol if we did garbage collection and
|
|
|
|
|
we did not mark this symbol. */
|
|
|
|
|
if (xcoff_hash_table (ldinfo->info)->gc
|
|
|
|
|
&& (h->flags & XCOFF_MARK) == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h->ldsym = NULL;
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We may have already processed this symbol due to the recursive
|
|
|
|
|
call above. */
|
|
|
|
|
if ((h->flags & XCOFF_BUILT_LDSYM) != 0)
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We need to add this symbol to the .loader symbols. */
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (h->ldsym == NULL);
|
|
|
|
|
amt = sizeof (struct internal_ldsym);
|
|
|
|
|
h->ldsym = bfd_zalloc (ldinfo->output_bfd, amt);
|
|
|
|
|
if (h->ldsym == NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((h->flags & XCOFF_IMPORT) != 0)
|
|
|
|
|
h->ldsym->l_ifile = h->ldindx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* The first 3 symbol table indices are reserved to indicate the
|
|
|
|
|
data, text and bss sections. */
|
|
|
|
|
h->ldindx = ldinfo->ldsym_count + 3;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
++ldinfo->ldsym_count;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! bfd_xcoff_put_ldsymbol_name (ldinfo->output_bfd, ldinfo,
|
|
|
|
|
h->ldsym, h->root.root.string))
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h->flags |= XCOFF_BUILT_LDSYM;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2009-03-14 17:32:06 +08:00
|
|
|
|
|
|
|
|
|
/* INPUT_BFD includes XCOFF symbol ISYM, which is associated with linker
|
|
|
|
|
hash table entry H and csect CSECT. AUX contains ISYM's auxillary
|
|
|
|
|
csect information, if any. NAME is the function's name if the name
|
|
|
|
|
is stored in the .debug section, otherwise it is null.
|
|
|
|
|
|
|
|
|
|
Return 1 if we should include an appropriately-adjusted ISYM
|
|
|
|
|
in the output file, 0 if we should discard ISYM, or -1 if an
|
|
|
|
|
error occured. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
xcoff_keep_symbol_p (struct bfd_link_info *info, bfd *input_bfd,
|
|
|
|
|
struct internal_syment *isym,
|
|
|
|
|
union internal_auxent *aux,
|
|
|
|
|
struct xcoff_link_hash_entry *h,
|
|
|
|
|
asection *csect, const char *name)
|
|
|
|
|
{
|
|
|
|
|
int smtyp;
|
|
|
|
|
|
|
|
|
|
/* If we are skipping this csect, we want to strip the symbol too. */
|
|
|
|
|
if (csect == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* Likewise if we garbage-collected the csect. */
|
|
|
|
|
if (xcoff_hash_table (info)->gc
|
|
|
|
|
&& !bfd_is_abs_section (csect)
|
|
|
|
|
&& !bfd_is_und_section (csect)
|
|
|
|
|
&& (csect->flags & SEC_MARK) == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* An XCOFF linker always removes C_STAT symbols. */
|
|
|
|
|
if (isym->n_sclass == C_STAT)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* We generate the TOC anchor separately. */
|
|
|
|
|
if (isym->n_sclass == C_HIDEXT
|
|
|
|
|
&& aux->x_csect.x_smclas == XMC_TC0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* If we are stripping all symbols, we want to discard this one. */
|
|
|
|
|
if (info->strip == strip_all)
|
|
|
|
|
return 0;
|
|
|
|
|
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
/* Discard symbols that are defined elsewhere. */
|
|
|
|
|
if (isym->n_sclass == C_EXT)
|
|
|
|
|
{
|
|
|
|
|
if ((h->flags & XCOFF_ALLOCATED) != 0)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!xcoff_final_definition_p (input_bfd, h, csect))
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2009-03-14 17:32:06 +08:00
|
|
|
|
|
|
|
|
|
/* If we're discarding local symbols, check whether ISYM is local. */
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
smtyp = SMTYP_SMTYP (aux->x_csect.x_smtyp);
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (info->discard == discard_all
|
|
|
|
|
&& isym->n_sclass != C_EXT
|
|
|
|
|
&& (isym->n_sclass != C_HIDEXT || smtyp != XTY_SD))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* If we're stripping debugging symbols, check whether ISYM is one. */
|
|
|
|
|
if (info->strip == strip_debugger
|
|
|
|
|
&& isym->n_scnum == N_DEBUG)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* If we are stripping symbols based on name, check how ISYM's
|
|
|
|
|
name should be handled. */
|
|
|
|
|
if (info->strip == strip_some
|
|
|
|
|
|| info->discard == discard_l)
|
|
|
|
|
{
|
|
|
|
|
char buf[SYMNMLEN + 1];
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
name = _bfd_coff_internal_syment_name (input_bfd, isym, buf);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info->strip == strip_some
|
|
|
|
|
&& bfd_hash_lookup (info->keep_hash, name, FALSE, FALSE) == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (info->discard == discard_l
|
|
|
|
|
&& isym->n_sclass != C_EXT
|
|
|
|
|
&& (isym->n_sclass != C_HIDEXT || smtyp != XTY_SD)
|
|
|
|
|
&& bfd_is_local_label_name (input_bfd, name))
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Build the .loader section. This is called by the XCOFF linker
|
|
|
|
|
emulation before_allocation routine. We must set the size of the
|
|
|
|
|
.loader section before the linker lays out the output file.
|
|
|
|
|
LIBPATH is the library path to search for shared objects; this is
|
|
|
|
|
normally built from the -L arguments passed to the linker. ENTRY
|
|
|
|
|
is the name of the entry point symbol (the -e linker option).
|
|
|
|
|
FILE_ALIGN is the alignment to use for sections within the file
|
|
|
|
|
(the -H linker option). MAXSTACK is the maximum stack size (the
|
|
|
|
|
-bmaxstack linker option). MAXDATA is the maximum data size (the
|
|
|
|
|
-bmaxdata linker option). GC is whether to do garbage collection
|
|
|
|
|
(the -bgc linker option). MODTYPE is the module type (the
|
|
|
|
|
-bmodtype linker option). TEXTRO is whether the text section must
|
|
|
|
|
be read only (the -btextro linker option). EXPORT_DEFINEDS is
|
|
|
|
|
whether all defined symbols should be exported (the -unix linker
|
|
|
|
|
option). SPECIAL_SECTIONS is set by this routine to csects with
|
|
|
|
|
magic names like _end. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_boolean
|
|
|
|
|
bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
const char *libpath,
|
|
|
|
|
const char *entry,
|
|
|
|
|
unsigned long file_align,
|
|
|
|
|
unsigned long maxstack,
|
|
|
|
|
unsigned long maxdata,
|
|
|
|
|
bfd_boolean gc,
|
|
|
|
|
int modtype,
|
|
|
|
|
bfd_boolean textro,
|
|
|
|
|
bfd_boolean export_defineds,
|
|
|
|
|
asection **special_sections,
|
|
|
|
|
bfd_boolean rtld)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *hentry;
|
|
|
|
|
asection *lsec;
|
|
|
|
|
struct xcoff_loader_info ldinfo;
|
|
|
|
|
int i;
|
|
|
|
|
size_t impsize, impcount;
|
|
|
|
|
struct xcoff_import_file *fl;
|
|
|
|
|
struct internal_ldhdr *ldhdr;
|
|
|
|
|
bfd_size_type stoff;
|
|
|
|
|
char *out;
|
|
|
|
|
asection *sec;
|
|
|
|
|
bfd *sub;
|
|
|
|
|
struct bfd_strtab_hash *debug_strtab;
|
|
|
|
|
bfd_byte *debug_contents = NULL;
|
|
|
|
|
bfd_size_type amt;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++)
|
|
|
|
|
special_sections[i] = NULL;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldinfo.failed = FALSE;
|
|
|
|
|
ldinfo.output_bfd = output_bfd;
|
|
|
|
|
ldinfo.info = info;
|
|
|
|
|
ldinfo.export_defineds = export_defineds;
|
|
|
|
|
ldinfo.ldsym_count = 0;
|
|
|
|
|
ldinfo.string_size = 0;
|
|
|
|
|
ldinfo.strings = NULL;
|
|
|
|
|
ldinfo.string_alc = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_data (output_bfd)->maxstack = maxstack;
|
|
|
|
|
xcoff_data (output_bfd)->maxdata = maxdata;
|
|
|
|
|
xcoff_data (output_bfd)->modtype = modtype;
|
2002-03-18 20:46:27 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_hash_table (info)->file_align = file_align;
|
|
|
|
|
xcoff_hash_table (info)->textro = textro;
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
xcoff_hash_table (info)->rtld = rtld;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
hentry = NULL;
|
|
|
|
|
if (entry != NULL)
|
|
|
|
|
{
|
|
|
|
|
hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry,
|
|
|
|
|
FALSE, FALSE, TRUE);
|
|
|
|
|
if (hentry != NULL)
|
|
|
|
|
hentry->flags |= XCOFF_ENTRY;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* __rtinit */
|
|
|
|
|
if (info->init_function || info->fini_function || rtld)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *hsym;
|
|
|
|
|
struct internal_ldsym *ldsym;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
hsym = xcoff_link_hash_lookup (xcoff_hash_table (info),
|
|
|
|
|
"__rtinit", FALSE, FALSE, TRUE);
|
|
|
|
|
if (hsym == NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("error: undefined symbol __rtinit"));
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_mark_symbol (info, hsym);
|
|
|
|
|
hsym->flags |= (XCOFF_DEF_REGULAR | XCOFF_RTINIT);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* __rtinit initialized. */
|
|
|
|
|
amt = sizeof (* ldsym);
|
|
|
|
|
ldsym = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldsym->l_value = 0; /* Will be filled in later. */
|
|
|
|
|
ldsym->l_scnum = 2; /* Data section. */
|
|
|
|
|
ldsym->l_smtype = XTY_SD; /* Csect section definition. */
|
|
|
|
|
ldsym->l_smclas = 5; /* .rw. */
|
|
|
|
|
ldsym->l_ifile = 0; /* Special system loader symbol. */
|
|
|
|
|
ldsym->l_parm = 0; /* NA. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Force __rtinit to be the first symbol in the loader symbol table
|
|
|
|
|
See xcoff_build_ldsyms
|
2002-11-30 16:39:46 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
The first 3 symbol table indices are reserved to indicate the data,
|
|
|
|
|
text and bss sections. */
|
|
|
|
|
BFD_ASSERT (0 == ldinfo.ldsym_count);
|
2001-12-23 01:18:34 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
hsym->ldindx = 3;
|
|
|
|
|
ldinfo.ldsym_count = 1;
|
|
|
|
|
hsym->ldsym = ldsym;
|
2001-12-23 01:18:34 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! bfd_xcoff_put_ldsymbol_name (ldinfo.output_bfd, &ldinfo,
|
|
|
|
|
hsym->ldsym, hsym->root.root.string))
|
|
|
|
|
return FALSE;
|
2001-12-23 01:18:34 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This symbol is written out by xcoff_write_global_symbol
|
|
|
|
|
Set stuff up so xcoff_write_global_symbol logic works. */
|
|
|
|
|
hsym->flags |= XCOFF_DEF_REGULAR | XCOFF_MARK;
|
|
|
|
|
hsym->root.type = bfd_link_hash_defined;
|
|
|
|
|
hsym->root.u.def.value = 0;
|
|
|
|
|
}
|
2001-12-23 01:18:34 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Garbage collect unused sections. */
|
|
|
|
|
if (info->relocatable
|
|
|
|
|
|| ! gc
|
|
|
|
|
|| hentry == NULL
|
|
|
|
|
|| (hentry->root.type != bfd_link_hash_defined
|
|
|
|
|
&& hentry->root.type != bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
gc = FALSE;
|
|
|
|
|
xcoff_hash_table (info)->gc = FALSE;
|
2001-12-23 01:18:34 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We still need to call xcoff_mark, in order to set ldrel_count
|
|
|
|
|
correctly. */
|
|
|
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
|
|
|
|
{
|
|
|
|
|
asection *o;
|
2001-12-23 01:18:34 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (o = sub->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
2009-03-14 17:18:22 +08:00
|
|
|
|
/* We shouldn't unconditionaly mark the TOC section.
|
|
|
|
|
The output file should only have a TOC if either
|
|
|
|
|
(a) one of the input files did or (b) we end up
|
|
|
|
|
creating TOC references as part of the link process. */
|
|
|
|
|
if (o != xcoff_hash_table (info)->toc_section
|
|
|
|
|
&& (o->flags & SEC_MARK) == 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
if (! xcoff_mark (info, o))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! xcoff_mark (info, hentry->root.u.def.section))
|
|
|
|
|
goto error_return;
|
|
|
|
|
xcoff_sweep (info);
|
|
|
|
|
xcoff_hash_table (info)->gc = TRUE;
|
|
|
|
|
}
|
2001-12-23 01:18:34 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Return special sections to the caller. */
|
|
|
|
|
for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++)
|
|
|
|
|
{
|
|
|
|
|
sec = xcoff_hash_table (info)->special_sections[i];
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (sec != NULL
|
|
|
|
|
&& gc
|
|
|
|
|
&& (sec->flags & SEC_MARK) == 0)
|
|
|
|
|
sec = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
special_sections[i] = sec;
|
|
|
|
|
}
|
2002-03-28 11:27:46 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (info->input_bfds == NULL)
|
|
|
|
|
/* I'm not sure what to do in this bizarre case. */
|
|
|
|
|
return TRUE;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_link_hash_traverse (xcoff_hash_table (info), xcoff_build_ldsyms,
|
|
|
|
|
(void *) &ldinfo);
|
|
|
|
|
if (ldinfo.failed)
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Work out the size of the import file names. Each import file ID
|
|
|
|
|
consists of three null terminated strings: the path, the file
|
|
|
|
|
name, and the archive member name. The first entry in the list
|
|
|
|
|
of names is the path to use to find objects, which the linker has
|
|
|
|
|
passed in as the libpath argument. For some reason, the path
|
|
|
|
|
entry in the other import file names appears to always be empty. */
|
|
|
|
|
impsize = strlen (libpath) + 3;
|
|
|
|
|
impcount = 1;
|
|
|
|
|
for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
++impcount;
|
|
|
|
|
impsize += (strlen (fl->path)
|
|
|
|
|
+ strlen (fl->file)
|
|
|
|
|
+ strlen (fl->member)
|
|
|
|
|
+ 3);
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Set up the .loader section header. */
|
|
|
|
|
ldhdr = &xcoff_hash_table (info)->ldhdr;
|
|
|
|
|
ldhdr->l_version = bfd_xcoff_ldhdr_version(output_bfd);
|
|
|
|
|
ldhdr->l_nsyms = ldinfo.ldsym_count;
|
|
|
|
|
ldhdr->l_nreloc = xcoff_hash_table (info)->ldrel_count;
|
|
|
|
|
ldhdr->l_istlen = impsize;
|
|
|
|
|
ldhdr->l_nimpid = impcount;
|
|
|
|
|
ldhdr->l_impoff = (bfd_xcoff_ldhdrsz(output_bfd)
|
|
|
|
|
+ ldhdr->l_nsyms * bfd_xcoff_ldsymsz(output_bfd)
|
|
|
|
|
+ ldhdr->l_nreloc * bfd_xcoff_ldrelsz(output_bfd));
|
|
|
|
|
ldhdr->l_stlen = ldinfo.string_size;
|
|
|
|
|
stoff = ldhdr->l_impoff + impsize;
|
|
|
|
|
if (ldinfo.string_size == 0)
|
|
|
|
|
ldhdr->l_stoff = 0;
|
|
|
|
|
else
|
|
|
|
|
ldhdr->l_stoff = stoff;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* 64 bit elements to ldhdr
|
|
|
|
|
The swap out routine for 32 bit will ignore them.
|
|
|
|
|
Nothing fancy, symbols come after the header and relocs come
|
|
|
|
|
after symbols. */
|
|
|
|
|
ldhdr->l_symoff = bfd_xcoff_ldhdrsz (output_bfd);
|
|
|
|
|
ldhdr->l_rldoff = (bfd_xcoff_ldhdrsz (output_bfd)
|
|
|
|
|
+ ldhdr->l_nsyms * bfd_xcoff_ldsymsz (output_bfd));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We now know the final size of the .loader section. Allocate
|
|
|
|
|
space for it. */
|
|
|
|
|
lsec = xcoff_hash_table (info)->loader_section;
|
|
|
|
|
lsec->size = stoff + ldhdr->l_stlen;
|
|
|
|
|
lsec->contents = bfd_zalloc (output_bfd, lsec->size);
|
|
|
|
|
if (lsec->contents == NULL)
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Set up the header. */
|
|
|
|
|
bfd_xcoff_swap_ldhdr_out (output_bfd, ldhdr, lsec->contents);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Set up the import file names. */
|
|
|
|
|
out = (char *) lsec->contents + ldhdr->l_impoff;
|
|
|
|
|
strcpy (out, libpath);
|
|
|
|
|
out += strlen (libpath) + 1;
|
|
|
|
|
*out++ = '\0';
|
|
|
|
|
*out++ = '\0';
|
|
|
|
|
for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
const char *s;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
s = fl->path;
|
|
|
|
|
while ((*out++ = *s++) != '\0')
|
|
|
|
|
;
|
|
|
|
|
s = fl->file;
|
|
|
|
|
while ((*out++ = *s++) != '\0')
|
|
|
|
|
;
|
|
|
|
|
s = fl->member;
|
|
|
|
|
while ((*out++ = *s++) != '\0')
|
|
|
|
|
;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT ((bfd_size_type) ((bfd_byte *) out - lsec->contents) == stoff);
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Set up the symbol string table. */
|
|
|
|
|
if (ldinfo.string_size > 0)
|
|
|
|
|
{
|
|
|
|
|
memcpy (out, ldinfo.strings, ldinfo.string_size);
|
|
|
|
|
free (ldinfo.strings);
|
|
|
|
|
ldinfo.strings = NULL;
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We can't set up the symbol table or the relocs yet, because we
|
|
|
|
|
don't yet know the final position of the various sections. The
|
|
|
|
|
.loader symbols are written out when the corresponding normal
|
|
|
|
|
symbols are written out in xcoff_link_input_bfd or
|
|
|
|
|
xcoff_write_global_symbol. The .loader relocs are written out
|
|
|
|
|
when the corresponding normal relocs are handled in
|
|
|
|
|
xcoff_link_input_bfd. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Allocate space for the magic sections. */
|
|
|
|
|
sec = xcoff_hash_table (info)->linkage_section;
|
|
|
|
|
if (sec->size > 0)
|
|
|
|
|
{
|
|
|
|
|
sec->contents = bfd_zalloc (output_bfd, sec->size);
|
|
|
|
|
if (sec->contents == NULL)
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
sec = xcoff_hash_table (info)->toc_section;
|
|
|
|
|
if (sec->size > 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
sec->contents = bfd_zalloc (output_bfd, sec->size);
|
|
|
|
|
if (sec->contents == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
sec = xcoff_hash_table (info)->descriptor_section;
|
|
|
|
|
if (sec->size > 0)
|
|
|
|
|
{
|
|
|
|
|
sec->contents = bfd_zalloc (output_bfd, sec->size);
|
|
|
|
|
if (sec->contents == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* Now that we've done garbage collection, decide which symbols to keep,
|
|
|
|
|
and figure out the contents of the .debug section. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
debug_strtab = xcoff_hash_table (info)->debug_strtab;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
|
|
|
|
{
|
|
|
|
|
asection *subdeb;
|
|
|
|
|
bfd_size_type symcount;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
long *debug_index;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
asection **csectpp;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
unsigned int *lineno_counts;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
struct xcoff_link_hash_entry **sym_hash;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_byte *esym, *esymend;
|
|
|
|
|
bfd_size_type symesz;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2008-02-15 11:35:53 +08:00
|
|
|
|
if (sub->xvec != info->output_bfd->xvec)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
continue;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if ((sub->flags & DYNAMIC) != 0
|
|
|
|
|
&& !info->static_link)
|
|
|
|
|
continue;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! _bfd_coff_get_external_symbols (sub))
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
symcount = obj_raw_syment_count (sub);
|
2009-03-14 17:32:06 +08:00
|
|
|
|
debug_index = bfd_zalloc (sub, symcount * sizeof (long));
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (debug_index == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
xcoff_data (sub)->debug_indices = debug_index;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (info->strip == strip_all
|
|
|
|
|
|| info->strip == strip_debugger
|
|
|
|
|
|| info->discard == discard_all)
|
|
|
|
|
/* We're stripping all debugging information, so there's no need
|
|
|
|
|
to read SUB's .debug section. */
|
|
|
|
|
subdeb = NULL;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Grab the contents of SUB's .debug section, if any. */
|
|
|
|
|
subdeb = bfd_get_section_by_name (sub, ".debug");
|
|
|
|
|
if (subdeb != NULL && subdeb->size > 0)
|
|
|
|
|
{
|
|
|
|
|
/* We use malloc and copy the names into the debug
|
|
|
|
|
stringtab, rather than bfd_alloc, because I expect
|
|
|
|
|
that, when linking many files together, many of the
|
|
|
|
|
strings will be the same. Storing the strings in the
|
|
|
|
|
hash table should save space in this case. */
|
|
|
|
|
if (!bfd_malloc_and_get_section (sub, subdeb, &debug_contents))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
csectpp = xcoff_data (sub)->csects;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
lineno_counts = xcoff_data (sub)->lineno_counts;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
sym_hash = obj_xcoff_sym_hashes (sub);
|
|
|
|
|
symesz = bfd_coff_symesz (sub);
|
|
|
|
|
esym = (bfd_byte *) obj_coff_external_syms (sub);
|
|
|
|
|
esymend = esym + symcount * symesz;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
while (esym < esymend)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
2009-03-14 17:32:06 +08:00
|
|
|
|
struct internal_syment sym;
|
|
|
|
|
union internal_auxent aux;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
asection *csect;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
const char *name;
|
|
|
|
|
int keep_p;
|
|
|
|
|
|
|
|
|
|
bfd_coff_swap_sym_in (sub, esym, &sym);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* If this is a C_EXT or C_HIDEXT symbol, we need the csect
|
|
|
|
|
information too. */
|
|
|
|
|
if (sym.n_sclass == C_EXT || sym.n_sclass == C_HIDEXT)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
2009-03-14 17:32:06 +08:00
|
|
|
|
BFD_ASSERT (sym.n_numaux > 0);
|
|
|
|
|
bfd_coff_swap_aux_in (sub, esym + symesz * sym.n_numaux,
|
|
|
|
|
sym.n_type, sym.n_sclass,
|
|
|
|
|
sym.n_numaux - 1, sym.n_numaux, &aux);
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* If this symbol's name is stored in the debug section,
|
|
|
|
|
get a pointer to it. */
|
|
|
|
|
if (debug_contents != NULL
|
|
|
|
|
&& sym._n._n_n._n_zeroes == 0
|
|
|
|
|
&& bfd_coff_symname_in_debug (sub, &sym))
|
|
|
|
|
name = (const char *) debug_contents + sym._n._n_n._n_offset;
|
|
|
|
|
else
|
|
|
|
|
name = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* Decide whether to copy this symbol to the output file. */
|
2009-03-14 17:32:33 +08:00
|
|
|
|
csect = *csectpp;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
keep_p = xcoff_keep_symbol_p (info, sub, &sym, &aux,
|
2009-03-14 17:32:33 +08:00
|
|
|
|
*sym_hash, csect, name);
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (keep_p < 0)
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (!keep_p)
|
|
|
|
|
/* Use a debug_index of -2 to record that a symbol should
|
|
|
|
|
be stripped. */
|
|
|
|
|
*debug_index = -2;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* See whether we should store the symbol name in the
|
|
|
|
|
output .debug section. */
|
|
|
|
|
if (name != NULL)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
bfd_size_type indx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
indx = _bfd_stringtab_add (debug_strtab, name, TRUE, TRUE);
|
|
|
|
|
if (indx == (bfd_size_type) -1)
|
|
|
|
|
goto error_return;
|
|
|
|
|
*debug_index = indx;
|
|
|
|
|
}
|
2009-03-14 17:32:06 +08:00
|
|
|
|
else
|
|
|
|
|
*debug_index = -1;
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
if (*sym_hash != 0)
|
|
|
|
|
(*sym_hash)->flags |= XCOFF_ALLOCATED;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
if (*lineno_counts > 0)
|
|
|
|
|
csect->output_section->lineno_count += *lineno_counts;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
2009-03-14 17:32:06 +08:00
|
|
|
|
|
|
|
|
|
esym += (sym.n_numaux + 1) * symesz;
|
|
|
|
|
csectpp += sym.n_numaux + 1;
|
|
|
|
|
sym_hash += sym.n_numaux + 1;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
lineno_counts += sym.n_numaux + 1;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
debug_index += sym.n_numaux + 1;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (debug_contents)
|
|
|
|
|
{
|
|
|
|
|
free (debug_contents);
|
|
|
|
|
debug_contents = NULL;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* Clear the size of subdeb, so that it is not included directly
|
|
|
|
|
in the output file. */
|
|
|
|
|
subdeb->size = 0;
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
if (! info->keep_memory)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_coff_free_symbols (sub))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (info->strip != strip_all)
|
|
|
|
|
xcoff_hash_table (info)->debug_section->size =
|
|
|
|
|
_bfd_stringtab_size (debug_strtab);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
error_return:
|
|
|
|
|
if (ldinfo.strings != NULL)
|
|
|
|
|
free (ldinfo.strings);
|
|
|
|
|
if (debug_contents != NULL)
|
|
|
|
|
free (debug_contents);
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_link_generate_rtinit (bfd *abfd,
|
|
|
|
|
const char *init,
|
|
|
|
|
const char *fini,
|
|
|
|
|
bfd_boolean rtld)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct bfd_in_memory *bim;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bim = bfd_malloc ((bfd_size_type) sizeof (* bim));
|
|
|
|
|
if (bim == NULL)
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bim->size = 0;
|
|
|
|
|
bim->buffer = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
abfd->link_next = 0;
|
|
|
|
|
abfd->format = bfd_object;
|
|
|
|
|
abfd->iostream = (void *) bim;
|
|
|
|
|
abfd->flags = BFD_IN_MEMORY;
|
|
|
|
|
abfd->direction = write_direction;
|
|
|
|
|
abfd->where = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! bfd_xcoff_generate_rtinit (abfd, init, fini, rtld))
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* need to reset to unknown or it will not be read back in correctly */
|
|
|
|
|
abfd->format = bfd_unknown;
|
|
|
|
|
abfd->direction = read_direction;
|
|
|
|
|
abfd->where = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Link an input file into the linker output file. This function
|
|
|
|
|
handles all the sections and relocations of the input file at once. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_link_input_bfd (struct xcoff_final_link_info *finfo,
|
|
|
|
|
bfd *input_bfd)
|
|
|
|
|
{
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
const char *strings;
|
|
|
|
|
bfd_size_type syment_base;
|
|
|
|
|
unsigned int n_tmask;
|
|
|
|
|
unsigned int n_btshft;
|
|
|
|
|
bfd_boolean copy, hash;
|
|
|
|
|
bfd_size_type isymesz;
|
|
|
|
|
bfd_size_type osymesz;
|
|
|
|
|
bfd_size_type linesz;
|
|
|
|
|
bfd_byte *esym;
|
|
|
|
|
bfd_byte *esym_end;
|
|
|
|
|
struct xcoff_link_hash_entry **sym_hash;
|
|
|
|
|
struct internal_syment *isymp;
|
|
|
|
|
asection **csectpp;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
unsigned int *lineno_counts;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
long *debug_index;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
long *indexp;
|
|
|
|
|
unsigned long output_index;
|
|
|
|
|
bfd_byte *outsym;
|
|
|
|
|
unsigned int incls;
|
|
|
|
|
asection *oline;
|
|
|
|
|
bfd_boolean keep_syms;
|
|
|
|
|
asection *o;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We can just skip DYNAMIC files, unless this is a static link. */
|
|
|
|
|
if ((input_bfd->flags & DYNAMIC) != 0
|
|
|
|
|
&& ! finfo->info->static_link)
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Move all the symbols to the output file. */
|
|
|
|
|
output_bfd = finfo->output_bfd;
|
|
|
|
|
strings = NULL;
|
|
|
|
|
syment_base = obj_raw_syment_count (output_bfd);
|
|
|
|
|
isymesz = bfd_coff_symesz (input_bfd);
|
|
|
|
|
osymesz = bfd_coff_symesz (output_bfd);
|
|
|
|
|
linesz = bfd_coff_linesz (input_bfd);
|
|
|
|
|
BFD_ASSERT (linesz == bfd_coff_linesz (output_bfd));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
n_tmask = coff_data (input_bfd)->local_n_tmask;
|
|
|
|
|
n_btshft = coff_data (input_bfd)->local_n_btshft;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Define macros so that ISFCN, et. al., macros work correctly. */
|
|
|
|
|
#define N_TMASK n_tmask
|
|
|
|
|
#define N_BTSHFT n_btshft
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
copy = FALSE;
|
|
|
|
|
if (! finfo->info->keep_memory)
|
|
|
|
|
copy = TRUE;
|
|
|
|
|
hash = TRUE;
|
|
|
|
|
if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
|
|
|
|
|
hash = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! _bfd_coff_get_external_symbols (input_bfd))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* Make one pass over the symbols and assign indices to symbols that
|
|
|
|
|
we have decided to keep. Also use create .loader symbol information
|
|
|
|
|
and update information in hash table entries. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
|
|
|
|
|
esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
|
|
|
|
|
sym_hash = obj_xcoff_sym_hashes (input_bfd);
|
|
|
|
|
csectpp = xcoff_data (input_bfd)->csects;
|
|
|
|
|
debug_index = xcoff_data (input_bfd)->debug_indices;
|
|
|
|
|
isymp = finfo->internal_syms;
|
|
|
|
|
indexp = finfo->sym_indices;
|
|
|
|
|
output_index = syment_base;
|
|
|
|
|
while (esym < esym_end)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
union internal_auxent aux;
|
|
|
|
|
int smtyp = 0;
|
|
|
|
|
int add;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_sym_in (input_bfd, (void *) esym, (void *) isymp);
|
2002-11-30 16:39:46 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If this is a C_EXT or C_HIDEXT symbol, we need the csect
|
|
|
|
|
information. */
|
|
|
|
|
if (isymp->n_sclass == C_EXT || isymp->n_sclass == C_HIDEXT)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (isymp->n_numaux > 0);
|
|
|
|
|
bfd_coff_swap_aux_in (input_bfd,
|
|
|
|
|
(void *) (esym + isymesz * isymp->n_numaux),
|
|
|
|
|
isymp->n_type, isymp->n_sclass,
|
|
|
|
|
isymp->n_numaux - 1, isymp->n_numaux,
|
|
|
|
|
(void *) &aux);
|
2002-11-30 16:39:46 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
smtyp = SMTYP_SMTYP (aux.x_csect.x_smtyp);
|
|
|
|
|
}
|
2002-11-30 16:39:46 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If this symbol is in the .loader section, swap out the
|
|
|
|
|
.loader symbol information. If this is an external symbol
|
|
|
|
|
reference to a defined symbol, though, then wait until we get
|
|
|
|
|
to the definition. */
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (isymp->n_sclass == C_EXT
|
2005-04-11 16:23:05 +08:00
|
|
|
|
&& *sym_hash != NULL
|
|
|
|
|
&& (*sym_hash)->ldsym != NULL
|
include/coff/
* xcoff.h (XCOFF_ALLOCATED): New flag.
bfd/
* xcofflink.c (xcoff_mark): When walking the relocations,
only mark the target symbol or the target section, not both.
(xcoff_final_definition_p): New function.
(xcoff_keep_symbol_p): Use it to check whether an external XCOFF
symbol is a valid definition of the associated output symbol.
Use XCOFF_ALLOCATED to stop the same hash table entry having
two output symbols.
(bfd_xcoff_size_dynamic_sections): Set XCOFF_ALLOCATED when
keeping a symbol.
(xcoff_link_input_bfd): Use xcoff_final_definition_p.
ld/testsuite/
* ld-powerpc/aix-no-dup-syms-1a.s, ld-powerpc/aix-no-dup-syms-1b.s,
ld-powerpc/aix-no-dup-syms-1.ex, ld-powerpc/aix-no-dup-syms-1.im,
ld-powerpc/aix-no-dup-syms-1-dso.dnd,
ld-powerpc/aix-no-dup-syms-1-dso.drd,
ld-powerpc/aix-no-dup-syms-1-dso.nd,
ld-powerpc/aix-no-dup-syms-1-dso.rd,
ld-powerpc/aix-no-dup-syms-1-rel.nd,
ld-powerpc/aix-no-dup-syms-1-rel.rd: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:33:39 +08:00
|
|
|
|
&& xcoff_final_definition_p (input_bfd, *sym_hash, *csectpp))
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
struct internal_ldsym *ldsym;
|
2002-01-05 21:11:33 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h = *sym_hash;
|
|
|
|
|
ldsym = h->ldsym;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (isymp->n_scnum > 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
ldsym->l_scnum = (*csectpp)->output_section->target_index;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
ldsym->l_value = (isymp->n_value
|
2005-04-11 16:23:05 +08:00
|
|
|
|
+ (*csectpp)->output_section->vma
|
|
|
|
|
+ (*csectpp)->output_offset
|
|
|
|
|
- (*csectpp)->vma);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2009-03-14 17:32:06 +08:00
|
|
|
|
ldsym->l_scnum = isymp->n_scnum;
|
|
|
|
|
ldsym->l_value = isymp->n_value;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldsym->l_smtype = smtyp;
|
|
|
|
|
if (((h->flags & XCOFF_DEF_REGULAR) == 0
|
|
|
|
|
&& (h->flags & XCOFF_DEF_DYNAMIC) != 0)
|
|
|
|
|
|| (h->flags & XCOFF_IMPORT) != 0)
|
|
|
|
|
ldsym->l_smtype |= L_IMPORT;
|
|
|
|
|
if (((h->flags & XCOFF_DEF_REGULAR) != 0
|
|
|
|
|
&& (h->flags & XCOFF_DEF_DYNAMIC) != 0)
|
|
|
|
|
|| (h->flags & XCOFF_EXPORT) != 0)
|
|
|
|
|
ldsym->l_smtype |= L_EXPORT;
|
|
|
|
|
if ((h->flags & XCOFF_ENTRY) != 0)
|
|
|
|
|
ldsym->l_smtype |= L_ENTRY;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldsym->l_smclas = aux.x_csect.x_smclas;
|
|
|
|
|
|
|
|
|
|
if (ldsym->l_ifile == (bfd_size_type) -1)
|
|
|
|
|
ldsym->l_ifile = 0;
|
|
|
|
|
else if (ldsym->l_ifile == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((ldsym->l_smtype & L_IMPORT) == 0)
|
|
|
|
|
ldsym->l_ifile = 0;
|
|
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd *impbfd;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
impbfd = h->root.u.def.section->owner;
|
|
|
|
|
else if (h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak)
|
|
|
|
|
impbfd = h->root.u.undef.abfd;
|
|
|
|
|
else
|
|
|
|
|
impbfd = NULL;
|
|
|
|
|
|
|
|
|
|
if (impbfd == NULL)
|
|
|
|
|
ldsym->l_ifile = 0;
|
|
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT (impbfd->xvec == finfo->output_bfd->xvec);
|
|
|
|
|
ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ldsym->l_parm = 0;
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (h->ldindx >= 0);
|
|
|
|
|
bfd_xcoff_swap_ldsym_out (finfo->output_bfd, ldsym,
|
|
|
|
|
(finfo->ldsym
|
|
|
|
|
+ ((h->ldindx - 3)
|
|
|
|
|
* bfd_xcoff_ldsymsz (finfo->output_bfd))));
|
|
|
|
|
h->ldsym = NULL;
|
|
|
|
|
|
|
|
|
|
/* Fill in snentry now that we know the target_index. */
|
|
|
|
|
if ((h->flags & XCOFF_ENTRY) != 0
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
xcoff_data (output_bfd)->snentry =
|
|
|
|
|
h->root.u.def.section->output_section->target_index;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
add = 1 + isymp->n_numaux;
|
|
|
|
|
|
|
|
|
|
if (*debug_index == -2)
|
|
|
|
|
/* We've decided to strip this symbol. */
|
|
|
|
|
*indexp = -1;
|
|
|
|
|
else
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* Assign the next unused index to this symbol. */
|
|
|
|
|
*indexp = output_index;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (isymp->n_sclass == C_EXT)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (*sym_hash != NULL);
|
|
|
|
|
(*sym_hash)->indx = output_index;
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* If this is a symbol in the TOC which we may have merged
|
|
|
|
|
(class XMC_TC), remember the symbol index of the TOC
|
|
|
|
|
symbol. */
|
|
|
|
|
if (isymp->n_sclass == C_HIDEXT
|
|
|
|
|
&& aux.x_csect.x_smclas == XMC_TC
|
|
|
|
|
&& *sym_hash != NULL)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (((*sym_hash)->flags & XCOFF_SET_TOC) == 0);
|
|
|
|
|
BFD_ASSERT ((*sym_hash)->toc_section != NULL);
|
|
|
|
|
(*sym_hash)->u.toc_indx = output_index;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
output_index += add;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
esym += add * isymesz;
|
|
|
|
|
isymp += add;
|
|
|
|
|
csectpp += add;
|
|
|
|
|
sym_hash += add;
|
|
|
|
|
debug_index += add;
|
|
|
|
|
++indexp;
|
|
|
|
|
for (--add; add > 0; --add)
|
|
|
|
|
*indexp++ = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now write out the symbols that we decided to keep. */
|
|
|
|
|
|
|
|
|
|
esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
|
|
|
|
|
esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
|
|
|
|
|
isymp = finfo->internal_syms;
|
|
|
|
|
indexp = finfo->sym_indices;
|
|
|
|
|
csectpp = xcoff_data (input_bfd)->csects;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
lineno_counts = xcoff_data (input_bfd)->lineno_counts;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
debug_index = xcoff_data (input_bfd)->debug_indices;
|
|
|
|
|
outsym = finfo->outsyms;
|
|
|
|
|
incls = 0;
|
|
|
|
|
oline = NULL;
|
|
|
|
|
while (esym < esym_end)
|
|
|
|
|
{
|
|
|
|
|
int add;
|
|
|
|
|
|
|
|
|
|
add = 1 + isymp->n_numaux;
|
|
|
|
|
|
|
|
|
|
if (*indexp < 0)
|
|
|
|
|
esym += add * isymesz;
|
|
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2009-03-14 17:32:06 +08:00
|
|
|
|
struct internal_syment isym;
|
|
|
|
|
int i;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* Adjust the symbol in order to output it. */
|
|
|
|
|
isym = *isymp;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (isym._n._n_n._n_zeroes == 0
|
|
|
|
|
&& isym._n._n_n._n_offset != 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This symbol has a long name. Enter it in the string
|
|
|
|
|
table we are building. If *debug_index != -1, the
|
|
|
|
|
name has already been entered in the .debug section. */
|
2009-03-14 17:32:06 +08:00
|
|
|
|
if (*debug_index >= 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
isym._n._n_n._n_offset = *debug_index;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
bfd_size_type indx;
|
|
|
|
|
|
|
|
|
|
name = _bfd_coff_internal_syment_name (input_bfd, &isym, NULL);
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
indx = _bfd_stringtab_add (finfo->strtab, name, hash, copy);
|
|
|
|
|
if (indx == (bfd_size_type) -1)
|
|
|
|
|
return FALSE;
|
|
|
|
|
isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
/* The value of a C_FILE symbol is the symbol index of the
|
|
|
|
|
next C_FILE symbol. The value of the last C_FILE symbol
|
|
|
|
|
is -1. We try to get this right, below, just before we
|
|
|
|
|
write the symbols out, but in the general case we may
|
|
|
|
|
have to write the symbol out twice. */
|
|
|
|
|
if (isym.n_sclass == C_FILE)
|
|
|
|
|
{
|
|
|
|
|
if (finfo->last_file_index != -1
|
2009-03-14 17:32:06 +08:00
|
|
|
|
&& finfo->last_file.n_value != (bfd_vma) *indexp)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
/* We must correct the value of the last C_FILE entry. */
|
2009-03-14 17:32:06 +08:00
|
|
|
|
finfo->last_file.n_value = *indexp;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((bfd_size_type) finfo->last_file_index >= syment_base)
|
|
|
|
|
{
|
|
|
|
|
/* The last C_FILE symbol is in this input file. */
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd,
|
|
|
|
|
(void *) &finfo->last_file,
|
|
|
|
|
(void *) (finfo->outsyms
|
|
|
|
|
+ ((finfo->last_file_index
|
|
|
|
|
- syment_base)
|
|
|
|
|
* osymesz)));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We have already written out the last C_FILE
|
|
|
|
|
symbol. We need to write it out again. We
|
|
|
|
|
borrow *outsym temporarily. */
|
|
|
|
|
file_ptr pos;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_sym_out (output_bfd,
|
|
|
|
|
(void *) &finfo->last_file,
|
|
|
|
|
(void *) outsym);
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
pos = obj_sym_filepos (output_bfd);
|
|
|
|
|
pos += finfo->last_file_index * osymesz;
|
|
|
|
|
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| (bfd_bwrite (outsym, osymesz, output_bfd)
|
|
|
|
|
!= osymesz))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:06 +08:00
|
|
|
|
finfo->last_file_index = *indexp;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
finfo->last_file = isym;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* The value of a C_BINCL or C_EINCL symbol is a file offset
|
|
|
|
|
into the line numbers. We update the symbol values when
|
|
|
|
|
we handle the line numbers. */
|
|
|
|
|
if (isym.n_sclass == C_BINCL
|
|
|
|
|
|| isym.n_sclass == C_EINCL)
|
|
|
|
|
{
|
|
|
|
|
isym.n_value = finfo->line_filepos;
|
|
|
|
|
++incls;
|
|
|
|
|
}
|
2009-03-14 17:32:06 +08:00
|
|
|
|
/* The value of a C_BSTAT symbol is the symbol table
|
|
|
|
|
index of the containing csect. */
|
|
|
|
|
else if (isym.n_sclass == C_BSTAT)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
bfd_vma indx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
indx = isym.n_value;
|
|
|
|
|
if (indx < obj_raw_syment_count (input_bfd))
|
|
|
|
|
{
|
|
|
|
|
long symindx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
symindx = finfo->sym_indices[indx];
|
|
|
|
|
if (symindx < 0)
|
|
|
|
|
isym.n_value = 0;
|
|
|
|
|
else
|
|
|
|
|
isym.n_value = symindx;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-03-14 17:32:06 +08:00
|
|
|
|
else if (isym.n_sclass != C_ESTAT
|
|
|
|
|
&& isym.n_sclass != C_DECL
|
|
|
|
|
&& isym.n_scnum > 0)
|
|
|
|
|
{
|
|
|
|
|
isym.n_scnum = (*csectpp)->output_section->target_index;
|
|
|
|
|
isym.n_value += ((*csectpp)->output_section->vma
|
|
|
|
|
+ (*csectpp)->output_offset
|
|
|
|
|
- (*csectpp)->vma);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Output the symbol. */
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd, (void *) &isym, (void *) outsym);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
esym += isymesz;
|
|
|
|
|
outsym += osymesz;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (i = 0; i < isymp->n_numaux && esym < esym_end; i++)
|
|
|
|
|
{
|
|
|
|
|
union internal_auxent aux;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_aux_in (input_bfd, (void *) esym, isymp->n_type,
|
|
|
|
|
isymp->n_sclass, i, isymp->n_numaux,
|
|
|
|
|
(void *) &aux);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (isymp->n_sclass == C_FILE)
|
|
|
|
|
{
|
|
|
|
|
/* This is the file name (or some comment put in by
|
|
|
|
|
the compiler). If it is long, we must put it in
|
|
|
|
|
the string table. */
|
|
|
|
|
if (aux.x_file.x_n.x_zeroes == 0
|
|
|
|
|
&& aux.x_file.x_n.x_offset != 0)
|
|
|
|
|
{
|
|
|
|
|
const char *filename;
|
|
|
|
|
bfd_size_type indx;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT (aux.x_file.x_n.x_offset
|
|
|
|
|
>= STRING_SIZE_SIZE);
|
|
|
|
|
if (strings == NULL)
|
|
|
|
|
{
|
|
|
|
|
strings = _bfd_coff_read_string_table (input_bfd);
|
|
|
|
|
if (strings == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
filename = strings + aux.x_file.x_n.x_offset;
|
|
|
|
|
indx = _bfd_stringtab_add (finfo->strtab, filename,
|
|
|
|
|
hash, copy);
|
|
|
|
|
if (indx == (bfd_size_type) -1)
|
|
|
|
|
return FALSE;
|
|
|
|
|
aux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((isymp->n_sclass == C_EXT
|
|
|
|
|
|| isymp->n_sclass == C_HIDEXT)
|
|
|
|
|
&& i + 1 == isymp->n_numaux)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We don't support type checking. I don't know if
|
|
|
|
|
anybody does. */
|
|
|
|
|
aux.x_csect.x_parmhash = 0;
|
|
|
|
|
/* I don't think anybody uses these fields, but we'd
|
|
|
|
|
better clobber them just in case. */
|
|
|
|
|
aux.x_csect.x_stab = 0;
|
|
|
|
|
aux.x_csect.x_snstab = 0;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_LD)
|
|
|
|
|
{
|
|
|
|
|
unsigned long indx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
indx = aux.x_csect.x_scnlen.l;
|
|
|
|
|
if (indx < obj_raw_syment_count (input_bfd))
|
|
|
|
|
{
|
|
|
|
|
long symindx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
symindx = finfo->sym_indices[indx];
|
|
|
|
|
if (symindx < 0)
|
|
|
|
|
{
|
|
|
|
|
aux.x_csect.x_scnlen.l = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aux.x_csect.x_scnlen.l = symindx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (isymp->n_sclass != C_STAT || isymp->n_type != T_NULL)
|
|
|
|
|
{
|
|
|
|
|
unsigned long indx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (ISFCN (isymp->n_type)
|
|
|
|
|
|| ISTAG (isymp->n_sclass)
|
|
|
|
|
|| isymp->n_sclass == C_BLOCK
|
|
|
|
|
|| isymp->n_sclass == C_FCN)
|
|
|
|
|
{
|
|
|
|
|
indx = aux.x_sym.x_fcnary.x_fcn.x_endndx.l;
|
|
|
|
|
if (indx > 0
|
|
|
|
|
&& indx < obj_raw_syment_count (input_bfd))
|
|
|
|
|
{
|
|
|
|
|
/* We look forward through the symbol for
|
|
|
|
|
the index of the next symbol we are going
|
|
|
|
|
to include. I don't know if this is
|
|
|
|
|
entirely right. */
|
|
|
|
|
while (finfo->sym_indices[indx] < 0
|
|
|
|
|
&& indx < obj_raw_syment_count (input_bfd))
|
|
|
|
|
++indx;
|
|
|
|
|
if (indx >= obj_raw_syment_count (input_bfd))
|
|
|
|
|
indx = output_index;
|
|
|
|
|
else
|
|
|
|
|
indx = finfo->sym_indices[indx];
|
|
|
|
|
aux.x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
indx = aux.x_sym.x_tagndx.l;
|
|
|
|
|
if (indx > 0 && indx < obj_raw_syment_count (input_bfd))
|
|
|
|
|
{
|
|
|
|
|
long symindx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
symindx = finfo->sym_indices[indx];
|
|
|
|
|
if (symindx < 0)
|
|
|
|
|
aux.x_sym.x_tagndx.l = 0;
|
|
|
|
|
else
|
|
|
|
|
aux.x_sym.x_tagndx.l = symindx;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Copy over the line numbers, unless we are stripping
|
|
|
|
|
them. We do this on a symbol by symbol basis in
|
|
|
|
|
order to more easily handle garbage collection. */
|
|
|
|
|
if ((isymp->n_sclass == C_EXT
|
|
|
|
|
|| isymp->n_sclass == C_HIDEXT)
|
|
|
|
|
&& i == 0
|
|
|
|
|
&& isymp->n_numaux > 1
|
|
|
|
|
&& ISFCN (isymp->n_type)
|
|
|
|
|
&& aux.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0)
|
|
|
|
|
{
|
2009-03-14 17:32:33 +08:00
|
|
|
|
if (*lineno_counts == 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
aux.x_sym.x_fcnary.x_fcn.x_lnnoptr = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
asection *enclosing;
|
|
|
|
|
unsigned int enc_count;
|
|
|
|
|
bfd_signed_vma linoff;
|
|
|
|
|
struct internal_lineno lin;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
bfd_byte *linp;
|
|
|
|
|
bfd_byte *linpend;
|
|
|
|
|
bfd_vma offset;
|
|
|
|
|
file_ptr pos;
|
|
|
|
|
bfd_size_type amt;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:33 +08:00
|
|
|
|
/* Read in the enclosing section's line-number
|
|
|
|
|
information, if we haven't already. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
o = *csectpp;
|
|
|
|
|
enclosing = xcoff_section_data (abfd, o)->enclosing;
|
|
|
|
|
enc_count = xcoff_section_data (abfd, o)->lineno_count;
|
|
|
|
|
if (oline != enclosing)
|
|
|
|
|
{
|
2009-03-14 17:32:33 +08:00
|
|
|
|
pos = enclosing->line_filepos;
|
|
|
|
|
amt = linesz * enc_count;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (bfd_seek (input_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| (bfd_bread (finfo->linenos, amt, input_bfd)
|
|
|
|
|
!= amt))
|
|
|
|
|
return FALSE;
|
|
|
|
|
oline = enclosing;
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2009-03-14 17:32:33 +08:00
|
|
|
|
/* Copy across the first entry, adjusting its
|
|
|
|
|
symbol index. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
linoff = (aux.x_sym.x_fcnary.x_fcn.x_lnnoptr
|
|
|
|
|
- enclosing->line_filepos);
|
2009-03-14 17:32:33 +08:00
|
|
|
|
linp = finfo->linenos + linoff;
|
|
|
|
|
bfd_coff_swap_lineno_in (input_bfd, linp, &lin);
|
|
|
|
|
lin.l_addr.l_symndx = *indexp;
|
|
|
|
|
bfd_coff_swap_lineno_out (output_bfd, &lin, linp);
|
|
|
|
|
linp += linesz;
|
|
|
|
|
|
|
|
|
|
/* Copy the other entries, adjusting their addresses. */
|
|
|
|
|
linpend = linp + *lineno_counts * linesz;
|
|
|
|
|
offset = (o->output_section->vma
|
|
|
|
|
+ o->output_offset
|
|
|
|
|
- o->vma);
|
|
|
|
|
for (; linp < linpend; linp += linesz)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
2009-03-14 17:32:33 +08:00
|
|
|
|
bfd_coff_swap_lineno_in (input_bfd, linp, &lin);
|
|
|
|
|
lin.l_addr.l_paddr += offset;
|
|
|
|
|
bfd_coff_swap_lineno_out (output_bfd, &lin, linp);
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:33 +08:00
|
|
|
|
/* Write out the entries we've just processed. */
|
|
|
|
|
pos = (o->output_section->line_filepos
|
2005-04-11 16:23:05 +08:00
|
|
|
|
+ o->output_section->lineno_count * linesz);
|
2009-03-14 17:32:33 +08:00
|
|
|
|
amt = linesz * *lineno_counts;
|
|
|
|
|
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite (finfo->linenos + linoff,
|
|
|
|
|
amt, output_bfd) != amt)
|
|
|
|
|
return FALSE;
|
|
|
|
|
o->output_section->lineno_count += *lineno_counts;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:33 +08:00
|
|
|
|
/* Record the offset of the symbol's line numbers
|
|
|
|
|
in the output file. */
|
|
|
|
|
aux.x_sym.x_fcnary.x_fcn.x_lnnoptr = pos;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:32:33 +08:00
|
|
|
|
if (incls > 0)
|
|
|
|
|
{
|
|
|
|
|
struct internal_syment *iisp, *iispend;
|
|
|
|
|
long *iindp;
|
|
|
|
|
bfd_byte *oos;
|
|
|
|
|
bfd_vma range_start, range_end;
|
|
|
|
|
int iiadd;
|
|
|
|
|
|
|
|
|
|
/* Update any C_BINCL or C_EINCL symbols
|
|
|
|
|
that refer to a line number in the
|
|
|
|
|
range we just output. */
|
|
|
|
|
iisp = finfo->internal_syms;
|
|
|
|
|
iispend = iisp + obj_raw_syment_count (input_bfd);
|
|
|
|
|
iindp = finfo->sym_indices;
|
|
|
|
|
oos = finfo->outsyms;
|
|
|
|
|
range_start = enclosing->line_filepos + linoff;
|
|
|
|
|
range_end = range_start + *lineno_counts * linesz;
|
|
|
|
|
while (iisp < iispend)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
2009-03-14 17:32:33 +08:00
|
|
|
|
if (*iindp >= 0
|
|
|
|
|
&& (iisp->n_sclass == C_BINCL
|
|
|
|
|
|| iisp->n_sclass == C_EINCL)
|
|
|
|
|
&& iisp->n_value >= range_start
|
|
|
|
|
&& iisp->n_value < range_end)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
2009-03-14 17:32:33 +08:00
|
|
|
|
struct internal_syment iis;
|
|
|
|
|
|
|
|
|
|
bfd_coff_swap_sym_in (output_bfd, oos, &iis);
|
|
|
|
|
iis.n_value = (iisp->n_value
|
|
|
|
|
- range_start
|
|
|
|
|
+ pos);
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd,
|
|
|
|
|
&iis, oos);
|
|
|
|
|
--incls;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
2009-03-14 17:32:33 +08:00
|
|
|
|
|
|
|
|
|
iiadd = 1 + iisp->n_numaux;
|
|
|
|
|
if (*iindp >= 0)
|
|
|
|
|
oos += iiadd * osymesz;
|
|
|
|
|
iisp += iiadd;
|
|
|
|
|
iindp += iiadd;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_coff_swap_aux_out (output_bfd, (void *) &aux, isymp->n_type,
|
|
|
|
|
isymp->n_sclass, i, isymp->n_numaux,
|
|
|
|
|
(void *) outsym);
|
|
|
|
|
outsym += osymesz;
|
|
|
|
|
esym += isymesz;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
indexp += add;
|
|
|
|
|
isymp += add;
|
|
|
|
|
csectpp += add;
|
2009-03-14 17:32:33 +08:00
|
|
|
|
lineno_counts += add;
|
2009-03-14 17:32:06 +08:00
|
|
|
|
debug_index += add;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If we swapped out a C_FILE symbol, guess that the next C_FILE
|
|
|
|
|
symbol will be the first symbol in the next input file. In the
|
|
|
|
|
normal case, this will save us from writing out the C_FILE symbol
|
|
|
|
|
again. */
|
|
|
|
|
if (finfo->last_file_index != -1
|
|
|
|
|
&& (bfd_size_type) finfo->last_file_index >= syment_base)
|
|
|
|
|
{
|
|
|
|
|
finfo->last_file.n_value = output_index;
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd, (void *) &finfo->last_file,
|
|
|
|
|
(void *) (finfo->outsyms
|
|
|
|
|
+ ((finfo->last_file_index - syment_base)
|
|
|
|
|
* osymesz)));
|
|
|
|
|
}
|
2000-09-07 05:21:51 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write the modified symbols to the output file. */
|
|
|
|
|
if (outsym > finfo->outsyms)
|
|
|
|
|
{
|
|
|
|
|
file_ptr pos = obj_sym_filepos (output_bfd) + syment_base * osymesz;
|
|
|
|
|
bfd_size_type amt = outsym - finfo->outsyms;
|
|
|
|
|
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
|
|
|
|
|
return FALSE;
|
2000-11-30 16:04:42 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT ((obj_raw_syment_count (output_bfd)
|
|
|
|
|
+ (outsym - finfo->outsyms) / osymesz)
|
|
|
|
|
== output_index);
|
2000-11-30 16:04:42 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
obj_raw_syment_count (output_bfd) = output_index;
|
|
|
|
|
}
|
2000-11-30 16:04:42 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Don't let the linker relocation routines discard the symbols. */
|
|
|
|
|
keep_syms = obj_coff_keep_syms (input_bfd);
|
|
|
|
|
obj_coff_keep_syms (input_bfd) = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Relocate the contents of each section. */
|
|
|
|
|
for (o = input_bfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
bfd_byte *contents;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! o->linker_mark)
|
|
|
|
|
/* This section was omitted from the link. */
|
|
|
|
|
continue;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((o->flags & SEC_HAS_CONTENTS) == 0
|
|
|
|
|
|| o->size == 0
|
|
|
|
|
|| (o->flags & SEC_IN_MEMORY) != 0)
|
|
|
|
|
continue;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We have set filepos correctly for the sections we created to
|
|
|
|
|
represent csects, so bfd_get_section_contents should work. */
|
|
|
|
|
if (coff_section_data (input_bfd, o) != NULL
|
|
|
|
|
&& coff_section_data (input_bfd, o)->contents != NULL)
|
|
|
|
|
contents = coff_section_data (input_bfd, o)->contents;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type sz = o->rawsize ? o->rawsize : o->size;
|
|
|
|
|
if (!bfd_get_section_contents (input_bfd, o, finfo->contents, 0, sz))
|
|
|
|
|
return FALSE;
|
|
|
|
|
contents = finfo->contents;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((o->flags & SEC_RELOC) != 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
int target_index;
|
|
|
|
|
struct internal_reloc *internal_relocs;
|
|
|
|
|
struct internal_reloc *irel;
|
|
|
|
|
bfd_vma offset;
|
|
|
|
|
struct internal_reloc *irelend;
|
|
|
|
|
struct xcoff_link_hash_entry **rel_hash;
|
|
|
|
|
long r_symndx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Read in the relocs. */
|
|
|
|
|
target_index = o->output_section->target_index;
|
|
|
|
|
internal_relocs = (xcoff_read_internal_relocs
|
|
|
|
|
(input_bfd, o, FALSE, finfo->external_relocs,
|
|
|
|
|
TRUE,
|
|
|
|
|
(finfo->section_info[target_index].relocs
|
|
|
|
|
+ o->output_section->reloc_count)));
|
|
|
|
|
if (internal_relocs == NULL)
|
|
|
|
|
return FALSE;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Call processor specific code to relocate the section
|
|
|
|
|
contents. */
|
|
|
|
|
if (! bfd_coff_relocate_section (output_bfd, finfo->info,
|
|
|
|
|
input_bfd, o,
|
|
|
|
|
contents,
|
|
|
|
|
internal_relocs,
|
|
|
|
|
finfo->internal_syms,
|
|
|
|
|
xcoff_data (input_bfd)->csects))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
offset = o->output_section->vma + o->output_offset - o->vma;
|
|
|
|
|
irel = internal_relocs;
|
|
|
|
|
irelend = irel + o->reloc_count;
|
|
|
|
|
rel_hash = (finfo->section_info[target_index].rel_hashes
|
|
|
|
|
+ o->output_section->reloc_count);
|
|
|
|
|
for (; irel < irelend; irel++, rel_hash++)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_hash_entry *h = NULL;
|
|
|
|
|
struct internal_ldrel ldrel;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
*rel_hash = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Adjust the reloc address and symbol index. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
irel->r_vaddr += offset;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
r_symndx = irel->r_symndx;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (r_symndx == -1)
|
|
|
|
|
h = NULL;
|
|
|
|
|
else
|
|
|
|
|
h = obj_xcoff_sym_hashes (input_bfd)[r_symndx];
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (r_symndx != -1 && finfo->info->strip != strip_all)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h != NULL
|
|
|
|
|
&& h->smclas != XMC_TD
|
|
|
|
|
&& (irel->r_type == R_TOC
|
|
|
|
|
|| irel->r_type == R_GL
|
|
|
|
|
|| irel->r_type == R_TCL
|
|
|
|
|
|| irel->r_type == R_TRL
|
|
|
|
|
|| irel->r_type == R_TRLA))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This is a TOC relative reloc with a symbol
|
|
|
|
|
attached. The symbol should be the one which
|
|
|
|
|
this reloc is for. We want to make this
|
|
|
|
|
reloc against the TOC address of the symbol,
|
|
|
|
|
not the symbol itself. */
|
|
|
|
|
BFD_ASSERT (h->toc_section != NULL);
|
|
|
|
|
BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
|
|
|
|
|
if (h->u.toc_indx != -1)
|
|
|
|
|
irel->r_symndx = h->u.toc_indx;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_toc_rel_hash *n;
|
|
|
|
|
struct xcoff_link_section_info *si;
|
|
|
|
|
bfd_size_type amt;
|
|
|
|
|
|
|
|
|
|
amt = sizeof (* n);
|
|
|
|
|
n = bfd_alloc (finfo->output_bfd, amt);
|
|
|
|
|
if (n == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
si = finfo->section_info + target_index;
|
|
|
|
|
n->next = si->toc_rel_hashes;
|
|
|
|
|
n->h = h;
|
|
|
|
|
n->rel = irel;
|
|
|
|
|
si->toc_rel_hashes = n;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else if (h != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This is a global symbol. */
|
|
|
|
|
if (h->indx >= 0)
|
|
|
|
|
irel->r_symndx = h->indx;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* This symbol is being written at the end
|
|
|
|
|
of the file, and we do not yet know the
|
|
|
|
|
symbol index. We save the pointer to the
|
|
|
|
|
hash table entry in the rel_hash list.
|
|
|
|
|
We set the indx field to -2 to indicate
|
|
|
|
|
that this symbol must not be stripped. */
|
|
|
|
|
*rel_hash = h;
|
|
|
|
|
h->indx = -2;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
long indx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
indx = finfo->sym_indices[r_symndx];
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (indx == -1)
|
|
|
|
|
{
|
|
|
|
|
struct internal_syment *is;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Relocations against a TC0 TOC anchor are
|
|
|
|
|
automatically transformed to be against
|
|
|
|
|
the TOC anchor in the output file. */
|
|
|
|
|
is = finfo->internal_syms + r_symndx;
|
|
|
|
|
if (is->n_sclass == C_HIDEXT
|
|
|
|
|
&& is->n_numaux > 0)
|
|
|
|
|
{
|
|
|
|
|
void * auxptr;
|
|
|
|
|
union internal_auxent aux;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
auxptr = ((void *)
|
|
|
|
|
(((bfd_byte *)
|
|
|
|
|
obj_coff_external_syms (input_bfd))
|
|
|
|
|
+ ((r_symndx + is->n_numaux)
|
|
|
|
|
* isymesz)));
|
|
|
|
|
bfd_coff_swap_aux_in (input_bfd, auxptr,
|
|
|
|
|
is->n_type, is->n_sclass,
|
|
|
|
|
is->n_numaux - 1,
|
|
|
|
|
is->n_numaux,
|
|
|
|
|
(void *) &aux);
|
|
|
|
|
if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_SD
|
|
|
|
|
&& aux.x_csect.x_smclas == XMC_TC0)
|
|
|
|
|
indx = finfo->toc_symindx;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (indx != -1)
|
|
|
|
|
irel->r_symndx = indx;
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct internal_syment *is;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
const char *name;
|
|
|
|
|
char buf[SYMNMLEN + 1];
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This reloc is against a symbol we are
|
|
|
|
|
stripping. It would be possible to handle
|
|
|
|
|
this case, but I don't think it's worth it. */
|
|
|
|
|
is = finfo->internal_syms + r_symndx;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
name = (_bfd_coff_internal_syment_name
|
|
|
|
|
(input_bfd, is, buf));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (name == NULL)
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! ((*finfo->info->callbacks->unattached_reloc)
|
|
|
|
|
(finfo->info, name, input_bfd, o,
|
|
|
|
|
irel->r_vaddr)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
switch (irel->r_type)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
default:
|
|
|
|
|
if (h == NULL
|
|
|
|
|
|| h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak
|
|
|
|
|
|| h->root.type == bfd_link_hash_common)
|
|
|
|
|
break;
|
|
|
|
|
/* Fall through. */
|
|
|
|
|
case R_POS:
|
|
|
|
|
case R_NEG:
|
|
|
|
|
case R_RL:
|
|
|
|
|
case R_RLA:
|
2009-03-14 17:15:34 +08:00
|
|
|
|
if (h != NULL
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& bfd_is_abs_section (h->root.u.def.section))
|
|
|
|
|
break;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* This reloc needs to be copied into the .loader
|
|
|
|
|
section. */
|
|
|
|
|
ldrel.l_vaddr = irel->r_vaddr;
|
|
|
|
|
if (r_symndx == -1)
|
|
|
|
|
ldrel.l_symndx = -(bfd_size_type ) 1;
|
|
|
|
|
else if (h == NULL
|
|
|
|
|
|| (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak
|
|
|
|
|
|| h->root.type == bfd_link_hash_common))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
asection *sec;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h == NULL)
|
|
|
|
|
sec = xcoff_data (input_bfd)->csects[r_symndx];
|
|
|
|
|
else if (h->root.type == bfd_link_hash_common)
|
|
|
|
|
sec = h->root.u.c.p->section;
|
|
|
|
|
else
|
|
|
|
|
sec = h->root.u.def.section;
|
|
|
|
|
sec = sec->output_section;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (strcmp (sec->name, ".text") == 0)
|
|
|
|
|
ldrel.l_symndx = 0;
|
|
|
|
|
else if (strcmp (sec->name, ".data") == 0)
|
|
|
|
|
ldrel.l_symndx = 1;
|
|
|
|
|
else if (strcmp (sec->name, ".bss") == 0)
|
|
|
|
|
ldrel.l_symndx = 2;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%B: loader reloc in unrecognized section `%A'"),
|
|
|
|
|
input_bfd, sec);
|
|
|
|
|
bfd_set_error (bfd_error_nonrepresentable_section);
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
if (h->ldindx < 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%B: `%s' in loader reloc but not loader sym"),
|
|
|
|
|
input_bfd,
|
|
|
|
|
h->root.root.string);
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
ldrel.l_symndx = h->ldindx;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
|
|
|
|
|
ldrel.l_rsecnm = o->output_section->target_index;
|
|
|
|
|
if (xcoff_hash_table (finfo->info)->textro
|
include/coff/
* xcoff.h (XCOFF_CALLED, XCOFF_IMPORT): Update comments.
(XCOFF_WAS_UNDEFINED): New flag.
(xcoff_link_hash_table): Add an "rtld" field.
bfd/
* coff-rs6000.c (xcoff_ppc_relocate_section): Report relocations
against undefined symbols if the symbol's XCOFF_WAS_UNDEFINED
flag is set. Assert that all undefined symbols are either
imported or defined by a dynamic object.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Extend function-symbol
handling to all relocations. Only set XCOFF_CALLED for function
symbols.
(xcoff_find_function): New function, split out from...
(bfd_xcoff_export_symbol) ...here.
(xcoff_set_import_path): New function, split out from...
(bfd_xcoff_import_symbol): ...here. Remove assertion for old
meaning of XCOFF_CALLED.
(xcoff_mark_symbol): If we mark an undefined and unimported
symbol, find some way of defining it. If the symbol is a function
descriptor, fill in its definition automatically. If the symbol
is a function, mark its descriptor and allocate room for global
linkage code. Otherwise mark the symbol as implicitly imported.
Move the code for creating function descriptors from...
(xcoff_build_ldsyms): ...here. Use XCOFF_WAS_UNDEFINED to
check for symbols that were implicitly defined.
(xcoff_mark): Don't count any dynamic relocations against
function symbols.
(bfd_xcoff_size_dynamic_sections): Save the rtld parameter
in the xcoff link info.
(xcoff_link_input_bfd): Remove handling of undefined and
unexported symbols.
ld/
* emultempl/aix.em (gld${EMULATION_NAME}_handle_option): Make
-berok and -bernotok control link_info.unresolved_syms_in_objects
and link_info.unresolved_syms_in_shared_libs instead of
force_make_executable.
ld/testsuite/
* ld-powerpc/aix-glink-1.ex, ld-powerpc/aix-glink-1.s,
ld-powerpc/aix-glink-1-32.dd, ld-powerpc/aix-glink-1-64.dd,
ld-powerpc/aix-glink-1-32.d, ld-powerpc/aix-glink-1-64.d: New tests.
* ld-powerpc/aix52.exp: Run them.
2009-03-14 17:17:32 +08:00
|
|
|
|
&& strcmp (o->output_section->name, ".text") == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%B: loader reloc in read-only section %A"),
|
|
|
|
|
input_bfd, o->output_section);
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel,
|
|
|
|
|
finfo->ldrel);
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
|
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
case R_TOC:
|
|
|
|
|
case R_GL:
|
|
|
|
|
case R_TCL:
|
|
|
|
|
case R_TRL:
|
|
|
|
|
case R_TRLA:
|
|
|
|
|
/* We should never need a .loader reloc for a TOC
|
|
|
|
|
relative reloc. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
o->output_section->reloc_count += o->reloc_count;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write out the modified section contents. */
|
|
|
|
|
if (! bfd_set_section_contents (output_bfd, o->output_section,
|
|
|
|
|
contents, (file_ptr) o->output_offset,
|
|
|
|
|
o->size))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
obj_coff_keep_syms (input_bfd) = keep_syms;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! finfo->info->keep_memory)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_coff_free_symbols (input_bfd))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
#undef N_TMASK
|
|
|
|
|
#undef N_BTSHFT
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Sort relocs by VMA. This is called via qsort. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
static int
|
|
|
|
|
xcoff_sort_relocs (const void * p1, const void * p2)
|
|
|
|
|
{
|
|
|
|
|
const struct internal_reloc *r1 = (const struct internal_reloc *) p1;
|
|
|
|
|
const struct internal_reloc *r2 = (const struct internal_reloc *) p2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (r1->r_vaddr > r2->r_vaddr)
|
|
|
|
|
return 1;
|
|
|
|
|
else if (r1->r_vaddr < r2->r_vaddr)
|
|
|
|
|
return -1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2009-03-14 17:18:22 +08:00
|
|
|
|
/* Return true if section SEC is a TOC section. */
|
|
|
|
|
|
|
|
|
|
static inline bfd_boolean
|
|
|
|
|
xcoff_toc_section_p (asection *sec)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
name = sec->name;
|
|
|
|
|
if (name[0] == '.' && name[1] == 't')
|
|
|
|
|
{
|
|
|
|
|
if (name[2] == 'c')
|
|
|
|
|
{
|
|
|
|
|
if (name[3] == '0' && name[4] == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
if (name[3] == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (name[2] == 'd' && name[3] == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See if the link requires a TOC (it usually does!). If so, find a
|
|
|
|
|
good place to put the TOC anchor csect, and write out the associated
|
|
|
|
|
symbol. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_find_tc0 (bfd *output_bfd, struct xcoff_final_link_info *finfo)
|
|
|
|
|
{
|
|
|
|
|
bfd_vma toc_start, toc_end, start, end, best_address;
|
|
|
|
|
asection *sec;
|
|
|
|
|
bfd *input_bfd;
|
|
|
|
|
int section_index;
|
|
|
|
|
struct internal_syment irsym;
|
|
|
|
|
union internal_auxent iraux;
|
|
|
|
|
file_ptr pos;
|
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
|
|
/* Set [TOC_START, TOC_END) to the range of the TOC. Record the
|
|
|
|
|
index of a csect at the beginning of the TOC. */
|
|
|
|
|
toc_start = ~(bfd_vma) 0;
|
|
|
|
|
toc_end = 0;
|
|
|
|
|
section_index = -1;
|
|
|
|
|
for (input_bfd = finfo->info->input_bfds;
|
|
|
|
|
input_bfd != NULL;
|
|
|
|
|
input_bfd = input_bfd->link_next)
|
|
|
|
|
for (sec = input_bfd->sections; sec != NULL; sec = sec->next)
|
|
|
|
|
if ((sec->flags & SEC_MARK) != 0 && xcoff_toc_section_p (sec))
|
|
|
|
|
{
|
|
|
|
|
start = sec->output_section->vma + sec->output_offset;
|
|
|
|
|
if (toc_start > start)
|
|
|
|
|
{
|
|
|
|
|
toc_start = start;
|
|
|
|
|
section_index = sec->output_section->target_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end = start + sec->size;
|
|
|
|
|
if (toc_end < end)
|
|
|
|
|
toc_end = end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There's no need for a TC0 symbol if we don't have a TOC. */
|
|
|
|
|
if (toc_end < toc_start)
|
|
|
|
|
{
|
|
|
|
|
xcoff_data (output_bfd)->toc = toc_start;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (toc_end - toc_start < 0x8000)
|
|
|
|
|
/* Every TOC csect can be accessed from TOC_START. */
|
|
|
|
|
best_address = toc_start;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Find the lowest TOC csect that is still within range of TOC_END. */
|
|
|
|
|
best_address = toc_end;
|
|
|
|
|
for (input_bfd = finfo->info->input_bfds;
|
|
|
|
|
input_bfd != NULL;
|
|
|
|
|
input_bfd = input_bfd->link_next)
|
|
|
|
|
for (sec = input_bfd->sections; sec != NULL; sec = sec->next)
|
|
|
|
|
if ((sec->flags & SEC_MARK) != 0 && xcoff_toc_section_p (sec))
|
|
|
|
|
{
|
|
|
|
|
start = sec->output_section->vma + sec->output_offset;
|
|
|
|
|
if (start < best_address
|
|
|
|
|
&& start + 0x8000 >= toc_end)
|
|
|
|
|
{
|
|
|
|
|
best_address = start;
|
|
|
|
|
section_index = sec->output_section->target_index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure that the start of the TOC is also within range. */
|
|
|
|
|
if (best_address > toc_start + 0x8000)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("TOC overflow: 0x%lx > 0x10000; try -mminimal-toc "
|
|
|
|
|
"when compiling"),
|
|
|
|
|
(unsigned long) (toc_end - toc_start));
|
|
|
|
|
bfd_set_error (bfd_error_file_too_big);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Record the chosen TOC value. */
|
|
|
|
|
finfo->toc_symindx = obj_raw_syment_count (output_bfd);
|
|
|
|
|
xcoff_data (output_bfd)->toc = best_address;
|
|
|
|
|
xcoff_data (output_bfd)->sntoc = section_index;
|
|
|
|
|
|
|
|
|
|
/* Fill out the TC0 symbol. */
|
|
|
|
|
if (!bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab, &irsym, "TOC"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
irsym.n_value = best_address;
|
|
|
|
|
irsym.n_scnum = section_index;
|
|
|
|
|
irsym.n_sclass = C_HIDEXT;
|
|
|
|
|
irsym.n_type = T_NULL;
|
|
|
|
|
irsym.n_numaux = 1;
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd, &irsym, finfo->outsyms);
|
|
|
|
|
|
|
|
|
|
/* Fill out the auxillary csect information. */
|
|
|
|
|
memset (&iraux, 0, sizeof iraux);
|
|
|
|
|
iraux.x_csect.x_smtyp = XTY_SD;
|
|
|
|
|
iraux.x_csect.x_smclas = XMC_TC0;
|
|
|
|
|
iraux.x_csect.x_scnlen.l = 0;
|
|
|
|
|
bfd_coff_swap_aux_out (output_bfd, &iraux, T_NULL, C_HIDEXT, 0, 1,
|
|
|
|
|
finfo->outsyms + bfd_coff_symesz (output_bfd));
|
|
|
|
|
|
|
|
|
|
/* Write the contents to the file. */
|
|
|
|
|
pos = obj_sym_filepos (output_bfd);
|
|
|
|
|
pos += obj_raw_syment_count (output_bfd) * bfd_coff_symesz (output_bfd);
|
|
|
|
|
size = 2 * bfd_coff_symesz (output_bfd);
|
|
|
|
|
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite (finfo->outsyms, size, output_bfd) != size)
|
|
|
|
|
return FALSE;
|
|
|
|
|
obj_raw_syment_count (output_bfd) += 2;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write out a non-XCOFF global symbol. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
static bfd_boolean
|
|
|
|
|
xcoff_write_global_symbol (struct xcoff_link_hash_entry *h, void * inf)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_final_link_info *finfo = (struct xcoff_final_link_info *) inf;
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
bfd_byte *outsym;
|
|
|
|
|
struct internal_syment isym;
|
|
|
|
|
union internal_auxent aux;
|
|
|
|
|
bfd_boolean result;
|
|
|
|
|
file_ptr pos;
|
|
|
|
|
bfd_size_type amt;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
output_bfd = finfo->output_bfd;
|
|
|
|
|
outsym = finfo->outsyms;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h = (struct xcoff_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
if (h->root.type == bfd_link_hash_new)
|
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If this symbol was garbage collected, just skip it. */
|
|
|
|
|
if (xcoff_hash_table (finfo->info)->gc
|
|
|
|
|
&& (h->flags & XCOFF_MARK) == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
/* If we need a .loader section entry, write it out. */
|
|
|
|
|
if (h->ldsym != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct internal_ldsym *ldsym;
|
|
|
|
|
bfd *impbfd;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldsym = h->ldsym;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak)
|
|
|
|
|
{
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldsym->l_value = 0;
|
|
|
|
|
ldsym->l_scnum = N_UNDEF;
|
|
|
|
|
ldsym->l_smtype = XTY_ER;
|
|
|
|
|
impbfd = h->root.u.undef.abfd;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
|
|
|
|
else if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
{
|
|
|
|
|
asection *sec;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
sec = h->root.u.def.section;
|
|
|
|
|
ldsym->l_value = (sec->output_section->vma
|
|
|
|
|
+ sec->output_offset
|
|
|
|
|
+ h->root.u.def.value);
|
|
|
|
|
ldsym->l_scnum = sec->output_section->target_index;
|
|
|
|
|
ldsym->l_smtype = XTY_SD;
|
|
|
|
|
impbfd = sec->owner;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else
|
|
|
|
|
abort ();
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (((h->flags & XCOFF_DEF_REGULAR) == 0
|
|
|
|
|
&& (h->flags & XCOFF_DEF_DYNAMIC) != 0)
|
|
|
|
|
|| (h->flags & XCOFF_IMPORT) != 0)
|
|
|
|
|
/* Clear l_smtype
|
|
|
|
|
Import symbols are defined so the check above will make
|
|
|
|
|
the l_smtype XTY_SD. But this is not correct, it should
|
|
|
|
|
be cleared. */
|
|
|
|
|
ldsym->l_smtype |= L_IMPORT;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (((h->flags & XCOFF_DEF_REGULAR) != 0
|
|
|
|
|
&& (h->flags & XCOFF_DEF_DYNAMIC) != 0)
|
|
|
|
|
|| (h->flags & XCOFF_EXPORT) != 0)
|
|
|
|
|
ldsym->l_smtype |= L_EXPORT;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((h->flags & XCOFF_ENTRY) != 0)
|
|
|
|
|
ldsym->l_smtype |= L_ENTRY;
|
|
|
|
|
|
|
|
|
|
if ((h->flags & XCOFF_RTINIT) != 0)
|
|
|
|
|
ldsym->l_smtype = XTY_SD;
|
|
|
|
|
|
|
|
|
|
ldsym->l_smclas = h->smclas;
|
|
|
|
|
|
|
|
|
|
if (ldsym->l_smtype & L_IMPORT)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& (h->root.u.def.value != 0))
|
|
|
|
|
ldsym->l_smclas = XMC_XO;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else if ((h->flags & (XCOFF_SYSCALL32 | XCOFF_SYSCALL64)) ==
|
|
|
|
|
(XCOFF_SYSCALL32 | XCOFF_SYSCALL64))
|
|
|
|
|
ldsym->l_smclas = XMC_SV3264;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else if (h->flags & XCOFF_SYSCALL32)
|
|
|
|
|
ldsym->l_smclas = XMC_SV;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else if (h->flags & XCOFF_SYSCALL64)
|
|
|
|
|
ldsym->l_smclas = XMC_SV64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ldsym->l_ifile == -(bfd_size_type) 1)
|
|
|
|
|
{
|
|
|
|
|
ldsym->l_ifile = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (ldsym->l_ifile == 0)
|
|
|
|
|
{
|
|
|
|
|
if ((ldsym->l_smtype & L_IMPORT) == 0)
|
|
|
|
|
ldsym->l_ifile = 0;
|
|
|
|
|
else if (impbfd == NULL)
|
|
|
|
|
ldsym->l_ifile = 0;
|
|
|
|
|
else
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT (impbfd->xvec == output_bfd->xvec);
|
|
|
|
|
ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldsym->l_parm = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT (h->ldindx >= 0);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_xcoff_swap_ldsym_out (output_bfd, ldsym,
|
|
|
|
|
(finfo->ldsym +
|
|
|
|
|
(h->ldindx - 3)
|
|
|
|
|
* bfd_xcoff_ldsymsz(finfo->output_bfd)));
|
|
|
|
|
h->ldsym = NULL;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If this symbol needs global linkage code, write it out. */
|
|
|
|
|
if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
&& (h->root.u.def.section
|
|
|
|
|
== xcoff_hash_table (finfo->info)->linkage_section))
|
|
|
|
|
{
|
|
|
|
|
bfd_byte *p;
|
|
|
|
|
bfd_vma tocoff;
|
|
|
|
|
unsigned int i;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
p = h->root.u.def.section->contents + h->root.u.def.value;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* The first instruction in the global linkage code loads a
|
|
|
|
|
specific TOC element. */
|
|
|
|
|
tocoff = (h->descriptor->toc_section->output_section->vma
|
|
|
|
|
+ h->descriptor->toc_section->output_offset
|
|
|
|
|
- xcoff_data (output_bfd)->toc);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((h->descriptor->flags & XCOFF_SET_TOC) != 0)
|
|
|
|
|
tocoff += h->descriptor->u.toc_offset;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* The first instruction in the glink code needs to be
|
|
|
|
|
cooked to to hold the correct offset in the toc. The
|
|
|
|
|
rest are just output raw. */
|
|
|
|
|
bfd_put_32 (output_bfd,
|
|
|
|
|
bfd_xcoff_glink_code(output_bfd, 0) | (tocoff & 0xffff), p);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Start with i == 1 to get past the first instruction done above
|
|
|
|
|
The /4 is because the glink code is in bytes and we are going
|
|
|
|
|
4 at a pop. */
|
|
|
|
|
for (i = 1; i < bfd_xcoff_glink_code_size(output_bfd) / 4; i++)
|
|
|
|
|
bfd_put_32 (output_bfd,
|
|
|
|
|
(bfd_vma) bfd_xcoff_glink_code(output_bfd, i),
|
|
|
|
|
&p[4 * i]);
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* If we created a TOC entry for this symbol, write out the required
|
|
|
|
|
relocs. */
|
|
|
|
|
if ((h->flags & XCOFF_SET_TOC) != 0)
|
|
|
|
|
{
|
|
|
|
|
asection *tocsec;
|
|
|
|
|
asection *osec;
|
|
|
|
|
int oindx;
|
|
|
|
|
struct internal_reloc *irel;
|
|
|
|
|
struct internal_ldrel ldrel;
|
|
|
|
|
struct internal_syment irsym;
|
|
|
|
|
union internal_auxent iraux;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
tocsec = h->toc_section;
|
|
|
|
|
osec = tocsec->output_section;
|
|
|
|
|
oindx = osec->target_index;
|
|
|
|
|
irel = finfo->section_info[oindx].relocs + osec->reloc_count;
|
|
|
|
|
irel->r_vaddr = (osec->vma
|
|
|
|
|
+ tocsec->output_offset
|
|
|
|
|
+ h->u.toc_offset);
|
|
|
|
|
|
|
|
|
|
if (h->indx >= 0)
|
|
|
|
|
irel->r_symndx = h->indx;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
h->indx = -2;
|
|
|
|
|
irel->r_symndx = obj_raw_syment_count (output_bfd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (h->ldindx >= 0);
|
|
|
|
|
|
|
|
|
|
/* Initialize the aux union here instead of closer to when it is
|
|
|
|
|
written out below because the length of the csect depends on
|
|
|
|
|
whether the output is 32 or 64 bit. */
|
|
|
|
|
memset (&iraux, 0, sizeof iraux);
|
|
|
|
|
iraux.x_csect.x_smtyp = XTY_SD;
|
|
|
|
|
/* iraux.x_csect.x_scnlen.l = 4 or 8, see below. */
|
|
|
|
|
iraux.x_csect.x_smclas = XMC_TC;
|
|
|
|
|
|
|
|
|
|
/* 32 bit uses a 32 bit R_POS to do the relocations
|
|
|
|
|
64 bit uses a 64 bit R_POS to do the relocations
|
|
|
|
|
|
|
|
|
|
Also needs to change the csect size : 4 for 32 bit, 8 for 64 bit
|
|
|
|
|
|
|
|
|
|
Which one is determined by the backend. */
|
|
|
|
|
if (bfd_xcoff_is_xcoff64 (output_bfd))
|
|
|
|
|
{
|
|
|
|
|
irel->r_size = 63;
|
|
|
|
|
iraux.x_csect.x_scnlen.l = 8;
|
|
|
|
|
}
|
|
|
|
|
else if (bfd_xcoff_is_xcoff32 (output_bfd))
|
|
|
|
|
{
|
|
|
|
|
irel->r_size = 31;
|
|
|
|
|
iraux.x_csect.x_scnlen.l = 4;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
irel->r_type = R_POS;
|
|
|
|
|
finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
|
|
|
|
|
++osec->reloc_count;
|
|
|
|
|
|
|
|
|
|
ldrel.l_vaddr = irel->r_vaddr;
|
|
|
|
|
ldrel.l_symndx = h->ldindx;
|
|
|
|
|
ldrel.l_rtype = (irel->r_size << 8) | R_POS;
|
|
|
|
|
ldrel.l_rsecnm = oindx;
|
|
|
|
|
bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
|
|
|
|
|
finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
|
|
|
|
|
|
|
|
|
|
/* We need to emit a symbol to define a csect which holds
|
|
|
|
|
the reloc. */
|
|
|
|
|
if (finfo->info->strip != strip_all)
|
|
|
|
|
{
|
|
|
|
|
result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab,
|
|
|
|
|
&irsym, h->root.root.string);
|
|
|
|
|
if (!result)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
irsym.n_value = irel->r_vaddr;
|
|
|
|
|
irsym.n_scnum = osec->target_index;
|
|
|
|
|
irsym.n_sclass = C_HIDEXT;
|
|
|
|
|
irsym.n_type = T_NULL;
|
|
|
|
|
irsym.n_numaux = 1;
|
|
|
|
|
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd, (void *) &irsym, (void *) outsym);
|
|
|
|
|
outsym += bfd_coff_symesz (output_bfd);
|
|
|
|
|
|
|
|
|
|
/* Note : iraux is initialized above. */
|
|
|
|
|
bfd_coff_swap_aux_out (output_bfd, (void *) &iraux, T_NULL, C_HIDEXT,
|
|
|
|
|
0, 1, (void *) outsym);
|
|
|
|
|
outsym += bfd_coff_auxesz (output_bfd);
|
|
|
|
|
|
|
|
|
|
if (h->indx >= 0)
|
|
|
|
|
{
|
|
|
|
|
/* We aren't going to write out the symbols below, so we
|
|
|
|
|
need to write them out now. */
|
|
|
|
|
pos = obj_sym_filepos (output_bfd);
|
|
|
|
|
pos += (obj_raw_syment_count (output_bfd)
|
|
|
|
|
* bfd_coff_symesz (output_bfd));
|
|
|
|
|
amt = outsym - finfo->outsyms;
|
|
|
|
|
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
|
|
|
|
|
return FALSE;
|
|
|
|
|
obj_raw_syment_count (output_bfd) +=
|
|
|
|
|
(outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd);
|
|
|
|
|
|
|
|
|
|
outsym = finfo->outsyms;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this symbol is a specially defined function descriptor, write
|
|
|
|
|
it out. The first word is the address of the function code
|
|
|
|
|
itself, the second word is the address of the TOC, and the third
|
|
|
|
|
word is zero.
|
|
|
|
|
|
|
|
|
|
32 bit vs 64 bit
|
|
|
|
|
The addresses for the 32 bit will take 4 bytes and the addresses
|
|
|
|
|
for 64 bit will take 8 bytes. Similar for the relocs. This type
|
|
|
|
|
of logic was also done above to create a TOC entry in
|
|
|
|
|
xcoff_write_global_symbol. */
|
|
|
|
|
if ((h->flags & XCOFF_DESCRIPTOR) != 0
|
|
|
|
|
&& h->root.type == bfd_link_hash_defined
|
|
|
|
|
&& (h->root.u.def.section
|
|
|
|
|
== xcoff_hash_table (finfo->info)->descriptor_section))
|
|
|
|
|
{
|
|
|
|
|
asection *sec;
|
|
|
|
|
asection *osec;
|
|
|
|
|
int oindx;
|
|
|
|
|
bfd_byte *p;
|
|
|
|
|
struct xcoff_link_hash_entry *hentry;
|
|
|
|
|
asection *esec;
|
|
|
|
|
struct internal_reloc *irel;
|
|
|
|
|
struct internal_ldrel ldrel;
|
|
|
|
|
asection *tsec;
|
|
|
|
|
unsigned int reloc_size, byte_size;
|
|
|
|
|
|
|
|
|
|
if (bfd_xcoff_is_xcoff64 (output_bfd))
|
|
|
|
|
{
|
|
|
|
|
reloc_size = 63;
|
|
|
|
|
byte_size = 8;
|
|
|
|
|
}
|
|
|
|
|
else if (bfd_xcoff_is_xcoff32 (output_bfd))
|
|
|
|
|
{
|
|
|
|
|
reloc_size = 31;
|
|
|
|
|
byte_size = 4;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
sec = h->root.u.def.section;
|
|
|
|
|
osec = sec->output_section;
|
|
|
|
|
oindx = osec->target_index;
|
|
|
|
|
p = sec->contents + h->root.u.def.value;
|
|
|
|
|
|
|
|
|
|
hentry = h->descriptor;
|
|
|
|
|
BFD_ASSERT (hentry != NULL
|
|
|
|
|
&& (hentry->root.type == bfd_link_hash_defined
|
|
|
|
|
|| hentry->root.type == bfd_link_hash_defweak));
|
|
|
|
|
esec = hentry->root.u.def.section;
|
|
|
|
|
|
|
|
|
|
irel = finfo->section_info[oindx].relocs + osec->reloc_count;
|
|
|
|
|
irel->r_vaddr = (osec->vma
|
|
|
|
|
+ sec->output_offset
|
|
|
|
|
+ h->root.u.def.value);
|
|
|
|
|
irel->r_symndx = esec->output_section->target_index;
|
|
|
|
|
irel->r_type = R_POS;
|
|
|
|
|
irel->r_size = reloc_size;
|
|
|
|
|
finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
|
|
|
|
|
++osec->reloc_count;
|
|
|
|
|
|
|
|
|
|
ldrel.l_vaddr = irel->r_vaddr;
|
|
|
|
|
if (strcmp (esec->output_section->name, ".text") == 0)
|
|
|
|
|
ldrel.l_symndx = 0;
|
|
|
|
|
else if (strcmp (esec->output_section->name, ".data") == 0)
|
|
|
|
|
ldrel.l_symndx = 1;
|
|
|
|
|
else if (strcmp (esec->output_section->name, ".bss") == 0)
|
|
|
|
|
ldrel.l_symndx = 2;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: loader reloc in unrecognized section `%s'"),
|
|
|
|
|
bfd_get_filename (output_bfd),
|
|
|
|
|
esec->output_section->name);
|
|
|
|
|
bfd_set_error (bfd_error_nonrepresentable_section);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
ldrel.l_rtype = (reloc_size << 8) | R_POS;
|
|
|
|
|
ldrel.l_rsecnm = oindx;
|
|
|
|
|
bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
|
|
|
|
|
finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
|
|
|
|
|
|
|
|
|
|
/* There are three items to write out,
|
|
|
|
|
the address of the code
|
|
|
|
|
the address of the toc anchor
|
|
|
|
|
the environment pointer.
|
|
|
|
|
We are ignoring the environment pointer. So set it to zero. */
|
|
|
|
|
if (bfd_xcoff_is_xcoff64 (output_bfd))
|
|
|
|
|
{
|
|
|
|
|
bfd_put_64 (output_bfd,
|
|
|
|
|
(esec->output_section->vma + esec->output_offset
|
|
|
|
|
+ hentry->root.u.def.value),
|
|
|
|
|
p);
|
|
|
|
|
bfd_put_64 (output_bfd, xcoff_data (output_bfd)->toc, p + 8);
|
|
|
|
|
bfd_put_64 (output_bfd, (bfd_vma) 0, p + 16);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* 32 bit backend
|
|
|
|
|
This logic was already called above so the error case where
|
|
|
|
|
the backend is neither has already been checked. */
|
|
|
|
|
bfd_put_32 (output_bfd,
|
|
|
|
|
(esec->output_section->vma + esec->output_offset
|
|
|
|
|
+ hentry->root.u.def.value),
|
|
|
|
|
p);
|
|
|
|
|
bfd_put_32 (output_bfd, xcoff_data (output_bfd)->toc, p + 4);
|
|
|
|
|
bfd_put_32 (output_bfd, (bfd_vma) 0, p + 8);
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
tsec = coff_section_from_bfd_index (output_bfd,
|
|
|
|
|
xcoff_data (output_bfd)->sntoc);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
++irel;
|
|
|
|
|
irel->r_vaddr = (osec->vma
|
|
|
|
|
+ sec->output_offset
|
|
|
|
|
+ h->root.u.def.value
|
|
|
|
|
+ byte_size);
|
|
|
|
|
irel->r_symndx = tsec->output_section->target_index;
|
|
|
|
|
irel->r_type = R_POS;
|
|
|
|
|
irel->r_size = reloc_size;
|
|
|
|
|
finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
|
|
|
|
|
++osec->reloc_count;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldrel.l_vaddr = irel->r_vaddr;
|
|
|
|
|
if (strcmp (tsec->output_section->name, ".text") == 0)
|
|
|
|
|
ldrel.l_symndx = 0;
|
|
|
|
|
else if (strcmp (tsec->output_section->name, ".data") == 0)
|
|
|
|
|
ldrel.l_symndx = 1;
|
|
|
|
|
else if (strcmp (tsec->output_section->name, ".bss") == 0)
|
|
|
|
|
ldrel.l_symndx = 2;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: loader reloc in unrecognized section `%s'"),
|
|
|
|
|
bfd_get_filename (output_bfd),
|
|
|
|
|
tsec->output_section->name);
|
|
|
|
|
bfd_set_error (bfd_error_nonrepresentable_section);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
ldrel.l_rtype = (reloc_size << 8) | R_POS;
|
|
|
|
|
ldrel.l_rsecnm = oindx;
|
|
|
|
|
bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
|
|
|
|
|
finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->indx >= 0 || finfo->info->strip == strip_all)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (outsym == finfo->outsyms);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->indx != -2
|
|
|
|
|
&& (finfo->info->strip == strip_all
|
|
|
|
|
|| (finfo->info->strip == strip_some
|
|
|
|
|
&& bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
|
|
|
|
|
FALSE, FALSE) == NULL)))
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (outsym == finfo->outsyms);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->indx != -2
|
|
|
|
|
&& (h->flags & (XCOFF_REF_REGULAR | XCOFF_DEF_REGULAR)) == 0)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (outsym == finfo->outsyms);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
memset (&aux, 0, sizeof aux);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h->indx = obj_raw_syment_count (output_bfd);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab, &isym,
|
|
|
|
|
h->root.root.string);
|
|
|
|
|
if (!result)
|
|
|
|
|
return FALSE;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak)
|
|
|
|
|
{
|
|
|
|
|
isym.n_value = 0;
|
|
|
|
|
isym.n_scnum = N_UNDEF;
|
|
|
|
|
isym.n_sclass = C_EXT;
|
|
|
|
|
aux.x_csect.x_smtyp = XTY_ER;
|
|
|
|
|
}
|
|
|
|
|
else if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& h->smclas == XMC_XO)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (bfd_is_abs_section (h->root.u.def.section));
|
|
|
|
|
isym.n_value = h->root.u.def.value;
|
|
|
|
|
isym.n_scnum = N_UNDEF;
|
|
|
|
|
isym.n_sclass = C_EXT;
|
|
|
|
|
aux.x_csect.x_smtyp = XTY_ER;
|
|
|
|
|
}
|
|
|
|
|
else if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
{
|
|
|
|
|
struct xcoff_link_size_list *l;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
isym.n_value = (h->root.u.def.section->output_section->vma
|
|
|
|
|
+ h->root.u.def.section->output_offset
|
|
|
|
|
+ h->root.u.def.value);
|
|
|
|
|
if (bfd_is_abs_section (h->root.u.def.section->output_section))
|
|
|
|
|
isym.n_scnum = N_ABS;
|
|
|
|
|
else
|
|
|
|
|
isym.n_scnum = h->root.u.def.section->output_section->target_index;
|
|
|
|
|
isym.n_sclass = C_HIDEXT;
|
|
|
|
|
aux.x_csect.x_smtyp = XTY_SD;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if ((h->flags & XCOFF_HAS_SIZE) != 0)
|
|
|
|
|
{
|
|
|
|
|
for (l = xcoff_hash_table (finfo->info)->size_list;
|
|
|
|
|
l != NULL;
|
|
|
|
|
l = l->next)
|
|
|
|
|
{
|
|
|
|
|
if (l->h == h)
|
|
|
|
|
{
|
|
|
|
|
aux.x_csect.x_scnlen.l = l->size;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else if (h->root.type == bfd_link_hash_common)
|
|
|
|
|
{
|
|
|
|
|
isym.n_value = (h->root.u.c.p->section->output_section->vma
|
|
|
|
|
+ h->root.u.c.p->section->output_offset);
|
|
|
|
|
isym.n_scnum = h->root.u.c.p->section->output_section->target_index;
|
|
|
|
|
isym.n_sclass = C_EXT;
|
|
|
|
|
aux.x_csect.x_smtyp = XTY_CM;
|
|
|
|
|
aux.x_csect.x_scnlen.l = h->root.u.c.size;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
isym.n_type = T_NULL;
|
|
|
|
|
isym.n_numaux = 1;
|
|
|
|
|
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd, (void *) &isym, (void *) outsym);
|
|
|
|
|
outsym += bfd_coff_symesz (output_bfd);
|
|
|
|
|
|
|
|
|
|
aux.x_csect.x_smclas = h->smclas;
|
|
|
|
|
bfd_coff_swap_aux_out (output_bfd, (void *) &aux, T_NULL, isym.n_sclass, 0, 1,
|
|
|
|
|
(void *) outsym);
|
|
|
|
|
outsym += bfd_coff_auxesz (output_bfd);
|
|
|
|
|
|
|
|
|
|
if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& h->smclas != XMC_XO)
|
|
|
|
|
{
|
|
|
|
|
/* We just output an SD symbol. Now output an LD symbol. */
|
|
|
|
|
h->indx += 2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
isym.n_sclass = C_EXT;
|
|
|
|
|
bfd_coff_swap_sym_out (output_bfd, (void *) &isym, (void *) outsym);
|
|
|
|
|
outsym += bfd_coff_symesz (output_bfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
aux.x_csect.x_smtyp = XTY_LD;
|
|
|
|
|
aux.x_csect.x_scnlen.l = obj_raw_syment_count (output_bfd);
|
|
|
|
|
bfd_coff_swap_aux_out (output_bfd, (void *) &aux, T_NULL, C_EXT, 0, 1,
|
|
|
|
|
(void *) outsym);
|
|
|
|
|
outsym += bfd_coff_auxesz (output_bfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
pos = obj_sym_filepos (output_bfd);
|
|
|
|
|
pos += obj_raw_syment_count (output_bfd) * bfd_coff_symesz (output_bfd);
|
|
|
|
|
amt = outsym - finfo->outsyms;
|
|
|
|
|
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
|
|
|
|
|
return FALSE;
|
|
|
|
|
obj_raw_syment_count (output_bfd) +=
|
|
|
|
|
(outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd);
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Handle a link order which is supposed to generate a reloc. */
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_reloc_link_order (bfd *output_bfd,
|
|
|
|
|
struct xcoff_final_link_info *finfo,
|
|
|
|
|
asection *output_section,
|
|
|
|
|
struct bfd_link_order *link_order)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
reloc_howto_type *howto;
|
|
|
|
|
struct xcoff_link_hash_entry *h;
|
|
|
|
|
asection *hsec;
|
|
|
|
|
bfd_vma hval;
|
|
|
|
|
bfd_vma addend;
|
|
|
|
|
struct internal_reloc *irel;
|
|
|
|
|
struct xcoff_link_hash_entry **rel_hash_ptr;
|
|
|
|
|
struct internal_ldrel ldrel;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (link_order->type == bfd_section_reloc_link_order)
|
|
|
|
|
/* We need to somehow locate a symbol in the right section. The
|
|
|
|
|
symbol must either have a value of zero, or we must adjust
|
|
|
|
|
the addend by the value of the symbol. FIXME: Write this
|
|
|
|
|
when we need it. The old linker couldn't handle this anyhow. */
|
|
|
|
|
abort ();
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
|
|
|
|
|
if (howto == NULL)
|
2002-03-28 11:27:46 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
return FALSE;
|
2002-03-28 11:27:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
h = ((struct xcoff_link_hash_entry *)
|
|
|
|
|
bfd_wrapped_link_hash_lookup (output_bfd, finfo->info,
|
|
|
|
|
link_order->u.reloc.p->u.name,
|
|
|
|
|
FALSE, FALSE, TRUE));
|
|
|
|
|
if (h == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (! ((*finfo->info->callbacks->unattached_reloc)
|
|
|
|
|
(finfo->info, link_order->u.reloc.p->u.name, NULL, NULL, (bfd_vma) 0)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->root.type == bfd_link_hash_common)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
hsec = h->root.u.c.p->section;
|
|
|
|
|
hval = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
{
|
|
|
|
|
hsec = h->root.u.def.section;
|
|
|
|
|
hval = h->root.u.def.value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
hsec = NULL;
|
|
|
|
|
hval = 0;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
addend = link_order->u.reloc.p->addend;
|
|
|
|
|
if (hsec != NULL)
|
|
|
|
|
addend += (hsec->output_section->vma
|
|
|
|
|
+ hsec->output_offset
|
|
|
|
|
+ hval);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (addend != 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type size;
|
|
|
|
|
bfd_byte *buf;
|
|
|
|
|
bfd_reloc_status_type rstat;
|
|
|
|
|
bfd_boolean ok;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
size = bfd_get_reloc_size (howto);
|
|
|
|
|
buf = bfd_zmalloc (size);
|
|
|
|
|
if (buf == NULL)
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
|
|
|
|
|
switch (rstat)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
case bfd_reloc_ok:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case bfd_reloc_outofrange:
|
|
|
|
|
abort ();
|
|
|
|
|
case bfd_reloc_overflow:
|
|
|
|
|
if (! ((*finfo->info->callbacks->reloc_overflow)
|
|
|
|
|
(finfo->info, NULL, link_order->u.reloc.p->u.name,
|
|
|
|
|
howto->name, addend, NULL, NULL, (bfd_vma) 0)))
|
|
|
|
|
{
|
|
|
|
|
free (buf);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ok = bfd_set_section_contents (output_bfd, output_section, (void *) buf,
|
|
|
|
|
(file_ptr) link_order->offset, size);
|
|
|
|
|
free (buf);
|
|
|
|
|
if (! ok)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Store the reloc information in the right place. It will get
|
|
|
|
|
swapped and written out at the end of the final_link routine. */
|
|
|
|
|
irel = (finfo->section_info[output_section->target_index].relocs
|
|
|
|
|
+ output_section->reloc_count);
|
|
|
|
|
rel_hash_ptr = (finfo->section_info[output_section->target_index].rel_hashes
|
|
|
|
|
+ output_section->reloc_count);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
memset (irel, 0, sizeof (struct internal_reloc));
|
|
|
|
|
*rel_hash_ptr = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
irel->r_vaddr = output_section->vma + link_order->offset;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (h->indx >= 0)
|
|
|
|
|
irel->r_symndx = h->indx;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Set the index to -2 to force this symbol to get written out. */
|
|
|
|
|
h->indx = -2;
|
|
|
|
|
*rel_hash_ptr = h;
|
|
|
|
|
irel->r_symndx = 0;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
irel->r_type = howto->type;
|
|
|
|
|
irel->r_size = howto->bitsize - 1;
|
|
|
|
|
if (howto->complain_on_overflow == complain_overflow_signed)
|
|
|
|
|
irel->r_size |= 0x80;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
++output_section->reloc_count;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Now output the reloc to the .loader section. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldrel.l_vaddr = irel->r_vaddr;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (hsec != NULL)
|
|
|
|
|
{
|
|
|
|
|
const char *secname;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
secname = hsec->output_section->name;
|
|
|
|
|
|
|
|
|
|
if (strcmp (secname, ".text") == 0)
|
|
|
|
|
ldrel.l_symndx = 0;
|
|
|
|
|
else if (strcmp (secname, ".data") == 0)
|
|
|
|
|
ldrel.l_symndx = 1;
|
|
|
|
|
else if (strcmp (secname, ".bss") == 0)
|
|
|
|
|
ldrel.l_symndx = 2;
|
|
|
|
|
else
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: loader reloc in unrecognized section `%s'"),
|
|
|
|
|
bfd_get_filename (output_bfd), secname);
|
|
|
|
|
bfd_set_error (bfd_error_nonrepresentable_section);
|
|
|
|
|
return FALSE;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (h->ldindx < 0)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: `%s' in loader reloc but not loader sym"),
|
|
|
|
|
bfd_get_filename (output_bfd),
|
|
|
|
|
h->root.root.string);
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
ldrel.l_symndx = h->ldindx;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
|
|
|
|
|
ldrel.l_rsecnm = output_section->target_index;
|
|
|
|
|
bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
|
|
|
|
|
finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Do the final link step. */
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_boolean
|
|
|
|
|
_bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type symesz;
|
|
|
|
|
struct xcoff_final_link_info finfo;
|
|
|
|
|
asection *o;
|
|
|
|
|
struct bfd_link_order *p;
|
|
|
|
|
bfd_size_type max_contents_size;
|
|
|
|
|
bfd_size_type max_sym_count;
|
|
|
|
|
bfd_size_type max_lineno_count;
|
|
|
|
|
bfd_size_type max_reloc_count;
|
|
|
|
|
bfd_size_type max_output_reloc_count;
|
|
|
|
|
file_ptr rel_filepos;
|
|
|
|
|
unsigned int relsz;
|
|
|
|
|
file_ptr line_filepos;
|
|
|
|
|
unsigned int linesz;
|
|
|
|
|
bfd *sub;
|
|
|
|
|
bfd_byte *external_relocs = NULL;
|
|
|
|
|
char strbuf[STRING_SIZE_SIZE];
|
|
|
|
|
file_ptr pos;
|
|
|
|
|
bfd_size_type amt;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (info->shared)
|
|
|
|
|
abfd->flags |= DYNAMIC;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
symesz = bfd_coff_symesz (abfd);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
finfo.info = info;
|
|
|
|
|
finfo.output_bfd = abfd;
|
|
|
|
|
finfo.strtab = NULL;
|
|
|
|
|
finfo.section_info = NULL;
|
|
|
|
|
finfo.last_file_index = -1;
|
|
|
|
|
finfo.toc_symindx = -1;
|
|
|
|
|
finfo.internal_syms = NULL;
|
|
|
|
|
finfo.sym_indices = NULL;
|
|
|
|
|
finfo.outsyms = NULL;
|
|
|
|
|
finfo.linenos = NULL;
|
|
|
|
|
finfo.contents = NULL;
|
|
|
|
|
finfo.external_relocs = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
finfo.ldsym = (xcoff_hash_table (info)->loader_section->contents
|
|
|
|
|
+ bfd_xcoff_ldhdrsz (abfd));
|
|
|
|
|
finfo.ldrel = (xcoff_hash_table (info)->loader_section->contents
|
|
|
|
|
+ bfd_xcoff_ldhdrsz(abfd)
|
|
|
|
|
+ (xcoff_hash_table (info)->ldhdr.l_nsyms
|
|
|
|
|
* bfd_xcoff_ldsymsz(abfd)));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
xcoff_data (abfd)->coff.link_info = info;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
finfo.strtab = _bfd_stringtab_init ();
|
|
|
|
|
if (finfo.strtab == NULL)
|
|
|
|
|
goto error_return;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2009-03-14 17:32:33 +08:00
|
|
|
|
/* Count the relocation entries required for the output file.
|
|
|
|
|
(We've already counted the line numbers.) Determine a few
|
|
|
|
|
maximum sizes. */
|
2005-04-11 16:23:05 +08:00
|
|
|
|
max_contents_size = 0;
|
|
|
|
|
max_lineno_count = 0;
|
|
|
|
|
max_reloc_count = 0;
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
o->reloc_count = 0;
|
2005-05-04 19:00:28 +08:00
|
|
|
|
for (p = o->map_head.link_order; p != NULL; p = p->next)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (p->type == bfd_indirect_link_order)
|
|
|
|
|
{
|
|
|
|
|
asection *sec;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
sec = p->u.indirect.section;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Mark all sections which are to be included in the
|
|
|
|
|
link. This will normally be every section. We need
|
|
|
|
|
to do this so that we can identify any sections which
|
|
|
|
|
the linker has decided to not include. */
|
|
|
|
|
sec->linker_mark = TRUE;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
o->reloc_count += sec->reloc_count;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (sec->rawsize > max_contents_size)
|
|
|
|
|
max_contents_size = sec->rawsize;
|
|
|
|
|
if (sec->size > max_contents_size)
|
|
|
|
|
max_contents_size = sec->size;
|
|
|
|
|
if (coff_section_data (sec->owner, sec) != NULL
|
|
|
|
|
&& xcoff_section_data (sec->owner, sec) != NULL
|
|
|
|
|
&& (xcoff_section_data (sec->owner, sec)->lineno_count
|
|
|
|
|
> max_lineno_count))
|
|
|
|
|
max_lineno_count =
|
|
|
|
|
xcoff_section_data (sec->owner, sec)->lineno_count;
|
|
|
|
|
if (sec->reloc_count > max_reloc_count)
|
|
|
|
|
max_reloc_count = sec->reloc_count;
|
|
|
|
|
}
|
|
|
|
|
else if (p->type == bfd_section_reloc_link_order
|
|
|
|
|
|| p->type == bfd_symbol_reloc_link_order)
|
|
|
|
|
++o->reloc_count;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Compute the file positions for all the sections. */
|
|
|
|
|
if (abfd->output_has_begun)
|
|
|
|
|
{
|
|
|
|
|
if (xcoff_hash_table (info)->file_align != 0)
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bfd_vma file_align;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
file_align = xcoff_hash_table (info)->file_align;
|
|
|
|
|
if (file_align != 0)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_boolean saw_contents;
|
|
|
|
|
int indx;
|
|
|
|
|
file_ptr sofar;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Insert .pad sections before every section which has
|
|
|
|
|
contents and is loaded, if it is preceded by some other
|
|
|
|
|
section which has contents and is loaded. */
|
|
|
|
|
saw_contents = TRUE;
|
2005-05-04 01:05:51 +08:00
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
2005-05-04 01:05:51 +08:00
|
|
|
|
if (strcmp (o->name, ".pad") == 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
saw_contents = FALSE;
|
2005-05-04 01:05:51 +08:00
|
|
|
|
else if ((o->flags & SEC_HAS_CONTENTS) != 0
|
|
|
|
|
&& (o->flags & SEC_LOAD) != 0)
|
2005-04-11 16:23:05 +08:00
|
|
|
|
{
|
|
|
|
|
if (! saw_contents)
|
|
|
|
|
saw_contents = TRUE;
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-05-03 09:05:03 +08:00
|
|
|
|
asection *n;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Create a pad section and place it before the section
|
|
|
|
|
that needs padding. This requires unlinking and
|
|
|
|
|
relinking the bfd's section list. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2006-06-01 11:45:58 +08:00
|
|
|
|
n = bfd_make_section_anyway_with_flags (abfd, ".pad",
|
|
|
|
|
SEC_HAS_CONTENTS);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
n->alignment_power = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-05-03 09:05:03 +08:00
|
|
|
|
bfd_section_list_remove (abfd, n);
|
2005-05-04 01:05:51 +08:00
|
|
|
|
bfd_section_list_insert_before (abfd, o, n);
|
2005-04-11 16:23:05 +08:00
|
|
|
|
saw_contents = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reset the section indices after inserting the new
|
|
|
|
|
sections. */
|
|
|
|
|
indx = 0;
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
++indx;
|
|
|
|
|
o->target_index = indx;
|
|
|
|
|
}
|
|
|
|
|
BFD_ASSERT ((unsigned int) indx == abfd->section_count);
|
|
|
|
|
|
|
|
|
|
/* Work out appropriate sizes for the .pad sections to force
|
|
|
|
|
each section to land on a page boundary. This bit of
|
|
|
|
|
code knows what compute_section_file_positions is going
|
|
|
|
|
to do. */
|
|
|
|
|
sofar = bfd_coff_filhsz (abfd);
|
|
|
|
|
sofar += bfd_coff_aoutsz (abfd);
|
|
|
|
|
sofar += abfd->section_count * bfd_coff_scnhsz (abfd);
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
if ((bfd_xcoff_is_reloc_count_overflow
|
|
|
|
|
(abfd, (bfd_vma) o->reloc_count))
|
|
|
|
|
|| (bfd_xcoff_is_lineno_count_overflow
|
|
|
|
|
(abfd, (bfd_vma) o->lineno_count)))
|
|
|
|
|
/* 64 does not overflow, need to check if 32 does */
|
|
|
|
|
sofar += bfd_coff_scnhsz (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (strcmp (o->name, ".pad") == 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_vma pageoff;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
BFD_ASSERT (o->size == 0);
|
|
|
|
|
pageoff = sofar & (file_align - 1);
|
|
|
|
|
if (pageoff != 0)
|
|
|
|
|
{
|
|
|
|
|
o->size = file_align - pageoff;
|
|
|
|
|
sofar += file_align - pageoff;
|
|
|
|
|
o->flags |= SEC_HAS_CONTENTS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_HAS_CONTENTS) != 0)
|
|
|
|
|
sofar += BFD_ALIGN (o->size,
|
|
|
|
|
1 << o->alignment_power);
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
if (! bfd_coff_compute_section_file_positions (abfd))
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Allocate space for the pointers we need to keep for the relocs. */
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We use section_count + 1, rather than section_count, because
|
|
|
|
|
the target_index fields are 1 based. */
|
|
|
|
|
amt = abfd->section_count + 1;
|
|
|
|
|
amt *= sizeof (struct xcoff_link_section_info);
|
|
|
|
|
finfo.section_info = bfd_malloc (amt);
|
|
|
|
|
if (finfo.section_info == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
for (i = 0; i <= abfd->section_count; i++)
|
|
|
|
|
{
|
|
|
|
|
finfo.section_info[i].relocs = NULL;
|
|
|
|
|
finfo.section_info[i].rel_hashes = NULL;
|
|
|
|
|
finfo.section_info[i].toc_rel_hashes = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Set the file positions for the relocs. */
|
|
|
|
|
rel_filepos = obj_relocbase (abfd);
|
|
|
|
|
relsz = bfd_coff_relsz (abfd);
|
|
|
|
|
max_output_reloc_count = 0;
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if (o->reloc_count == 0)
|
|
|
|
|
o->rel_filepos = 0;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* A stripped file has no relocs. However, we still
|
|
|
|
|
allocate the buffers, so that later code doesn't have to
|
|
|
|
|
worry about whether we are stripping or not. */
|
|
|
|
|
if (info->strip == strip_all)
|
|
|
|
|
o->rel_filepos = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
o->flags |= SEC_RELOC;
|
|
|
|
|
o->rel_filepos = rel_filepos;
|
|
|
|
|
rel_filepos += o->reloc_count * relsz;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We don't know the indices of global symbols until we have
|
|
|
|
|
written out all the local symbols. For each section in
|
|
|
|
|
the output file, we keep an array of pointers to hash
|
|
|
|
|
table entries. Each entry in the array corresponds to a
|
|
|
|
|
reloc. When we find a reloc against a global symbol, we
|
|
|
|
|
set the corresponding entry in this array so that we can
|
|
|
|
|
fix up the symbol index after we have written out all the
|
|
|
|
|
local symbols.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
Because of this problem, we also keep the relocs in
|
|
|
|
|
memory until the end of the link. This wastes memory.
|
|
|
|
|
We could backpatch the file later, I suppose, although it
|
|
|
|
|
would be slow. */
|
|
|
|
|
amt = o->reloc_count;
|
|
|
|
|
amt *= sizeof (struct internal_reloc);
|
|
|
|
|
finfo.section_info[o->target_index].relocs = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
amt = o->reloc_count;
|
|
|
|
|
amt *= sizeof (struct xcoff_link_hash_entry *);
|
|
|
|
|
finfo.section_info[o->target_index].rel_hashes = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (finfo.section_info[o->target_index].relocs == NULL
|
|
|
|
|
|| finfo.section_info[o->target_index].rel_hashes == NULL)
|
|
|
|
|
goto error_return;
|
2001-05-25 04:50:50 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (o->reloc_count > max_output_reloc_count)
|
|
|
|
|
max_output_reloc_count = o->reloc_count;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
}
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* We now know the size of the relocs, so we can determine the file
|
|
|
|
|
positions of the line numbers. */
|
|
|
|
|
line_filepos = rel_filepos;
|
|
|
|
|
finfo.line_filepos = line_filepos;
|
|
|
|
|
linesz = bfd_coff_linesz (abfd);
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if (o->lineno_count == 0)
|
|
|
|
|
o->line_filepos = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
o->line_filepos = line_filepos;
|
|
|
|
|
line_filepos += o->lineno_count * linesz;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Reset the reloc and lineno counts, so that we can use them to
|
|
|
|
|
count the number of entries we have output so far. */
|
|
|
|
|
o->reloc_count = 0;
|
|
|
|
|
o->lineno_count = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
obj_sym_filepos (abfd) = line_filepos;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Figure out the largest number of symbols in an input BFD. Take
|
|
|
|
|
the opportunity to clear the output_has_begun fields of all the
|
|
|
|
|
input BFD's. We want at least 6 symbols, since that is the
|
|
|
|
|
number which xcoff_write_global_symbol may need. */
|
|
|
|
|
max_sym_count = 6;
|
|
|
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
bfd_size_type sz;
|
|
|
|
|
|
|
|
|
|
sub->output_has_begun = FALSE;
|
|
|
|
|
sz = obj_raw_syment_count (sub);
|
|
|
|
|
if (sz > max_sym_count)
|
|
|
|
|
max_sym_count = sz;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Allocate some buffers used while linking. */
|
|
|
|
|
amt = max_sym_count * sizeof (struct internal_syment);
|
|
|
|
|
finfo.internal_syms = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
amt = max_sym_count * sizeof (long);
|
|
|
|
|
finfo.sym_indices = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
amt = (max_sym_count + 1) * symesz;
|
|
|
|
|
finfo.outsyms = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
amt = max_lineno_count * bfd_coff_linesz (abfd);
|
|
|
|
|
finfo.linenos = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
amt = max_contents_size;
|
|
|
|
|
finfo.contents = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
amt = max_reloc_count * relsz;
|
|
|
|
|
finfo.external_relocs = bfd_malloc (amt);
|
|
|
|
|
|
|
|
|
|
if ((finfo.internal_syms == NULL && max_sym_count > 0)
|
|
|
|
|
|| (finfo.sym_indices == NULL && max_sym_count > 0)
|
|
|
|
|
|| finfo.outsyms == NULL
|
|
|
|
|
|| (finfo.linenos == NULL && max_lineno_count > 0)
|
|
|
|
|
|| (finfo.contents == NULL && max_contents_size > 0)
|
|
|
|
|
|| (finfo.external_relocs == NULL && max_reloc_count > 0))
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
obj_raw_syment_count (abfd) = 0;
|
2009-03-14 17:18:22 +08:00
|
|
|
|
|
|
|
|
|
/* Find a TOC symbol, if we need one. */
|
|
|
|
|
if (!xcoff_find_tc0 (abfd, &finfo))
|
|
|
|
|
goto error_return;
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
/* We now know the position of everything in the file, except that
|
|
|
|
|
we don't know the size of the symbol table and therefore we don't
|
|
|
|
|
know where the string table starts. We just build the string
|
|
|
|
|
table in memory as we go along. We process all the relocations
|
|
|
|
|
for a single input file at once. */
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
2005-05-04 19:00:28 +08:00
|
|
|
|
for (p = o->map_head.link_order; p != NULL; p = p->next)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (p->type == bfd_indirect_link_order
|
|
|
|
|
&& p->u.indirect.section->owner->xvec == abfd->xvec)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
sub = p->u.indirect.section->owner;
|
|
|
|
|
if (! sub->output_has_begun)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (! xcoff_link_input_bfd (&finfo, sub))
|
|
|
|
|
goto error_return;
|
|
|
|
|
sub->output_has_begun = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
else if (p->type == bfd_section_reloc_link_order
|
|
|
|
|
|| p->type == bfd_symbol_reloc_link_order)
|
|
|
|
|
{
|
|
|
|
|
if (! xcoff_reloc_link_order (abfd, &finfo, o, p))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_default_link_order (abfd, info, o, p))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
|
|
|
|
|
/* Free up the buffers used by xcoff_link_input_bfd. */
|
|
|
|
|
if (finfo.internal_syms != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
free (finfo.internal_syms);
|
|
|
|
|
finfo.internal_syms = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (finfo.sym_indices != NULL)
|
|
|
|
|
{
|
|
|
|
|
free (finfo.sym_indices);
|
|
|
|
|
finfo.sym_indices = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (finfo.linenos != NULL)
|
|
|
|
|
{
|
|
|
|
|
free (finfo.linenos);
|
|
|
|
|
finfo.linenos = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (finfo.contents != NULL)
|
|
|
|
|
{
|
|
|
|
|
free (finfo.contents);
|
|
|
|
|
finfo.contents = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (finfo.external_relocs != NULL)
|
|
|
|
|
{
|
|
|
|
|
free (finfo.external_relocs);
|
|
|
|
|
finfo.external_relocs = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* The value of the last C_FILE symbol is supposed to be -1. Write
|
|
|
|
|
it out again. */
|
|
|
|
|
if (finfo.last_file_index != -1)
|
|
|
|
|
{
|
|
|
|
|
finfo.last_file.n_value = -(bfd_vma) 1;
|
|
|
|
|
bfd_coff_swap_sym_out (abfd, (void *) &finfo.last_file,
|
|
|
|
|
(void *) finfo.outsyms);
|
|
|
|
|
pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
|
|
|
|
|
if (bfd_seek (abfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write out all the global symbols which do not come from XCOFF
|
|
|
|
|
input files. */
|
|
|
|
|
xcoff_link_hash_traverse (xcoff_hash_table (info),
|
|
|
|
|
xcoff_write_global_symbol,
|
|
|
|
|
(void *) &finfo);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (finfo.outsyms != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
free (finfo.outsyms);
|
|
|
|
|
finfo.outsyms = NULL;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Now that we have written out all the global symbols, we know the
|
|
|
|
|
symbol indices to use for relocs against them, and we can finally
|
|
|
|
|
write out the relocs. */
|
|
|
|
|
amt = max_output_reloc_count * relsz;
|
|
|
|
|
external_relocs = bfd_malloc (amt);
|
|
|
|
|
if (external_relocs == NULL && max_output_reloc_count != 0)
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
struct internal_reloc *irel;
|
|
|
|
|
struct internal_reloc *irelend;
|
|
|
|
|
struct xcoff_link_hash_entry **rel_hash;
|
|
|
|
|
struct xcoff_toc_rel_hash *toc_rel_hash;
|
|
|
|
|
bfd_byte *erel;
|
|
|
|
|
bfd_size_type rel_size;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* A stripped file has no relocs. */
|
|
|
|
|
if (info->strip == strip_all)
|
|
|
|
|
{
|
|
|
|
|
o->reloc_count = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (o->reloc_count == 0)
|
|
|
|
|
continue;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
irel = finfo.section_info[o->target_index].relocs;
|
|
|
|
|
irelend = irel + o->reloc_count;
|
|
|
|
|
rel_hash = finfo.section_info[o->target_index].rel_hashes;
|
|
|
|
|
for (; irel < irelend; irel++, rel_hash++, erel += relsz)
|
|
|
|
|
{
|
|
|
|
|
if (*rel_hash != NULL)
|
|
|
|
|
{
|
|
|
|
|
if ((*rel_hash)->indx < 0)
|
|
|
|
|
{
|
|
|
|
|
if (! ((*info->callbacks->unattached_reloc)
|
|
|
|
|
(info, (*rel_hash)->root.root.string,
|
|
|
|
|
NULL, o, irel->r_vaddr)))
|
|
|
|
|
goto error_return;
|
|
|
|
|
(*rel_hash)->indx = 0;
|
|
|
|
|
}
|
|
|
|
|
irel->r_symndx = (*rel_hash)->indx;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (toc_rel_hash = finfo.section_info[o->target_index].toc_rel_hashes;
|
|
|
|
|
toc_rel_hash != NULL;
|
|
|
|
|
toc_rel_hash = toc_rel_hash->next)
|
|
|
|
|
{
|
|
|
|
|
if (toc_rel_hash->h->u.toc_indx < 0)
|
|
|
|
|
{
|
|
|
|
|
if (! ((*info->callbacks->unattached_reloc)
|
|
|
|
|
(info, toc_rel_hash->h->root.root.string,
|
|
|
|
|
NULL, o, toc_rel_hash->rel->r_vaddr)))
|
|
|
|
|
goto error_return;
|
|
|
|
|
toc_rel_hash->h->u.toc_indx = 0;
|
|
|
|
|
}
|
|
|
|
|
toc_rel_hash->rel->r_symndx = toc_rel_hash->h->u.toc_indx;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* XCOFF requires that the relocs be sorted by address. We tend
|
|
|
|
|
to produce them in the order in which their containing csects
|
|
|
|
|
appear in the symbol table, which is not necessarily by
|
|
|
|
|
address. So we sort them here. There may be a better way to
|
|
|
|
|
do this. */
|
|
|
|
|
qsort ((void *) finfo.section_info[o->target_index].relocs,
|
|
|
|
|
o->reloc_count, sizeof (struct internal_reloc),
|
|
|
|
|
xcoff_sort_relocs);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
irel = finfo.section_info[o->target_index].relocs;
|
|
|
|
|
irelend = irel + o->reloc_count;
|
|
|
|
|
erel = external_relocs;
|
|
|
|
|
for (; irel < irelend; irel++, rel_hash++, erel += relsz)
|
|
|
|
|
bfd_coff_swap_reloc_out (abfd, (void *) irel, (void *) erel);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
rel_size = relsz * o->reloc_count;
|
|
|
|
|
if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite ((void *) external_relocs, rel_size, abfd) != rel_size)
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (external_relocs != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
free (external_relocs);
|
|
|
|
|
external_relocs = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Free up the section information. */
|
|
|
|
|
if (finfo.section_info != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
unsigned int i;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (i = 0; i < abfd->section_count; i++)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (finfo.section_info[i].relocs != NULL)
|
|
|
|
|
free (finfo.section_info[i].relocs);
|
|
|
|
|
if (finfo.section_info[i].rel_hashes != NULL)
|
|
|
|
|
free (finfo.section_info[i].rel_hashes);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
free (finfo.section_info);
|
|
|
|
|
finfo.section_info = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write out the loader section contents. */
|
|
|
|
|
BFD_ASSERT ((bfd_byte *) finfo.ldrel
|
|
|
|
|
== (xcoff_hash_table (info)->loader_section->contents
|
|
|
|
|
+ xcoff_hash_table (info)->ldhdr.l_impoff));
|
|
|
|
|
o = xcoff_hash_table (info)->loader_section;
|
|
|
|
|
if (! bfd_set_section_contents (abfd, o->output_section, o->contents,
|
|
|
|
|
(file_ptr) o->output_offset, o->size))
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write out the magic sections. */
|
|
|
|
|
o = xcoff_hash_table (info)->linkage_section;
|
|
|
|
|
if (o->size > 0
|
|
|
|
|
&& ! bfd_set_section_contents (abfd, o->output_section, o->contents,
|
|
|
|
|
(file_ptr) o->output_offset,
|
|
|
|
|
o->size))
|
|
|
|
|
goto error_return;
|
|
|
|
|
o = xcoff_hash_table (info)->toc_section;
|
|
|
|
|
if (o->size > 0
|
|
|
|
|
&& ! bfd_set_section_contents (abfd, o->output_section, o->contents,
|
|
|
|
|
(file_ptr) o->output_offset,
|
|
|
|
|
o->size))
|
|
|
|
|
goto error_return;
|
|
|
|
|
o = xcoff_hash_table (info)->descriptor_section;
|
|
|
|
|
if (o->size > 0
|
|
|
|
|
&& ! bfd_set_section_contents (abfd, o->output_section, o->contents,
|
|
|
|
|
(file_ptr) o->output_offset,
|
|
|
|
|
o->size))
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write out the string table. */
|
|
|
|
|
pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz;
|
|
|
|
|
if (bfd_seek (abfd, pos, SEEK_SET) != 0)
|
|
|
|
|
goto error_return;
|
|
|
|
|
H_PUT_32 (abfd,
|
|
|
|
|
_bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
|
|
|
|
|
strbuf);
|
|
|
|
|
amt = STRING_SIZE_SIZE;
|
|
|
|
|
if (bfd_bwrite (strbuf, amt, abfd) != amt)
|
|
|
|
|
goto error_return;
|
|
|
|
|
if (! _bfd_stringtab_emit (abfd, finfo.strtab))
|
|
|
|
|
goto error_return;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
_bfd_stringtab_free (finfo.strtab);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Write out the debugging string table. */
|
|
|
|
|
o = xcoff_hash_table (info)->debug_section;
|
|
|
|
|
if (o != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
struct bfd_strtab_hash *debug_strtab;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
debug_strtab = xcoff_hash_table (info)->debug_strtab;
|
|
|
|
|
BFD_ASSERT (o->output_section->size - o->output_offset
|
|
|
|
|
>= _bfd_stringtab_size (debug_strtab));
|
|
|
|
|
pos = o->output_section->filepos + o->output_offset;
|
|
|
|
|
if (bfd_seek (abfd, pos, SEEK_SET) != 0)
|
|
|
|
|
goto error_return;
|
|
|
|
|
if (! _bfd_stringtab_emit (abfd, debug_strtab))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
/* Setting bfd_get_symcount to 0 will cause write_object_contents to
|
|
|
|
|
not try to write out the symbols. */
|
|
|
|
|
bfd_get_symcount (abfd) = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
error_return:
|
|
|
|
|
if (finfo.strtab != NULL)
|
|
|
|
|
_bfd_stringtab_free (finfo.strtab);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (finfo.section_info != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
unsigned int i;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
for (i = 0; i < abfd->section_count; i++)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (finfo.section_info[i].relocs != NULL)
|
|
|
|
|
free (finfo.section_info[i].relocs);
|
|
|
|
|
if (finfo.section_info[i].rel_hashes != NULL)
|
|
|
|
|
free (finfo.section_info[i].rel_hashes);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2005-04-11 16:23:05 +08:00
|
|
|
|
free (finfo.section_info);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-11 16:23:05 +08:00
|
|
|
|
if (finfo.internal_syms != NULL)
|
|
|
|
|
free (finfo.internal_syms);
|
|
|
|
|
if (finfo.sym_indices != NULL)
|
|
|
|
|
free (finfo.sym_indices);
|
|
|
|
|
if (finfo.outsyms != NULL)
|
|
|
|
|
free (finfo.outsyms);
|
|
|
|
|
if (finfo.linenos != NULL)
|
|
|
|
|
free (finfo.linenos);
|
|
|
|
|
if (finfo.contents != NULL)
|
|
|
|
|
free (finfo.contents);
|
|
|
|
|
if (finfo.external_relocs != NULL)
|
|
|
|
|
free (finfo.external_relocs);
|
|
|
|
|
if (external_relocs != NULL)
|
|
|
|
|
free (external_relocs);
|
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|