1999-05-03 15:29:11 +08:00
|
|
|
/* Support for the generic parts of COFF, for BFD.
|
2001-03-09 05:04:02 +08:00
|
|
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
2007-04-26 22:47:00 +08:00
|
|
|
2000, 2001, 2002, 2003, 2004, 2005, 2007
|
1999-05-03 15:29:11 +08:00
|
|
|
Free Software Foundation, Inc.
|
|
|
|
Written by Cygnus Support.
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-03-23 00:14:43 +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
|
2005-03-23 00:14:43 +08:00
|
|
|
(at your option) any later version.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-03-23 00:14:43 +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
|
|
|
|
2005-03-23 00:14:43 +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
|
|
|
|
|
|
|
/* Most of this hacked by Steve Chamberlain, sac@cygnus.com.
|
|
|
|
Split out of coffcode.h by Ian Taylor, ian@cygnus.com. */
|
|
|
|
|
|
|
|
/* This file contains COFF code that is not dependent on any
|
|
|
|
particular COFF target. There is only one version of this file in
|
|
|
|
libbfd.a, so no target specific code may be put in here. Or, to
|
|
|
|
put it another way,
|
|
|
|
|
|
|
|
********** DO NOT PUT TARGET SPECIFIC CODE IN THIS FILE **********
|
|
|
|
|
|
|
|
If you need to add some target specific behaviour, add a new hook
|
|
|
|
function to bfd_coff_backend_data.
|
|
|
|
|
|
|
|
Some of these functions are also called by the ECOFF routines.
|
|
|
|
Those functions may not use any COFF specific information, such as
|
|
|
|
coff_data (abfd). */
|
|
|
|
|
|
|
|
#include "sysdep.h"
|
2007-04-26 22:47:00 +08:00
|
|
|
#include "bfd.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
#include "libbfd.h"
|
|
|
|
#include "coff/internal.h"
|
|
|
|
#include "libcoff.h"
|
|
|
|
|
|
|
|
/* Take a section header read from a coff file (in HOST byte order),
|
|
|
|
and make a BFD "section" out of it. This is used by ECOFF. */
|
2005-03-23 00:14:43 +08:00
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
static bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
make_a_section_from_file (bfd *abfd,
|
|
|
|
struct internal_scnhdr *hdr,
|
|
|
|
unsigned int target_index)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
asection *return_section;
|
|
|
|
char *name;
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean result = TRUE;
|
2001-06-15 17:03:14 +08:00
|
|
|
flagword flags;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
|
|
|
/* Handle long section names as in PE. */
|
|
|
|
if (bfd_coff_long_section_names (abfd)
|
|
|
|
&& hdr->s_name[0] == '/')
|
|
|
|
{
|
|
|
|
char buf[SCNNMLEN];
|
|
|
|
long strindex;
|
|
|
|
char *p;
|
|
|
|
const char *strings;
|
|
|
|
|
|
|
|
memcpy (buf, hdr->s_name + 1, SCNNMLEN - 1);
|
|
|
|
buf[SCNNMLEN - 1] = '\0';
|
|
|
|
strindex = strtol (buf, &p, 10);
|
|
|
|
if (*p == '\0' && strindex >= 0)
|
|
|
|
{
|
|
|
|
strings = _bfd_coff_read_string_table (abfd);
|
|
|
|
if (strings == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
/* FIXME: For extra safety, we should make sure that
|
|
|
|
strindex does not run us past the end, but right now we
|
|
|
|
don't know the length of the string table. */
|
|
|
|
strings += strindex;
|
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
|
|
|
name = bfd_alloc (abfd, (bfd_size_type) strlen (strings) + 1);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (name == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
strcpy (name, strings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
{
|
|
|
|
/* Assorted wastage to null-terminate the name, thanks AT&T! */
|
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
|
|
|
name = bfd_alloc (abfd, (bfd_size_type) sizeof (hdr->s_name) + 1);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (name == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
|
|
|
|
name[sizeof (hdr->s_name)] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_section = bfd_make_section_anyway (abfd, name);
|
|
|
|
if (return_section == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
return_section->vma = hdr->s_vaddr;
|
|
|
|
return_section->lma = hdr->s_paddr;
|
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
|
|
|
return_section->size = hdr->s_size;
|
1999-05-03 15:29:11 +08:00
|
|
|
return_section->filepos = hdr->s_scnptr;
|
|
|
|
return_section->rel_filepos = hdr->s_relptr;
|
|
|
|
return_section->reloc_count = hdr->s_nreloc;
|
|
|
|
|
|
|
|
bfd_coff_set_alignment_hook (abfd, return_section, hdr);
|
|
|
|
|
|
|
|
return_section->line_filepos = hdr->s_lnnoptr;
|
|
|
|
|
|
|
|
return_section->lineno_count = hdr->s_nlnno;
|
|
|
|
return_section->userdata = NULL;
|
2005-03-23 00:14:43 +08:00
|
|
|
return_section->next = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
return_section->target_index = target_index;
|
2001-06-15 17:03:14 +08:00
|
|
|
|
|
|
|
if (! bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name, return_section,
|
|
|
|
& flags))
|
2002-11-30 16:39:46 +08:00
|
|
|
result = 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
|
|
|
|
2001-06-15 17:03:14 +08:00
|
|
|
return_section->flags = flags;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
/* At least on i386-coff, the line number count for a shared library
|
|
|
|
section must be ignored. */
|
|
|
|
if ((return_section->flags & SEC_COFF_SHARED_LIBRARY) != 0)
|
|
|
|
return_section->lineno_count = 0;
|
|
|
|
|
|
|
|
if (hdr->s_nreloc != 0)
|
|
|
|
return_section->flags |= SEC_RELOC;
|
2005-03-23 00:14:43 +08:00
|
|
|
/* FIXME: should this check 'hdr->s_size > 0'. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (hdr->s_scnptr != 0)
|
|
|
|
return_section->flags |= SEC_HAS_CONTENTS;
|
2001-06-15 17:03:14 +08:00
|
|
|
|
|
|
|
return result;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read in a COFF object and make it into a BFD. This is used by
|
|
|
|
ECOFF as well. */
|
|
|
|
|
|
|
|
static const bfd_target *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_real_object_p (bfd *abfd,
|
|
|
|
unsigned nscns,
|
|
|
|
struct internal_filehdr *internal_f,
|
|
|
|
struct internal_aouthdr *internal_a)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
flagword oflags = abfd->flags;
|
|
|
|
bfd_vma ostart = bfd_get_start_address (abfd);
|
2005-03-23 00:14:43 +08:00
|
|
|
void * tdata;
|
|
|
|
void * tdata_save;
|
|
|
|
bfd_size_type readsize; /* Length of file_info. */
|
1999-05-03 15:29:11 +08:00
|
|
|
unsigned int scnhsz;
|
|
|
|
char *external_sections;
|
|
|
|
|
|
|
|
if (!(internal_f->f_flags & F_RELFLG))
|
|
|
|
abfd->flags |= HAS_RELOC;
|
|
|
|
if ((internal_f->f_flags & F_EXEC))
|
|
|
|
abfd->flags |= EXEC_P;
|
|
|
|
if (!(internal_f->f_flags & F_LNNO))
|
|
|
|
abfd->flags |= HAS_LINENO;
|
|
|
|
if (!(internal_f->f_flags & F_LSYMS))
|
|
|
|
abfd->flags |= HAS_LOCALS;
|
|
|
|
|
|
|
|
/* FIXME: How can we set D_PAGED correctly? */
|
|
|
|
if ((internal_f->f_flags & F_EXEC) != 0)
|
|
|
|
abfd->flags |= D_PAGED;
|
|
|
|
|
|
|
|
bfd_get_symcount (abfd) = internal_f->f_nsyms;
|
|
|
|
if (internal_f->f_nsyms)
|
|
|
|
abfd->flags |= HAS_SYMS;
|
|
|
|
|
|
|
|
if (internal_a != (struct internal_aouthdr *) NULL)
|
|
|
|
bfd_get_start_address (abfd) = internal_a->entry;
|
|
|
|
else
|
|
|
|
bfd_get_start_address (abfd) = 0;
|
|
|
|
|
|
|
|
/* Set up the tdata area. ECOFF uses its own routine, and overrides
|
|
|
|
abfd->flags. */
|
2002-07-30 13:49:24 +08:00
|
|
|
tdata_save = abfd->tdata.any;
|
2005-03-23 00:14:43 +08:00
|
|
|
tdata = bfd_coff_mkobject_hook (abfd, (void *) internal_f, (void *) internal_a);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (tdata == NULL)
|
2002-07-30 13:49:24 +08:00
|
|
|
goto fail2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
scnhsz = bfd_coff_scnhsz (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
|
|
|
readsize = (bfd_size_type) nscns * scnhsz;
|
2005-03-23 00:14:43 +08:00
|
|
|
external_sections = bfd_alloc (abfd, readsize);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (!external_sections)
|
|
|
|
goto fail;
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
if (bfd_bread ((void *) external_sections, readsize, abfd) != readsize)
|
1999-05-03 15:29:11 +08:00
|
|
|
goto fail;
|
|
|
|
|
2000-02-09 21:41:44 +08:00
|
|
|
/* Set the arch/mach *before* swapping in sections; section header swapping
|
2000-11-28 09:33:15 +08:00
|
|
|
may depend on arch/mach info. */
|
2005-03-23 00:14:43 +08:00
|
|
|
if (! bfd_coff_set_arch_mach_hook (abfd, (void *) internal_f))
|
2000-02-09 21:41:44 +08:00
|
|
|
goto fail;
|
|
|
|
|
2003-03-26 04:56:01 +08:00
|
|
|
/* Now copy data as required; construct all asections etc. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (nscns != 0)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < nscns; i++)
|
|
|
|
{
|
|
|
|
struct internal_scnhdr tmp;
|
|
|
|
bfd_coff_swap_scnhdr_in (abfd,
|
2005-03-23 00:14:43 +08:00
|
|
|
(void *) (external_sections + i * scnhsz),
|
|
|
|
(void *) & tmp);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (! make_a_section_from_file (abfd, &tmp, i + 1))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return abfd->xvec;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
bfd_release (abfd, tdata);
|
2002-07-30 13:49:24 +08:00
|
|
|
fail2:
|
|
|
|
abfd->tdata.any = tdata_save;
|
1999-05-03 15:29:11 +08:00
|
|
|
abfd->flags = oflags;
|
|
|
|
bfd_get_start_address (abfd) = ostart;
|
|
|
|
return (const bfd_target *) NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Turn a COFF file into a BFD, but fail with bfd_error_wrong_format if it is
|
|
|
|
not a COFF file. This is also used by ECOFF. */
|
|
|
|
|
|
|
|
const bfd_target *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_object_p (bfd *abfd)
|
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
|
|
|
bfd_size_type filhsz;
|
|
|
|
bfd_size_type aoutsz;
|
|
|
|
unsigned int nscns;
|
2005-03-23 00:14:43 +08:00
|
|
|
void * filehdr;
|
1999-05-03 15:29:11 +08:00
|
|
|
struct internal_filehdr internal_f;
|
|
|
|
struct internal_aouthdr internal_a;
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Figure out how much to read. */
|
1999-05-03 15:29:11 +08:00
|
|
|
filhsz = bfd_coff_filhsz (abfd);
|
|
|
|
aoutsz = bfd_coff_aoutsz (abfd);
|
|
|
|
|
|
|
|
filehdr = bfd_alloc (abfd, filhsz);
|
|
|
|
if (filehdr == NULL)
|
2002-07-30 13:49:24 +08:00
|
|
|
return 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 (bfd_bread (filehdr, filhsz, abfd) != filhsz)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
if (bfd_get_error () != bfd_error_system_call)
|
|
|
|
bfd_set_error (bfd_error_wrong_format);
|
2002-07-30 13:49:24 +08:00
|
|
|
bfd_release (abfd, filehdr);
|
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f);
|
|
|
|
bfd_release (abfd, filehdr);
|
|
|
|
|
2001-11-03 00:29:15 +08:00
|
|
|
/* The XCOFF format has two sizes for the f_opthdr. SMALL_AOUTSZ
|
|
|
|
(less than aoutsz) used in object files and AOUTSZ (equal to
|
|
|
|
aoutsz) in executables. The bfd_coff_swap_aouthdr_in function
|
|
|
|
expects this header to be aoutsz bytes in length, so we use that
|
|
|
|
value in the call to bfd_alloc below. But we must be careful to
|
|
|
|
only read in f_opthdr bytes in the call to bfd_bread. We should
|
|
|
|
also attempt to catch corrupt or non-COFF binaries with a strange
|
|
|
|
value for f_opthdr. */
|
2002-06-25 14:21:54 +08:00
|
|
|
if (! bfd_coff_bad_format_hook (abfd, &internal_f)
|
2001-11-02 23:47:24 +08:00
|
|
|
|| internal_f.f_opthdr > aoutsz)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_wrong_format);
|
2002-07-30 13:49:24 +08:00
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
nscns = internal_f.f_nscns;
|
|
|
|
|
|
|
|
if (internal_f.f_opthdr)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
void * opthdr;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
opthdr = bfd_alloc (abfd, aoutsz);
|
|
|
|
if (opthdr == NULL)
|
2002-07-30 13:49:24 +08:00
|
|
|
return 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 (bfd_bread (opthdr, (bfd_size_type) internal_f.f_opthdr, abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
!= internal_f.f_opthdr)
|
|
|
|
{
|
2002-07-30 13:49:24 +08:00
|
|
|
bfd_release (abfd, opthdr);
|
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_coff_swap_aouthdr_in (abfd, opthdr, (void *) &internal_a);
|
2002-07-30 13:49:24 +08:00
|
|
|
bfd_release (abfd, opthdr);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return coff_real_object_p (abfd, nscns, &internal_f,
|
|
|
|
(internal_f.f_opthdr != 0
|
|
|
|
? &internal_a
|
|
|
|
: (struct internal_aouthdr *) NULL));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the BFD section from a COFF symbol section number. */
|
|
|
|
|
|
|
|
asection *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_section_from_bfd_index (bfd *abfd, int index)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2003-10-19 Andrew Cagney <cagney@redhat.com>
* targets.c: Replace "struct sec" with "struct bfd_section"
* syms.c, sparclynx.c, section.c, opncls.c: Ditto.
* libcoff-in.h, libbfd-in.h, elfxx-target.h: Ditto.
* elf.c, coffgen.c, bfd.c, bfd-in.h, aoutf1.h: Ditto.
* aout-tic30.c, aout-target.h:
* bfd-in2.h, libcoff.h, libbfd.h: Regenerate.
Index: binutils/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* coffgrok.h (coff_section): Replace 'struct sec" with "struct
bfd_section".
Index: gdb/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* symtab.c: Replace "struct sec" with "struct bfd_section".
* objfiles.c, linespec.c, blockframe.c, block.c: Ditto.
Index: ld/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* pe-dll.c: Replace "struct sec" with "struct bfd_section".
Index: sim/common/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* sim-base.h: Replace "struct sec" with "struct bfd_section".
2003-10-20 22:38:46 +08:00
|
|
|
struct bfd_section *answer = abfd->sections;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (index == N_ABS)
|
|
|
|
return bfd_abs_section_ptr;
|
|
|
|
if (index == N_UNDEF)
|
|
|
|
return bfd_und_section_ptr;
|
|
|
|
if (index == N_DEBUG)
|
|
|
|
return bfd_abs_section_ptr;
|
|
|
|
|
|
|
|
while (answer)
|
|
|
|
{
|
|
|
|
if (answer->target_index == index)
|
|
|
|
return answer;
|
|
|
|
answer = answer->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
|
|
|
|
has a bad symbol table in biglitpow.o. */
|
|
|
|
return bfd_und_section_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the upper bound of a COFF symbol table. */
|
|
|
|
|
|
|
|
long
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_get_symtab_upper_bound (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
if (!bfd_coff_slurp_symbol_table (abfd))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return (bfd_get_symcount (abfd) + 1) * (sizeof (coff_symbol_type *));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Canonicalize a COFF symbol table. */
|
|
|
|
|
|
|
|
long
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_canonicalize_symtab (bfd *abfd, asymbol **alocation)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int counter;
|
|
|
|
coff_symbol_type *symbase;
|
|
|
|
coff_symbol_type **location = (coff_symbol_type **) alocation;
|
|
|
|
|
|
|
|
if (!bfd_coff_slurp_symbol_table (abfd))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
symbase = obj_symbols (abfd);
|
|
|
|
counter = bfd_get_symcount (abfd);
|
|
|
|
while (counter-- > 0)
|
|
|
|
*location++ = symbase++;
|
|
|
|
|
|
|
|
*location = NULL;
|
|
|
|
|
|
|
|
return bfd_get_symcount (abfd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the name of a symbol. The caller must pass in a buffer of size
|
|
|
|
>= SYMNMLEN + 1. */
|
|
|
|
|
|
|
|
const char *
|
2005-03-23 00:14:43 +08:00
|
|
|
_bfd_coff_internal_syment_name (bfd *abfd,
|
|
|
|
const struct internal_syment *sym,
|
|
|
|
char *buf)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
/* FIXME: It's not clear this will work correctly if sizeof
|
|
|
|
(_n_zeroes) != 4. */
|
|
|
|
if (sym->_n._n_n._n_zeroes != 0
|
|
|
|
|| sym->_n._n_n._n_offset == 0)
|
|
|
|
{
|
|
|
|
memcpy (buf, sym->_n._n_name, SYMNMLEN);
|
|
|
|
buf[SYMNMLEN] = '\0';
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *strings;
|
|
|
|
|
|
|
|
BFD_ASSERT (sym->_n._n_n._n_offset >= STRING_SIZE_SIZE);
|
|
|
|
strings = obj_coff_strings (abfd);
|
|
|
|
if (strings == NULL)
|
|
|
|
{
|
|
|
|
strings = _bfd_coff_read_string_table (abfd);
|
|
|
|
if (strings == NULL)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return strings + sym->_n._n_n._n_offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read in and swap the relocs. This returns a buffer holding the
|
2002-11-30 16:39:46 +08:00
|
|
|
relocs for section SEC in file ABFD. If CACHE is TRUE and
|
1999-05-03 15:29:11 +08:00
|
|
|
INTERNAL_RELOCS is NULL, the relocs read in will be saved in case
|
|
|
|
the function is called again. If EXTERNAL_RELOCS is not NULL, it
|
|
|
|
is a buffer large enough to hold the unswapped relocs. If
|
|
|
|
INTERNAL_RELOCS is not NULL, it is a buffer large enough to hold
|
2002-11-30 16:39:46 +08:00
|
|
|
the swapped relocs. If REQUIRE_INTERNAL is TRUE, then the return
|
1999-05-03 15:29:11 +08:00
|
|
|
value must be INTERNAL_RELOCS. The function returns NULL on error. */
|
|
|
|
|
|
|
|
struct internal_reloc *
|
2005-03-23 00:14:43 +08:00
|
|
|
_bfd_coff_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
|
|
|
{
|
|
|
|
bfd_size_type relsz;
|
|
|
|
bfd_byte *free_external = NULL;
|
|
|
|
struct internal_reloc *free_internal = NULL;
|
|
|
|
bfd_byte *erel;
|
|
|
|
bfd_byte *erel_end;
|
|
|
|
struct internal_reloc *irel;
|
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
|
|
|
|
|
|
|
if (coff_section_data (abfd, sec) != NULL
|
|
|
|
&& coff_section_data (abfd, sec)->relocs != NULL)
|
|
|
|
{
|
|
|
|
if (! require_internal)
|
|
|
|
return coff_section_data (abfd, sec)->relocs;
|
|
|
|
memcpy (internal_relocs, coff_section_data (abfd, sec)->relocs,
|
|
|
|
sec->reloc_count * sizeof (struct internal_reloc));
|
|
|
|
return internal_relocs;
|
|
|
|
}
|
|
|
|
|
|
|
|
relsz = bfd_coff_relsz (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
|
|
|
amt = sec->reloc_count * relsz;
|
1999-05-03 15:29:11 +08:00
|
|
|
if (external_relocs == NULL)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
free_external = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (free_external == NULL && sec->reloc_count > 0)
|
|
|
|
goto error_return;
|
|
|
|
external_relocs = free_external;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 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
|
|
|
|| bfd_bread (external_relocs, amt, abfd) != amt)
|
1999-05-03 15:29:11 +08:00
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
if (internal_relocs == 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 = sec->reloc_count;
|
|
|
|
amt *= sizeof (struct internal_reloc);
|
2005-03-23 00:14:43 +08:00
|
|
|
free_internal = bfd_malloc (amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (free_internal == NULL && sec->reloc_count > 0)
|
|
|
|
goto error_return;
|
|
|
|
internal_relocs = free_internal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Swap in the relocs. */
|
|
|
|
erel = external_relocs;
|
|
|
|
erel_end = erel + relsz * sec->reloc_count;
|
|
|
|
irel = internal_relocs;
|
|
|
|
for (; erel < erel_end; erel += relsz, irel++)
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_coff_swap_reloc_in (abfd, (void *) erel, (void *) irel);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (free_external != NULL)
|
|
|
|
{
|
|
|
|
free (free_external);
|
|
|
|
free_external = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cache && free_internal != NULL)
|
|
|
|
{
|
|
|
|
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
|
|
|
amt = sizeof (struct coff_section_tdata);
|
2005-03-23 00:14:43 +08:00
|
|
|
sec->used_by_bfd = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (sec->used_by_bfd == NULL)
|
|
|
|
goto error_return;
|
|
|
|
coff_section_data (abfd, sec)->contents = NULL;
|
|
|
|
}
|
|
|
|
coff_section_data (abfd, sec)->relocs = free_internal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return internal_relocs;
|
|
|
|
|
|
|
|
error_return:
|
|
|
|
if (free_external != NULL)
|
|
|
|
free (free_external);
|
|
|
|
if (free_internal != NULL)
|
|
|
|
free (free_internal);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set lineno_count for the output sections of a COFF file. */
|
|
|
|
|
|
|
|
int
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_count_linenumbers (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int limit = bfd_get_symcount (abfd);
|
|
|
|
unsigned int i;
|
|
|
|
int total = 0;
|
|
|
|
asymbol **p;
|
|
|
|
asection *s;
|
|
|
|
|
|
|
|
if (limit == 0)
|
|
|
|
{
|
|
|
|
/* This may be from the backend linker, in which case the
|
|
|
|
lineno_count in the sections is correct. */
|
|
|
|
for (s = abfd->sections; s != NULL; s = s->next)
|
|
|
|
total += s->lineno_count;
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (s = abfd->sections; s != NULL; s = s->next)
|
|
|
|
BFD_ASSERT (s->lineno_count == 0);
|
|
|
|
|
|
|
|
for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
|
|
|
|
{
|
|
|
|
asymbol *q_maybe = *p;
|
|
|
|
|
2000-06-17 04:35:08 +08:00
|
|
|
if (bfd_family_coff (bfd_asymbol_bfd (q_maybe)))
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
coff_symbol_type *q = coffsymbol (q_maybe);
|
|
|
|
|
|
|
|
/* The AIX 4.1 compiler can sometimes generate line numbers
|
|
|
|
attached to debugging symbols. We try to simply ignore
|
|
|
|
those here. */
|
|
|
|
if (q->lineno != NULL
|
|
|
|
&& q->symbol.section->owner != NULL)
|
|
|
|
{
|
|
|
|
/* This symbol has line numbers. Increment the owning
|
|
|
|
section's linenumber count. */
|
|
|
|
alent *l = q->lineno;
|
|
|
|
|
2001-11-19 23:35:38 +08:00
|
|
|
do
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2001-11-19 23:35:38 +08:00
|
|
|
asection * sec = q->symbol.section->output_section;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
2001-11-19 23:35:38 +08:00
|
|
|
/* Do not try to update fields in read-only sections. */
|
|
|
|
if (! bfd_is_const_section (sec))
|
|
|
|
sec->lineno_count ++;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
++total;
|
|
|
|
++l;
|
|
|
|
}
|
2001-11-19 23:35:38 +08:00
|
|
|
while (l->line_number != 0);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Takes a bfd and a symbol, returns a pointer to the coff specific
|
|
|
|
area of the symbol if there is one. */
|
|
|
|
|
|
|
|
coff_symbol_type *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_symbol_from (bfd *ignore_abfd ATTRIBUTE_UNUSED,
|
|
|
|
asymbol *symbol)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2000-06-17 04:35:08 +08:00
|
|
|
if (!bfd_family_coff (bfd_asymbol_bfd (symbol)))
|
1999-05-03 15:29:11 +08:00
|
|
|
return (coff_symbol_type *) NULL;
|
|
|
|
|
|
|
|
if (bfd_asymbol_bfd (symbol)->tdata.coff_obj_data == (coff_data_type *) NULL)
|
|
|
|
return (coff_symbol_type *) NULL;
|
|
|
|
|
|
|
|
return (coff_symbol_type *) symbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-03-23 00:14:43 +08:00
|
|
|
fixup_symbol_value (bfd *abfd,
|
|
|
|
coff_symbol_type *coff_symbol_ptr,
|
|
|
|
struct internal_syment *syment)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Normalize the symbol flags. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (bfd_is_com_section (coff_symbol_ptr->symbol.section))
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
/* A common symbol is undefined with a value. */
|
1999-05-03 15:29:11 +08:00
|
|
|
syment->n_scnum = N_UNDEF;
|
|
|
|
syment->n_value = coff_symbol_ptr->symbol.value;
|
|
|
|
}
|
1999-09-11 22:41:11 +08:00
|
|
|
else if ((coff_symbol_ptr->symbol.flags & BSF_DEBUGGING) != 0
|
|
|
|
&& (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING_RELOC) == 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
syment->n_value = coff_symbol_ptr->symbol.value;
|
|
|
|
}
|
|
|
|
else if (bfd_is_und_section (coff_symbol_ptr->symbol.section))
|
|
|
|
{
|
|
|
|
syment->n_scnum = N_UNDEF;
|
|
|
|
syment->n_value = 0;
|
|
|
|
}
|
1999-08-18 13:59:47 +08:00
|
|
|
/* FIXME: Do we need to handle the absolute section here? */
|
1999-05-03 15:29:11 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (coff_symbol_ptr->symbol.section)
|
|
|
|
{
|
|
|
|
syment->n_scnum =
|
|
|
|
coff_symbol_ptr->symbol.section->output_section->target_index;
|
|
|
|
|
|
|
|
syment->n_value = (coff_symbol_ptr->symbol.value
|
|
|
|
+ coff_symbol_ptr->symbol.section->output_offset);
|
|
|
|
if (! obj_pe (abfd))
|
2000-04-07 08:58:07 +08:00
|
|
|
{
|
|
|
|
syment->n_value += (syment->n_sclass == C_STATLAB)
|
|
|
|
? coff_symbol_ptr->symbol.section->output_section->lma
|
|
|
|
: coff_symbol_ptr->symbol.section->output_section->vma;
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BFD_ASSERT (0);
|
|
|
|
/* This can happen, but I don't know why yet (steve@cygnus.com) */
|
|
|
|
syment->n_scnum = N_ABS;
|
|
|
|
syment->n_value = coff_symbol_ptr->symbol.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Run through all the symbols in the symbol table and work out what
|
|
|
|
their indexes into the symbol table will be when output.
|
|
|
|
|
|
|
|
Coff requires that each C_FILE symbol points to the next one in the
|
|
|
|
chain, and that the last one points to the first external symbol. We
|
|
|
|
do that here too. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_renumber_symbols (bfd *bfd_ptr, int *first_undef)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
|
|
|
|
asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
|
|
|
|
unsigned int native_index = 0;
|
2005-03-23 00:14:43 +08:00
|
|
|
struct internal_syment *last_file = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
unsigned int symbol_index;
|
|
|
|
|
|
|
|
/* COFF demands that undefined symbols come after all other symbols.
|
|
|
|
Since we don't need to impose this extra knowledge on all our
|
|
|
|
client programs, deal with that here. Sort the symbol table;
|
|
|
|
just move the undefined symbols to the end, leaving the rest
|
|
|
|
alone. The O'Reilly book says that defined global symbols come
|
|
|
|
at the end before the undefined symbols, so we do that here as
|
|
|
|
well. */
|
|
|
|
/* @@ Do we have some condition we could test for, so we don't always
|
|
|
|
have to do this? I don't think relocatability is quite right, but
|
|
|
|
I'm not certain. [raeburn:19920508.1711EST] */
|
|
|
|
{
|
|
|
|
asymbol **newsyms;
|
|
|
|
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
|
|
|
bfd_size_type amt;
|
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
|
|
|
amt = sizeof (asymbol *) * ((bfd_size_type) symbol_count + 1);
|
2005-03-23 00:14:43 +08:00
|
|
|
newsyms = bfd_alloc (bfd_ptr, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (!newsyms)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
bfd_ptr->outsymbols = newsyms;
|
|
|
|
for (i = 0; i < symbol_count; i++)
|
|
|
|
if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) != 0
|
|
|
|
|| (!bfd_is_und_section (symbol_ptr_ptr[i]->section)
|
|
|
|
&& !bfd_is_com_section (symbol_ptr_ptr[i]->section)
|
|
|
|
&& ((symbol_ptr_ptr[i]->flags & BSF_FUNCTION) != 0
|
|
|
|
|| ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL | BSF_WEAK))
|
|
|
|
== 0))))
|
|
|
|
*newsyms++ = symbol_ptr_ptr[i];
|
|
|
|
|
|
|
|
for (i = 0; i < symbol_count; i++)
|
|
|
|
if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) == 0
|
|
|
|
&& !bfd_is_und_section (symbol_ptr_ptr[i]->section)
|
|
|
|
&& (bfd_is_com_section (symbol_ptr_ptr[i]->section)
|
|
|
|
|| ((symbol_ptr_ptr[i]->flags & BSF_FUNCTION) == 0
|
|
|
|
&& ((symbol_ptr_ptr[i]->flags & (BSF_GLOBAL | BSF_WEAK))
|
|
|
|
!= 0))))
|
|
|
|
*newsyms++ = symbol_ptr_ptr[i];
|
|
|
|
|
|
|
|
*first_undef = newsyms - bfd_ptr->outsymbols;
|
|
|
|
|
|
|
|
for (i = 0; i < symbol_count; i++)
|
|
|
|
if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) == 0
|
|
|
|
&& bfd_is_und_section (symbol_ptr_ptr[i]->section))
|
|
|
|
*newsyms++ = symbol_ptr_ptr[i];
|
|
|
|
*newsyms = (asymbol *) NULL;
|
|
|
|
symbol_ptr_ptr = bfd_ptr->outsymbols;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
|
|
|
|
{
|
|
|
|
coff_symbol_type *coff_symbol_ptr = coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
|
2000-11-28 09:33:15 +08:00
|
|
|
symbol_ptr_ptr[symbol_index]->udata.i = symbol_index;
|
1999-05-03 15:29:11 +08:00
|
|
|
if (coff_symbol_ptr && coff_symbol_ptr->native)
|
|
|
|
{
|
|
|
|
combined_entry_type *s = coff_symbol_ptr->native;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (s->u.syment.n_sclass == C_FILE)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
if (last_file != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
last_file->n_value = native_index;
|
|
|
|
last_file = &(s->u.syment);
|
|
|
|
}
|
|
|
|
else
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Modify the symbol values according to their section and
|
|
|
|
type. */
|
|
|
|
fixup_symbol_value (bfd_ptr, coff_symbol_ptr, &(s->u.syment));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
for (i = 0; i < s->u.syment.n_numaux + 1; i++)
|
|
|
|
s[i].offset = native_index++;
|
|
|
|
}
|
|
|
|
else
|
2005-03-23 00:14:43 +08:00
|
|
|
native_index++;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2005-03-23 00:14:43 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
obj_conv_table_size (bfd_ptr) = native_index;
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Run thorough the symbol table again, and fix it so that all
|
|
|
|
pointers to entries are changed to the entries' index in the output
|
|
|
|
symbol table. */
|
|
|
|
|
|
|
|
void
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_mangle_symbols (bfd *bfd_ptr)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
|
|
|
|
asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
|
|
|
|
unsigned int symbol_index;
|
|
|
|
|
|
|
|
for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
|
|
|
|
{
|
|
|
|
coff_symbol_type *coff_symbol_ptr =
|
|
|
|
coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
|
|
|
|
|
|
|
|
if (coff_symbol_ptr && coff_symbol_ptr->native)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
combined_entry_type *s = coff_symbol_ptr->native;
|
|
|
|
|
|
|
|
if (s->fix_value)
|
|
|
|
{
|
|
|
|
/* FIXME: We should use a union here. */
|
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
|
|
|
s->u.syment.n_value =
|
2007-07-12 15:16:41 +08:00
|
|
|
(bfd_hostptr_t) ((combined_entry_type *)
|
|
|
|
((bfd_hostptr_t) s->u.syment.n_value))->offset;
|
1999-05-03 15:29:11 +08:00
|
|
|
s->fix_value = 0;
|
|
|
|
}
|
|
|
|
if (s->fix_line)
|
|
|
|
{
|
|
|
|
/* The value is the offset into the line number entries
|
|
|
|
for the symbol's section. On output, the symbol's
|
|
|
|
section should be N_DEBUG. */
|
|
|
|
s->u.syment.n_value =
|
|
|
|
(coff_symbol_ptr->symbol.section->output_section->line_filepos
|
|
|
|
+ s->u.syment.n_value * bfd_coff_linesz (bfd_ptr));
|
|
|
|
coff_symbol_ptr->symbol.section =
|
|
|
|
coff_section_from_bfd_index (bfd_ptr, N_DEBUG);
|
|
|
|
BFD_ASSERT (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING);
|
|
|
|
}
|
|
|
|
for (i = 0; i < s->u.syment.n_numaux; i++)
|
|
|
|
{
|
|
|
|
combined_entry_type *a = s + i + 1;
|
|
|
|
if (a->fix_tag)
|
|
|
|
{
|
|
|
|
a->u.auxent.x_sym.x_tagndx.l =
|
|
|
|
a->u.auxent.x_sym.x_tagndx.p->offset;
|
|
|
|
a->fix_tag = 0;
|
|
|
|
}
|
|
|
|
if (a->fix_end)
|
|
|
|
{
|
|
|
|
a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l =
|
|
|
|
a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p->offset;
|
|
|
|
a->fix_end = 0;
|
|
|
|
}
|
|
|
|
if (a->fix_scnlen)
|
|
|
|
{
|
|
|
|
a->u.auxent.x_csect.x_scnlen.l =
|
|
|
|
a->u.auxent.x_csect.x_scnlen.p->offset;
|
|
|
|
a->fix_scnlen = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_fix_symbol_name (bfd *abfd,
|
|
|
|
asymbol *symbol,
|
|
|
|
combined_entry_type *native,
|
|
|
|
bfd_size_type *string_size_p,
|
|
|
|
asection **debug_string_section_p,
|
|
|
|
bfd_size_type *debug_string_size_p)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int name_length;
|
|
|
|
union internal_auxent *auxent;
|
|
|
|
char *name = (char *) (symbol->name);
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
if (name == NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
/* COFF symbols always have names, so we'll make one up. */
|
1999-05-03 15:29:11 +08:00
|
|
|
symbol->name = "strange";
|
|
|
|
name = (char *) symbol->name;
|
|
|
|
}
|
|
|
|
name_length = strlen (name);
|
|
|
|
|
|
|
|
if (native->u.syment.n_sclass == C_FILE
|
|
|
|
&& native->u.syment.n_numaux > 0)
|
|
|
|
{
|
1999-09-07 12:28:27 +08:00
|
|
|
unsigned int filnmlen;
|
|
|
|
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
if (bfd_coff_force_symnames_in_strings (abfd))
|
|
|
|
{
|
2000-11-28 09:33:15 +08:00
|
|
|
native->u.syment._n._n_n._n_offset =
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
(*string_size_p + STRING_SIZE_SIZE);
|
|
|
|
native->u.syment._n._n_n._n_zeroes = 0;
|
|
|
|
*string_size_p += 6; /* strlen(".file") + 1 */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN);
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
auxent = &(native + 1)->u.auxent;
|
|
|
|
|
1999-09-07 12:28:27 +08:00
|
|
|
filnmlen = bfd_coff_filnmlen (abfd);
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (bfd_coff_long_filenames (abfd))
|
|
|
|
{
|
1999-09-07 12:28:27 +08:00
|
|
|
if (name_length <= filnmlen)
|
2005-03-23 00:14:43 +08:00
|
|
|
strncpy (auxent->x_file.x_fname, name, filnmlen);
|
1999-05-03 15:29:11 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
auxent->x_file.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE;
|
|
|
|
auxent->x_file.x_n.x_zeroes = 0;
|
|
|
|
*string_size_p += name_length + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-09-07 12:28:27 +08:00
|
|
|
strncpy (auxent->x_file.x_fname, name, filnmlen);
|
|
|
|
if (name_length > filnmlen)
|
|
|
|
name[filnmlen] = '\0';
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
if (name_length <= SYMNMLEN && !bfd_coff_force_symnames_in_strings (abfd))
|
2005-03-23 00:14:43 +08:00
|
|
|
/* This name will fit into the symbol neatly. */
|
|
|
|
strncpy (native->u.syment._n._n_name, symbol->name, SYMNMLEN);
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
else if (!bfd_coff_symname_in_debug (abfd, &native->u.syment))
|
|
|
|
{
|
|
|
|
native->u.syment._n._n_n._n_offset = (*string_size_p
|
|
|
|
+ STRING_SIZE_SIZE);
|
|
|
|
native->u.syment._n._n_n._n_zeroes = 0;
|
|
|
|
*string_size_p += name_length + 1;
|
|
|
|
}
|
|
|
|
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
|
|
|
file_ptr filepos;
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
bfd_byte buf[4];
|
|
|
|
int prefix_len = bfd_coff_debug_string_prefix_length (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
/* This name should be written into the .debug section. For
|
|
|
|
some reason each name is preceded by a two byte length
|
|
|
|
and also followed by a null byte. FIXME: We assume that
|
|
|
|
the .debug section has already been created, and that it
|
|
|
|
is large enough. */
|
|
|
|
if (*debug_string_section_p == (asection *) NULL)
|
|
|
|
*debug_string_section_p = bfd_get_section_by_name (abfd, ".debug");
|
|
|
|
filepos = bfd_tell (abfd);
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
if (prefix_len == 4)
|
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_put_32 (abfd, (bfd_vma) (name_length + 1), buf);
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
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
|
|
|
bfd_put_16 (abfd, (bfd_vma) (name_length + 1), buf);
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (!bfd_set_section_contents (abfd,
|
|
|
|
*debug_string_section_p,
|
2005-03-23 00:14:43 +08:00
|
|
|
(void *) buf,
|
1999-05-03 15:29:11 +08:00
|
|
|
(file_ptr) *debug_string_size_p,
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
(bfd_size_type) prefix_len)
|
1999-05-03 15:29:11 +08:00
|
|
|
|| !bfd_set_section_contents (abfd,
|
|
|
|
*debug_string_section_p,
|
2005-03-23 00:14:43 +08:00
|
|
|
(void *) symbol->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
|
|
|
(file_ptr) (*debug_string_size_p
|
|
|
|
+ prefix_len),
|
1999-05-03 15:29:11 +08:00
|
|
|
(bfd_size_type) name_length + 1))
|
|
|
|
abort ();
|
|
|
|
if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
|
|
|
|
abort ();
|
2000-11-28 09:33:15 +08:00
|
|
|
native->u.syment._n._n_n._n_offset =
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
*debug_string_size_p + prefix_len;
|
1999-05-03 15:29:11 +08:00
|
|
|
native->u.syment._n._n_n._n_zeroes = 0;
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
*debug_string_size_p += name_length + 1 + prefix_len;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We need to keep track of the symbol index so that when we write out
|
|
|
|
the relocs we can get the index for a symbol. This method is a
|
|
|
|
hack. FIXME. */
|
|
|
|
|
|
|
|
#define set_index(symbol, idx) ((symbol)->udata.i = (idx))
|
|
|
|
|
|
|
|
/* Write a symbol out to a COFF file. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
static bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_write_symbol (bfd *abfd,
|
|
|
|
asymbol *symbol,
|
|
|
|
combined_entry_type *native,
|
|
|
|
bfd_vma *written,
|
|
|
|
bfd_size_type *string_size_p,
|
|
|
|
asection **debug_string_section_p,
|
|
|
|
bfd_size_type *debug_string_size_p)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int numaux = native->u.syment.n_numaux;
|
|
|
|
int type = native->u.syment.n_type;
|
|
|
|
int class = native->u.syment.n_sclass;
|
2005-03-23 00:14:43 +08:00
|
|
|
void * buf;
|
1999-05-03 15:29:11 +08:00
|
|
|
bfd_size_type symesz;
|
|
|
|
|
|
|
|
if (native->u.syment.n_sclass == C_FILE)
|
|
|
|
symbol->flags |= BSF_DEBUGGING;
|
|
|
|
|
|
|
|
if (symbol->flags & BSF_DEBUGGING
|
|
|
|
&& bfd_is_abs_section (symbol->section))
|
2005-03-23 00:14:43 +08:00
|
|
|
native->u.syment.n_scnum = N_DEBUG;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
else if (bfd_is_abs_section (symbol->section))
|
2005-03-23 00:14:43 +08:00
|
|
|
native->u.syment.n_scnum = N_ABS;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
else if (bfd_is_und_section (symbol->section))
|
2005-03-23 00:14:43 +08:00
|
|
|
native->u.syment.n_scnum = N_UNDEF;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
else
|
2005-03-23 00:14:43 +08:00
|
|
|
native->u.syment.n_scnum =
|
|
|
|
symbol->section->output_section->target_index;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
coff_fix_symbol_name (abfd, symbol, native, string_size_p,
|
|
|
|
debug_string_section_p, debug_string_size_p);
|
|
|
|
|
|
|
|
symesz = bfd_coff_symesz (abfd);
|
|
|
|
buf = bfd_alloc (abfd, symesz);
|
|
|
|
if (!buf)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
|
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_bwrite (buf, symesz, abfd) != symesz)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
bfd_release (abfd, buf);
|
|
|
|
|
|
|
|
if (native->u.syment.n_numaux > 0)
|
|
|
|
{
|
|
|
|
bfd_size_type auxesz;
|
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
auxesz = bfd_coff_auxesz (abfd);
|
|
|
|
buf = bfd_alloc (abfd, auxesz);
|
|
|
|
if (!buf)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
for (j = 0; j < native->u.syment.n_numaux; j++)
|
|
|
|
{
|
|
|
|
bfd_coff_swap_aux_out (abfd,
|
|
|
|
&((native + j + 1)->u.auxent),
|
2005-03-23 00:14:43 +08:00
|
|
|
type, class, (int) j,
|
1999-05-03 15:29:11 +08:00
|
|
|
native->u.syment.n_numaux,
|
|
|
|
buf);
|
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_bwrite (buf, auxesz, abfd) != auxesz)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
bfd_release (abfd, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store the index for use when we write out the relocs. */
|
|
|
|
set_index (symbol, *written);
|
|
|
|
|
|
|
|
*written += numaux + 1;
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out a symbol to a COFF file that does not come from a COFF
|
|
|
|
file originally. This symbol may have been created by the linker,
|
|
|
|
or we may be linking a non COFF file to a COFF file. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
static bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_write_alien_symbol (bfd *abfd,
|
|
|
|
asymbol *symbol,
|
|
|
|
bfd_vma *written,
|
|
|
|
bfd_size_type *string_size_p,
|
|
|
|
asection **debug_string_section_p,
|
|
|
|
bfd_size_type *debug_string_size_p)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
combined_entry_type *native;
|
|
|
|
combined_entry_type dummy;
|
|
|
|
|
|
|
|
native = &dummy;
|
|
|
|
native->u.syment.n_type = T_NULL;
|
|
|
|
native->u.syment.n_flags = 0;
|
|
|
|
if (bfd_is_und_section (symbol->section))
|
|
|
|
{
|
|
|
|
native->u.syment.n_scnum = N_UNDEF;
|
|
|
|
native->u.syment.n_value = symbol->value;
|
|
|
|
}
|
|
|
|
else if (bfd_is_com_section (symbol->section))
|
|
|
|
{
|
|
|
|
native->u.syment.n_scnum = N_UNDEF;
|
|
|
|
native->u.syment.n_value = symbol->value;
|
|
|
|
}
|
|
|
|
else if (symbol->flags & BSF_DEBUGGING)
|
|
|
|
{
|
|
|
|
/* There isn't much point to writing out a debugging symbol
|
|
|
|
unless we are prepared to convert it into COFF debugging
|
|
|
|
format. So, we just ignore them. We must clobber the symbol
|
|
|
|
name to keep it from being put in the string table. */
|
|
|
|
symbol->name = "";
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
native->u.syment.n_scnum =
|
|
|
|
symbol->section->output_section->target_index;
|
|
|
|
native->u.syment.n_value = (symbol->value
|
|
|
|
+ symbol->section->output_offset);
|
|
|
|
if (! obj_pe (abfd))
|
|
|
|
native->u.syment.n_value += symbol->section->output_section->vma;
|
|
|
|
|
2001-10-10 20:08:29 +08:00
|
|
|
/* Copy the any flags from the file header into the symbol.
|
1999-05-03 15:29:11 +08:00
|
|
|
FIXME: Why? */
|
|
|
|
{
|
|
|
|
coff_symbol_type *c = coff_symbol_from (abfd, symbol);
|
|
|
|
if (c != (coff_symbol_type *) NULL)
|
|
|
|
native->u.syment.n_flags = bfd_asymbol_bfd (&c->symbol)->flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
native->u.syment.n_type = 0;
|
|
|
|
if (symbol->flags & BSF_LOCAL)
|
|
|
|
native->u.syment.n_sclass = C_STAT;
|
|
|
|
else if (symbol->flags & BSF_WEAK)
|
|
|
|
native->u.syment.n_sclass = obj_pe (abfd) ? C_NT_WEAK : C_WEAKEXT;
|
|
|
|
else
|
|
|
|
native->u.syment.n_sclass = C_EXT;
|
|
|
|
native->u.syment.n_numaux = 0;
|
|
|
|
|
|
|
|
return coff_write_symbol (abfd, symbol, native, written, string_size_p,
|
|
|
|
debug_string_section_p, debug_string_size_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write a native symbol to a COFF file. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
static bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_write_native_symbol (bfd *abfd,
|
|
|
|
coff_symbol_type *symbol,
|
|
|
|
bfd_vma *written,
|
|
|
|
bfd_size_type *string_size_p,
|
|
|
|
asection **debug_string_section_p,
|
|
|
|
bfd_size_type *debug_string_size_p)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
combined_entry_type *native = symbol->native;
|
|
|
|
alent *lineno = symbol->lineno;
|
|
|
|
|
|
|
|
/* If this symbol has an associated line number, we must store the
|
|
|
|
symbol index in the line number field. We also tag the auxent to
|
|
|
|
point to the right place in the lineno table. */
|
|
|
|
if (lineno && !symbol->done_lineno && symbol->symbol.section->owner != NULL)
|
|
|
|
{
|
|
|
|
unsigned int count = 0;
|
2005-03-23 00:14:43 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
lineno[count].u.offset = *written;
|
|
|
|
if (native->u.syment.n_numaux)
|
|
|
|
{
|
|
|
|
union internal_auxent *a = &((native + 1)->u.auxent);
|
|
|
|
|
|
|
|
a->x_sym.x_fcnary.x_fcn.x_lnnoptr =
|
|
|
|
symbol->symbol.section->output_section->moving_line_filepos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Count and relocate all other linenumbers. */
|
|
|
|
count++;
|
|
|
|
while (lineno[count].line_number != 0)
|
|
|
|
{
|
|
|
|
lineno[count].u.offset +=
|
|
|
|
(symbol->symbol.section->output_section->vma
|
|
|
|
+ symbol->symbol.section->output_offset);
|
|
|
|
count++;
|
|
|
|
}
|
2002-11-30 16:39:46 +08:00
|
|
|
symbol->done_lineno = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2001-11-19 23:35:38 +08:00
|
|
|
if (! bfd_is_const_section (symbol->symbol.section->output_section))
|
|
|
|
symbol->symbol.section->output_section->moving_line_filepos +=
|
|
|
|
count * bfd_coff_linesz (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return coff_write_symbol (abfd, &(symbol->symbol), native, written,
|
|
|
|
string_size_p, debug_string_section_p,
|
|
|
|
debug_string_size_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out the COFF symbols. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_write_symbols (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
bfd_size_type string_size;
|
|
|
|
asection *debug_string_section;
|
|
|
|
bfd_size_type debug_string_size;
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int limit = bfd_get_symcount (abfd);
|
2005-02-20 22:59:07 +08:00
|
|
|
bfd_vma written = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
asymbol **p;
|
|
|
|
|
|
|
|
string_size = 0;
|
|
|
|
debug_string_section = NULL;
|
|
|
|
debug_string_size = 0;
|
|
|
|
|
|
|
|
/* If this target supports long section names, they must be put into
|
|
|
|
the string table. This is supported by PE. This code must
|
|
|
|
handle section names just as they are handled in
|
|
|
|
coff_write_object_contents. */
|
|
|
|
if (bfd_coff_long_section_names (abfd))
|
|
|
|
{
|
|
|
|
asection *o;
|
|
|
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
len = strlen (o->name);
|
|
|
|
if (len > SCNNMLEN)
|
|
|
|
string_size += len + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Seek to the right place. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Output all the symbols we have. */
|
1999-05-03 15:29:11 +08:00
|
|
|
written = 0;
|
|
|
|
for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
|
|
|
|
{
|
|
|
|
asymbol *symbol = *p;
|
|
|
|
coff_symbol_type *c_symbol = coff_symbol_from (abfd, symbol);
|
|
|
|
|
|
|
|
if (c_symbol == (coff_symbol_type *) NULL
|
|
|
|
|| c_symbol->native == (combined_entry_type *) NULL)
|
|
|
|
{
|
|
|
|
if (!coff_write_alien_symbol (abfd, symbol, &written, &string_size,
|
|
|
|
&debug_string_section,
|
|
|
|
&debug_string_size))
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!coff_write_native_symbol (abfd, c_symbol, &written,
|
|
|
|
&string_size, &debug_string_section,
|
|
|
|
&debug_string_size))
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
obj_raw_syment_count (abfd) = written;
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Now write out strings. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (string_size != 0)
|
|
|
|
{
|
|
|
|
unsigned int size = string_size + STRING_SIZE_SIZE;
|
|
|
|
bfd_byte buffer[STRING_SIZE_SIZE];
|
|
|
|
|
|
|
|
#if STRING_SIZE_SIZE == 4
|
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
|
|
|
H_PUT_32 (abfd, size, buffer);
|
1999-05-03 15:29:11 +08:00
|
|
|
#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
|
|
|
#error Change H_PUT_32
|
1999-05-03 15:29:11 +08:00
|
|
|
#endif
|
2005-03-23 00:14:43 +08:00
|
|
|
if (bfd_bwrite ((void *) buffer, (bfd_size_type) sizeof (buffer), 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
|
|
|
!= sizeof (buffer))
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
/* Handle long section names. This code must handle section
|
|
|
|
names just as they are handled in coff_write_object_contents. */
|
|
|
|
if (bfd_coff_long_section_names (abfd))
|
|
|
|
{
|
|
|
|
asection *o;
|
|
|
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
len = strlen (o->name);
|
|
|
|
if (len > SCNNMLEN)
|
|
|
|
{
|
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_bwrite (o->name, (bfd_size_type) (len + 1), abfd)
|
|
|
|
!= len + 1)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (p = abfd->outsymbols, i = 0;
|
|
|
|
i < limit;
|
|
|
|
i++, p++)
|
|
|
|
{
|
|
|
|
asymbol *q = *p;
|
|
|
|
size_t name_length = strlen (q->name);
|
|
|
|
coff_symbol_type *c_symbol = coff_symbol_from (abfd, q);
|
|
|
|
size_t maxlen;
|
|
|
|
|
|
|
|
/* Figure out whether the symbol name should go in the string
|
|
|
|
table. Symbol names that are short enough are stored
|
|
|
|
directly in the syment structure. File names permit a
|
|
|
|
different, longer, length in the syment structure. On
|
|
|
|
XCOFF, some symbol names are stored in the .debug section
|
|
|
|
rather than in the string table. */
|
|
|
|
|
|
|
|
if (c_symbol == NULL
|
|
|
|
|| c_symbol->native == NULL)
|
2005-03-23 00:14:43 +08:00
|
|
|
/* This is not a COFF symbol, so it certainly is not a
|
|
|
|
file name, nor does it go in the .debug section. */
|
|
|
|
maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
else if (bfd_coff_symname_in_debug (abfd,
|
|
|
|
&c_symbol->native->u.syment))
|
2005-03-23 00:14:43 +08:00
|
|
|
/* This symbol name is in the XCOFF .debug section.
|
|
|
|
Don't write it into the string table. */
|
|
|
|
maxlen = name_length;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
else if (c_symbol->native->u.syment.n_sclass == C_FILE
|
|
|
|
&& c_symbol->native->u.syment.n_numaux > 0)
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
{
|
2000-11-28 09:33:15 +08:00
|
|
|
if (bfd_coff_force_symnames_in_strings (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
|
|
|
{
|
|
|
|
if (bfd_bwrite (".file", (bfd_size_type) 6, abfd) != 6)
|
2002-11-30 16:39:46 +08:00
|
|
|
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
|
|
|
}
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
maxlen = bfd_coff_filnmlen (abfd);
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
else
|
Add XCOFF64 support.
bfd:
* Makefile.am (coff64-rs6000.lo): New rule.
* Makefile.in: Regenerate.
* coff-rs6000.c (xcoff_mkobject, xcoff_copy_private_bfd_data,
xcoff_is_local_label_name, xcoff_rtype2howto,
xcoff_reloc_type_lookup, xcoff_slurp_armap, xcoff_archive_p,
xcoff_read_ar_hdr, xcoff_openr_next_archived_file, xcoff_write_armap,
xcoff_write_archive_contents): No longer static, and prefix with _bfd_.
(NO_COFF_SYMBOLS): Define.
(xcoff64_swap_sym_in, xcoff64_swap_sym_out, xcoff64_swap_aux_in,
xcoff64_swap_aux_out): New functions; handle xcoff symbol tables
internally.
(MINUS_ONE): New macro.
(xcoff_howto_tabl, xcoff_reloc_type_lookup): Add 64 bit POS
relocation.
(coff_SWAP_sym_in, coff_SWAP_sym_out, coff_SWAP_aux_in,
coff_SWAP_aux_out): Map to the new functions.
* coff64-rs6000.c: New file.
* libcoff.h (bfd_coff_backend_data): Add new fields
_bfd_coff_force_symnames_in_strings and
_bfd_coff_debug_string_prefix_length.
(bfd_coff_force_symnames_in_strings,
bfd_coff_debug_string_prefix_length): New macros for above fields.
* coffcode.h (coff_set_arch_mach_hook): Handle XCOFF64 magic.
Set machine to 620 for XCOFF64. Use bfd_coff_swap_sym_in instead
of using coff_swap_sym_in directly.
(FORCE_SYMNAMES_IN_STRINGS): New macro, defined for XCOFF64.
(coff_set_flags) Set magic for XCOFF64.
(coff_compute_section_file_positions): Add symbol name length to
string section length if bfd_coff_debug_string_prefix_length is
true.
(coff_write_object_contents): Don't do reloc overflow for XCOFF64.
(coff_slurp_line_table): Use bfd_coff_swap_lineno_in instead of
using coff_swap_lineno_in directly.
(bfd_coff_backend_data): Add _bfd_coff_force_symnames_in_strings
and _bfd_coff_debug_string_prefix_length fields.
* coffgen.c (coff_fix_symbol_name, coff_write_symbols): Force
symbol names into strings table when
bfd_coff_force_symnames_in_strings is true.
* coffswap.h (MAX_SCNHDR_NRELOC, MAX_SCNHDR_NLNNO, GET_RELOC_VADDR,
SET_RELOC_VADDR): New macros.
(coff_swap_reloc_in, coff_swap_reloc_out): Use above macros.
(coff_swap_aux_in, coff_swap_aux_out): Remove RS6000COFF_C
code.
(coff_swap_aouthdr_in, coff_swap_aouthdr_out): Handle XCOFF64
changes within RS6000COFF_C specific code.
(coff_swap_scnhdr_out): Use PUT_SCNHDR_NLNNO, PUT_SCNHDR_NRELOC,
MAX_SCNHDR_NRELOC, and MAX_SCNHDR_NLNNO.
* reloc.c (bfd_perform_relocation, bfd_install_relocation):
Extend existing hack on target name.
* xcofflink.c (XCOFF_XVECP): Extend existing hack on
target name.
* coff-tic54x.c (ticof): Keep up to date with new fields
in bfd_coff_backend_data.
* config.bfd: Add bfd_powerpc_64_arch to targ_arch and define
targ_selvecs to include rs6000coff64_vec for rs6000.
* configure.in: Add rs6000coff64_vec case.
* cpu-powerpc.c: New bfd_arch_info_type.
gas:
* as.c (parse_args): Allow md_parse_option to override -a listing
option.
* config/obj-coff.c (add_lineno): Change type of offset parameter
from "int" to "bfd_vma."
* config/tc-ppc.c (md_pseudo_table): Add "llong" and "machine."
(ppc_mach, ppc_subseg_align, ppc_target_format): New.
(ppc_change_csect): Align correctly for XCOFF64.
(ppc_machine): New function, which discards "ppc_machine" line.
(ppc_tc): Cons for 8 when code is 64 bit.
(md_apply_fix3): Don't check operand->insert. Handle 64 bit
relocations.
(md_parse_option): Handle -a64 and -a32.
(ppc_xcoff64): New.
* config/tc-ppc.h (TARGET_MACH): Define.
(TARGET_FORMAT): Move to function.
(SUB_SEGMENT_ALIGN): Use ppc_subseg_align.
include:
* include/coff/rs6k64.h: New file.
opcodes:
* configure.in: Add bfd_powerpc_64_arch.
* disassemble.c (disassembler): Use print_insn_big_powerpc for
64 bit code.
2000-04-26 23:09:44 +08:00
|
|
|
maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (name_length > maxlen)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
if (bfd_bwrite ((void *) (q->name), (bfd_size_type) name_length + 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
|
|
|
abfd) != name_length + 1)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We would normally not write anything here, but we'll write
|
|
|
|
out 4 so that any stupid coff reader which tries to read the
|
|
|
|
string table even when there isn't one won't croak. */
|
|
|
|
unsigned int size = STRING_SIZE_SIZE;
|
|
|
|
bfd_byte buffer[STRING_SIZE_SIZE];
|
|
|
|
|
|
|
|
#if STRING_SIZE_SIZE == 4
|
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
|
|
|
H_PUT_32 (abfd, size, buffer);
|
1999-05-03 15:29:11 +08:00
|
|
|
#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
|
|
|
#error Change H_PUT_32
|
1999-05-03 15:29:11 +08:00
|
|
|
#endif
|
2005-03-23 00:14:43 +08:00
|
|
|
if (bfd_bwrite ((void *) buffer, (bfd_size_type) STRING_SIZE_SIZE, abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
!= STRING_SIZE_SIZE)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the .debug section was created to be the correct size.
|
|
|
|
We should create it ourselves on the fly, but we don't because
|
|
|
|
BFD won't let us write to any section until we know how large all
|
|
|
|
the sections are. We could still do it by making another pass
|
|
|
|
over the symbols. FIXME. */
|
|
|
|
BFD_ASSERT (debug_string_size == 0
|
|
|
|
|| (debug_string_section != (asection *) NULL
|
|
|
|
&& (BFD_ALIGN (debug_string_size,
|
|
|
|
1 << debug_string_section->alignment_power)
|
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
|
|
|
== debug_string_section->size)));
|
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
|
|
|
}
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_write_linenumbers (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
asection *s;
|
|
|
|
bfd_size_type linesz;
|
2005-03-23 00:14:43 +08:00
|
|
|
void * buff;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
linesz = bfd_coff_linesz (abfd);
|
|
|
|
buff = bfd_alloc (abfd, linesz);
|
|
|
|
if (!buff)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
|
|
|
|
{
|
|
|
|
if (s->lineno_count)
|
|
|
|
{
|
|
|
|
asymbol **q = abfd->outsymbols;
|
|
|
|
if (bfd_seek (abfd, s->line_filepos, SEEK_SET) != 0)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Find all the linenumbers in this section. */
|
1999-05-03 15:29:11 +08:00
|
|
|
while (*q)
|
|
|
|
{
|
|
|
|
asymbol *p = *q;
|
|
|
|
if (p->section->output_section == s)
|
|
|
|
{
|
|
|
|
alent *l =
|
|
|
|
BFD_SEND (bfd_asymbol_bfd (p), _get_lineno,
|
|
|
|
(bfd_asymbol_bfd (p), p));
|
|
|
|
if (l)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Found a linenumber entry, output. */
|
1999-05-03 15:29:11 +08:00
|
|
|
struct internal_lineno out;
|
2005-03-23 00:14:43 +08:00
|
|
|
memset ((void *) & out, 0, sizeof (out));
|
1999-05-03 15:29:11 +08:00
|
|
|
out.l_lnno = 0;
|
|
|
|
out.l_addr.l_symndx = l->u.offset;
|
|
|
|
bfd_coff_swap_lineno_out (abfd, &out, buff);
|
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_bwrite (buff, (bfd_size_type) linesz, abfd)
|
|
|
|
!= linesz)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
l++;
|
|
|
|
while (l->line_number)
|
|
|
|
{
|
|
|
|
out.l_lnno = l->line_number;
|
|
|
|
out.l_addr.l_symndx = l->u.offset;
|
|
|
|
bfd_coff_swap_lineno_out (abfd, &out, buff);
|
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_bwrite (buff, (bfd_size_type) linesz, abfd)
|
|
|
|
!= linesz)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
l++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
q++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bfd_release (abfd, buff);
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
alent *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_get_lineno (bfd *ignore_abfd ATTRIBUTE_UNUSED, asymbol *symbol)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
return coffsymbol (symbol)->lineno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function transforms the offsets into the symbol table into
|
|
|
|
pointers to syments. */
|
|
|
|
|
|
|
|
static void
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_pointerize_aux (bfd *abfd,
|
|
|
|
combined_entry_type *table_base,
|
|
|
|
combined_entry_type *symbol,
|
|
|
|
unsigned int indaux,
|
|
|
|
combined_entry_type *auxent)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
unsigned int type = symbol->u.syment.n_type;
|
|
|
|
unsigned int class = symbol->u.syment.n_sclass;
|
|
|
|
|
|
|
|
if (coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
|
|
|
|
{
|
|
|
|
if ((*coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook)
|
|
|
|
(abfd, table_base, symbol, indaux, auxent))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Don't bother if this is a file or a section. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (class == C_STAT && type == T_NULL)
|
|
|
|
return;
|
|
|
|
if (class == C_FILE)
|
|
|
|
return;
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Otherwise patch up. */
|
|
|
|
#define N_TMASK coff_data (abfd)->local_n_tmask
|
1999-05-03 15:29:11 +08:00
|
|
|
#define N_BTSHFT coff_data (abfd)->local_n_btshft
|
2005-03-23 00:14:43 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if ((ISFCN (type) || ISTAG (class) || class == C_BLOCK || class == C_FCN)
|
|
|
|
&& auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l > 0)
|
|
|
|
{
|
|
|
|
auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p =
|
|
|
|
table_base + auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
|
|
|
|
auxent->fix_end = 1;
|
|
|
|
}
|
|
|
|
/* A negative tagndx is meaningless, but the SCO 3.2v4 cc can
|
|
|
|
generate one, so we must be careful to ignore it. */
|
|
|
|
if (auxent->u.auxent.x_sym.x_tagndx.l > 0)
|
|
|
|
{
|
|
|
|
auxent->u.auxent.x_sym.x_tagndx.p =
|
|
|
|
table_base + auxent->u.auxent.x_sym.x_tagndx.l;
|
|
|
|
auxent->fix_tag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate space for the ".debug" section, and read it.
|
|
|
|
We did not read the debug section until now, because
|
2000-11-28 09:33:15 +08:00
|
|
|
we didn't want to go to the trouble until someone needed it. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
static char *
|
2005-03-23 00:14:43 +08:00
|
|
|
build_debug_section (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
char *debug_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
|
|
|
file_ptr position;
|
|
|
|
bfd_size_type sec_size;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
asection *sect = bfd_get_section_by_name (abfd, ".debug");
|
|
|
|
|
|
|
|
if (!sect)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_no_debug_section);
|
|
|
|
return 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
|
|
|
sec_size = sect->size;
|
2005-03-23 00:14:43 +08:00
|
|
|
debug_section = bfd_alloc (abfd, sec_size);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (debug_section == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2000-11-28 09:33:15 +08:00
|
|
|
/* Seek to the beginning of the `.debug' section and read it.
|
1999-05-03 15:29:11 +08:00
|
|
|
Save the current position first; it is needed by our caller.
|
|
|
|
Then read debug section and reset the file pointer. */
|
|
|
|
|
|
|
|
position = bfd_tell (abfd);
|
|
|
|
if (bfd_seek (abfd, sect->filepos, SEEK_SET) != 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
|
|
|
|| bfd_bread (debug_section, sec_size, abfd) != sec_size
|
1999-05-03 15:29:11 +08:00
|
|
|
|| bfd_seek (abfd, position, SEEK_SET) != 0)
|
|
|
|
return NULL;
|
|
|
|
return debug_section;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return a pointer to a malloc'd copy of 'name'. 'name' may not be
|
|
|
|
\0-terminated, but will not exceed 'maxlen' characters. The copy *will*
|
|
|
|
be \0-terminated. */
|
2005-03-23 00:14:43 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
static char *
|
2005-03-23 00:14:43 +08:00
|
|
|
copy_name (bfd *abfd, char *name, size_t maxlen)
|
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
|
|
|
size_t len;
|
1999-05-03 15:29:11 +08:00
|
|
|
char *newname;
|
|
|
|
|
|
|
|
for (len = 0; len < maxlen; ++len)
|
2005-03-23 00:14:43 +08:00
|
|
|
if (name[len] == '\0')
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ((newname = bfd_alloc (abfd, (bfd_size_type) len + 1)) == NULL)
|
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
strncpy (newname, name, len);
|
|
|
|
newname[len] = '\0';
|
|
|
|
return newname;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read in the external symbols. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
_bfd_coff_get_external_symbols (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
bfd_size_type 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
|
|
|
bfd_size_type size;
|
2005-03-23 00:14:43 +08:00
|
|
|
void * syms;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (obj_coff_external_syms (abfd) != NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
symesz = bfd_coff_symesz (abfd);
|
|
|
|
|
|
|
|
size = obj_raw_syment_count (abfd) * symesz;
|
2007-07-26 10:01:49 +08:00
|
|
|
if (size == 0)
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
syms = bfd_malloc (size);
|
2007-07-26 10:01:49 +08:00
|
|
|
if (syms == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 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
|
|
|
|| bfd_bread (syms, size, abfd) != size)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
if (syms != NULL)
|
|
|
|
free (syms);
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
obj_coff_external_syms (abfd) = syms;
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read in the external strings. The strings are not loaded until
|
|
|
|
they are needed. This is because we have no simple way of
|
|
|
|
detecting a missing string table in an archive. */
|
|
|
|
|
|
|
|
const char *
|
2005-03-23 00:14:43 +08:00
|
|
|
_bfd_coff_read_string_table (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
char extstrsize[STRING_SIZE_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_size_type strsize;
|
1999-05-03 15:29:11 +08:00
|
|
|
char *strings;
|
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
|
|
|
file_ptr pos;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (obj_coff_strings (abfd) != NULL)
|
|
|
|
return obj_coff_strings (abfd);
|
|
|
|
|
|
|
|
if (obj_sym_filepos (abfd) == 0)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_no_symbols);
|
|
|
|
return 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
|
|
|
pos = obj_sym_filepos (abfd);
|
|
|
|
pos += obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
|
|
|
|
if (bfd_seek (abfd, pos, SEEK_SET) != 0)
|
1999-05-03 15:29:11 +08:00
|
|
|
return NULL;
|
2000-11-28 09:33:15 +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_bread (extstrsize, (bfd_size_type) sizeof extstrsize, abfd)
|
|
|
|
!= sizeof extstrsize)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
if (bfd_get_error () != bfd_error_file_truncated)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* There is no string table. */
|
|
|
|
strsize = STRING_SIZE_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#if STRING_SIZE_SIZE == 4
|
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
|
|
|
strsize = H_GET_32 (abfd, extstrsize);
|
1999-05-03 15:29:11 +08:00
|
|
|
#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
|
|
|
#error Change H_GET_32
|
1999-05-03 15:29:11 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strsize < STRING_SIZE_SIZE)
|
|
|
|
{
|
|
|
|
(*_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 string table size %lu"), abfd, (unsigned long) strsize);
|
1999-05-03 15:29:11 +08:00
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
strings = bfd_malloc (strsize);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (strings == NULL)
|
|
|
|
return 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 (bfd_bread (strings + STRING_SIZE_SIZE, strsize - STRING_SIZE_SIZE, abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
!= strsize - STRING_SIZE_SIZE)
|
|
|
|
{
|
|
|
|
free (strings);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj_coff_strings (abfd) = strings;
|
|
|
|
|
|
|
|
return strings;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free up the external symbols and strings read from a COFF file. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
_bfd_coff_free_symbols (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
if (obj_coff_external_syms (abfd) != NULL
|
|
|
|
&& ! obj_coff_keep_syms (abfd))
|
|
|
|
{
|
|
|
|
free (obj_coff_external_syms (abfd));
|
|
|
|
obj_coff_external_syms (abfd) = NULL;
|
|
|
|
}
|
|
|
|
if (obj_coff_strings (abfd) != NULL
|
|
|
|
&& ! obj_coff_keep_strings (abfd))
|
|
|
|
{
|
|
|
|
free (obj_coff_strings (abfd));
|
|
|
|
obj_coff_strings (abfd) = NULL;
|
|
|
|
}
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read a symbol table into freshly bfd_allocated memory, swap it, and
|
|
|
|
knit the symbol names into a normalized form. By normalized here I
|
|
|
|
mean that all symbols have an n_offset pointer that points to a null-
|
|
|
|
terminated string. */
|
|
|
|
|
|
|
|
combined_entry_type *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_get_normalized_symtab (bfd *abfd)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
combined_entry_type *internal;
|
|
|
|
combined_entry_type *internal_ptr;
|
|
|
|
combined_entry_type *symbol_ptr;
|
|
|
|
combined_entry_type *internal_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
|
|
|
size_t symesz;
|
1999-05-03 15:29:11 +08:00
|
|
|
char *raw_src;
|
|
|
|
char *raw_end;
|
|
|
|
const char *string_table = NULL;
|
|
|
|
char *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
|
|
|
bfd_size_type size;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (obj_raw_syments (abfd) != NULL)
|
|
|
|
return obj_raw_syments (abfd);
|
|
|
|
|
|
|
|
size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
|
2005-03-23 00:14:43 +08:00
|
|
|
internal = bfd_zalloc (abfd, size);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (internal == NULL && size != 0)
|
|
|
|
return NULL;
|
|
|
|
internal_end = internal + obj_raw_syment_count (abfd);
|
|
|
|
|
|
|
|
if (! _bfd_coff_get_external_symbols (abfd))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
raw_src = (char *) obj_coff_external_syms (abfd);
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Mark the end of the symbols. */
|
1999-05-03 15:29:11 +08:00
|
|
|
symesz = bfd_coff_symesz (abfd);
|
|
|
|
raw_end = (char *) raw_src + obj_raw_syment_count (abfd) * symesz;
|
|
|
|
|
|
|
|
/* FIXME SOMEDAY. A string table size of zero is very weird, but
|
|
|
|
probably possible. If one shows up, it will probably kill us. */
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Swap all the raw entries. */
|
1999-05-03 15:29:11 +08:00
|
|
|
for (internal_ptr = internal;
|
|
|
|
raw_src < raw_end;
|
|
|
|
raw_src += symesz, internal_ptr++)
|
|
|
|
{
|
|
|
|
|
|
|
|
unsigned int i;
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_coff_swap_sym_in (abfd, (void *) raw_src,
|
|
|
|
(void *) & internal_ptr->u.syment);
|
1999-05-03 15:29:11 +08:00
|
|
|
symbol_ptr = internal_ptr;
|
|
|
|
|
|
|
|
for (i = 0;
|
|
|
|
i < symbol_ptr->u.syment.n_numaux;
|
|
|
|
i++)
|
|
|
|
{
|
|
|
|
internal_ptr++;
|
|
|
|
raw_src += symesz;
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_coff_swap_aux_in (abfd, (void *) raw_src,
|
1999-05-03 15:29:11 +08:00
|
|
|
symbol_ptr->u.syment.n_type,
|
|
|
|
symbol_ptr->u.syment.n_sclass,
|
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
|
|
|
(int) i, symbol_ptr->u.syment.n_numaux,
|
1999-05-03 15:29:11 +08:00
|
|
|
&(internal_ptr->u.auxent));
|
|
|
|
coff_pointerize_aux (abfd, internal, symbol_ptr, i,
|
|
|
|
internal_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the raw symbols, but not the strings (if we have them). */
|
2002-11-30 16:39:46 +08:00
|
|
|
obj_coff_keep_strings (abfd) = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
if (! _bfd_coff_free_symbols (abfd))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (internal_ptr = internal; internal_ptr < internal_end;
|
|
|
|
internal_ptr++)
|
|
|
|
{
|
|
|
|
if (internal_ptr->u.syment.n_sclass == C_FILE
|
|
|
|
&& internal_ptr->u.syment.n_numaux > 0)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Make a file symbol point to the name in the auxent, since
|
|
|
|
the text ".file" is redundant. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if ((internal_ptr + 1)->u.auxent.x_file.x_n.x_zeroes == 0)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
/* The filename is a long one, point into the string table. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (string_table == NULL)
|
|
|
|
{
|
|
|
|
string_table = _bfd_coff_read_string_table (abfd);
|
|
|
|
if (string_table == NULL)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal_ptr->u.syment._n._n_n._n_offset =
|
2007-07-12 15:16:41 +08:00
|
|
|
((bfd_hostptr_t)
|
1999-05-03 15:29:11 +08:00
|
|
|
(string_table
|
|
|
|
+ (internal_ptr + 1)->u.auxent.x_file.x_n.x_offset));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-08-18 13:59:47 +08:00
|
|
|
/* Ordinary short filename, put into memory anyway. The
|
|
|
|
Microsoft PE tools sometimes store a filename in
|
|
|
|
multiple AUX entries. */
|
1999-05-12 05:05:44 +08:00
|
|
|
if (internal_ptr->u.syment.n_numaux > 1
|
|
|
|
&& coff_data (abfd)->pe)
|
2005-03-23 00:14:43 +08:00
|
|
|
internal_ptr->u.syment._n._n_n._n_offset =
|
2007-07-12 15:16:41 +08:00
|
|
|
((bfd_hostptr_t)
|
2005-03-23 00:14:43 +08:00
|
|
|
copy_name (abfd,
|
|
|
|
(internal_ptr + 1)->u.auxent.x_file.x_fname,
|
|
|
|
internal_ptr->u.syment.n_numaux * symesz));
|
1999-05-12 05:05:44 +08:00
|
|
|
else
|
2005-03-23 00:14:43 +08:00
|
|
|
internal_ptr->u.syment._n._n_n._n_offset =
|
2007-07-12 15:16:41 +08:00
|
|
|
((bfd_hostptr_t)
|
2005-03-23 00:14:43 +08:00
|
|
|
copy_name (abfd,
|
|
|
|
(internal_ptr + 1)->u.auxent.x_file.x_fname,
|
|
|
|
(size_t) bfd_coff_filnmlen (abfd)));
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (internal_ptr->u.syment._n._n_n._n_zeroes != 0)
|
|
|
|
{
|
|
|
|
/* This is a "short" name. Make it long. */
|
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
|
|
|
size_t i;
|
|
|
|
char *newstring;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Find the length of this string without walking into memory
|
1999-05-03 15:29:11 +08:00
|
|
|
that isn't ours. */
|
|
|
|
for (i = 0; i < 8; ++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
|
|
|
if (internal_ptr->u.syment._n._n_name[i] == '\0')
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
newstring = bfd_zalloc (abfd, (bfd_size_type) (i + 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
|
|
|
if (newstring == NULL)
|
2005-03-23 00:14:43 +08:00
|
|
|
return 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
|
|
|
strncpy (newstring, internal_ptr->u.syment._n._n_name, i);
|
2007-07-12 15:16:41 +08:00
|
|
|
internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) newstring;
|
1999-05-03 15:29:11 +08:00
|
|
|
internal_ptr->u.syment._n._n_n._n_zeroes = 0;
|
|
|
|
}
|
|
|
|
else if (internal_ptr->u.syment._n._n_n._n_offset == 0)
|
2007-07-12 15:16:41 +08:00
|
|
|
internal_ptr->u.syment._n._n_n._n_offset = (bfd_vma) "";
|
1999-05-03 15:29:11 +08:00
|
|
|
else if (!bfd_coff_symname_in_debug (abfd, &internal_ptr->u.syment))
|
|
|
|
{
|
|
|
|
/* Long name already. Point symbol at the string in the
|
|
|
|
table. */
|
|
|
|
if (string_table == NULL)
|
|
|
|
{
|
|
|
|
string_table = _bfd_coff_read_string_table (abfd);
|
|
|
|
if (string_table == NULL)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
internal_ptr->u.syment._n._n_n._n_offset =
|
2007-07-12 15:16:41 +08:00
|
|
|
((bfd_hostptr_t)
|
1999-05-03 15:29:11 +08:00
|
|
|
(string_table
|
|
|
|
+ internal_ptr->u.syment._n._n_n._n_offset));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Long name in debug section. Very similar. */
|
|
|
|
if (debug_section == NULL)
|
|
|
|
debug_section = build_debug_section (abfd);
|
2007-07-12 15:16:41 +08:00
|
|
|
internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t)
|
1999-05-03 15:29:11 +08:00
|
|
|
(debug_section + internal_ptr->u.syment._n._n_n._n_offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
internal_ptr += internal_ptr->u.syment.n_numaux;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj_raw_syments (abfd) = internal;
|
|
|
|
BFD_ASSERT (obj_raw_syment_count (abfd)
|
|
|
|
== (unsigned int) (internal_ptr - internal));
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
return internal;
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
long
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_get_reloc_upper_bound (bfd *abfd, sec_ptr asect)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
if (bfd_get_format (abfd) != bfd_object)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return (asect->reloc_count + 1) * sizeof (arelent *);
|
|
|
|
}
|
|
|
|
|
|
|
|
asymbol *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_make_empty_symbol (bfd *abfd)
|
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
|
|
|
bfd_size_type amt = sizeof (coff_symbol_type);
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_symbol_type *new = bfd_zalloc (abfd, amt);
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (new == NULL)
|
2005-03-23 00:14:43 +08:00
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
new->symbol.section = 0;
|
|
|
|
new->native = 0;
|
2005-03-23 00:14:43 +08:00
|
|
|
new->lineno = NULL;
|
2002-11-30 16:39:46 +08:00
|
|
|
new->done_lineno = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
new->symbol.the_bfd = abfd;
|
2005-03-23 00:14:43 +08:00
|
|
|
|
|
|
|
return & new->symbol;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make a debugging symbol. */
|
|
|
|
|
|
|
|
asymbol *
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_bfd_make_debug_symbol (bfd *abfd,
|
|
|
|
void * ptr ATTRIBUTE_UNUSED,
|
|
|
|
unsigned long sz ATTRIBUTE_UNUSED)
|
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
|
|
|
bfd_size_type amt = sizeof (coff_symbol_type);
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_symbol_type *new = bfd_alloc (abfd, amt);
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (new == NULL)
|
2005-03-23 00:14:43 +08:00
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
/* @@ The 10 is a guess at a plausible maximum number of aux entries
|
|
|
|
(but shouldn't be a constant). */
|
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 (combined_entry_type) * 10;
|
2005-03-23 00:14:43 +08:00
|
|
|
new->native = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (!new->native)
|
2005-03-23 00:14:43 +08:00
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
new->symbol.section = bfd_abs_section_ptr;
|
|
|
|
new->symbol.flags = BSF_DEBUGGING;
|
2005-03-23 00:14:43 +08:00
|
|
|
new->lineno = NULL;
|
2002-11-30 16:39:46 +08:00
|
|
|
new->done_lineno = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
new->symbol.the_bfd = abfd;
|
2005-03-23 00:14:43 +08:00
|
|
|
|
|
|
|
return & new->symbol;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_get_symbol_info (bfd *abfd, asymbol *symbol, symbol_info *ret)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
bfd_symbol_info (symbol, ret);
|
2005-03-23 00:14:43 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (coffsymbol (symbol)->native != NULL
|
|
|
|
&& coffsymbol (symbol)->native->fix_value)
|
2005-03-23 00:14:43 +08:00
|
|
|
ret->value = coffsymbol (symbol)->native->u.syment.n_value -
|
2007-07-12 15:16:41 +08:00
|
|
|
(bfd_hostptr_t) obj_raw_syments (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the COFF syment for a symbol. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_coff_get_syment (bfd *abfd,
|
|
|
|
asymbol *symbol,
|
|
|
|
struct internal_syment *psyment)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
coff_symbol_type *csym;
|
|
|
|
|
|
|
|
csym = coff_symbol_from (abfd, symbol);
|
|
|
|
if (csym == NULL || csym->native == NULL)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
*psyment = csym->native->u.syment;
|
|
|
|
|
|
|
|
if (csym->native->fix_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
|
|
|
psyment->n_value = psyment->n_value -
|
2007-07-12 15:16:41 +08:00
|
|
|
(bfd_hostptr_t) obj_raw_syments (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
/* FIXME: We should handle fix_line here. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the COFF auxent for a symbol. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_coff_get_auxent (bfd *abfd,
|
|
|
|
asymbol *symbol,
|
|
|
|
int indx,
|
|
|
|
union internal_auxent *pauxent)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
coff_symbol_type *csym;
|
|
|
|
combined_entry_type *ent;
|
|
|
|
|
|
|
|
csym = coff_symbol_from (abfd, symbol);
|
|
|
|
|
|
|
|
if (csym == NULL
|
|
|
|
|| csym->native == NULL
|
|
|
|
|| indx >= csym->native->u.syment.n_numaux)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ent = csym->native + indx + 1;
|
|
|
|
|
|
|
|
*pauxent = ent->u.auxent;
|
|
|
|
|
|
|
|
if (ent->fix_tag)
|
|
|
|
pauxent->x_sym.x_tagndx.l =
|
|
|
|
((combined_entry_type *) pauxent->x_sym.x_tagndx.p
|
|
|
|
- obj_raw_syments (abfd));
|
|
|
|
|
|
|
|
if (ent->fix_end)
|
|
|
|
pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l =
|
|
|
|
((combined_entry_type *) pauxent->x_sym.x_fcnary.x_fcn.x_endndx.p
|
|
|
|
- obj_raw_syments (abfd));
|
|
|
|
|
|
|
|
if (ent->fix_scnlen)
|
|
|
|
pauxent->x_csect.x_scnlen.l =
|
|
|
|
((combined_entry_type *) pauxent->x_csect.x_scnlen.p
|
|
|
|
- obj_raw_syments (abfd));
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Print out information about COFF symbol. */
|
|
|
|
|
|
|
|
void
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_print_symbol (bfd *abfd,
|
|
|
|
void * filep,
|
|
|
|
asymbol *symbol,
|
|
|
|
bfd_print_symbol_type how)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
FILE * file = (FILE *) filep;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
switch (how)
|
|
|
|
{
|
|
|
|
case bfd_print_symbol_name:
|
|
|
|
fprintf (file, "%s", symbol->name);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case bfd_print_symbol_more:
|
|
|
|
fprintf (file, "coff %s %s",
|
|
|
|
coffsymbol (symbol)->native ? "n" : "g",
|
|
|
|
coffsymbol (symbol)->lineno ? "l" : " ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case bfd_print_symbol_all:
|
|
|
|
if (coffsymbol (symbol)->native)
|
|
|
|
{
|
2001-05-25 04:50:50 +08:00
|
|
|
bfd_vma val;
|
1999-05-03 15:29:11 +08:00
|
|
|
unsigned int aux;
|
|
|
|
combined_entry_type *combined = coffsymbol (symbol)->native;
|
|
|
|
combined_entry_type *root = obj_raw_syments (abfd);
|
|
|
|
struct lineno_cache_entry *l = coffsymbol (symbol)->lineno;
|
|
|
|
|
|
|
|
fprintf (file, "[%3ld]", (long) (combined - root));
|
|
|
|
|
|
|
|
if (! combined->fix_value)
|
2001-05-25 04:50:50 +08:00
|
|
|
val = (bfd_vma) combined->u.syment.n_value;
|
1999-05-03 15:29:11 +08:00
|
|
|
else
|
2007-07-12 15:16:41 +08:00
|
|
|
val = combined->u.syment.n_value - (bfd_hostptr_t) root;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-04-21 15:45:39 +08:00
|
|
|
fprintf (file, "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x",
|
1999-05-03 15:29:11 +08:00
|
|
|
combined->u.syment.n_scnum,
|
|
|
|
combined->u.syment.n_flags,
|
|
|
|
combined->u.syment.n_type,
|
|
|
|
combined->u.syment.n_sclass,
|
2005-04-15 19:47:47 +08:00
|
|
|
combined->u.syment.n_numaux);
|
2007-04-03 00:51:13 +08:00
|
|
|
#ifdef BFD64
|
|
|
|
/* fprintf_vma() on a 64-bit enabled host will always print a 64-bit
|
|
|
|
value, but really we want to display the address in the target's
|
|
|
|
address size. Since we do not have a field in the bfd structure
|
|
|
|
to tell us this, we take a guess, based on the target's name. */
|
|
|
|
if (strstr (bfd_get_target (abfd), "64") == NULL)
|
|
|
|
fprintf (file, "%08lx", (unsigned long) (val & 0xffffffff));
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
fprintf_vma (file, val);
|
2005-04-15 19:47:47 +08:00
|
|
|
fprintf (file, " %s", symbol->name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
|
|
|
|
{
|
|
|
|
combined_entry_type *auxp = combined + aux + 1;
|
|
|
|
long tagndx;
|
|
|
|
|
|
|
|
if (auxp->fix_tag)
|
|
|
|
tagndx = auxp->u.auxent.x_sym.x_tagndx.p - root;
|
|
|
|
else
|
|
|
|
tagndx = auxp->u.auxent.x_sym.x_tagndx.l;
|
|
|
|
|
|
|
|
fprintf (file, "\n");
|
|
|
|
|
|
|
|
if (bfd_coff_print_aux (abfd, file, root, combined, auxp, aux))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (combined->u.syment.n_sclass)
|
|
|
|
{
|
|
|
|
case C_FILE:
|
|
|
|
fprintf (file, "File ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case C_STAT:
|
|
|
|
if (combined->u.syment.n_type == T_NULL)
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Probably a section symbol ? */
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
fprintf (file, "AUX scnlen 0x%lx nreloc %d nlnno %d",
|
|
|
|
(long) auxp->u.auxent.x_scn.x_scnlen,
|
|
|
|
auxp->u.auxent.x_scn.x_nreloc,
|
|
|
|
auxp->u.auxent.x_scn.x_nlinno);
|
|
|
|
if (auxp->u.auxent.x_scn.x_checksum != 0
|
|
|
|
|| auxp->u.auxent.x_scn.x_associated != 0
|
|
|
|
|| auxp->u.auxent.x_scn.x_comdat != 0)
|
|
|
|
fprintf (file, " checksum 0x%lx assoc %d comdat %d",
|
|
|
|
auxp->u.auxent.x_scn.x_checksum,
|
|
|
|
auxp->u.auxent.x_scn.x_associated,
|
|
|
|
auxp->u.auxent.x_scn.x_comdat);
|
|
|
|
break;
|
|
|
|
}
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Otherwise fall through. */
|
1999-09-11 23:16:14 +08:00
|
|
|
case C_EXT:
|
|
|
|
if (ISFCN (combined->u.syment.n_type))
|
|
|
|
{
|
2001-08-17 16:57:42 +08:00
|
|
|
long next, llnos;
|
|
|
|
|
|
|
|
if (auxp->fix_end)
|
|
|
|
next = (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
|
|
|
|
- root);
|
|
|
|
else
|
|
|
|
next = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
|
|
|
|
llnos = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr;
|
1999-09-11 23:16:14 +08:00
|
|
|
fprintf (file,
|
2002-01-25 23:13:52 +08:00
|
|
|
"AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld",
|
2001-08-17 16:57:42 +08:00
|
|
|
tagndx, auxp->u.auxent.x_sym.x_misc.x_fsize,
|
|
|
|
llnos, next);
|
1999-09-11 23:16:14 +08:00
|
|
|
break;
|
|
|
|
}
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Otherwise fall through. */
|
1999-05-03 15:29:11 +08:00
|
|
|
default:
|
|
|
|
fprintf (file, "AUX lnno %d size 0x%x tagndx %ld",
|
|
|
|
auxp->u.auxent.x_sym.x_misc.x_lnsz.x_lnno,
|
|
|
|
auxp->u.auxent.x_sym.x_misc.x_lnsz.x_size,
|
|
|
|
tagndx);
|
|
|
|
if (auxp->fix_end)
|
|
|
|
fprintf (file, " endndx %ld",
|
|
|
|
((long)
|
|
|
|
(auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
|
|
|
|
- root)));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l)
|
|
|
|
{
|
|
|
|
fprintf (file, "\n%s :", l->u.sym->name);
|
|
|
|
l++;
|
|
|
|
while (l->line_number)
|
|
|
|
{
|
2005-04-15 19:47:47 +08:00
|
|
|
fprintf (file, "\n%4d : ", l->line_number);
|
|
|
|
fprintf_vma (file, l->u.offset + symbol->section->vma);
|
1999-05-03 15:29:11 +08:00
|
|
|
l++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_print_symbol_vandf (abfd, (void *) file, symbol);
|
1999-05-03 15:29:11 +08:00
|
|
|
fprintf (file, " %-5s %s %s %s",
|
|
|
|
symbol->section->name,
|
|
|
|
coffsymbol (symbol)->native ? "n" : "g",
|
|
|
|
coffsymbol (symbol)->lineno ? "l" : " ",
|
|
|
|
symbol->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return whether a symbol name implies a local symbol. In COFF,
|
|
|
|
local symbols generally start with ``.L''. Most targets use this
|
|
|
|
function for the is_local_label_name entry point, but some may
|
|
|
|
override it. */
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
_bfd_coff_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
const char *name)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
return name[0] == '.' && name[1] == 'L';
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
2000-01-14 06:10:36 +08:00
|
|
|
/* Provided a BFD, a section and an offset (in bytes, not octets) into the
|
|
|
|
section, calculate and return the name of the source file and the line
|
|
|
|
nearest to the wanted location. */
|
2000-12-09 02:34:32 +08:00
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
coff_find_nearest_line (bfd *abfd,
|
|
|
|
asection *section,
|
|
|
|
asymbol **symbols,
|
|
|
|
bfd_vma offset,
|
|
|
|
const char **filename_ptr,
|
|
|
|
const char **functionname_ptr,
|
|
|
|
unsigned int *line_ptr)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean found;
|
1999-05-03 15:29:11 +08:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int line_base;
|
|
|
|
coff_data_type *cof = coff_data (abfd);
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Run through the raw syments if available. */
|
1999-05-03 15:29:11 +08:00
|
|
|
combined_entry_type *p;
|
|
|
|
combined_entry_type *pend;
|
|
|
|
alent *l;
|
|
|
|
struct coff_section_tdata *sec_data;
|
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
|
|
|
|
|
|
|
/* Before looking through the symbol table, try to use a .stab
|
|
|
|
section to find the information. */
|
|
|
|
if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
|
|
|
|
&found, filename_ptr,
|
|
|
|
functionname_ptr, line_ptr,
|
2000-12-09 06:50:07 +08:00
|
|
|
&coff_data(abfd)->line_info))
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
2000-12-09 06:50:07 +08:00
|
|
|
|
2001-02-08 07:50:04 +08:00
|
|
|
if (found)
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
2001-02-08 07:50:04 +08:00
|
|
|
|
2000-12-09 06:50:07 +08:00
|
|
|
/* Also try examining DWARF2 debugging information. */
|
|
|
|
if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
|
|
|
|
filename_ptr, functionname_ptr,
|
|
|
|
line_ptr, 0,
|
|
|
|
&coff_data(abfd)->dwarf2_find_line_info))
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
2000-12-09 06:50:07 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
*filename_ptr = 0;
|
|
|
|
*functionname_ptr = 0;
|
|
|
|
*line_ptr = 0;
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Don't try and find line numbers in a non coff file. */
|
2000-06-17 04:35:08 +08:00
|
|
|
if (!bfd_family_coff (abfd))
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
if (cof == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
/* Find the first C_FILE symbol. */
|
|
|
|
p = cof->raw_syments;
|
|
|
|
if (!p)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
pend = p + cof->raw_syment_count;
|
|
|
|
while (p < pend)
|
|
|
|
{
|
|
|
|
if (p->u.syment.n_sclass == C_FILE)
|
|
|
|
break;
|
|
|
|
p += 1 + p->u.syment.n_numaux;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p < pend)
|
|
|
|
{
|
|
|
|
bfd_vma sec_vma;
|
|
|
|
bfd_vma maxdiff;
|
|
|
|
|
|
|
|
/* Look through the C_FILE symbols to find the best one. */
|
|
|
|
sec_vma = bfd_get_section_vma (abfd, section);
|
|
|
|
*filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
|
|
|
|
maxdiff = (bfd_vma) 0 - (bfd_vma) 1;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
combined_entry_type *p2;
|
|
|
|
|
|
|
|
for (p2 = p + 1 + p->u.syment.n_numaux;
|
|
|
|
p2 < pend;
|
|
|
|
p2 += 1 + p2->u.syment.n_numaux)
|
|
|
|
{
|
|
|
|
if (p2->u.syment.n_scnum > 0
|
|
|
|
&& (section
|
|
|
|
== coff_section_from_bfd_index (abfd,
|
|
|
|
p2->u.syment.n_scnum)))
|
|
|
|
break;
|
|
|
|
if (p2->u.syment.n_sclass == C_FILE)
|
|
|
|
{
|
|
|
|
p2 = pend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-09 12:04:17 +08:00
|
|
|
/* We use <= MAXDIFF here so that if we get a zero length
|
|
|
|
file, we actually use the next file entry. */
|
1999-05-03 15:29:11 +08:00
|
|
|
if (p2 < pend
|
|
|
|
&& offset + sec_vma >= (bfd_vma) p2->u.syment.n_value
|
1999-08-09 12:04:17 +08:00
|
|
|
&& offset + sec_vma - (bfd_vma) p2->u.syment.n_value <= maxdiff)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
*filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
|
|
|
|
maxdiff = offset + sec_vma - p2->u.syment.n_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Avoid endless loops on erroneous files by ensuring that
|
|
|
|
we always move forward in the file. */
|
2001-08-17 16:57:42 +08:00
|
|
|
if (p >= cof->raw_syments + p->u.syment.n_value)
|
1999-05-03 15:29:11 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
p = cof->raw_syments + p->u.syment.n_value;
|
|
|
|
if (p > pend || p->u.syment.n_sclass != C_FILE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Now wander though the raw linenumbers of the section. */
|
|
|
|
/* If we have been called on this section before, and th. e offset we
|
1999-05-03 15:29:11 +08:00
|
|
|
want is further down then we can prime the lookup loop. */
|
|
|
|
sec_data = coff_section_data (abfd, section);
|
|
|
|
if (sec_data != NULL
|
|
|
|
&& sec_data->i > 0
|
|
|
|
&& offset >= sec_data->offset)
|
|
|
|
{
|
|
|
|
i = sec_data->i;
|
|
|
|
*functionname_ptr = sec_data->function;
|
|
|
|
line_base = sec_data->line_base;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
line_base = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (section->lineno != NULL)
|
|
|
|
{
|
1999-08-09 12:04:17 +08:00
|
|
|
bfd_vma last_value = 0;
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
l = §ion->lineno[i];
|
|
|
|
|
|
|
|
for (; i < section->lineno_count; i++)
|
|
|
|
{
|
|
|
|
if (l->line_number == 0)
|
|
|
|
{
|
2005-03-23 00:14:43 +08:00
|
|
|
/* Get the symbol this line number points at. */
|
1999-05-03 15:29:11 +08:00
|
|
|
coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym);
|
|
|
|
if (coff->symbol.value > offset)
|
|
|
|
break;
|
|
|
|
*functionname_ptr = coff->symbol.name;
|
1999-08-09 12:04:17 +08:00
|
|
|
last_value = coff->symbol.value;
|
1999-05-03 15:29:11 +08:00
|
|
|
if (coff->native)
|
|
|
|
{
|
|
|
|
combined_entry_type *s = coff->native;
|
|
|
|
s = s + 1 + s->u.syment.n_numaux;
|
|
|
|
|
|
|
|
/* In XCOFF a debugging symbol can follow the
|
|
|
|
function symbol. */
|
|
|
|
if (s->u.syment.n_scnum == N_DEBUG)
|
|
|
|
s = s + 1 + s->u.syment.n_numaux;
|
|
|
|
|
|
|
|
/* S should now point to the .bf of the function. */
|
|
|
|
if (s->u.syment.n_numaux)
|
|
|
|
{
|
|
|
|
/* The linenumber is stored in the auxent. */
|
|
|
|
union internal_auxent *a = &((s + 1)->u.auxent);
|
|
|
|
line_base = a->x_sym.x_misc.x_lnsz.x_lnno;
|
|
|
|
*line_ptr = line_base;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (l->u.offset > offset)
|
|
|
|
break;
|
|
|
|
*line_ptr = l->line_number + line_base - 1;
|
|
|
|
}
|
|
|
|
l++;
|
|
|
|
}
|
1999-08-09 12:04:17 +08:00
|
|
|
|
|
|
|
/* If we fell off the end of the loop, then assume that this
|
|
|
|
symbol has no line number info. Otherwise, symbols with no
|
|
|
|
line number info get reported with the line number of the
|
|
|
|
last line of the last symbol which does have line number
|
|
|
|
info. We use 0x100 as a slop to account for cases where the
|
|
|
|
last line has executable code. */
|
|
|
|
if (i >= section->lineno_count
|
|
|
|
&& last_value != 0
|
|
|
|
&& offset - last_value > 0x100)
|
|
|
|
{
|
|
|
|
*functionname_ptr = NULL;
|
|
|
|
*line_ptr = 0;
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cache the results for the next call. */
|
|
|
|
if (sec_data == NULL && section->owner == 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
|
|
|
amt = sizeof (struct coff_section_tdata);
|
2005-03-23 00:14:43 +08:00
|
|
|
section->used_by_bfd = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
sec_data = (struct coff_section_tdata *) section->used_by_bfd;
|
|
|
|
}
|
|
|
|
if (sec_data != NULL)
|
|
|
|
{
|
|
|
|
sec_data->offset = offset;
|
|
|
|
sec_data->i = i;
|
|
|
|
sec_data->function = *functionname_ptr;
|
|
|
|
sec_data->line_base = line_base;
|
|
|
|
}
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
|
2005-05-24 01:44:55 +08:00
|
|
|
bfd_boolean
|
|
|
|
coff_find_inliner_info (bfd *abfd,
|
|
|
|
const char **filename_ptr,
|
|
|
|
const char **functionname_ptr,
|
|
|
|
unsigned int *line_ptr)
|
|
|
|
{
|
|
|
|
bfd_boolean found;
|
|
|
|
|
|
|
|
found = _bfd_dwarf2_find_inliner_info (abfd, filename_ptr,
|
|
|
|
functionname_ptr, line_ptr,
|
|
|
|
&coff_data(abfd)->dwarf2_find_line_info);
|
|
|
|
return (found);
|
|
|
|
}
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
int
|
2006-06-19 21:17:44 +08:00
|
|
|
coff_sizeof_headers (bfd *abfd, struct bfd_link_info *info)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
size_t size;
|
|
|
|
|
2006-06-19 21:17:44 +08:00
|
|
|
if (!info->relocatable)
|
2005-03-23 00:14:43 +08:00
|
|
|
size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
else
|
2005-03-23 00:14:43 +08:00
|
|
|
size = bfd_coff_filhsz (abfd);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
size += abfd->section_count * bfd_coff_scnhsz (abfd);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Change the class of a coff symbol held by BFD. */
|
2005-03-23 00:14:43 +08:00
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
bfd_boolean
|
2005-03-23 00:14:43 +08:00
|
|
|
bfd_coff_set_symbol_class (bfd * abfd,
|
|
|
|
asymbol * symbol,
|
|
|
|
unsigned int class)
|
1999-05-03 15:29:11 +08:00
|
|
|
{
|
|
|
|
coff_symbol_type * csym;
|
|
|
|
|
|
|
|
csym = coff_symbol_from (abfd, symbol);
|
|
|
|
if (csym == NULL)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
|
|
|
else if (csym->native == NULL)
|
|
|
|
{
|
|
|
|
/* This is an alien symbol which no native coff backend data.
|
|
|
|
We cheat here by creating a fake native entry for it and
|
|
|
|
then filling in the class. This code is based on that in
|
|
|
|
coff_write_alien_symbol(). */
|
2000-11-28 09:33:15 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
combined_entry_type * native;
|
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 (* native);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
2005-03-23 00:14:43 +08:00
|
|
|
native = bfd_zalloc (abfd, amt);
|
1999-05-03 15:29:11 +08:00
|
|
|
if (native == NULL)
|
2002-11-30 16:39:46 +08:00
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
native->u.syment.n_type = T_NULL;
|
|
|
|
native->u.syment.n_sclass = class;
|
2000-11-28 09:33:15 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
if (bfd_is_und_section (symbol->section))
|
|
|
|
{
|
|
|
|
native->u.syment.n_scnum = N_UNDEF;
|
|
|
|
native->u.syment.n_value = symbol->value;
|
|
|
|
}
|
|
|
|
else if (bfd_is_com_section (symbol->section))
|
|
|
|
{
|
|
|
|
native->u.syment.n_scnum = N_UNDEF;
|
|
|
|
native->u.syment.n_value = symbol->value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
native->u.syment.n_scnum =
|
|
|
|
symbol->section->output_section->target_index;
|
|
|
|
native->u.syment.n_value = (symbol->value
|
|
|
|
+ symbol->section->output_offset);
|
|
|
|
if (! obj_pe (abfd))
|
|
|
|
native->u.syment.n_value += symbol->section->output_section->vma;
|
2000-11-28 09:33:15 +08:00
|
|
|
|
2001-10-10 20:08:29 +08:00
|
|
|
/* Copy the any flags from the file header into the symbol.
|
1999-05-03 15:29:11 +08:00
|
|
|
FIXME: Why? */
|
|
|
|
native->u.syment.n_flags = bfd_asymbol_bfd (& csym->symbol)->flags;
|
|
|
|
}
|
2000-11-28 09:33:15 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
csym->native = native;
|
|
|
|
}
|
|
|
|
else
|
2005-03-23 00:14:43 +08:00
|
|
|
csym->native->u.syment.n_sclass = class;
|
2000-11-28 09:33:15 +08:00
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
}
|
2004-07-21 23:42:58 +08:00
|
|
|
|
|
|
|
struct coff_comdat_info *
|
|
|
|
bfd_coff_get_comdat_section (bfd *abfd, struct bfd_section *sec)
|
|
|
|
{
|
2005-02-21 19:21:29 +08:00
|
|
|
if (bfd_get_flavour (abfd) == bfd_target_coff_flavour
|
|
|
|
&& coff_section_data (abfd, sec) != NULL)
|
2004-07-21 23:42:58 +08:00
|
|
|
return coff_section_data (abfd, sec)->comdat;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|