binutils-gdb/bfd/elf.c

9732 lines
273 KiB
C
Raw Normal View History

1999-05-03 09:29:11 +02:00
/* ELF executable support for BFD.
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
1999-05-03 09:29:11 +02:00
This file is part of BFD, the Binary File Descriptor library.
1999-05-03 09:29:11 +02: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
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
1999-05-03 09:29:11 +02: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 09:29:11 +02:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
1999-05-03 09:29:11 +02:00
/*
SECTION
1999-05-03 09:29:11 +02:00
ELF backends
BFD support for ELF formats is being worked on.
Currently, the best supported back ends are for sparc and i386
(running svr4 or Solaris 2).
Documentation of the internals of the support code still needs
to be written. The code is changing quickly enough that we
2002-01-30 11:31:28 +01:00
haven't bothered yet. */
1999-05-03 09:29:11 +02:00
/* For sparc64-cross-sparc32. */
#define _SYSCALL32
1999-05-03 09:29:11 +02:00
#include "sysdep.h"
#include "bfd.h"
1999-05-03 09:29:11 +02:00
#include "bfdlink.h"
#include "libbfd.h"
#define ARCH_SIZE 0
#include "elf-bfd.h"
#include "libiberty.h"
#include "safe-ctype.h"
1999-05-03 09:29:11 +02:00
#ifdef CORE_HEADER
#include CORE_HEADER
#endif
static int elf_sort_sections (const void *, const void *);
static bfd_boolean assign_file_positions_except_relocs (bfd *, struct bfd_link_info *);
static bfd_boolean prep_headers (bfd *);
static bfd_boolean swap_out_syms (bfd *, struct bfd_strtab_hash **, int) ;
static bfd_boolean elf_read_notes (bfd *, file_ptr, bfd_size_type) ;
static bfd_boolean elf_parse_notes (bfd *abfd, char *buf, size_t size,
file_ptr offset);
1999-05-03 09:29:11 +02:00
/* Swap version information in and out. The version information is
currently size independent. If that ever changes, this code will
need to move into elfcode.h. */
/* Swap in a Verdef structure. */
void
_bfd_elf_swap_verdef_in (bfd *abfd,
const Elf_External_Verdef *src,
Elf_Internal_Verdef *dst)
1999-05-03 09:29:11 +02:00
{
dst->vd_version = H_GET_16 (abfd, src->vd_version);
dst->vd_flags = H_GET_16 (abfd, src->vd_flags);
dst->vd_ndx = H_GET_16 (abfd, src->vd_ndx);
dst->vd_cnt = H_GET_16 (abfd, src->vd_cnt);
dst->vd_hash = H_GET_32 (abfd, src->vd_hash);
dst->vd_aux = H_GET_32 (abfd, src->vd_aux);
dst->vd_next = H_GET_32 (abfd, src->vd_next);
1999-05-03 09:29:11 +02:00
}
/* Swap out a Verdef structure. */
void
_bfd_elf_swap_verdef_out (bfd *abfd,
const Elf_Internal_Verdef *src,
Elf_External_Verdef *dst)
1999-05-03 09:29:11 +02:00
{
H_PUT_16 (abfd, src->vd_version, dst->vd_version);
H_PUT_16 (abfd, src->vd_flags, dst->vd_flags);
H_PUT_16 (abfd, src->vd_ndx, dst->vd_ndx);
H_PUT_16 (abfd, src->vd_cnt, dst->vd_cnt);
H_PUT_32 (abfd, src->vd_hash, dst->vd_hash);
H_PUT_32 (abfd, src->vd_aux, dst->vd_aux);
H_PUT_32 (abfd, src->vd_next, dst->vd_next);
1999-05-03 09:29:11 +02:00
}
/* Swap in a Verdaux structure. */
void
_bfd_elf_swap_verdaux_in (bfd *abfd,
const Elf_External_Verdaux *src,
Elf_Internal_Verdaux *dst)
1999-05-03 09:29:11 +02:00
{
dst->vda_name = H_GET_32 (abfd, src->vda_name);
dst->vda_next = H_GET_32 (abfd, src->vda_next);
1999-05-03 09:29:11 +02:00
}
/* Swap out a Verdaux structure. */
void
_bfd_elf_swap_verdaux_out (bfd *abfd,
const Elf_Internal_Verdaux *src,
Elf_External_Verdaux *dst)
1999-05-03 09:29:11 +02:00
{
H_PUT_32 (abfd, src->vda_name, dst->vda_name);
H_PUT_32 (abfd, src->vda_next, dst->vda_next);
1999-05-03 09:29:11 +02:00
}
/* Swap in a Verneed structure. */
void
_bfd_elf_swap_verneed_in (bfd *abfd,
const Elf_External_Verneed *src,
Elf_Internal_Verneed *dst)
1999-05-03 09:29:11 +02:00
{
dst->vn_version = H_GET_16 (abfd, src->vn_version);
dst->vn_cnt = H_GET_16 (abfd, src->vn_cnt);
dst->vn_file = H_GET_32 (abfd, src->vn_file);
dst->vn_aux = H_GET_32 (abfd, src->vn_aux);
dst->vn_next = H_GET_32 (abfd, src->vn_next);
1999-05-03 09:29:11 +02:00
}
/* Swap out a Verneed structure. */
void
_bfd_elf_swap_verneed_out (bfd *abfd,
const Elf_Internal_Verneed *src,
Elf_External_Verneed *dst)
1999-05-03 09:29:11 +02:00
{
H_PUT_16 (abfd, src->vn_version, dst->vn_version);
H_PUT_16 (abfd, src->vn_cnt, dst->vn_cnt);
H_PUT_32 (abfd, src->vn_file, dst->vn_file);
H_PUT_32 (abfd, src->vn_aux, dst->vn_aux);
H_PUT_32 (abfd, src->vn_next, dst->vn_next);
1999-05-03 09:29:11 +02:00
}
/* Swap in a Vernaux structure. */
void
_bfd_elf_swap_vernaux_in (bfd *abfd,
const Elf_External_Vernaux *src,
Elf_Internal_Vernaux *dst)
1999-05-03 09:29:11 +02:00
{
dst->vna_hash = H_GET_32 (abfd, src->vna_hash);
dst->vna_flags = H_GET_16 (abfd, src->vna_flags);
dst->vna_other = H_GET_16 (abfd, src->vna_other);
dst->vna_name = H_GET_32 (abfd, src->vna_name);
dst->vna_next = H_GET_32 (abfd, src->vna_next);
1999-05-03 09:29:11 +02:00
}
/* Swap out a Vernaux structure. */
void
_bfd_elf_swap_vernaux_out (bfd *abfd,
const Elf_Internal_Vernaux *src,
Elf_External_Vernaux *dst)
1999-05-03 09:29:11 +02:00
{
H_PUT_32 (abfd, src->vna_hash, dst->vna_hash);
H_PUT_16 (abfd, src->vna_flags, dst->vna_flags);
H_PUT_16 (abfd, src->vna_other, dst->vna_other);
H_PUT_32 (abfd, src->vna_name, dst->vna_name);
H_PUT_32 (abfd, src->vna_next, dst->vna_next);
1999-05-03 09:29:11 +02:00
}
/* Swap in a Versym structure. */
void
_bfd_elf_swap_versym_in (bfd *abfd,
const Elf_External_Versym *src,
Elf_Internal_Versym *dst)
1999-05-03 09:29:11 +02:00
{
dst->vs_vers = H_GET_16 (abfd, src->vs_vers);
1999-05-03 09:29:11 +02:00
}
/* Swap out a Versym structure. */
void
_bfd_elf_swap_versym_out (bfd *abfd,
const Elf_Internal_Versym *src,
Elf_External_Versym *dst)
1999-05-03 09:29:11 +02:00
{
H_PUT_16 (abfd, src->vs_vers, dst->vs_vers);
1999-05-03 09:29:11 +02:00
}
/* Standard ELF hash function. Do not change this function; you will
cause invalid hash tables to be generated. */
1999-05-03 09:29:11 +02:00
unsigned long
bfd_elf_hash (const char *namearg)
1999-05-03 09:29:11 +02:00
{
const unsigned char *name = (const unsigned char *) namearg;
1999-05-03 09:29:11 +02:00
unsigned long h = 0;
unsigned long g;
int ch;
while ((ch = *name++) != '\0')
{
h = (h << 4) + ch;
if ((g = (h & 0xf0000000)) != 0)
{
h ^= g >> 24;
/* The ELF ABI says `h &= ~g', but this is equivalent in
this case and on some machines one insn instead of two. */
h ^= g;
}
}
return h & 0xffffffff;
1999-05-03 09:29:11 +02:00
}
include/ * bfdlink.h (struct bfd_link_info): Add emit_hash and emit_gnu_hash bitfields. include/elf/ * common.h (SHT_GNU_HASH, DT_GNU_HASH): Define. ld/ * scripttempl/elf.sc: Add .gnu.hash section. * emultempl/elf32.em (OPTION_HASH_STYLE): Define. (gld${EMULATION_NAME}_add_options): Register --hash-style option. (gld${EMULATION_NAME}_handle_option): Handle it. (gld${EMULATION_NAME}_list_options): Document it. * ldmain.c (main): Initialize emit_hash and emit_gnu_hash. * ld.texinfo: Document --hash-style option. bfd/ * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_GNU_HASH. (bfd_section_from_shdr, elf_fake_sections, assign_section_numbers): Handle SHT_GNU_HASH. (special_sections_g): Include .gnu.hash section. (bfd_elf_gnu_hash): New function. * elf-bfd.h (bfd_elf_gnu_hash, _bfd_elf_hash_symbol): New prototypes. (struct elf_backend_data): Add elf_hash_symbol method. * elflink.c (_bfd_elf_link_create_dynamic_sections): Create .hash only if info->emit_hash, create .gnu.hash section if info->emit_gnu_hash. (struct collect_gnu_hash_codes): New type. (elf_collect_gnu_hash_codes, elf_renumber_gnu_hash_syms, _bfd_elf_hash_symbol): New functions. (compute_bucket_count): Don't compute HASHCODES array, instead add that and NSYMS as arguments. Use bed->s->sizeof_hash_entry instead of bed->s->arch_size / 8. Fix .hash size estimation. When not optimizing, use the number of hashed symbols rather than dynsymcount. (bfd_elf_size_dynamic_sections): Only add DT_HASH if info->emit_hash, and ADD DT_GNU_HASH if info->emit_gnu_hash. (bfd_elf_size_dynsym_hash_dynstr): Size .hash only if info->emit_hash, adjust compute_bucket_count caller. Create and populate .gnu.hash section if info->emit_gnu_hash. (elf_link_output_extsym): Only populate .hash section if finfo->hash_sec != NULL. (bfd_elf_final_link): Adjust assertion. Handle DT_GNU_HASH. * elfxx-target.h (elf_backend_hash_symbol): Define if not yet defined. (elfNN_bed): Add elf_backend_hash_symbol. * elf64-x86-64.c (elf64_x86_64_hash_symbol): New function. (elf_backend_hash_symbol): Define. * elf32-i386.c (elf_i386_hash_symbol): New function. (elf_backend_hash_symbol): Define. binutils/ * readelf.c (get_dynamic_type): Handle DT_GNU_HASH. (get_section_type_name): Handle SHT_GNU_HASH. (dynamic_info_DT_GNU_HASH): New variable. (process_dynamic_section): Handle DT_GNU_HASH. (process_symbol_table): Print also DT_GNU_HASH histogram. ld/testsuite/ * ld-powerpc/tlsso32.r: Adjust. * ld-powerpc/tlsso32.d: Adjust. * ld-powerpc/tlsso32.g: Adjust. * ld-powerpc/tlsso.r: Adjust. * ld-powerpc/tlsso.g: Adjust. * ld-powerpc/tlstocso.g: Adjust.
2006-07-10 23:40:25 +02:00
/* DT_GNU_HASH hash function. Do not change this function; you will
cause invalid hash tables to be generated. */
unsigned long
bfd_elf_gnu_hash (const char *namearg)
{
const unsigned char *name = (const unsigned char *) namearg;
unsigned long h = 5381;
unsigned char ch;
while ((ch = *name++) != '\0')
h = (h << 5) + h + ch;
return h & 0xffffffff;
}
/* Create a tdata field OBJECT_SIZE bytes in length, zeroed out and with
the object_id field of an elf_obj_tdata field set to OBJECT_ID. */
bfd_boolean
bfd_elf_allocate_object (bfd *abfd,
PR ld/5692 * elf-bfd.h (enum elf_object_id): New enum, used to identify target specific extensions to the elf_obj_tdata structure. (struct elf_obj_tdata): New field 'object_id'. (elf_object_id, elf_program_header_size, elf_symtab_hdr): New macros for accessing fields in the elf_obj_tdata structure. (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object. (bfd_elf_allocate_object): New function. * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object and implement by calling bfd_elf_allocate_object. (bfd_elf_allocate_object): New function: Allocates an elf_obj_tdata structure, possibly with a target specific extension. * elfxx-target.h (bfd_elfNN_mkobject): Use bfd_elf_make_generic_object as the default value. * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata for consistency with other, similar structures. (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM ELF bfd. (elf32_arm_mkobject): Call bfd_elf_allocate_object. (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check the bfd being processed. (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise. (bfd_elf32_arm_set_target_relocs): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_copy_private_bfd_data): Likewise. (bfd_elf32_arm_merge_eabi_attributes): Likewise. (bfd_elf32_arm_merge_private_bfd_data): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_gc_mark_extra_sections): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr. (bfd_elf32_arm_init_maps): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_relocate_section): Likewise. (bfd_elf32_arm_gc_sweep_hook): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object. (is_i386_elf): New macro. Checks a BFD to make sure that is an x86 ELF bfd. (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd being processed. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_check_relocs): Use elf_symtab_hdr. (elf_i386_gc_sweep_hook): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object. (elf_create_pointer_linker_section): Use is_ppc_elf_target to verify that the bfd before accessing target specific fields. (ppc_elf_check_relocs): Likewise. (elf_finish_pointer_linker_section): Likewise. (elf_create_pointer_linker_section): Use elf_symtab_hdr. (ppc_elf_check_relocs): Likewise. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_tls_optimize): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf64-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object. (is_sh_elf): New macro. Checks a BFD to make sure that is an SH ELF bfd. (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the bfd being processed. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_copy_private_data): Likewise. (sh_elf_relax_section): Use elf_symtab_hdr. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_get_relocated_section_contents): Likewise. (sh_elf_gc_sweep_hook): Likewise. (sh_elf_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object. (is_alpha_elf): New macro. Checks a BFD to make sure that is an Alpha ELF bfd. (elf64_alpha_create_got_section): Use is_alpha_elf macro to check the bfd being processed. (elf64_alpha_create_dynamic_section): Likewise. (elf64_alpha_check_relocs): Likewise. (elf64_alpha_size_got_sections): Likewise. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_final_link): Likewise. (elf64_alpha_check_relocs): Use elf_symtab_hdr. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section_r): Likewise. (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object. (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd being processed. (opd_entry_value): Likewise. (allocate_dynrelocs): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_check_relocs): Use elf_symtab_hdr. (opd_entry_value): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. (get_sym_h): Likewise. (ppc64_elf_edit_opd): Likewise. (ppc64_elf_tls_optimize): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_size_stubs): Likewise. (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf32-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object. (is_x86_64_elf): New macro. Checks a BFD to make sure that is an x86_64 ELF bfd. (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd being processed. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. (elf64_x86_64_check_relocs): Use elf_symtab_hdr. (elf64_x86_64_gc_sweep_hook): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object. (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc ELF bfd. (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the bfd being processed. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise.
2008-02-12 12:32:31 +01:00
size_t object_size,
* elf-bfd.h (emum elf_object_id): Rename to elf_target_id. Add entries for other architectures. (struct elf_link_hash_table): Add hash_table_id field. (elf_hash_table_id): New accessor macro. * elflink.c (_bfd_elf_link_hash_table_init): Add target_id parameter. * elf-m10300.c (elf32_mn10300_hash_table): Check table id before returning cast pointer. (elf32_mn10300_link_hash_table_create): Identify new table as containing MN10300 extensions. (mn10300_elf_relax_section): Check pointer returned by elf32_mn10300_hash_table. * elf32-arm.c: Likewise, except using ARM extensions. * elf32-avr.c: Likewise, except using AVR extensions. * elf32-bfin.c: Likewise, except using BFIN extensions. * elf32-cris.c: Likewise, except using CRIS extensions. * elf32-frv.c: Likewise, except using FRV extensions. * elf32-hppa.c: Likewise, except using HPPA32 extensions. * elf32-i386.c: Likewise, except using I386 extensions. * elf32-lm32.c: Likewise, except using LM32 extensions. * elf32-m32r.c: Likewise, except using M32RM extensions. * elf32-m68hc11.c: Likewise, except using M68HC11 extensions. * elf32-m68hc1x.c: Likewise, except using M68HC11 extensions. * elf32-m68hc1x.h: Likewise, except using M68HC11 extensions. * elf32-m68k.c: Likewise, except using M68K extensions. * elf32-microblaze.c: Likewise, except using MICROBLAZE extensions. * elf32-ppc.c: Likewise, except using PPC32 extensions. * elf32-s390.c: Likewise, except using S390 extensions. * elf32-sh.c: Likewise, except using SH extensions. * elf32-spu.c: Likewise, except using SPU extensions. * elf32-xtensa.c: Likewise, except using XTENSA extensions. * elf64-alpha.c: Likewise, except using ALPHA extensions. * elf64-hppa.c: Likewise, except using HPPA64 extensions. * elf64-ppc.c: Likewise, except using PPC64 extensions. * elf64-s390.c: Likewise, except using S390 extensions. * elf64-x86-64.c: Likewise, except using X86_64 extensions. * elfxx-ia64.c: Likewise, except using IA64 extensions. * elfxx-mips.c: Likewise, except using MIPS extensions. * elfxx-sparc.c: Likewise, except using SPARC extensions. * elfxx-sparc.h: Likewise, except using SPARC extensions. * elf32-cr16.c (struct elf32_cr16_link_hash_table): Delete redundant structure. (elf32_cr16_hash_table): Delete unused macro. (elf32_cr16_link_hash_traverse): Delete unused macro. * elf32-score.c: Likewise. * elf32-score7.c: Likewise. * elf32-vax.c: Likewise. * elf64-sh64.c: Likewise. * emultempl/alphaelf.em: Update value expected from elf_object_id. * emultempl/hppaelf.em: Likewise. * emultempl/mipself.em: Likewise. * emultempl/ppc32elf.em: Likewise. * emultempl/ppc64elf.em: Likewise.
2010-02-04 10:16:43 +01:00
enum elf_target_id object_id)
1999-05-03 09:29:11 +02:00
{
PR ld/5692 * elf-bfd.h (enum elf_object_id): New enum, used to identify target specific extensions to the elf_obj_tdata structure. (struct elf_obj_tdata): New field 'object_id'. (elf_object_id, elf_program_header_size, elf_symtab_hdr): New macros for accessing fields in the elf_obj_tdata structure. (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object. (bfd_elf_allocate_object): New function. * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object and implement by calling bfd_elf_allocate_object. (bfd_elf_allocate_object): New function: Allocates an elf_obj_tdata structure, possibly with a target specific extension. * elfxx-target.h (bfd_elfNN_mkobject): Use bfd_elf_make_generic_object as the default value. * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata for consistency with other, similar structures. (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM ELF bfd. (elf32_arm_mkobject): Call bfd_elf_allocate_object. (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check the bfd being processed. (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise. (bfd_elf32_arm_set_target_relocs): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_copy_private_bfd_data): Likewise. (bfd_elf32_arm_merge_eabi_attributes): Likewise. (bfd_elf32_arm_merge_private_bfd_data): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_gc_mark_extra_sections): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr. (bfd_elf32_arm_init_maps): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_relocate_section): Likewise. (bfd_elf32_arm_gc_sweep_hook): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object. (is_i386_elf): New macro. Checks a BFD to make sure that is an x86 ELF bfd. (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd being processed. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_check_relocs): Use elf_symtab_hdr. (elf_i386_gc_sweep_hook): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object. (elf_create_pointer_linker_section): Use is_ppc_elf_target to verify that the bfd before accessing target specific fields. (ppc_elf_check_relocs): Likewise. (elf_finish_pointer_linker_section): Likewise. (elf_create_pointer_linker_section): Use elf_symtab_hdr. (ppc_elf_check_relocs): Likewise. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_tls_optimize): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf64-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object. (is_sh_elf): New macro. Checks a BFD to make sure that is an SH ELF bfd. (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the bfd being processed. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_copy_private_data): Likewise. (sh_elf_relax_section): Use elf_symtab_hdr. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_get_relocated_section_contents): Likewise. (sh_elf_gc_sweep_hook): Likewise. (sh_elf_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object. (is_alpha_elf): New macro. Checks a BFD to make sure that is an Alpha ELF bfd. (elf64_alpha_create_got_section): Use is_alpha_elf macro to check the bfd being processed. (elf64_alpha_create_dynamic_section): Likewise. (elf64_alpha_check_relocs): Likewise. (elf64_alpha_size_got_sections): Likewise. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_final_link): Likewise. (elf64_alpha_check_relocs): Use elf_symtab_hdr. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section_r): Likewise. (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object. (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd being processed. (opd_entry_value): Likewise. (allocate_dynrelocs): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_check_relocs): Use elf_symtab_hdr. (opd_entry_value): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. (get_sym_h): Likewise. (ppc64_elf_edit_opd): Likewise. (ppc64_elf_tls_optimize): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_size_stubs): Likewise. (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf32-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object. (is_x86_64_elf): New macro. Checks a BFD to make sure that is an x86_64 ELF bfd. (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd being processed. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. (elf64_x86_64_check_relocs): Use elf_symtab_hdr. (elf64_x86_64_gc_sweep_hook): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object. (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc ELF bfd. (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the bfd being processed. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise.
2008-02-12 12:32:31 +01:00
BFD_ASSERT (object_size >= sizeof (struct elf_obj_tdata));
abfd->tdata.any = bfd_zalloc (abfd, object_size);
if (abfd->tdata.any == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
PR ld/5692 * elf-bfd.h (enum elf_object_id): New enum, used to identify target specific extensions to the elf_obj_tdata structure. (struct elf_obj_tdata): New field 'object_id'. (elf_object_id, elf_program_header_size, elf_symtab_hdr): New macros for accessing fields in the elf_obj_tdata structure. (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object. (bfd_elf_allocate_object): New function. * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object and implement by calling bfd_elf_allocate_object. (bfd_elf_allocate_object): New function: Allocates an elf_obj_tdata structure, possibly with a target specific extension. * elfxx-target.h (bfd_elfNN_mkobject): Use bfd_elf_make_generic_object as the default value. * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata for consistency with other, similar structures. (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM ELF bfd. (elf32_arm_mkobject): Call bfd_elf_allocate_object. (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check the bfd being processed. (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise. (bfd_elf32_arm_set_target_relocs): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_copy_private_bfd_data): Likewise. (bfd_elf32_arm_merge_eabi_attributes): Likewise. (bfd_elf32_arm_merge_private_bfd_data): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_gc_mark_extra_sections): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr. (bfd_elf32_arm_init_maps): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_relocate_section): Likewise. (bfd_elf32_arm_gc_sweep_hook): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object. (is_i386_elf): New macro. Checks a BFD to make sure that is an x86 ELF bfd. (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd being processed. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_check_relocs): Use elf_symtab_hdr. (elf_i386_gc_sweep_hook): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object. (elf_create_pointer_linker_section): Use is_ppc_elf_target to verify that the bfd before accessing target specific fields. (ppc_elf_check_relocs): Likewise. (elf_finish_pointer_linker_section): Likewise. (elf_create_pointer_linker_section): Use elf_symtab_hdr. (ppc_elf_check_relocs): Likewise. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_tls_optimize): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf64-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object. (is_sh_elf): New macro. Checks a BFD to make sure that is an SH ELF bfd. (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the bfd being processed. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_copy_private_data): Likewise. (sh_elf_relax_section): Use elf_symtab_hdr. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_get_relocated_section_contents): Likewise. (sh_elf_gc_sweep_hook): Likewise. (sh_elf_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object. (is_alpha_elf): New macro. Checks a BFD to make sure that is an Alpha ELF bfd. (elf64_alpha_create_got_section): Use is_alpha_elf macro to check the bfd being processed. (elf64_alpha_create_dynamic_section): Likewise. (elf64_alpha_check_relocs): Likewise. (elf64_alpha_size_got_sections): Likewise. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_final_link): Likewise. (elf64_alpha_check_relocs): Use elf_symtab_hdr. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section_r): Likewise. (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object. (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd being processed. (opd_entry_value): Likewise. (allocate_dynrelocs): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_check_relocs): Use elf_symtab_hdr. (opd_entry_value): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. (get_sym_h): Likewise. (ppc64_elf_edit_opd): Likewise. (ppc64_elf_tls_optimize): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_size_stubs): Likewise. (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf32-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object. (is_x86_64_elf): New macro. Checks a BFD to make sure that is an x86_64 ELF bfd. (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd being processed. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. (elf64_x86_64_check_relocs): Use elf_symtab_hdr. (elf64_x86_64_gc_sweep_hook): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object. (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc ELF bfd. (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the bfd being processed. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise.
2008-02-12 12:32:31 +01:00
elf_object_id (abfd) = object_id;
elf_program_header_size (abfd) = (bfd_size_type) -1;
return TRUE;
1999-05-03 09:29:11 +02:00
}
PR ld/5692 * elf-bfd.h (enum elf_object_id): New enum, used to identify target specific extensions to the elf_obj_tdata structure. (struct elf_obj_tdata): New field 'object_id'. (elf_object_id, elf_program_header_size, elf_symtab_hdr): New macros for accessing fields in the elf_obj_tdata structure. (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object. (bfd_elf_allocate_object): New function. * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object and implement by calling bfd_elf_allocate_object. (bfd_elf_allocate_object): New function: Allocates an elf_obj_tdata structure, possibly with a target specific extension. * elfxx-target.h (bfd_elfNN_mkobject): Use bfd_elf_make_generic_object as the default value. * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata for consistency with other, similar structures. (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM ELF bfd. (elf32_arm_mkobject): Call bfd_elf_allocate_object. (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check the bfd being processed. (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise. (bfd_elf32_arm_set_target_relocs): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_copy_private_bfd_data): Likewise. (bfd_elf32_arm_merge_eabi_attributes): Likewise. (bfd_elf32_arm_merge_private_bfd_data): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_gc_mark_extra_sections): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr. (bfd_elf32_arm_init_maps): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_relocate_section): Likewise. (bfd_elf32_arm_gc_sweep_hook): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object. (is_i386_elf): New macro. Checks a BFD to make sure that is an x86 ELF bfd. (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd being processed. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_check_relocs): Use elf_symtab_hdr. (elf_i386_gc_sweep_hook): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object. (elf_create_pointer_linker_section): Use is_ppc_elf_target to verify that the bfd before accessing target specific fields. (ppc_elf_check_relocs): Likewise. (elf_finish_pointer_linker_section): Likewise. (elf_create_pointer_linker_section): Use elf_symtab_hdr. (ppc_elf_check_relocs): Likewise. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_tls_optimize): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf64-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object. (is_sh_elf): New macro. Checks a BFD to make sure that is an SH ELF bfd. (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the bfd being processed. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_copy_private_data): Likewise. (sh_elf_relax_section): Use elf_symtab_hdr. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_get_relocated_section_contents): Likewise. (sh_elf_gc_sweep_hook): Likewise. (sh_elf_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object. (is_alpha_elf): New macro. Checks a BFD to make sure that is an Alpha ELF bfd. (elf64_alpha_create_got_section): Use is_alpha_elf macro to check the bfd being processed. (elf64_alpha_create_dynamic_section): Likewise. (elf64_alpha_check_relocs): Likewise. (elf64_alpha_size_got_sections): Likewise. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_final_link): Likewise. (elf64_alpha_check_relocs): Use elf_symtab_hdr. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section_r): Likewise. (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object. (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd being processed. (opd_entry_value): Likewise. (allocate_dynrelocs): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_check_relocs): Use elf_symtab_hdr. (opd_entry_value): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. (get_sym_h): Likewise. (ppc64_elf_edit_opd): Likewise. (ppc64_elf_tls_optimize): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_size_stubs): Likewise. (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf32-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object. (is_x86_64_elf): New macro. Checks a BFD to make sure that is an x86_64 ELF bfd. (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd being processed. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. (elf64_x86_64_check_relocs): Use elf_symtab_hdr. (elf64_x86_64_gc_sweep_hook): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object. (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc ELF bfd. (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the bfd being processed. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise.
2008-02-12 12:32:31 +01:00
bfd_boolean
Add target_id to elf_backend_data. 2010-08-25 H.J. Lu <hongjiu.lu@intel.com> PR ld/11944 * elf-bfd.h (elf_backend_data): Add target_id. (bfd_elf_make_generic_object): Renamed to ... (bfd_elf_make_object): This. * elf.c (bfd_elf_make_generic_object): Removed. (bfd_elf_make_object): New. (bfd_elf_mkcorefile): Really treat it as an object file. * elf-m10300.c (ELF_TARGET_ID): New. * elf32-arm.c (ELF_TARGET_ID): Likewise. * elf32-bfin.c (ELF_TARGET_ID): Likewise. * elf32-cris.c (ELF_TARGET_ID): Likewise. * elf32-frv.c (ELF_TARGET_ID): Likewise. * elf32-i386.c (ELF_TARGET_ID): Likewise. * elf32-lm32.c (ELF_TARGET_ID): Likewise. * elf32-m32r.c (ELF_TARGET_ID): Likewise. * elf32-m68hc11.c (ELF_TARGET_ID): Likewise. * elf32-m68hc12.c (ELF_TARGET_ID): Likewise. * elf32-m68k.c (ELF_TARGET_ID): Likewise. * elf32-microblaze.c (ELF_TARGET_ID): Likewise. * elf32-ppc.c (ELF_TARGET_ID): Likewise. * elf32-s390.c (ELF_TARGET_ID): Likewise. * elf32-sh.c (ELF_TARGET_ID): Likewise. * elf32-sparc.c (ELF_TARGET_ID): Likewise. * elf32-spu.c (ELF_TARGET_ID): Likewise. * elf32-tic6x.c (ELF_TARGET_ID): Likewise. * elf32-xtensa.c (ELF_TARGET_ID): Likewise. * elf64-alpha.c (ELF_TARGET_ID): Likewise. * elf64-hppa.c (ELF_TARGET_ID): Likewise. * elf64-ppc.c (ELF_TARGET_ID): Likewise. * elf64-s390.c (ELF_TARGET_ID): Likewise. * elf64-x86-64.c (ELF_TARGET_ID): Likewise. * elfxx-ia64.c (ELF_TARGET_ID): Likewise. * elf32-hppa.c (elf32_hppa_mkobject): Removed. (bfd_elf32_mkobject): Likewise. (ELF_TARGET_ID): New. * elf32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elf64-mips.c (ELF_TARGET_ID): New. (bfd_elf64_mkobject): Removed. * elfn32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elfxx-mips.c (_bfd_mips_elf_mkobject): Removed. * elfxx-mips.h (_bfd_mips_elf_mkobject): Likewise. * elfxx-target.h (bfd_elfNN_mkobject): Default to bfd_elf_make_object. (ELF_TARGET_ID): New. Default to GENERIC_ELF_DATA. (elfNN_bed): Initialize target_id.
2010-08-25 16:53:45 +02:00
bfd_elf_make_object (bfd *abfd)
PR ld/5692 * elf-bfd.h (enum elf_object_id): New enum, used to identify target specific extensions to the elf_obj_tdata structure. (struct elf_obj_tdata): New field 'object_id'. (elf_object_id, elf_program_header_size, elf_symtab_hdr): New macros for accessing fields in the elf_obj_tdata structure. (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object. (bfd_elf_allocate_object): New function. * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object and implement by calling bfd_elf_allocate_object. (bfd_elf_allocate_object): New function: Allocates an elf_obj_tdata structure, possibly with a target specific extension. * elfxx-target.h (bfd_elfNN_mkobject): Use bfd_elf_make_generic_object as the default value. * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata for consistency with other, similar structures. (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM ELF bfd. (elf32_arm_mkobject): Call bfd_elf_allocate_object. (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check the bfd being processed. (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise. (bfd_elf32_arm_set_target_relocs): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_copy_private_bfd_data): Likewise. (bfd_elf32_arm_merge_eabi_attributes): Likewise. (bfd_elf32_arm_merge_private_bfd_data): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_gc_mark_extra_sections): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr. (bfd_elf32_arm_init_maps): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_relocate_section): Likewise. (bfd_elf32_arm_gc_sweep_hook): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object. (is_i386_elf): New macro. Checks a BFD to make sure that is an x86 ELF bfd. (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd being processed. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_check_relocs): Use elf_symtab_hdr. (elf_i386_gc_sweep_hook): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object. (elf_create_pointer_linker_section): Use is_ppc_elf_target to verify that the bfd before accessing target specific fields. (ppc_elf_check_relocs): Likewise. (elf_finish_pointer_linker_section): Likewise. (elf_create_pointer_linker_section): Use elf_symtab_hdr. (ppc_elf_check_relocs): Likewise. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_tls_optimize): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf64-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object. (is_sh_elf): New macro. Checks a BFD to make sure that is an SH ELF bfd. (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the bfd being processed. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_copy_private_data): Likewise. (sh_elf_relax_section): Use elf_symtab_hdr. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_get_relocated_section_contents): Likewise. (sh_elf_gc_sweep_hook): Likewise. (sh_elf_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object. (is_alpha_elf): New macro. Checks a BFD to make sure that is an Alpha ELF bfd. (elf64_alpha_create_got_section): Use is_alpha_elf macro to check the bfd being processed. (elf64_alpha_create_dynamic_section): Likewise. (elf64_alpha_check_relocs): Likewise. (elf64_alpha_size_got_sections): Likewise. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_final_link): Likewise. (elf64_alpha_check_relocs): Use elf_symtab_hdr. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section_r): Likewise. (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object. (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd being processed. (opd_entry_value): Likewise. (allocate_dynrelocs): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_check_relocs): Use elf_symtab_hdr. (opd_entry_value): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. (get_sym_h): Likewise. (ppc64_elf_edit_opd): Likewise. (ppc64_elf_tls_optimize): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_size_stubs): Likewise. (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf32-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object. (is_x86_64_elf): New macro. Checks a BFD to make sure that is an x86_64 ELF bfd. (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd being processed. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. (elf64_x86_64_check_relocs): Use elf_symtab_hdr. (elf64_x86_64_gc_sweep_hook): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object. (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc ELF bfd. (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the bfd being processed. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise.
2008-02-12 12:32:31 +01:00
{
Add target_id to elf_backend_data. 2010-08-25 H.J. Lu <hongjiu.lu@intel.com> PR ld/11944 * elf-bfd.h (elf_backend_data): Add target_id. (bfd_elf_make_generic_object): Renamed to ... (bfd_elf_make_object): This. * elf.c (bfd_elf_make_generic_object): Removed. (bfd_elf_make_object): New. (bfd_elf_mkcorefile): Really treat it as an object file. * elf-m10300.c (ELF_TARGET_ID): New. * elf32-arm.c (ELF_TARGET_ID): Likewise. * elf32-bfin.c (ELF_TARGET_ID): Likewise. * elf32-cris.c (ELF_TARGET_ID): Likewise. * elf32-frv.c (ELF_TARGET_ID): Likewise. * elf32-i386.c (ELF_TARGET_ID): Likewise. * elf32-lm32.c (ELF_TARGET_ID): Likewise. * elf32-m32r.c (ELF_TARGET_ID): Likewise. * elf32-m68hc11.c (ELF_TARGET_ID): Likewise. * elf32-m68hc12.c (ELF_TARGET_ID): Likewise. * elf32-m68k.c (ELF_TARGET_ID): Likewise. * elf32-microblaze.c (ELF_TARGET_ID): Likewise. * elf32-ppc.c (ELF_TARGET_ID): Likewise. * elf32-s390.c (ELF_TARGET_ID): Likewise. * elf32-sh.c (ELF_TARGET_ID): Likewise. * elf32-sparc.c (ELF_TARGET_ID): Likewise. * elf32-spu.c (ELF_TARGET_ID): Likewise. * elf32-tic6x.c (ELF_TARGET_ID): Likewise. * elf32-xtensa.c (ELF_TARGET_ID): Likewise. * elf64-alpha.c (ELF_TARGET_ID): Likewise. * elf64-hppa.c (ELF_TARGET_ID): Likewise. * elf64-ppc.c (ELF_TARGET_ID): Likewise. * elf64-s390.c (ELF_TARGET_ID): Likewise. * elf64-x86-64.c (ELF_TARGET_ID): Likewise. * elfxx-ia64.c (ELF_TARGET_ID): Likewise. * elf32-hppa.c (elf32_hppa_mkobject): Removed. (bfd_elf32_mkobject): Likewise. (ELF_TARGET_ID): New. * elf32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elf64-mips.c (ELF_TARGET_ID): New. (bfd_elf64_mkobject): Removed. * elfn32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elfxx-mips.c (_bfd_mips_elf_mkobject): Removed. * elfxx-mips.h (_bfd_mips_elf_mkobject): Likewise. * elfxx-target.h (bfd_elfNN_mkobject): Default to bfd_elf_make_object. (ELF_TARGET_ID): New. Default to GENERIC_ELF_DATA. (elfNN_bed): Initialize target_id.
2010-08-25 16:53:45 +02:00
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
PR ld/5692 * elf-bfd.h (enum elf_object_id): New enum, used to identify target specific extensions to the elf_obj_tdata structure. (struct elf_obj_tdata): New field 'object_id'. (elf_object_id, elf_program_header_size, elf_symtab_hdr): New macros for accessing fields in the elf_obj_tdata structure. (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object. (bfd_elf_allocate_object): New function. * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object and implement by calling bfd_elf_allocate_object. (bfd_elf_allocate_object): New function: Allocates an elf_obj_tdata structure, possibly with a target specific extension. * elfxx-target.h (bfd_elfNN_mkobject): Use bfd_elf_make_generic_object as the default value. * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata for consistency with other, similar structures. (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM ELF bfd. (elf32_arm_mkobject): Call bfd_elf_allocate_object. (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check the bfd being processed. (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise. (bfd_elf32_arm_set_target_relocs): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_copy_private_bfd_data): Likewise. (bfd_elf32_arm_merge_eabi_attributes): Likewise. (bfd_elf32_arm_merge_private_bfd_data): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_gc_mark_extra_sections): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr. (bfd_elf32_arm_init_maps): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_relocate_section): Likewise. (bfd_elf32_arm_gc_sweep_hook): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object. (is_i386_elf): New macro. Checks a BFD to make sure that is an x86 ELF bfd. (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd being processed. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_check_relocs): Use elf_symtab_hdr. (elf_i386_gc_sweep_hook): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object. (elf_create_pointer_linker_section): Use is_ppc_elf_target to verify that the bfd before accessing target specific fields. (ppc_elf_check_relocs): Likewise. (elf_finish_pointer_linker_section): Likewise. (elf_create_pointer_linker_section): Use elf_symtab_hdr. (ppc_elf_check_relocs): Likewise. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_tls_optimize): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf64-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object. (is_sh_elf): New macro. Checks a BFD to make sure that is an SH ELF bfd. (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the bfd being processed. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_copy_private_data): Likewise. (sh_elf_relax_section): Use elf_symtab_hdr. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_get_relocated_section_contents): Likewise. (sh_elf_gc_sweep_hook): Likewise. (sh_elf_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object. (is_alpha_elf): New macro. Checks a BFD to make sure that is an Alpha ELF bfd. (elf64_alpha_create_got_section): Use is_alpha_elf macro to check the bfd being processed. (elf64_alpha_create_dynamic_section): Likewise. (elf64_alpha_check_relocs): Likewise. (elf64_alpha_size_got_sections): Likewise. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_final_link): Likewise. (elf64_alpha_check_relocs): Use elf_symtab_hdr. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section_r): Likewise. (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object. (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd being processed. (opd_entry_value): Likewise. (allocate_dynrelocs): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_check_relocs): Use elf_symtab_hdr. (opd_entry_value): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. (get_sym_h): Likewise. (ppc64_elf_edit_opd): Likewise. (ppc64_elf_tls_optimize): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_size_stubs): Likewise. (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf32-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object. (is_x86_64_elf): New macro. Checks a BFD to make sure that is an x86_64 ELF bfd. (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd being processed. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. (elf64_x86_64_check_relocs): Use elf_symtab_hdr. (elf64_x86_64_gc_sweep_hook): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object. (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc ELF bfd. (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the bfd being processed. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise.
2008-02-12 12:32:31 +01:00
return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
Add target_id to elf_backend_data. 2010-08-25 H.J. Lu <hongjiu.lu@intel.com> PR ld/11944 * elf-bfd.h (elf_backend_data): Add target_id. (bfd_elf_make_generic_object): Renamed to ... (bfd_elf_make_object): This. * elf.c (bfd_elf_make_generic_object): Removed. (bfd_elf_make_object): New. (bfd_elf_mkcorefile): Really treat it as an object file. * elf-m10300.c (ELF_TARGET_ID): New. * elf32-arm.c (ELF_TARGET_ID): Likewise. * elf32-bfin.c (ELF_TARGET_ID): Likewise. * elf32-cris.c (ELF_TARGET_ID): Likewise. * elf32-frv.c (ELF_TARGET_ID): Likewise. * elf32-i386.c (ELF_TARGET_ID): Likewise. * elf32-lm32.c (ELF_TARGET_ID): Likewise. * elf32-m32r.c (ELF_TARGET_ID): Likewise. * elf32-m68hc11.c (ELF_TARGET_ID): Likewise. * elf32-m68hc12.c (ELF_TARGET_ID): Likewise. * elf32-m68k.c (ELF_TARGET_ID): Likewise. * elf32-microblaze.c (ELF_TARGET_ID): Likewise. * elf32-ppc.c (ELF_TARGET_ID): Likewise. * elf32-s390.c (ELF_TARGET_ID): Likewise. * elf32-sh.c (ELF_TARGET_ID): Likewise. * elf32-sparc.c (ELF_TARGET_ID): Likewise. * elf32-spu.c (ELF_TARGET_ID): Likewise. * elf32-tic6x.c (ELF_TARGET_ID): Likewise. * elf32-xtensa.c (ELF_TARGET_ID): Likewise. * elf64-alpha.c (ELF_TARGET_ID): Likewise. * elf64-hppa.c (ELF_TARGET_ID): Likewise. * elf64-ppc.c (ELF_TARGET_ID): Likewise. * elf64-s390.c (ELF_TARGET_ID): Likewise. * elf64-x86-64.c (ELF_TARGET_ID): Likewise. * elfxx-ia64.c (ELF_TARGET_ID): Likewise. * elf32-hppa.c (elf32_hppa_mkobject): Removed. (bfd_elf32_mkobject): Likewise. (ELF_TARGET_ID): New. * elf32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elf64-mips.c (ELF_TARGET_ID): New. (bfd_elf64_mkobject): Removed. * elfn32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elfxx-mips.c (_bfd_mips_elf_mkobject): Removed. * elfxx-mips.h (_bfd_mips_elf_mkobject): Likewise. * elfxx-target.h (bfd_elfNN_mkobject): Default to bfd_elf_make_object. (ELF_TARGET_ID): New. Default to GENERIC_ELF_DATA. (elfNN_bed): Initialize target_id.
2010-08-25 16:53:45 +02:00
bed->target_id);
PR ld/5692 * elf-bfd.h (enum elf_object_id): New enum, used to identify target specific extensions to the elf_obj_tdata structure. (struct elf_obj_tdata): New field 'object_id'. (elf_object_id, elf_program_header_size, elf_symtab_hdr): New macros for accessing fields in the elf_obj_tdata structure. (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object. (bfd_elf_allocate_object): New function. * elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object and implement by calling bfd_elf_allocate_object. (bfd_elf_allocate_object): New function: Allocates an elf_obj_tdata structure, possibly with a target specific extension. * elfxx-target.h (bfd_elfNN_mkobject): Use bfd_elf_make_generic_object as the default value. * elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata for consistency with other, similar structures. (is_arm_elf): New macro. Checks a BFD to make sure that is an ARM ELF bfd. (elf32_arm_mkobject): Call bfd_elf_allocate_object. (bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check the bfd being processed. (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise. (bfd_elf32_arm_set_target_relocs): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_copy_private_bfd_data): Likewise. (bfd_elf32_arm_merge_eabi_attributes): Likewise. (bfd_elf32_arm_merge_private_bfd_data): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_gc_mark_extra_sections): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. (bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr. (bfd_elf32_arm_init_maps): Likewise. (bfd_elf32_arm_final_link_relocate): Likewise. (bfd_elf32_arm_relocate_section): Likewise. (bfd_elf32_arm_gc_sweep_hook): Likewise. (bfd_elf32_arm_check_relocs): Likewise. (bfd_elf32_arm_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object. (is_i386_elf): New macro. Checks a BFD to make sure that is an x86 ELF bfd. (elf_i386_check_relocs): Use is_i386_elf macro to check the bfd being processed. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_check_relocs): Use elf_symtab_hdr. (elf_i386_gc_sweep_hook): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object. (elf_create_pointer_linker_section): Use is_ppc_elf_target to verify that the bfd before accessing target specific fields. (ppc_elf_check_relocs): Likewise. (elf_finish_pointer_linker_section): Likewise. (elf_create_pointer_linker_section): Use elf_symtab_hdr. (ppc_elf_check_relocs): Likewise. (ppc_elf_gc_sweep_hook): Likewise. (ppc_elf_tls_optimize): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. * elf32-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf64-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object. (is_sh_elf): New macro. Checks a BFD to make sure that is an SH ELF bfd. (sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the bfd being processed. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_copy_private_data): Likewise. (sh_elf_relax_section): Use elf_symtab_hdr. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_get_relocated_section_contents): Likewise. (sh_elf_gc_sweep_hook): Likewise. (sh_elf_check_relocs): Likewise. * elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object. (is_alpha_elf): New macro. Checks a BFD to make sure that is an Alpha ELF bfd. (elf64_alpha_create_got_section): Use is_alpha_elf macro to check the bfd being processed. (elf64_alpha_create_dynamic_section): Likewise. (elf64_alpha_check_relocs): Likewise. (elf64_alpha_size_got_sections): Likewise. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_final_link): Likewise. (elf64_alpha_check_relocs): Use elf_symtab_hdr. (elf64_alpha_relax_section): Likewise. (elf64_alpha_relocate_section_r): Likewise. (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object. (ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd being processed. (opd_entry_value): Likewise. (allocate_dynrelocs): Likewise. (ppc64_elf_relocate_section): Likewise. (ppc64_elf_check_relocs): Use elf_symtab_hdr. (opd_entry_value): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. (get_sym_h): Likewise. (ppc64_elf_edit_opd): Likewise. (ppc64_elf_tls_optimize): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. (toc_adjusting_stub_needed): Likewise. (ppc64_elf_size_stubs): Likewise. (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (struct elf_s390_obj_tdata): Add a comment reminding programmers to keep this structure in sync with the one defined in elf32-s390.c. (elf_s390_mkobject): Call bfd_elf_allocate_object. (is_s390_elf): New macro. Checks a BFD to make sure that is an s390 ELF bfd. (elf_s390_check_relocs): Use is_s390_elf macro to check the bfd being processed. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. (elf_s390_check_relocs): Use elf_symtab_hdr. (elf_s390_gc_sweep_hook): Likewise. (elf_s390_size_dynamic_sections): Likewise. (elf_s390_relocate_section): Likewise. * elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object. (is_x86_64_elf): New macro. Checks a BFD to make sure that is an x86_64 ELF bfd. (elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd being processed. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. (elf64_x86_64_check_relocs): Use elf_symtab_hdr. (elf64_x86_64_gc_sweep_hook): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object. (is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc ELF bfd. (_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the bfd being processed. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr. (_bfd_sparc_elf_gc_sweep_hook): Likewise. (_bfd_sparc_elf_size_dynamic_sections): Likewise. (_bfd_sparc_elf_relocate_section): Likewise.
2008-02-12 12:32:31 +01:00
}
bfd_boolean
bfd_elf_mkcorefile (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
/* I think this can be done just like an object file. */
Add target_id to elf_backend_data. 2010-08-25 H.J. Lu <hongjiu.lu@intel.com> PR ld/11944 * elf-bfd.h (elf_backend_data): Add target_id. (bfd_elf_make_generic_object): Renamed to ... (bfd_elf_make_object): This. * elf.c (bfd_elf_make_generic_object): Removed. (bfd_elf_make_object): New. (bfd_elf_mkcorefile): Really treat it as an object file. * elf-m10300.c (ELF_TARGET_ID): New. * elf32-arm.c (ELF_TARGET_ID): Likewise. * elf32-bfin.c (ELF_TARGET_ID): Likewise. * elf32-cris.c (ELF_TARGET_ID): Likewise. * elf32-frv.c (ELF_TARGET_ID): Likewise. * elf32-i386.c (ELF_TARGET_ID): Likewise. * elf32-lm32.c (ELF_TARGET_ID): Likewise. * elf32-m32r.c (ELF_TARGET_ID): Likewise. * elf32-m68hc11.c (ELF_TARGET_ID): Likewise. * elf32-m68hc12.c (ELF_TARGET_ID): Likewise. * elf32-m68k.c (ELF_TARGET_ID): Likewise. * elf32-microblaze.c (ELF_TARGET_ID): Likewise. * elf32-ppc.c (ELF_TARGET_ID): Likewise. * elf32-s390.c (ELF_TARGET_ID): Likewise. * elf32-sh.c (ELF_TARGET_ID): Likewise. * elf32-sparc.c (ELF_TARGET_ID): Likewise. * elf32-spu.c (ELF_TARGET_ID): Likewise. * elf32-tic6x.c (ELF_TARGET_ID): Likewise. * elf32-xtensa.c (ELF_TARGET_ID): Likewise. * elf64-alpha.c (ELF_TARGET_ID): Likewise. * elf64-hppa.c (ELF_TARGET_ID): Likewise. * elf64-ppc.c (ELF_TARGET_ID): Likewise. * elf64-s390.c (ELF_TARGET_ID): Likewise. * elf64-x86-64.c (ELF_TARGET_ID): Likewise. * elfxx-ia64.c (ELF_TARGET_ID): Likewise. * elf32-hppa.c (elf32_hppa_mkobject): Removed. (bfd_elf32_mkobject): Likewise. (ELF_TARGET_ID): New. * elf32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elf64-mips.c (ELF_TARGET_ID): New. (bfd_elf64_mkobject): Removed. * elfn32-mips.c (ELF_TARGET_ID): New. (bfd_elf32_mkobject): Removed. * elfxx-mips.c (_bfd_mips_elf_mkobject): Removed. * elfxx-mips.h (_bfd_mips_elf_mkobject): Likewise. * elfxx-target.h (bfd_elfNN_mkobject): Default to bfd_elf_make_object. (ELF_TARGET_ID): New. Default to GENERIC_ELF_DATA. (elfNN_bed): Initialize target_id.
2010-08-25 16:53:45 +02:00
return abfd->xvec->_bfd_set_format[(int) bfd_object] (abfd);
1999-05-03 09:29:11 +02:00
}
static char *
bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Shdr **i_shdrp;
include/ * xtensa-isa-internal.h (xtensa_length_decode_fn): Warning fix. * xtensa-isa.h (xtensa_insnbuf_to_chars): Likewise. (xtensa_insnbuf_from_chars, xtensa_isa_length_from_chars): Likewise. include/coff/ * xcoff.h (struct xcoff_loader_info): Warning fix. bfd/ * bfd-in.h (bfd_elf_bfd_from_remote_memory): Warning fix. * coff-m68k.c (bfd_m68k_coff_create_embedded_relocs): Likewise. * coff-rs6000.c (xcoff_write_armap_big): Warning fixes. Remove useless assignments. (xcoff_write_archive_contents_big): Likewise. (_bfd_xcoff_put_ldsymbol_name): Likewise. * coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise. * coffgen.c (coff_write_symbols): Make "written" a bfd_vma. * cofflink.c (process_embedded_commands): Warning fixes. * cpu-arm.c: Delete unnecessary prototypes. Convert to C90. Warning fixes. * dwarf2.c: Warning fixes. * elf-bfd.h: Likewise. * elf-eh-frame.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-sh-symbian.c: Likewise. * elf32-sh.c: Delete unnecessary prototypes. Warning fixes. * elf64-sh64.c: Likewise. * peicode.h: Likewise. * elf64-mmix.c: Warning fixes. * elfcode.h: Likewise. * elfxx-mips.c: Likewise. * libbfd-in.h: Likewise. * libbfd.c: Likewise. * mach-o.c: Likewise. * merge.c: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * pef.c: Likewise. * srec.c: Likewise. * vms-hdr.c: Likewise. * vms-tir.c: Likewise. * xtensa-isa.c: Likewise. * xtensa-modules.c: Likewise. * xsym.c: Likewise. (pstrcmp): Use correct choice of string lengths. Fix return value. (bfd_sym_module_name): Correct string length. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2005-02-20 15:59:07 +01:00
bfd_byte *shstrtab = NULL;
file_ptr offset;
bfd_size_type shstrtabsize;
1999-05-03 09:29:11 +02:00
i_shdrp = elf_elfsections (abfd);
if (i_shdrp == 0
|| shindex >= elf_numsections (abfd)
|| i_shdrp[shindex] == 0)
include/ * xtensa-isa-internal.h (xtensa_length_decode_fn): Warning fix. * xtensa-isa.h (xtensa_insnbuf_to_chars): Likewise. (xtensa_insnbuf_from_chars, xtensa_isa_length_from_chars): Likewise. include/coff/ * xcoff.h (struct xcoff_loader_info): Warning fix. bfd/ * bfd-in.h (bfd_elf_bfd_from_remote_memory): Warning fix. * coff-m68k.c (bfd_m68k_coff_create_embedded_relocs): Likewise. * coff-rs6000.c (xcoff_write_armap_big): Warning fixes. Remove useless assignments. (xcoff_write_archive_contents_big): Likewise. (_bfd_xcoff_put_ldsymbol_name): Likewise. * coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise. * coffgen.c (coff_write_symbols): Make "written" a bfd_vma. * cofflink.c (process_embedded_commands): Warning fixes. * cpu-arm.c: Delete unnecessary prototypes. Convert to C90. Warning fixes. * dwarf2.c: Warning fixes. * elf-bfd.h: Likewise. * elf-eh-frame.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-sh-symbian.c: Likewise. * elf32-sh.c: Delete unnecessary prototypes. Warning fixes. * elf64-sh64.c: Likewise. * peicode.h: Likewise. * elf64-mmix.c: Warning fixes. * elfcode.h: Likewise. * elfxx-mips.c: Likewise. * libbfd-in.h: Likewise. * libbfd.c: Likewise. * mach-o.c: Likewise. * merge.c: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * pef.c: Likewise. * srec.c: Likewise. * vms-hdr.c: Likewise. * vms-tir.c: Likewise. * xtensa-isa.c: Likewise. * xtensa-modules.c: Likewise. * xsym.c: Likewise. (pstrcmp): Use correct choice of string lengths. Fix return value. (bfd_sym_module_name): Correct string length. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2005-02-20 15:59:07 +01:00
return NULL;
1999-05-03 09:29:11 +02:00
include/ * xtensa-isa-internal.h (xtensa_length_decode_fn): Warning fix. * xtensa-isa.h (xtensa_insnbuf_to_chars): Likewise. (xtensa_insnbuf_from_chars, xtensa_isa_length_from_chars): Likewise. include/coff/ * xcoff.h (struct xcoff_loader_info): Warning fix. bfd/ * bfd-in.h (bfd_elf_bfd_from_remote_memory): Warning fix. * coff-m68k.c (bfd_m68k_coff_create_embedded_relocs): Likewise. * coff-rs6000.c (xcoff_write_armap_big): Warning fixes. Remove useless assignments. (xcoff_write_archive_contents_big): Likewise. (_bfd_xcoff_put_ldsymbol_name): Likewise. * coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise. * coffgen.c (coff_write_symbols): Make "written" a bfd_vma. * cofflink.c (process_embedded_commands): Warning fixes. * cpu-arm.c: Delete unnecessary prototypes. Convert to C90. Warning fixes. * dwarf2.c: Warning fixes. * elf-bfd.h: Likewise. * elf-eh-frame.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-sh-symbian.c: Likewise. * elf32-sh.c: Delete unnecessary prototypes. Warning fixes. * elf64-sh64.c: Likewise. * peicode.h: Likewise. * elf64-mmix.c: Warning fixes. * elfcode.h: Likewise. * elfxx-mips.c: Likewise. * libbfd-in.h: Likewise. * libbfd.c: Likewise. * mach-o.c: Likewise. * merge.c: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * pef.c: Likewise. * srec.c: Likewise. * vms-hdr.c: Likewise. * vms-tir.c: Likewise. * xtensa-isa.c: Likewise. * xtensa-modules.c: Likewise. * xsym.c: Likewise. (pstrcmp): Use correct choice of string lengths. Fix return value. (bfd_sym_module_name): Correct string length. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2005-02-20 15:59:07 +01:00
shstrtab = i_shdrp[shindex]->contents;
1999-05-03 09:29:11 +02:00
if (shstrtab == NULL)
{
/* No cached one, attempt to read, and cache what we read. */
1999-05-03 09:29:11 +02:00
offset = i_shdrp[shindex]->sh_offset;
shstrtabsize = i_shdrp[shindex]->sh_size;
/* Allocate and clear an extra byte at the end, to prevent crashes
in case the string table is not terminated. */
if (shstrtabsize + 1 <= 1
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
|| (shstrtab = (bfd_byte *) bfd_alloc (abfd, shstrtabsize + 1)) == NULL
|| bfd_seek (abfd, offset, SEEK_SET) != 0)
shstrtab = NULL;
else if (bfd_bread (shstrtab, shstrtabsize, abfd) != shstrtabsize)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_file_truncated);
shstrtab = NULL;
/* Once we've failed to read it, make sure we don't keep
trying. Otherwise, we'll keep allocating space for
the string table over and over. */
i_shdrp[shindex]->sh_size = 0;
}
else
shstrtab[shstrtabsize] = '\0';
i_shdrp[shindex]->contents = shstrtab;
1999-05-03 09:29:11 +02:00
}
include/ * xtensa-isa-internal.h (xtensa_length_decode_fn): Warning fix. * xtensa-isa.h (xtensa_insnbuf_to_chars): Likewise. (xtensa_insnbuf_from_chars, xtensa_isa_length_from_chars): Likewise. include/coff/ * xcoff.h (struct xcoff_loader_info): Warning fix. bfd/ * bfd-in.h (bfd_elf_bfd_from_remote_memory): Warning fix. * coff-m68k.c (bfd_m68k_coff_create_embedded_relocs): Likewise. * coff-rs6000.c (xcoff_write_armap_big): Warning fixes. Remove useless assignments. (xcoff_write_archive_contents_big): Likewise. (_bfd_xcoff_put_ldsymbol_name): Likewise. * coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise. * coffgen.c (coff_write_symbols): Make "written" a bfd_vma. * cofflink.c (process_embedded_commands): Warning fixes. * cpu-arm.c: Delete unnecessary prototypes. Convert to C90. Warning fixes. * dwarf2.c: Warning fixes. * elf-bfd.h: Likewise. * elf-eh-frame.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-sh-symbian.c: Likewise. * elf32-sh.c: Delete unnecessary prototypes. Warning fixes. * elf64-sh64.c: Likewise. * peicode.h: Likewise. * elf64-mmix.c: Warning fixes. * elfcode.h: Likewise. * elfxx-mips.c: Likewise. * libbfd-in.h: Likewise. * libbfd.c: Likewise. * mach-o.c: Likewise. * merge.c: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * pef.c: Likewise. * srec.c: Likewise. * vms-hdr.c: Likewise. * vms-tir.c: Likewise. * xtensa-isa.c: Likewise. * xtensa-modules.c: Likewise. * xsym.c: Likewise. (pstrcmp): Use correct choice of string lengths. Fix return value. (bfd_sym_module_name): Correct string length. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2005-02-20 15:59:07 +01:00
return (char *) shstrtab;
1999-05-03 09:29:11 +02:00
}
char *
bfd_elf_string_from_elf_section (bfd *abfd,
unsigned int shindex,
unsigned int strindex)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Shdr *hdr;
if (strindex == 0)
return "";
if (elf_elfsections (abfd) == NULL || shindex >= elf_numsections (abfd))
return NULL;
1999-05-03 09:29:11 +02:00
hdr = elf_elfsections (abfd)[shindex];
if (hdr->contents == NULL
&& bfd_elf_get_str_section (abfd, shindex) == NULL)
return NULL;
if (strindex >= hdr->sh_size)
{
unsigned int shstrndx = elf_elfheader(abfd)->e_shstrndx;
1999-05-03 09:29:11 +02:00
(*_bfd_error_handler)
bfd/ * bfd.c (_bfd_default_error_handler): Handle %A and %B. (bfd_archive_filename, bfd_get_section_ident): Delete. * ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call bfd_archive_filename. * elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler to warn about symbols in discarded sections. Use _bfd_error_handler. * aout-adobe.c (aout_adobe_callback): See below. * aout-cris.c (swap_ext_reloc_in): .. * coff-arm.c (find_thumb_glue, find_arm_glue, coff_arm_relocate_section, bfd_arm_process_before_allocation, coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags, coff_arm_copy_private_bfd_data): .. * coff-i860.c (i860_reloc_processing): .. * coff-mcore.c (mcore_coff_unsupported_reloc, coff_mcore_relocate_section): .. * coff-ppc.c (coff_ppc_relocate_section): .. * coff-rs6000.c (xcoff_create_csect_from_smclas * coff-sh.c (sh_relax_section, sh_relax_delete_bytes, sh_swap_insns, sh_relocate_section): .. * coff-tic54x.c (tic54x_reloc_processing): .. * coff-tic80.c (coff_tic80_relocate_section): .. * coff64-rs6000.c (xcoff64_create_csect_from_smclas): .. * coffcode.h (styp_to_sec_flags, coff_slurp_line_table, coff_slurp_symbol_table, coff_classify_symbol, coff_slurp_reloc_table): .. * coffgen.c (_bfd_coff_read_string_table): .. * cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd, _bfd_coff_generic_relocate_section): .. * cpu-arm.c (bfd_arm_merge_machines): .. * cpu-sh.c (sh_merge_bfd_arch): .. * elf-hppa.h (elf_hppa_relocate_section): .. * elf.c (bfd_elf_string_from_elf_section, setup_group, _bfd_elf_setup_group_pointers, bfd_section_from_shdr, assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol, copy_private_bfd_data, _bfd_elf_validate_reloc): .. * elf32-arm.h (find_thumb_glue, find_arm_glue, bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub, elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate, elf32_arm_relocate_section, elf32_arm_set_private_flags, elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): .. * elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs, cris_elf_merge_private_bfd_data * elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): .. * elf32-gen.c (elf32_generic_link_add_symbols): .. * elf32-hppa.c (hppa_add_stub, hppa_build_one_stub, elf32_hppa_check_relocs, get_local_syms, final_link_relocate, elf32_hppa_relocate_section): .. * elf32-i370.c (i370_elf_merge_private_bfd_data, i370_elf_check_relocs, i370_elf_relocate_section): .. * elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs, elf_i386_relocate_section): .. * elf32-m32r.c (m32r_elf_relocate_section, m32r_elf_merge_private_bfd_data): .. * elf32-m68hc1x.c (m68hc12_add_stub, _bfd_m68hc11_elf_merge_private_bfd_data): .. * elf32-m68k.c (elf_m68k_relocate_section): .. * elf32-mcore.c (mcore_elf_unsupported_reloc, mcore_elf_relocate_section): .. * elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc, ppc_elf_check_relocs, ppc_elf_relocate_section, ppc_elf_begin_write_processing): .. * elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn, elf_s390_relocate_section): .. * elf32-sh-symbian.c (sh_symbian_import_as, sh_symbian_process_embedded_commands, sh_symbian_relocate_section): .. * elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes, sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs, sh_elf_merge_private_data): .. * elf32-sparc.c (elf32_sparc_check_relocs, elf32_sparc_relocate_section, elf32_sparc_merge_private_bfd_data): .. * elf32-v850.c (v850_elf_check_relocs, v850_elf_merge_private_bfd_data): .. * elf32-xtensa.c (elf_xtensa_check_relocs, elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): .. * elf64-alpha.c (elf64_alpha_relax_with_lituse, elf64_alpha_relax_got_load, elf64_alpha_size_got_sections, elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): .. * elf64-gen.c (elf64_generic_link_add_symbols): .. * elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub, ppc64_elf_check_relocs, ppc64_elf_edit_opd, ppc64_elf_relocate_section): .. * elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn, elf_s390_relocate_section): .. * elf64-sh64.c (sh_elf64_relocate_section): .. * elf64-sparc.c (sparc64_elf_check_relocs, sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section, sparc64_elf_merge_private_bfd_data): .. * elf64-x86-64.c (elf64_x86_64_check_relocs, elf64_x86_64_relocate_section): .. * elflink.c (_bfd_elf_add_default_symbol, _bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section, _bfd_elf_link_output_relocs, elf_link_add_object_symbols, bfd_elf_size_dynamic_sections, elf_link_output_extsym, elf_get_linked_section_vma, elf_fixup_link_order, bfd_elf_final_link, bfd_elf_gc_record_vtinherit, bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): .. * elfxx-ia64.c (elfNN_ia64_relax_section, elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): .. * elfxx-mips.c (mips_elf_perform_relocation, _bfd_mips_elf_check_relocs, _bfd_mips_elf_merge_private_bfd_data): .. * ieee.c (ieee_slurp_external_symbols): .. * ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): .. * libbfd.c (_bfd_generic_verify_endian_match): .. * linker.c (_bfd_generic_link_add_one_symbol, _bfd_generic_section_already_linked): .. * pdp11.c (translate_to_native_sym_flags): .. * pe-mips.c (coff_pe_mips_relocate_section): .. * peicode.h (pe_ILF_build_a_bfd): .. * srec.c (srec_bad_byte): .. * stabs.c (_bfd_link_section_stabs): .. * xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): .. Replace all uses of bfd_archive_filename and bfd_get_section_ident with corresponding %B and %A in _bfd_error_handler format string. Replace occurrences of "fprintf (stderr," with _bfd_error_handler calls to use %A and %B. Fix "against symbol .. from section" and similar error messages. Combine multiple _bfd_error_handler calls where they were separated due to bfd_archive_filename deficiencies. * bfd-in2.h: Regenerate. include/ * bfdlink.h (struct bfd_link_callbacks): Remove "error_handler". (LD_DEFINITION_IN_DISCARDED_SECTION): Delete. ld/ * ldmain.c (link_callbacks): Remove "error_handler". * ldmisc.c: Include elf-bfd.h. (vfinfo): Sort comment. Handle %A. Use %A instead of bfd_get_section_indent. (error_handler): Delete. * ldmisc.h (error_handler): Delete declaration.
2004-08-13 05:16:01 +02:00
(_("%B: invalid string offset %u >= %lu for section `%s'"),
abfd, strindex, (unsigned long) hdr->sh_size,
(shindex == shstrndx && strindex == hdr->sh_name
1999-05-03 09:29:11 +02:00
? ".shstrtab"
: bfd_elf_string_from_elf_section (abfd, shstrndx, hdr->sh_name)));
return NULL;
1999-05-03 09:29:11 +02:00
}
return ((char *) hdr->contents) + strindex;
}
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
/* Read and convert symbols to internal format.
SYMCOUNT specifies the number of symbols to read, starting from
symbol SYMOFFSET. If any of INTSYM_BUF, EXTSYM_BUF or EXTSHNDX_BUF
are non-NULL, they are used to store the internal symbols, external
symbols, and symbol section index extensions, respectively.
Returns a pointer to the internal symbol buffer (malloced if necessary)
or NULL if there were no symbols or some kind of problem. */
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
Elf_Internal_Sym *
bfd_elf_get_elf_syms (bfd *ibfd,
Elf_Internal_Shdr *symtab_hdr,
size_t symcount,
size_t symoffset,
Elf_Internal_Sym *intsym_buf,
void *extsym_buf,
Elf_External_Sym_Shndx *extshndx_buf)
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
{
Elf_Internal_Shdr *shndx_hdr;
void *alloc_ext;
const bfd_byte *esym;
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
Elf_External_Sym_Shndx *alloc_extshndx;
Elf_External_Sym_Shndx *shndx;
Elf_Internal_Sym *alloc_intsym;
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
Elf_Internal_Sym *isym;
Elf_Internal_Sym *isymend;
const struct elf_backend_data *bed;
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
size_t extsym_size;
bfd_size_type amt;
file_ptr pos;
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
abort ();
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
if (symcount == 0)
return intsym_buf;
/* Normal syms might have section extension entries. */
shndx_hdr = NULL;
if (symtab_hdr == &elf_tdata (ibfd)->symtab_hdr)
shndx_hdr = &elf_tdata (ibfd)->symtab_shndx_hdr;
/* Read the symbols. */
alloc_ext = NULL;
alloc_extshndx = NULL;
alloc_intsym = NULL;
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
bed = get_elf_backend_data (ibfd);
extsym_size = bed->s->sizeof_sym;
amt = symcount * extsym_size;
pos = symtab_hdr->sh_offset + symoffset * extsym_size;
if (extsym_buf == NULL)
{
alloc_ext = bfd_malloc2 (symcount, extsym_size);
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
extsym_buf = alloc_ext;
}
if (extsym_buf == NULL
|| bfd_seek (ibfd, pos, SEEK_SET) != 0
|| bfd_bread (extsym_buf, amt, ibfd) != amt)
{
intsym_buf = NULL;
goto out;
}
if (shndx_hdr == NULL || shndx_hdr->sh_size == 0)
extshndx_buf = NULL;
else
{
amt = symcount * sizeof (Elf_External_Sym_Shndx);
pos = shndx_hdr->sh_offset + symoffset * sizeof (Elf_External_Sym_Shndx);
if (extshndx_buf == NULL)
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
alloc_extshndx = (Elf_External_Sym_Shndx *)
bfd_malloc2 (symcount, sizeof (Elf_External_Sym_Shndx));
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
extshndx_buf = alloc_extshndx;
}
if (extshndx_buf == NULL
|| bfd_seek (ibfd, pos, SEEK_SET) != 0
|| bfd_bread (extshndx_buf, amt, ibfd) != amt)
{
intsym_buf = NULL;
goto out;
}
}
if (intsym_buf == NULL)
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
alloc_intsym = (Elf_Internal_Sym *)
bfd_malloc2 (symcount, sizeof (Elf_Internal_Sym));
intsym_buf = alloc_intsym;
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
if (intsym_buf == NULL)
goto out;
}
/* Convert the symbols to internal form. */
isymend = intsym_buf + symcount;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
for (esym = (const bfd_byte *) extsym_buf, isym = intsym_buf,
shndx = extshndx_buf;
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
isym < isymend;
esym += extsym_size, isym++, shndx = shndx != NULL ? shndx + 1 : NULL)
if (!(*bed->s->swap_symbol_in) (ibfd, esym, shndx, isym))
{
symoffset += (esym - (bfd_byte *) extsym_buf) / extsym_size;
(*_bfd_error_handler) (_("%B symbol number %lu references "
"nonexistent SHT_SYMTAB_SHNDX section"),
ibfd, (unsigned long) symoffset);
if (alloc_intsym != NULL)
free (alloc_intsym);
intsym_buf = NULL;
goto out;
}
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
out:
if (alloc_ext != NULL)
free (alloc_ext);
if (alloc_extshndx != NULL)
free (alloc_extshndx);
return intsym_buf;
}
/* Look up a symbol name. */
const char *
bfd_elf_sym_name (bfd *abfd,
Elf_Internal_Shdr *symtab_hdr,
Elf_Internal_Sym *isym,
asection *sym_sec)
{
const char *name;
unsigned int iname = isym->st_name;
unsigned int shindex = symtab_hdr->sh_link;
if (iname == 0 && ELF_ST_TYPE (isym->st_info) == STT_SECTION
/* Check for a bogus st_shndx to avoid crashing. */
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
&& isym->st_shndx < elf_numsections (abfd))
{
iname = elf_elfsections (abfd)[isym->st_shndx]->sh_name;
shindex = elf_elfheader (abfd)->e_shstrndx;
}
name = bfd_elf_string_from_elf_section (abfd, shindex, iname);
if (name == NULL)
name = "(null)";
else if (sym_sec && *name == '\0')
name = bfd_section_name (abfd, sym_sec);
return name;
}
/* Elf_Internal_Shdr->contents is an array of these for SHT_GROUP
sections. The first element is the flags, the rest are section
pointers. */
typedef union elf_internal_group {
Elf_Internal_Shdr *shdr;
unsigned int flags;
} Elf_Internal_Group;
/* Return the name of the group signature symbol. Why isn't the
signature just a string? */
static const char *
group_signature (bfd *abfd, Elf_Internal_Shdr *ghdr)
{
Elf_Internal_Shdr *hdr;
unsigned char esym[sizeof (Elf64_External_Sym)];
Elf_External_Sym_Shndx eshndx;
Elf_Internal_Sym isym;
/* First we need to ensure the symbol table is available. Make sure
that it is a symbol table section. */
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
if (ghdr->sh_link >= elf_numsections (abfd))
return NULL;
hdr = elf_elfsections (abfd) [ghdr->sh_link];
if (hdr->sh_type != SHT_SYMTAB
|| ! bfd_section_from_shdr (abfd, ghdr->sh_link))
return NULL;
/* Go read the symbol. */
hdr = &elf_tdata (abfd)->symtab_hdr;
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx, change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
2002-07-07 11:10:41 +02:00
if (bfd_elf_get_elf_syms (abfd, hdr, 1, ghdr->sh_info,
&isym, esym, &eshndx) == NULL)
return NULL;
return bfd_elf_sym_name (abfd, hdr, &isym, NULL);
}
/* Set next_in_group list pointer, and group name for NEWSECT. */
static bfd_boolean
setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
{
unsigned int num_group = elf_tdata (abfd)->num_group;
/* If num_group is zero, read in all SHT_GROUP sections. The count
is set to -1 if there are no SHT_GROUP sections. */
if (num_group == 0)
{
unsigned int i, shnum;
/* First count the number of groups. If we have a SHT_GROUP
section with just a flag word (ie. sh_size is 4), ignore it. */
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
shnum = elf_numsections (abfd);
num_group = 0;
#define IS_VALID_GROUP_SECTION_HEADER(shdr) \
( (shdr)->sh_type == SHT_GROUP \
&& (shdr)->sh_size >= (2 * GRP_ENTRY_SIZE) \
&& (shdr)->sh_entsize == GRP_ENTRY_SIZE \
&& ((shdr)->sh_size % GRP_ENTRY_SIZE) == 0)
for (i = 0; i < shnum; i++)
{
Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
if (IS_VALID_GROUP_SECTION_HEADER (shdr))
num_group += 1;
}
if (num_group == 0)
{
num_group = (unsigned) -1;
elf_tdata (abfd)->num_group = num_group;
}
else
{
/* We keep a list of elf section headers for group sections,
so we can find them quickly. */
bfd_size_type amt;
elf_tdata (abfd)->num_group = num_group;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
elf_tdata (abfd)->group_sect_ptr = (Elf_Internal_Shdr **)
bfd_alloc2 (abfd, num_group, sizeof (Elf_Internal_Shdr *));
if (elf_tdata (abfd)->group_sect_ptr == NULL)
return FALSE;
num_group = 0;
for (i = 0; i < shnum; i++)
{
Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
if (IS_VALID_GROUP_SECTION_HEADER (shdr))
{
unsigned char *src;
Elf_Internal_Group *dest;
/* Add to list of sections. */
elf_tdata (abfd)->group_sect_ptr[num_group] = shdr;
num_group += 1;
/* Read the raw contents. */
BFD_ASSERT (sizeof (*dest) >= 4);
amt = shdr->sh_size * sizeof (*dest) / 4;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
shdr->contents = (unsigned char *)
bfd_alloc2 (abfd, shdr->sh_size, sizeof (*dest) / 4);
/* PR binutils/4110: Handle corrupt group headers. */
if (shdr->contents == NULL)
{
_bfd_error_handler
(_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
memset (shdr->contents, 0, amt);
if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0
|| (bfd_bread (shdr->contents, shdr->sh_size, abfd)
!= shdr->sh_size))
return FALSE;
/* Translate raw contents, a flag word followed by an
array of elf section indices all in target byte order,
to the flag word followed by an array of elf section
pointers. */
src = shdr->contents + shdr->sh_size;
dest = (Elf_Internal_Group *) (shdr->contents + amt);
while (1)
{
unsigned int idx;
src -= 4;
--dest;
idx = H_GET_32 (abfd, src);
if (src == shdr->contents)
{
dest->flags = idx;
if (shdr->bfd_section != NULL && (idx & GRP_COMDAT))
shdr->bfd_section->flags
|= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
break;
}
if (idx >= shnum)
{
((*_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 05:16:01 +02:00
(_("%B: invalid SHT_GROUP entry"), abfd));
idx = 0;
}
dest->shdr = elf_elfsections (abfd)[idx];
}
}
}
}
}
if (num_group != (unsigned) -1)
{
unsigned int i;
for (i = 0; i < num_group; i++)
{
Elf_Internal_Shdr *shdr = elf_tdata (abfd)->group_sect_ptr[i];
Elf_Internal_Group *idx = (Elf_Internal_Group *) shdr->contents;
unsigned int n_elt = shdr->sh_size / 4;
/* Look through this group's sections to see if current
section is a member. */
while (--n_elt != 0)
if ((++idx)->shdr == hdr)
{
asection *s = NULL;
/* We are a member of this group. Go looking through
other members to see if any others are linked via
next_in_group. */
idx = (Elf_Internal_Group *) shdr->contents;
n_elt = shdr->sh_size / 4;
while (--n_elt != 0)
if ((s = (++idx)->shdr->bfd_section) != NULL
&& elf_next_in_group (s) != NULL)
break;
if (n_elt != 0)
{
/* Snarf the group name from other member, and
insert current section in circular list. */
elf_group_name (newsect) = elf_group_name (s);
elf_next_in_group (newsect) = elf_next_in_group (s);
elf_next_in_group (s) = newsect;
}
else
{
const char *gname;
gname = group_signature (abfd, shdr);
if (gname == NULL)
return FALSE;
elf_group_name (newsect) = gname;
/* Start a circular list with one element. */
elf_next_in_group (newsect) = newsect;
}
/* If the group section has been created, point to the
new member. */
if (shdr->bfd_section != NULL)
elf_next_in_group (shdr->bfd_section) = newsect;
i = num_group - 1;
break;
}
}
}
if (elf_group_name (newsect) == NULL)
{
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 05:16:01 +02:00
(*_bfd_error_handler) (_("%B: no group info for section %A"),
abfd, newsect);
}
return TRUE;
}
bfd_boolean
_bfd_elf_setup_sections (bfd *abfd)
{
unsigned int i;
unsigned int num_group = elf_tdata (abfd)->num_group;
bfd_boolean result = TRUE;
asection *s;
/* Process SHF_LINK_ORDER. */
for (s = abfd->sections; s != NULL; s = s->next)
{
Elf_Internal_Shdr *this_hdr = &elf_section_data (s)->this_hdr;
if ((this_hdr->sh_flags & SHF_LINK_ORDER) != 0)
{
unsigned int elfsec = this_hdr->sh_link;
/* FIXME: The old Intel compiler and old strip/objcopy may
not set the sh_link or sh_info fields. Hence we could
get the situation where elfsec is 0. */
if (elfsec == 0)
{
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->link_order_error_handler)
bed->link_order_error_handler
(_("%B: warning: sh_link not set for section `%A'"),
abfd, s);
}
else
{
asection *linksec = NULL;
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
if (elfsec < elf_numsections (abfd))
{
this_hdr = elf_elfsections (abfd)[elfsec];
linksec = this_hdr->bfd_section;
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
}
/* PR 1991, 2008:
Some strip/objcopy may leave an incorrect value in
sh_link. We don't want to proceed. */
if (linksec == NULL)
{
(*_bfd_error_handler)
(_("%B: sh_link [%d] in section `%A' is incorrect"),
s->owner, s, elfsec);
result = FALSE;
}
elf_linked_to_section (s) = linksec;
}
}
}
/* Process section groups. */
if (num_group == (unsigned) -1)
return result;
for (i = 0; i < num_group; i++)
{
Elf_Internal_Shdr *shdr = elf_tdata (abfd)->group_sect_ptr[i];
Elf_Internal_Group *idx = (Elf_Internal_Group *) shdr->contents;
unsigned int n_elt = shdr->sh_size / 4;
while (--n_elt != 0)
if ((++idx)->shdr->bfd_section)
elf_sec_group (idx->shdr->bfd_section) = shdr->bfd_section;
else if (idx->shdr->sh_type == SHT_RELA
|| idx->shdr->sh_type == SHT_REL)
/* We won't include relocation sections in section groups in
output object files. We adjust the group section size here
so that relocatable link will work correctly when
relocation sections are in section group in input object
files. */
shdr->bfd_section->size -= 4;
else
{
/* There are some unknown sections in the group. */
(*_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 05:16:01 +02:00
(_("%B: unknown [%d] section `%s' in group [%s]"),
abfd,
(unsigned int) idx->shdr->sh_type,
bfd_elf_string_from_elf_section (abfd,
(elf_elfheader (abfd)
->e_shstrndx),
idx->shdr->sh_name),
shdr->bfd_section->name);
result = FALSE;
}
}
return result;
}
* section.c (bfd_make_section_anyway): Add all sections to hash tab. * elf-bfd.h (bfd_elf_is_group_section): Declare. * elf.c (bfd_elf_is_group_section): New function. * elfxx-target.h (bfd_elfNN_bfd_is_group_section * section.c (bfd_generic_is_group_section): New function. * targets.c (struct bfd_target): Add _bfd_is_group_section field. (BFD_JUMP_TABLE_LINK): Adjust. * aout-adobe.c (aout_32_bfd_is_group_section): Define. * aout-target.h (MY_bfd_is_group_section): Define. * aout-tic30.c (MY_bfd_is_group_section): Define. * bfd.c (bfd_is_group_section): Define. * binary.c (binary_bfd_is_group_section): Define. * bout.c (b_out_bfd_is_group_section): Define. * coff-alpha.c (_bfd_ecoff_bfd_is_group_section): Define. * coff-mips.c (_bfd_ecoff_bfd_is_group_section): Define. * coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Adjust. * coff64-rs6000.c (rs6000coff64_vec, aix5coff64_vec): Adjust. * coffcode.h (coff_bfd_is_group_section): Define. * i386msdos.c (msdos_bfd_is_group_section): Define. * i386os9k.c (os9k_bfd_is_group_section): Define. * ieee.c (ieee_bfd_is_group_section): Define. * ihex.c (ihex_bfd_is_group_section): Define. * libbfd-in.h (_bfd_nolink_bfd_is_group_section): Define. * mach-o.c (bfd_mach_o_bfd_is_group_section): Define. * mmo.c (mmo_bfd_is_group_section): Define. * nlm-target.h (nlm_bfd_is_group_section): Define. * oasys.c (oasys_bfd_is_group_section): Define. * pef.c (bfd_pef_bfd_is_group_section): Define. * ppcboot.c (ppcboot_bfd_is_group_section): Define. * srec.c (srec_bfd_is_group_section): Define. * tekhex.c (tekhex_bfd_is_group_section): Define. * versados.c (versados_bfd_is_group_section): Define. * vms.c (vms_bfd_is_group_section): Define. * xsym.c (bfd_sym_bfd_is_group_section): Define. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2004-04-30 16:23:40 +02:00
bfd_boolean
bfd_elf_is_group_section (bfd *abfd ATTRIBUTE_UNUSED, const asection *sec)
{
return elf_next_in_group (sec) != NULL;
}
1999-05-03 09:29:11 +02:00
/* Make a BFD section from an ELF section. We store a pointer to the
BFD section in the bfd_section field of the header. */
bfd_boolean
_bfd_elf_make_section_from_shdr (bfd *abfd,
Elf_Internal_Shdr *hdr,
const char *name,
int shindex)
1999-05-03 09:29:11 +02:00
{
asection *newsect;
flagword flags;
const struct elf_backend_data *bed;
1999-05-03 09:29:11 +02:00
if (hdr->bfd_section != NULL)
return TRUE;
1999-05-03 09:29:11 +02:00
newsect = bfd_make_section_anyway (abfd, name);
if (newsect == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
hdr->bfd_section = newsect;
elf_section_data (newsect)->this_hdr = *hdr;
elf_section_data (newsect)->this_idx = shindex;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
/* Always use the real type/flags. */
elf_section_type (newsect) = hdr->sh_type;
elf_section_flags (newsect) = hdr->sh_flags;
1999-05-03 09:29:11 +02:00
newsect->filepos = hdr->sh_offset;
if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
|| ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
|| ! bfd_set_section_alignment (abfd, newsect,
bfd_log2 (hdr->sh_addralign)))
return FALSE;
1999-05-03 09:29:11 +02:00
flags = SEC_NO_FLAGS;
if (hdr->sh_type != SHT_NOBITS)
flags |= SEC_HAS_CONTENTS;
if (hdr->sh_type == SHT_GROUP)
flags |= SEC_GROUP | SEC_EXCLUDE;
1999-05-03 09:29:11 +02:00
if ((hdr->sh_flags & SHF_ALLOC) != 0)
{
flags |= SEC_ALLOC;
if (hdr->sh_type != SHT_NOBITS)
flags |= SEC_LOAD;
}
if ((hdr->sh_flags & SHF_WRITE) == 0)
flags |= SEC_READONLY;
if ((hdr->sh_flags & SHF_EXECINSTR) != 0)
flags |= SEC_CODE;
else if ((flags & SEC_LOAD) != 0)
flags |= SEC_DATA;
bfd/ * libbfd-in.h (_bfd_merge_section): New. (_bfd_write_merged_section): New. (_bfd_merged_section_offset): New. * libbfd.h: Rebuilt. * linker.c (_bfd_generic_link_output_symbols): Handle discard_sec_merge. * aoutx.h (aout_link_write_symbols): Likewise. * pdp11.c (aout_link_write_symbols): Likewise. * elflink.h (elf_link_add_object_symbols): Call _bfd_merge_section. (elf_bfd_final_link): Adjust global symbols pointing into SEC_MERGE sections. (elf_link_sec_merge_syms): New. (elf_link_input_bfd): Call _bfd_merged_section_offset and _bfd_write_merged_section. Handle discard_sec_merge. * elf-bfd.h (struct elf_link_hash_table): Add merge_info field. (struct bfd_elf_section_data): Likewise. * elf.c (_bfd_elf_make_section_from_shdr): Set SEC_MERGE and SEC_STRINGS section flags and entsize from their ELF counterparts. (_bfd_elf_link_hash_table_init): Initialize merge_info. (elf_fake_sections): Set SHF_MERGE, SHF_STRINGS and sh_entsize from their BFD counterparts. * merge.c: New file. * Makefile.am: Add strtab.lo. * Makefile.in: Rebuilt. include/ * bfdlink.h (bfd_link_discard): Add discard_sec_merge. gas/ * config/obj-elf.c (obj_elf_change_section): Add entsize argument, handle SHF_MERGE and SHF_STRINGS. (obj_elf_parse_section_letters): Set SHF_MERGE and SHF_STRINGS. (obj_elf_section): Allow additional argument specifying entity size. * write.c (adjust_reloc_syms): Keep relocations against local symbols in SEC_MERGE sections. ld/ * ldmain.c (main): Default to discard_sec_merge. * lexsup.c (OPTION_DISCARD_NONE): Define. (ld_options): Add --discard-none. (parse_args): Handle OPTION_DISCARD_NONE. * ldlang.c (wild_doit): SEC_MERGE should be set in the output section only if SEC_MERGE and SEC_STRINGS flags and entsize of all its input sections match.
2001-04-13 02:34:36 +02:00
if ((hdr->sh_flags & SHF_MERGE) != 0)
{
flags |= SEC_MERGE;
newsect->entsize = hdr->sh_entsize;
if ((hdr->sh_flags & SHF_STRINGS) != 0)
flags |= SEC_STRINGS;
}
if (hdr->sh_flags & SHF_GROUP)
if (!setup_group (abfd, hdr, newsect))
return FALSE;
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
if ((hdr->sh_flags & SHF_TLS) != 0)
flags |= SEC_THREAD_LOCAL;
Implement generic SHF_EXCLUDE. bfd/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * elf.c (_bfd_elf_make_section_from_shdr): Handle SHF_EXCLUDE (elf_fake_sections): Likewise. * elf32-i370.c (i370_elf_section_from_shdr): Don't handle SHF_EXCLUDE here. * elf32-ppc.c (ppc_elf_fake_sections): Likewise. binutils/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * readelf.c (get_elf_section_flags): Treat SHF_EXCLUDE as a generic flag. binutils/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * binutils-all/objcopy.exp: Run exclude-1a and exclude-1b for ELF targets. * binutils-all/exclude-1.s: New. * binutils-all/exclude-1a.d: Likewise. * binutils-all/exclude-1b.d: Likewise. gas/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * obj-elf.c (obj_elf_change_section): Handle SHF_EXCLUDE. (obj_elf_parse_section_letters): Likewise. (obj_elf_section_word): Likewise. * config/tc-ppc.c (ppc_section_letter): Removed. (ppc_section_word): Likewise. * config/tc-ppc.h (ppc_section_letter): Likewise. (ppc_section_word): Likewise. (md_elf_section_letter): Likewise. (md_elf_section_word): Likewise. * doc/as.texinfo: Document `e' and `#exclude'. gas/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * gas/elf/elf.exp: Run section8. * gas/elf/section8.d: New. * gas/elf/section8.s: Likewise. include/elf/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * common.h (SHF_EXCLUDE): New. * i370.h (SHF_EXCLUDE): Removed. * or32.h (SHF_EXCLUDE): Likewise. * ppc.h (SHF_EXCLUDE): Likewise. * sparc.h (SHF_EXCLUDE): Likewise. ld/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * ld-elf/exclude3.s: New. * ld-elf/exclude3a.d: Likewise. * ld-elf/exclude3b.d: Likewise. * ld-elf/exclude3c.d: Likewise.
2010-05-18 05:31:07 +02:00
if ((hdr->sh_flags & SHF_EXCLUDE) != 0)
flags |= SEC_EXCLUDE;
1999-05-03 09:29:11 +02:00
if ((flags & SEC_ALLOC) == 0)
{
/* The debugging sections appear to be recognized only by name,
not any sort of flag. Their SEC_ALLOC bits are cleared. */
static const struct
{
const char *name;
int len;
} debug_sections [] =
{
{ STRING_COMMA_LEN ("debug") }, /* 'd' */
{ NULL, 0 }, /* 'e' */
{ NULL, 0 }, /* 'f' */
{ STRING_COMMA_LEN ("gnu.linkonce.wi.") }, /* 'g' */
{ NULL, 0 }, /* 'h' */
{ NULL, 0 }, /* 'i' */
{ NULL, 0 }, /* 'j' */
{ NULL, 0 }, /* 'k' */
{ STRING_COMMA_LEN ("line") }, /* 'l' */
{ NULL, 0 }, /* 'm' */
{ NULL, 0 }, /* 'n' */
{ NULL, 0 }, /* 'o' */
{ NULL, 0 }, /* 'p' */
{ NULL, 0 }, /* 'q' */
{ NULL, 0 }, /* 'r' */
bfd/ * Makefile.am (BFD32_LIBS): Add compress.lo. (BFD32_LIBS_CFILES): Add compress.c. (BFD_H_FILES): Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf2.c (read_section): New function. (read_indirect_string): Call new function read_section. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Call new function read_section when just one .zdebug_info section is found, otherwise read and compress multiple sections. (_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr. * elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix. (special_sections_z): New struct. (special_sections): Refer to special_sections_z. * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize sections named .zdebug_*. (_bfd_mips_elf_fake_sections): Likewise. * compress.c: New file. (bfd_uncompress_section_contents): New function. bfd/doc/ * Makefile.am (BFD_H_DEP): Add ../compress.c. * Makefile.in: Regenerate. binutils/ * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf.c (debug_displays): Add .zdebug_* strings. * dwarf.h (struct dwarf_section): Add fields uncompressed_namd and compressed_name. * objdump.c (load_debug_section): Call bfd_uncompress_section_contents when loading a compressed section. (dump_dwarf_section): Recognize compressed section name. (mach_o_dwarf_sections): Rename as mach_o_uncompressed_dwarf_sections. (mach_o_compressed_dwarf_sections): New variable. (generic_dwarf_section): Rename as generic_uncompressed_dwarf_sections. (generic_compressed_dwarf_sections): New variable. (check_mach_o_dwarf): Save and restore mach_o_compressed_dwarf_sections. * readelf.c: Add #include for config.h and zlib.h (process_section_headers): Recognize compressed section name. (uncompress_section_contents): New function. (load_debug_section): Call uncompress_section_contents when loading a compressed section. (display_debug_section): Recognize compressed section name. binutils/testsuite: * binutils-all/objdump.exp: Add test for objdump -s on a file with a compressed debug section. Add test for objdump -W on a file that contains a compressed debug section. * binutils-all/readelf.exp: Call readelf_compressed_wa_test. (readelf_compressed_wa_test): New function. * binutils-all/dw2-compressed.S: New file. * binutils-all/objdump.W: New file. * binutils-all/objdump.s: New file. * binutils-all/readelf.wa: New file.
2008-07-10 03:32:23 +02:00
{ STRING_COMMA_LEN ("stab") }, /* 's' */
{ NULL, 0 }, /* 't' */
{ NULL, 0 }, /* 'u' */
{ NULL, 0 }, /* 'v' */
{ NULL, 0 }, /* 'w' */
{ NULL, 0 }, /* 'x' */
{ NULL, 0 }, /* 'y' */
{ STRING_COMMA_LEN ("zdebug") } /* 'z' */
};
if (name [0] == '.')
{
int i = name [1] - 'd';
if (i >= 0
&& i < (int) ARRAY_SIZE (debug_sections)
&& debug_sections [i].name != NULL
&& strncmp (&name [1], debug_sections [i].name,
debug_sections [i].len) == 0)
flags |= SEC_DEBUGGING;
}
}
1999-05-03 09:29:11 +02:00
/* As a GNU extension, if the name begins with .gnu.linkonce, we
only link a single copy of the section. This is used to support
g++. g++ will emit each template expansion in its own section.
The symbols will be defined as weak, so that multiple definitions
are permitted. The GNU linker extension is to actually discard
all but one of the sections. */
if (CONST_STRNEQ (name, ".gnu.linkonce")
&& elf_next_in_group (newsect) == NULL)
1999-05-03 09:29:11 +02:00
flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
bed = get_elf_backend_data (abfd);
if (bed->elf_backend_section_flags)
if (! bed->elf_backend_section_flags (&flags, hdr))
return FALSE;
1999-05-03 09:29:11 +02:00
if (! bfd_set_section_flags (abfd, newsect, flags))
return FALSE;
1999-05-03 09:29:11 +02:00
/* We do not parse the PT_NOTE segments as we are interested even in the
separate debug info files which may have the segments offsets corrupted.
PT_NOTEs from the core files are currently not parsed using BFD. */
if (hdr->sh_type == SHT_NOTE)
{
bfd_byte *contents;
if (!bfd_malloc_and_get_section (abfd, newsect, &contents))
return FALSE;
elf_parse_notes (abfd, (char *) contents, hdr->sh_size, -1);
free (contents);
}
1999-05-03 09:29:11 +02:00
if ((flags & SEC_ALLOC) != 0)
{
Elf_Internal_Phdr *phdr;
unsigned int i, nload;
/* Some ELF linkers produce binaries with all the program header
p_paddr fields zero. If we have such a binary with more than
one PT_LOAD header, then leave the section lma equal to vma
so that we don't create sections with overlapping lma. */
phdr = elf_tdata (abfd)->phdr;
for (nload = 0, i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
if (phdr->p_paddr != 0)
break;
else if (phdr->p_type == PT_LOAD && phdr->p_memsz != 0)
++nload;
if (i >= elf_elfheader (abfd)->e_phnum && nload > 1)
return TRUE;
1999-05-03 09:29:11 +02:00
phdr = elf_tdata (abfd)->phdr;
for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
{
if (((phdr->p_type == PT_LOAD
&& (hdr->sh_flags & SHF_TLS) == 0)
|| phdr->p_type == PT_TLS)
&& ELF_SECTION_IN_SEGMENT (hdr, phdr))
1999-05-03 09:29:11 +02:00
{
if ((flags & SEC_LOAD) == 0)
newsect->lma = (phdr->p_paddr
+ hdr->sh_addr - phdr->p_vaddr);
else
/* We used to use the same adjustment for SEC_LOAD
sections, but that doesn't work if the segment
is packed with code from multiple VMAs.
Instead we calculate the section LMA based on
the segment LMA. It is assumed that the
segment will contain sections with contiguous
LMAs, even if the VMAs are not. */
newsect->lma = (phdr->p_paddr
+ hdr->sh_offset - phdr->p_offset);
/* With contiguous segments, we can't tell from file
offsets whether a section with zero size should
be placed at the end of one segment or the
beginning of the next. Decide based on vaddr. */
if (hdr->sh_addr >= phdr->p_vaddr
&& (hdr->sh_addr + hdr->sh_size
<= phdr->p_vaddr + phdr->p_memsz))
break;
1999-05-03 09:29:11 +02:00
}
}
}
Add compressed debug section support to binutils and ld. bfd/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> Cary Coutant <ccoutant@google.com> * archive.c (bfd_openr_next_archived_file): Copy BFD_COMPRESS and BFD_DECOMPRESS. * bfd.c (BFD_COMPRESS): New. (BFD_DECOMPRESS): Likewise. (BFD_FLAGS_SAVED): Likewise. (bfd_preserve_save): Replace BFD_IN_MEMORY with BFD_FLAGS_SAVED. * compress.c (bfd_uncompress_section_contents): Removed. (get_uncompressed_size): New. (decompress_contents): Likewise. (bfd_compress_section_contents): Likewise. (bfd_get_full_section_contents): Likewise. (bfd_is_section_compressed): Likewise. (bfd_init_section_decompress_status): Likewise. (bfd_init_section_compress_status): Likewise. * dwarf2.c (dwarf_debug_sections): New. (dwarf_debug_section_enum): Likewise. (read_section): Remove section_name and compressed_section_name. Add dwarf_debug_section_enum. Try compressed debug section. (read_indirect_string): Updated. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Updated. * ecoff.c (bfd_debug_section): Add compress_status and compressed_size. * elf.c (_bfd_elf_make_section_from_shdr): Call bfd_is_section_compressed to check if a DWARF debug section is compressed. Call bfd_init_section_compress_status or bfd_init_section_decompress_status if needed. * elflink.c (elf_link_input_bfd): Replace bfd_get_section_contents with bfd_get_full_section_contents. * merge.c (_bfd_add_merge_section): Likewise. * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. * simple.c (bfd_simple_get_relocated_section_contents): Likewise. * elfxx-target.h (TARGET_BIG_SYM): Allow BFD_COMPRESS and BFD_DECOMPRESS. (TARGET_LITTLE_SYM): Likewise. * libbfd-in.h (dwarf_debug_section): New. (dwarf_debug_sections): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Issue an error when getting contents on compressed/decompressed section. * section.c (COMPRESS_SECTION_NONE): New. (COMPRESS_SECTION_DONE): Likewise. (DECOMPRESS_SECTION_SIZED): Likewise. (BFD_FAKE_SECTION): Add compress_status and compressed_size. (bfd_malloc_and_get_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. binutils/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * addr2line.c (process_file): Set BFD_DECOMPRESS. * objcopy.c (do_debug_sections): New. (OPTION_COMPRESS_DEBUG_SECTIONS): New. (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. (copy_usage): Add --compress-debug-sections and --decompress-debug-sections. (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. (copy_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to rename DWARF debug sections. * objdump.c (load_specific_debug_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. Remove bfd_uncompress_section_contents. (dump_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (display_file): Set BFD_DECOMPRESS if needed. * readelf.c (uncompress_section_contents): Set buffer to NULL to indiate decompression failure. (load_specific_debug_section): Always call uncompress_section_contents. * doc/binutils.texi: Document --compress-debug-sections and --decompress-debug-sections. binutils/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * binutils-all/compress.exp: New. * binutils-all/dw2-1.S: Likewise. * binutils-all/dw2-2.S: Likewise. * binutils-all/libdw2-compressed.out: Likewise. * binutils-all/libdw2.out: Likewise. gas/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Optimize section flags check. gas/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * elf/dwarf2-1.s: Replace .zdebug_abbrev section with .debug_abbrev section. * elf/dwarf2-2.3: Likewise. * elf/dwarf2-1.d: Pass --compress-debug-sections to assembler. Updated. * elf/dwarf2-2.d: Likewise. * gas/i386/i386.exp: Remove xfail on dw2-compress-2 and x86-64-dw2-compress-2. ld/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ldfile.c (ldfile_try_open_bfd): Set BFD_DECOMPRESS after bfd_openr returns. * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Likewise. * scripttempl/elf.sc: Include compressed DWARF debug sections. ld/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/compress.exp: New. * ld-elf/compress1.s: Likewise. * ld-elf/compress1a.d: Likewise. * ld-elf/compress1b.d: Likewise. * ld-elf/compress1c.d: Likewise.
2010-10-29 14:10:39 +02:00
/* Compress/decompress DWARF debug sections with names: .debug_* and
.zdebug_*, after the section flags is set. */
if ((flags & SEC_DEBUGGING)
&& ((name[1] == 'd' && name[6] == '_')
|| (name[1] == 'z' && name[7] == '_')))
{
enum { nothing, compress, decompress } action = nothing;
char *new_name;
Add compressed debug section support to binutils and ld. bfd/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> Cary Coutant <ccoutant@google.com> * archive.c (bfd_openr_next_archived_file): Copy BFD_COMPRESS and BFD_DECOMPRESS. * bfd.c (BFD_COMPRESS): New. (BFD_DECOMPRESS): Likewise. (BFD_FLAGS_SAVED): Likewise. (bfd_preserve_save): Replace BFD_IN_MEMORY with BFD_FLAGS_SAVED. * compress.c (bfd_uncompress_section_contents): Removed. (get_uncompressed_size): New. (decompress_contents): Likewise. (bfd_compress_section_contents): Likewise. (bfd_get_full_section_contents): Likewise. (bfd_is_section_compressed): Likewise. (bfd_init_section_decompress_status): Likewise. (bfd_init_section_compress_status): Likewise. * dwarf2.c (dwarf_debug_sections): New. (dwarf_debug_section_enum): Likewise. (read_section): Remove section_name and compressed_section_name. Add dwarf_debug_section_enum. Try compressed debug section. (read_indirect_string): Updated. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Updated. * ecoff.c (bfd_debug_section): Add compress_status and compressed_size. * elf.c (_bfd_elf_make_section_from_shdr): Call bfd_is_section_compressed to check if a DWARF debug section is compressed. Call bfd_init_section_compress_status or bfd_init_section_decompress_status if needed. * elflink.c (elf_link_input_bfd): Replace bfd_get_section_contents with bfd_get_full_section_contents. * merge.c (_bfd_add_merge_section): Likewise. * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. * simple.c (bfd_simple_get_relocated_section_contents): Likewise. * elfxx-target.h (TARGET_BIG_SYM): Allow BFD_COMPRESS and BFD_DECOMPRESS. (TARGET_LITTLE_SYM): Likewise. * libbfd-in.h (dwarf_debug_section): New. (dwarf_debug_sections): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Issue an error when getting contents on compressed/decompressed section. * section.c (COMPRESS_SECTION_NONE): New. (COMPRESS_SECTION_DONE): Likewise. (DECOMPRESS_SECTION_SIZED): Likewise. (BFD_FAKE_SECTION): Add compress_status and compressed_size. (bfd_malloc_and_get_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. binutils/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * addr2line.c (process_file): Set BFD_DECOMPRESS. * objcopy.c (do_debug_sections): New. (OPTION_COMPRESS_DEBUG_SECTIONS): New. (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. (copy_usage): Add --compress-debug-sections and --decompress-debug-sections. (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. (copy_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to rename DWARF debug sections. * objdump.c (load_specific_debug_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. Remove bfd_uncompress_section_contents. (dump_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (display_file): Set BFD_DECOMPRESS if needed. * readelf.c (uncompress_section_contents): Set buffer to NULL to indiate decompression failure. (load_specific_debug_section): Always call uncompress_section_contents. * doc/binutils.texi: Document --compress-debug-sections and --decompress-debug-sections. binutils/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * binutils-all/compress.exp: New. * binutils-all/dw2-1.S: Likewise. * binutils-all/dw2-2.S: Likewise. * binutils-all/libdw2-compressed.out: Likewise. * binutils-all/libdw2.out: Likewise. gas/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Optimize section flags check. gas/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * elf/dwarf2-1.s: Replace .zdebug_abbrev section with .debug_abbrev section. * elf/dwarf2-2.3: Likewise. * elf/dwarf2-1.d: Pass --compress-debug-sections to assembler. Updated. * elf/dwarf2-2.d: Likewise. * gas/i386/i386.exp: Remove xfail on dw2-compress-2 and x86-64-dw2-compress-2. ld/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ldfile.c (ldfile_try_open_bfd): Set BFD_DECOMPRESS after bfd_openr returns. * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Likewise. * scripttempl/elf.sc: Include compressed DWARF debug sections. ld/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/compress.exp: New. * ld-elf/compress1.s: Likewise. * ld-elf/compress1a.d: Likewise. * ld-elf/compress1b.d: Likewise. * ld-elf/compress1c.d: Likewise.
2010-10-29 14:10:39 +02:00
if (bfd_is_section_compressed (abfd, newsect))
{
/* Compressed section. Check if we should decompress. */
if ((abfd->flags & BFD_DECOMPRESS))
action = decompress;
}
else
{
/* Normal section. Check if we should compress. */
if ((abfd->flags & BFD_COMPRESS))
action = compress;
}
new_name = NULL;
Add compressed debug section support to binutils and ld. bfd/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> Cary Coutant <ccoutant@google.com> * archive.c (bfd_openr_next_archived_file): Copy BFD_COMPRESS and BFD_DECOMPRESS. * bfd.c (BFD_COMPRESS): New. (BFD_DECOMPRESS): Likewise. (BFD_FLAGS_SAVED): Likewise. (bfd_preserve_save): Replace BFD_IN_MEMORY with BFD_FLAGS_SAVED. * compress.c (bfd_uncompress_section_contents): Removed. (get_uncompressed_size): New. (decompress_contents): Likewise. (bfd_compress_section_contents): Likewise. (bfd_get_full_section_contents): Likewise. (bfd_is_section_compressed): Likewise. (bfd_init_section_decompress_status): Likewise. (bfd_init_section_compress_status): Likewise. * dwarf2.c (dwarf_debug_sections): New. (dwarf_debug_section_enum): Likewise. (read_section): Remove section_name and compressed_section_name. Add dwarf_debug_section_enum. Try compressed debug section. (read_indirect_string): Updated. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Updated. * ecoff.c (bfd_debug_section): Add compress_status and compressed_size. * elf.c (_bfd_elf_make_section_from_shdr): Call bfd_is_section_compressed to check if a DWARF debug section is compressed. Call bfd_init_section_compress_status or bfd_init_section_decompress_status if needed. * elflink.c (elf_link_input_bfd): Replace bfd_get_section_contents with bfd_get_full_section_contents. * merge.c (_bfd_add_merge_section): Likewise. * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. * simple.c (bfd_simple_get_relocated_section_contents): Likewise. * elfxx-target.h (TARGET_BIG_SYM): Allow BFD_COMPRESS and BFD_DECOMPRESS. (TARGET_LITTLE_SYM): Likewise. * libbfd-in.h (dwarf_debug_section): New. (dwarf_debug_sections): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Issue an error when getting contents on compressed/decompressed section. * section.c (COMPRESS_SECTION_NONE): New. (COMPRESS_SECTION_DONE): Likewise. (DECOMPRESS_SECTION_SIZED): Likewise. (BFD_FAKE_SECTION): Add compress_status and compressed_size. (bfd_malloc_and_get_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. binutils/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * addr2line.c (process_file): Set BFD_DECOMPRESS. * objcopy.c (do_debug_sections): New. (OPTION_COMPRESS_DEBUG_SECTIONS): New. (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. (copy_usage): Add --compress-debug-sections and --decompress-debug-sections. (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. (copy_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to rename DWARF debug sections. * objdump.c (load_specific_debug_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. Remove bfd_uncompress_section_contents. (dump_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (display_file): Set BFD_DECOMPRESS if needed. * readelf.c (uncompress_section_contents): Set buffer to NULL to indiate decompression failure. (load_specific_debug_section): Always call uncompress_section_contents. * doc/binutils.texi: Document --compress-debug-sections and --decompress-debug-sections. binutils/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * binutils-all/compress.exp: New. * binutils-all/dw2-1.S: Likewise. * binutils-all/dw2-2.S: Likewise. * binutils-all/libdw2-compressed.out: Likewise. * binutils-all/libdw2.out: Likewise. gas/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Optimize section flags check. gas/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * elf/dwarf2-1.s: Replace .zdebug_abbrev section with .debug_abbrev section. * elf/dwarf2-2.3: Likewise. * elf/dwarf2-1.d: Pass --compress-debug-sections to assembler. Updated. * elf/dwarf2-2.d: Likewise. * gas/i386/i386.exp: Remove xfail on dw2-compress-2 and x86-64-dw2-compress-2. ld/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ldfile.c (ldfile_try_open_bfd): Set BFD_DECOMPRESS after bfd_openr returns. * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Likewise. * scripttempl/elf.sc: Include compressed DWARF debug sections. ld/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/compress.exp: New. * ld-elf/compress1.s: Likewise. * ld-elf/compress1a.d: Likewise. * ld-elf/compress1b.d: Likewise. * ld-elf/compress1c.d: Likewise.
2010-10-29 14:10:39 +02:00
switch (action)
{
case nothing:
break;
case compress:
if (!bfd_init_section_compress_status (abfd, newsect))
{
(*_bfd_error_handler)
(_("%B: unable to initialize commpress status for section %s"),
abfd, name);
return FALSE;
}
if (name[1] != 'z')
{
unsigned int len = strlen (name);
new_name = bfd_alloc (abfd, len + 2);
if (new_name == NULL)
return FALSE;
new_name[0] = '.';
new_name[1] = 'z';
memcpy (new_name + 2, name + 1, len);
}
Add compressed debug section support to binutils and ld. bfd/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> Cary Coutant <ccoutant@google.com> * archive.c (bfd_openr_next_archived_file): Copy BFD_COMPRESS and BFD_DECOMPRESS. * bfd.c (BFD_COMPRESS): New. (BFD_DECOMPRESS): Likewise. (BFD_FLAGS_SAVED): Likewise. (bfd_preserve_save): Replace BFD_IN_MEMORY with BFD_FLAGS_SAVED. * compress.c (bfd_uncompress_section_contents): Removed. (get_uncompressed_size): New. (decompress_contents): Likewise. (bfd_compress_section_contents): Likewise. (bfd_get_full_section_contents): Likewise. (bfd_is_section_compressed): Likewise. (bfd_init_section_decompress_status): Likewise. (bfd_init_section_compress_status): Likewise. * dwarf2.c (dwarf_debug_sections): New. (dwarf_debug_section_enum): Likewise. (read_section): Remove section_name and compressed_section_name. Add dwarf_debug_section_enum. Try compressed debug section. (read_indirect_string): Updated. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Updated. * ecoff.c (bfd_debug_section): Add compress_status and compressed_size. * elf.c (_bfd_elf_make_section_from_shdr): Call bfd_is_section_compressed to check if a DWARF debug section is compressed. Call bfd_init_section_compress_status or bfd_init_section_decompress_status if needed. * elflink.c (elf_link_input_bfd): Replace bfd_get_section_contents with bfd_get_full_section_contents. * merge.c (_bfd_add_merge_section): Likewise. * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. * simple.c (bfd_simple_get_relocated_section_contents): Likewise. * elfxx-target.h (TARGET_BIG_SYM): Allow BFD_COMPRESS and BFD_DECOMPRESS. (TARGET_LITTLE_SYM): Likewise. * libbfd-in.h (dwarf_debug_section): New. (dwarf_debug_sections): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Issue an error when getting contents on compressed/decompressed section. * section.c (COMPRESS_SECTION_NONE): New. (COMPRESS_SECTION_DONE): Likewise. (DECOMPRESS_SECTION_SIZED): Likewise. (BFD_FAKE_SECTION): Add compress_status and compressed_size. (bfd_malloc_and_get_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. binutils/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * addr2line.c (process_file): Set BFD_DECOMPRESS. * objcopy.c (do_debug_sections): New. (OPTION_COMPRESS_DEBUG_SECTIONS): New. (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. (copy_usage): Add --compress-debug-sections and --decompress-debug-sections. (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. (copy_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to rename DWARF debug sections. * objdump.c (load_specific_debug_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. Remove bfd_uncompress_section_contents. (dump_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (display_file): Set BFD_DECOMPRESS if needed. * readelf.c (uncompress_section_contents): Set buffer to NULL to indiate decompression failure. (load_specific_debug_section): Always call uncompress_section_contents. * doc/binutils.texi: Document --compress-debug-sections and --decompress-debug-sections. binutils/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * binutils-all/compress.exp: New. * binutils-all/dw2-1.S: Likewise. * binutils-all/dw2-2.S: Likewise. * binutils-all/libdw2-compressed.out: Likewise. * binutils-all/libdw2.out: Likewise. gas/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Optimize section flags check. gas/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * elf/dwarf2-1.s: Replace .zdebug_abbrev section with .debug_abbrev section. * elf/dwarf2-2.3: Likewise. * elf/dwarf2-1.d: Pass --compress-debug-sections to assembler. Updated. * elf/dwarf2-2.d: Likewise. * gas/i386/i386.exp: Remove xfail on dw2-compress-2 and x86-64-dw2-compress-2. ld/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ldfile.c (ldfile_try_open_bfd): Set BFD_DECOMPRESS after bfd_openr returns. * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Likewise. * scripttempl/elf.sc: Include compressed DWARF debug sections. ld/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/compress.exp: New. * ld-elf/compress1.s: Likewise. * ld-elf/compress1a.d: Likewise. * ld-elf/compress1b.d: Likewise. * ld-elf/compress1c.d: Likewise.
2010-10-29 14:10:39 +02:00
break;
case decompress:
if (!bfd_init_section_decompress_status (abfd, newsect))
{
(*_bfd_error_handler)
(_("%B: unable to initialize decommpress status for section %s"),
abfd, name);
return FALSE;
}
if (name[1] == 'z')
{
unsigned int len = strlen (name);
new_name = bfd_alloc (abfd, len);
if (new_name == NULL)
return FALSE;
new_name[0] = '.';
memcpy (new_name + 1, name + 2, len - 1);
}
Add compressed debug section support to binutils and ld. bfd/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> Cary Coutant <ccoutant@google.com> * archive.c (bfd_openr_next_archived_file): Copy BFD_COMPRESS and BFD_DECOMPRESS. * bfd.c (BFD_COMPRESS): New. (BFD_DECOMPRESS): Likewise. (BFD_FLAGS_SAVED): Likewise. (bfd_preserve_save): Replace BFD_IN_MEMORY with BFD_FLAGS_SAVED. * compress.c (bfd_uncompress_section_contents): Removed. (get_uncompressed_size): New. (decompress_contents): Likewise. (bfd_compress_section_contents): Likewise. (bfd_get_full_section_contents): Likewise. (bfd_is_section_compressed): Likewise. (bfd_init_section_decompress_status): Likewise. (bfd_init_section_compress_status): Likewise. * dwarf2.c (dwarf_debug_sections): New. (dwarf_debug_section_enum): Likewise. (read_section): Remove section_name and compressed_section_name. Add dwarf_debug_section_enum. Try compressed debug section. (read_indirect_string): Updated. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Updated. * ecoff.c (bfd_debug_section): Add compress_status and compressed_size. * elf.c (_bfd_elf_make_section_from_shdr): Call bfd_is_section_compressed to check if a DWARF debug section is compressed. Call bfd_init_section_compress_status or bfd_init_section_decompress_status if needed. * elflink.c (elf_link_input_bfd): Replace bfd_get_section_contents with bfd_get_full_section_contents. * merge.c (_bfd_add_merge_section): Likewise. * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. * simple.c (bfd_simple_get_relocated_section_contents): Likewise. * elfxx-target.h (TARGET_BIG_SYM): Allow BFD_COMPRESS and BFD_DECOMPRESS. (TARGET_LITTLE_SYM): Likewise. * libbfd-in.h (dwarf_debug_section): New. (dwarf_debug_sections): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Issue an error when getting contents on compressed/decompressed section. * section.c (COMPRESS_SECTION_NONE): New. (COMPRESS_SECTION_DONE): Likewise. (DECOMPRESS_SECTION_SIZED): Likewise. (BFD_FAKE_SECTION): Add compress_status and compressed_size. (bfd_malloc_and_get_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. binutils/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * addr2line.c (process_file): Set BFD_DECOMPRESS. * objcopy.c (do_debug_sections): New. (OPTION_COMPRESS_DEBUG_SECTIONS): New. (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. (copy_usage): Add --compress-debug-sections and --decompress-debug-sections. (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. (copy_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to rename DWARF debug sections. * objdump.c (load_specific_debug_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. Remove bfd_uncompress_section_contents. (dump_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (display_file): Set BFD_DECOMPRESS if needed. * readelf.c (uncompress_section_contents): Set buffer to NULL to indiate decompression failure. (load_specific_debug_section): Always call uncompress_section_contents. * doc/binutils.texi: Document --compress-debug-sections and --decompress-debug-sections. binutils/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * binutils-all/compress.exp: New. * binutils-all/dw2-1.S: Likewise. * binutils-all/dw2-2.S: Likewise. * binutils-all/libdw2-compressed.out: Likewise. * binutils-all/libdw2.out: Likewise. gas/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Optimize section flags check. gas/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * elf/dwarf2-1.s: Replace .zdebug_abbrev section with .debug_abbrev section. * elf/dwarf2-2.3: Likewise. * elf/dwarf2-1.d: Pass --compress-debug-sections to assembler. Updated. * elf/dwarf2-2.d: Likewise. * gas/i386/i386.exp: Remove xfail on dw2-compress-2 and x86-64-dw2-compress-2. ld/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ldfile.c (ldfile_try_open_bfd): Set BFD_DECOMPRESS after bfd_openr returns. * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Likewise. * scripttempl/elf.sc: Include compressed DWARF debug sections. ld/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/compress.exp: New. * ld-elf/compress1.s: Likewise. * ld-elf/compress1a.d: Likewise. * ld-elf/compress1b.d: Likewise. * ld-elf/compress1c.d: Likewise.
2010-10-29 14:10:39 +02:00
break;
}
if (new_name != NULL)
bfd_rename_section (abfd, newsect, new_name);
Add compressed debug section support to binutils and ld. bfd/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> Cary Coutant <ccoutant@google.com> * archive.c (bfd_openr_next_archived_file): Copy BFD_COMPRESS and BFD_DECOMPRESS. * bfd.c (BFD_COMPRESS): New. (BFD_DECOMPRESS): Likewise. (BFD_FLAGS_SAVED): Likewise. (bfd_preserve_save): Replace BFD_IN_MEMORY with BFD_FLAGS_SAVED. * compress.c (bfd_uncompress_section_contents): Removed. (get_uncompressed_size): New. (decompress_contents): Likewise. (bfd_compress_section_contents): Likewise. (bfd_get_full_section_contents): Likewise. (bfd_is_section_compressed): Likewise. (bfd_init_section_decompress_status): Likewise. (bfd_init_section_compress_status): Likewise. * dwarf2.c (dwarf_debug_sections): New. (dwarf_debug_section_enum): Likewise. (read_section): Remove section_name and compressed_section_name. Add dwarf_debug_section_enum. Try compressed debug section. (read_indirect_string): Updated. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Updated. * ecoff.c (bfd_debug_section): Add compress_status and compressed_size. * elf.c (_bfd_elf_make_section_from_shdr): Call bfd_is_section_compressed to check if a DWARF debug section is compressed. Call bfd_init_section_compress_status or bfd_init_section_decompress_status if needed. * elflink.c (elf_link_input_bfd): Replace bfd_get_section_contents with bfd_get_full_section_contents. * merge.c (_bfd_add_merge_section): Likewise. * reloc.c (bfd_generic_get_relocated_section_contents): Likewise. * simple.c (bfd_simple_get_relocated_section_contents): Likewise. * elfxx-target.h (TARGET_BIG_SYM): Allow BFD_COMPRESS and BFD_DECOMPRESS. (TARGET_LITTLE_SYM): Likewise. * libbfd-in.h (dwarf_debug_section): New. (dwarf_debug_sections): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Issue an error when getting contents on compressed/decompressed section. * section.c (COMPRESS_SECTION_NONE): New. (COMPRESS_SECTION_DONE): Likewise. (DECOMPRESS_SECTION_SIZED): Likewise. (BFD_FAKE_SECTION): Add compress_status and compressed_size. (bfd_malloc_and_get_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. * bfd-in2.h: Regenerated. * libbfd.h: Likewise. binutils/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * addr2line.c (process_file): Set BFD_DECOMPRESS. * objcopy.c (do_debug_sections): New. (OPTION_COMPRESS_DEBUG_SECTIONS): New. (OPTION_DECOMPRESS_DEBUG_SECTIONS): Likewise. (copy_options): Add OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. (copy_usage): Add --compress-debug-sections and --decompress-debug-sections. (copy_file): Set BFD_COMPRESS or BFD_DECOMPRESS. (copy_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (copy_main): Handle OPTION_COMPRESS_DEBUG_SECTIONS and OPTION_DECOMPRESS_DEBUG_SECTIONS. Check do_debug_sections to rename DWARF debug sections. * objdump.c (load_specific_debug_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. Remove bfd_uncompress_section_contents. (dump_section): Replace bfd_get_section_contents with bfd_get_full_section_contents. (display_file): Set BFD_DECOMPRESS if needed. * readelf.c (uncompress_section_contents): Set buffer to NULL to indiate decompression failure. (load_specific_debug_section): Always call uncompress_section_contents. * doc/binutils.texi: Document --compress-debug-sections and --decompress-debug-sections. binutils/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * binutils-all/compress.exp: New. * binutils-all/dw2-1.S: Likewise. * binutils-all/dw2-2.S: Likewise. * binutils-all/libdw2-compressed.out: Likewise. * binutils-all/libdw2.out: Likewise. gas/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * write.c (compress_debug): Optimize section flags check. gas/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * elf/dwarf2-1.s: Replace .zdebug_abbrev section with .debug_abbrev section. * elf/dwarf2-2.3: Likewise. * elf/dwarf2-1.d: Pass --compress-debug-sections to assembler. Updated. * elf/dwarf2-2.d: Likewise. * gas/i386/i386.exp: Remove xfail on dw2-compress-2 and x86-64-dw2-compress-2. ld/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ldfile.c (ldfile_try_open_bfd): Set BFD_DECOMPRESS after bfd_openr returns. * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Likewise. * scripttempl/elf.sc: Include compressed DWARF debug sections. ld/testsuite/ 2010-10-29 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/compress.exp: New. * ld-elf/compress1.s: Likewise. * ld-elf/compress1a.d: Likewise. * ld-elf/compress1b.d: Likewise. * ld-elf/compress1c.d: Likewise.
2010-10-29 14:10:39 +02:00
}
return TRUE;
1999-05-03 09:29:11 +02:00
}
const char *const bfd_elf_section_type_names[] = {
"SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",
"SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",
"SHT_NOBITS", "SHT_REL", "SHT_SHLIB", "SHT_DYNSYM",
};
2003-06-25 08:40:27 +02:00
/* ELF relocs are against symbols. If we are producing relocatable
1999-05-03 09:29:11 +02:00
output, and the reloc is against an external symbol, and nothing
has given us any additional addend, the resulting reloc will also
be against the same symbol. In such a case, we don't want to
change anything about the way the reloc is handled, since it will
all be done at final link time. Rather than put special case code
into bfd_perform_relocation, all the reloc types use this howto
function. It just short circuits the reloc if producing
2003-06-25 08:40:27 +02:00
relocatable output against an external symbol. */
1999-05-03 09:29:11 +02:00
bfd_reloc_status_type
bfd_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry,
asymbol *symbol,
void *data ATTRIBUTE_UNUSED,
asection *input_section,
bfd *output_bfd,
char **error_message ATTRIBUTE_UNUSED)
{
if (output_bfd != NULL
1999-05-03 09:29:11 +02:00
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& (! reloc_entry->howto->partial_inplace
|| reloc_entry->addend == 0))
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
return bfd_reloc_continue;
}
/* Copy the program header and other data from one object module to
another. */
1999-05-03 09:29:11 +02:00
bfd_boolean
_bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
{
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
BFD_ASSERT (!elf_flags_init (obfd)
|| (elf_elfheader (obfd)->e_flags
== elf_elfheader (ibfd)->e_flags));
elf_gp (obfd) = elf_gp (ibfd);
elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
elf_flags_init (obfd) = TRUE;
bfd: * elf-attrs.c: New. * Makefile.am (BFD32_BACKENDS): Add elf-attrs.lo. (BFD32_BACKENDS_CFILES): Add elf-attrs.c. (elf-attrs.lo): Generate dependencies. * Makefile.in: Regenerate. * configure.in (elf): Add elf-attrs.lo. * configure: Regenerate. * elf-bfd.h (struct elf_backend_data): Add entries for object attributes. (NUM_KNOWN_OBJ_ATTRIBUTES, obj_attribute, obj_attribute_list, OBJ_ATTR_PROC, OBJ_ATTR_GNU, OBJ_ATTR_FIRST, OBJ_ATTR_LAST, Tag_NULL, Tag_File, Tag_Section, Tag_Symbol, Tag_compatibility): New. (struct elf_obj_tdata): Add entries for object attributes. (elf_known_obj_attributes, elf_other_obj_attributes, elf_known_obj_attributes_proc, elf_other_obj_attributes_proc): New. (bfd_elf_obj_attr_size, bfd_elf_set_obj_attr_contents, bfd_elf_get_obj_attr_int, bfd_elf_add_obj_attr_int, bfd_elf_add_proc_attr_int, bfd_elf_add_obj_attr_string, bfd_elf_add_proc_attr_string, bfd_elf_add_obj_attr_compat, bfd_elf_add_proc_attr_compat, _bfd_elf_attr_strdup, _bfd_elf_copy_obj_attributes, _bfd_elf_obj_attrs_arg_type, _bfd_elf_parse_attributes, _bfd_elf_merge_object_attributes): New. * elf.c (_bfd_elf_copy_private_bfd_data): Copy object attributes. (bfd_section_from_shdr): Handle attributes sections. * elflink.c (bfd_elf_final_link): Handle attributes sections. * elfxx-target.h (elf_backend_obj_attrs_vendor, elf_backend_obj_attrs_section, elf_backend_obj_attrs_arg_type, elf_backend_obj_attrs_section_type): New. (elfNN_bed): Update. * elf32-arm.c (NUM_KNOWN_ATTRIBUTES, aeabi_attribute, aeabi_attribute_list): Remove. (struct elf32_arm_obj_tdata): Remove object attributes fields. (check_use_blx, bfd_elf32_arm_set_vfp11_fix, using_thumb2, elf32_arm_copy_private_bfd_data, elf32_arm_merge_eabi_attributes): Update for new object attributes interfaces. (uleb128_size, is_default_attr, eabi_attr_size, elf32_arm_eabi_attr_size, write_uleb128, write_eabi_attribute, elf32_arm_set_eabi_attr_contents, elf32_arm_bfd_final_link, elf32_arm_new_eabi_attr, elf32_arm_get_eabi_attr_int, elf32_arm_add_eabi_attr_int, attr_strdup, elf32_arm_add_eabi_attr_string, elf32_arm_add_eabi_attr_compat, copy_eabi_attributes, elf32_arm_parse_attributes): Remove. Moved to generic code in elf-attrs.c. (elf32_arm_obj_attrs_arg_type): New. (elf32_arm_fake_sections): Do not handle .ARM.attributes. (elf32_arm_section_from_shdr): Do not handle SHT_ARM_ATTRIBUTES. (bfd_elf32_bfd_final_link): Remove. (elf_backend_obj_attrs_vendor, elf_backend_obj_attrs_section, elf_backend_obj_attrs_arg_type, elf_backend_obj_attrs_section_type): New. * elf32-bfin.c (bfin_elf_copy_private_bfd_data): Copy object attributes. * elf32-frv.c (frv_elf_copy_private_bfd_data): Likewise. * elf32-iq2000.c (iq2000_elf_copy_private_bfd_data): Likewise. * elf32-mep.c (mep_elf_copy_private_bfd_data): Likewise. * elf32-mt.c (mt_elf_copy_private_bfd_data): Likewise. * elf32-sh.c (sh_elf_copy_private_data): Likewise. * elf64-sh64.c (sh_elf64_copy_private_data_internal): Likewise. binutils: * readelf.c (display_gnu_attribute): New. (process_arm_specific): Rearrange as process_attributes. (process_arm_specific): Replace by wrapper of process_attributes. gas: * as.c (create_obj_attrs_section): New. (main): Call create_obj_attrs_section for ELF. * read.c (s_gnu_attribute, skip_whitespace, skip_past_char, skip_past_comma, s_vendor_attribute): New. (potable): Add gnu_attribute for ELF. * read.h (s_vendor_attribute): Declare. * config/tc-arm.c (s_arm_eabi_attribute): Replace by wrapper round s_vendor_attribute. (aeabi_set_public_attributes): Update for new attributes interfaces. (arm_md_end): Remove attributes contents setting now done generically. include/elf: * arm.h (elf32_arm_add_eabi_attr_int, elf32_arm_add_eabi_attr_string, elf32_arm_add_eabi_attr_compat, elf32_arm_get_eabi_attr_int, elf32_arm_set_eabi_attr_contents, elf32_arm_eabi_attr_size, Tag_NULL, Tag_File, Tag_Section, Tag_Symbol, Tag_compatibility): Remove. * common.h (SHT_GNU_ATTRIBUTES): Define. ld: * emulparams/armelf.sh (OTHER_SECTIONS): Remove .ARM.attributes. (ATTRS_SECTIONS): Define. * scripttempl/elf.sc, scripttempl/elf32sh-symbian.sc, scripttempl/elf_chaos.sc, scripttempl/elfi370.sc, scripttempl/elfxtensa.sc: Handle ATTRS_SECTIONS.
2007-06-29 18:29:17 +02:00
/* Copy object attributes. */
_bfd_elf_copy_obj_attributes (ibfd, obfd);
return TRUE;
}
static const char *
get_segment_type (unsigned int p_type)
{
const char *pt;
switch (p_type)
{
case PT_NULL: pt = "NULL"; break;
case PT_LOAD: pt = "LOAD"; break;
case PT_DYNAMIC: pt = "DYNAMIC"; break;
case PT_INTERP: pt = "INTERP"; break;
case PT_NOTE: pt = "NOTE"; break;
case PT_SHLIB: pt = "SHLIB"; break;
case PT_PHDR: pt = "PHDR"; break;
case PT_TLS: pt = "TLS"; break;
case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
case PT_GNU_STACK: pt = "STACK"; break;
case PT_GNU_RELRO: pt = "RELRO"; break;
default: pt = NULL; break;
}
return pt;
}
/* Print out the program headers. */
bfd_boolean
_bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
1999-05-03 09:29:11 +02:00
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
FILE *f = (FILE *) farg;
1999-05-03 09:29:11 +02:00
Elf_Internal_Phdr *p;
asection *s;
bfd_byte *dynbuf = NULL;
p = elf_tdata (abfd)->phdr;
if (p != NULL)
{
unsigned int i, c;
fprintf (f, _("\nProgram Header:\n"));
c = elf_elfheader (abfd)->e_phnum;
for (i = 0; i < c; i++, p++)
{
const char *pt = get_segment_type (p->p_type);
1999-05-03 09:29:11 +02:00
char buf[20];
if (pt == NULL)
1999-05-03 09:29:11 +02:00
{
sprintf (buf, "0x%lx", p->p_type);
pt = buf;
1999-05-03 09:29:11 +02:00
}
fprintf (f, "%8s off 0x", pt);
bfd_fprintf_vma (abfd, f, p->p_offset);
1999-05-03 09:29:11 +02:00
fprintf (f, " vaddr 0x");
bfd_fprintf_vma (abfd, f, p->p_vaddr);
1999-05-03 09:29:11 +02:00
fprintf (f, " paddr 0x");
bfd_fprintf_vma (abfd, f, p->p_paddr);
1999-05-03 09:29:11 +02:00
fprintf (f, " align 2**%u\n", bfd_log2 (p->p_align));
fprintf (f, " filesz 0x");
bfd_fprintf_vma (abfd, f, p->p_filesz);
1999-05-03 09:29:11 +02:00
fprintf (f, " memsz 0x");
bfd_fprintf_vma (abfd, f, p->p_memsz);
1999-05-03 09:29:11 +02:00
fprintf (f, " flags %c%c%c",
(p->p_flags & PF_R) != 0 ? 'r' : '-',
(p->p_flags & PF_W) != 0 ? 'w' : '-',
(p->p_flags & PF_X) != 0 ? 'x' : '-');
if ((p->p_flags &~ (unsigned) (PF_R | PF_W | PF_X)) != 0)
fprintf (f, " %lx", p->p_flags &~ (unsigned) (PF_R | PF_W | PF_X));
1999-05-03 09:29:11 +02:00
fprintf (f, "\n");
}
}
s = bfd_get_section_by_name (abfd, ".dynamic");
if (s != NULL)
{
unsigned int elfsec;
unsigned long shlink;
1999-05-03 09:29:11 +02:00
bfd_byte *extdyn, *extdynend;
size_t extdynsize;
void (*swap_dyn_in) (bfd *, const void *, Elf_Internal_Dyn *);
1999-05-03 09:29:11 +02:00
fprintf (f, _("\nDynamic Section:\n"));
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 06:46:28 +02:00
if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
1999-05-03 09:29:11 +02:00
goto error_return;
elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
if (elfsec == SHN_BAD)
1999-05-03 09:29:11 +02:00
goto error_return;
shlink = elf_elfsections (abfd)[elfsec]->sh_link;
1999-05-03 09:29:11 +02:00
extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
extdyn = dynbuf;
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 06:46:28 +02:00
extdynend = extdyn + s->size;
1999-05-03 09:29:11 +02:00
for (; extdyn < extdynend; extdyn += extdynsize)
{
Elf_Internal_Dyn dyn;
const char *name = "";
1999-05-03 09:29:11 +02:00
char ab[20];
bfd_boolean stringp;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
(*swap_dyn_in) (abfd, extdyn, &dyn);
1999-05-03 09:29:11 +02:00
if (dyn.d_tag == DT_NULL)
break;
stringp = FALSE;
1999-05-03 09:29:11 +02:00
switch (dyn.d_tag)
{
default:
if (bed->elf_backend_get_target_dtag)
name = (*bed->elf_backend_get_target_dtag) (dyn.d_tag);
if (!strcmp (name, ""))
{
sprintf (ab, "0x%lx", (unsigned long) dyn.d_tag);
name = ab;
}
1999-05-03 09:29:11 +02:00
break;
case DT_NEEDED: name = "NEEDED"; stringp = TRUE; break;
1999-05-03 09:29:11 +02:00
case DT_PLTRELSZ: name = "PLTRELSZ"; break;
case DT_PLTGOT: name = "PLTGOT"; break;
case DT_HASH: name = "HASH"; break;
case DT_STRTAB: name = "STRTAB"; break;
case DT_SYMTAB: name = "SYMTAB"; break;
case DT_RELA: name = "RELA"; break;
case DT_RELASZ: name = "RELASZ"; break;
case DT_RELAENT: name = "RELAENT"; break;
case DT_STRSZ: name = "STRSZ"; break;
case DT_SYMENT: name = "SYMENT"; break;
case DT_INIT: name = "INIT"; break;
case DT_FINI: name = "FINI"; break;
case DT_SONAME: name = "SONAME"; stringp = TRUE; break;
case DT_RPATH: name = "RPATH"; stringp = TRUE; break;
1999-05-03 09:29:11 +02:00
case DT_SYMBOLIC: name = "SYMBOLIC"; break;
case DT_REL: name = "REL"; break;
case DT_RELSZ: name = "RELSZ"; break;
case DT_RELENT: name = "RELENT"; break;
case DT_PLTREL: name = "PLTREL"; break;
case DT_DEBUG: name = "DEBUG"; break;
case DT_TEXTREL: name = "TEXTREL"; break;
case DT_JMPREL: name = "JMPREL"; break;
case DT_BIND_NOW: name = "BIND_NOW"; break;
case DT_INIT_ARRAY: name = "INIT_ARRAY"; break;
case DT_FINI_ARRAY: name = "FINI_ARRAY"; break;
case DT_INIT_ARRAYSZ: name = "INIT_ARRAYSZ"; break;
case DT_FINI_ARRAYSZ: name = "FINI_ARRAYSZ"; break;
case DT_RUNPATH: name = "RUNPATH"; stringp = TRUE; break;
case DT_FLAGS: name = "FLAGS"; break;
case DT_PREINIT_ARRAY: name = "PREINIT_ARRAY"; break;
case DT_PREINIT_ARRAYSZ: name = "PREINIT_ARRAYSZ"; break;
case DT_CHECKSUM: name = "CHECKSUM"; break;
case DT_PLTPADSZ: name = "PLTPADSZ"; break;
case DT_MOVEENT: name = "MOVEENT"; break;
case DT_MOVESZ: name = "MOVESZ"; break;
case DT_FEATURE: name = "FEATURE"; break;
case DT_POSFLAG_1: name = "POSFLAG_1"; break;
case DT_SYMINSZ: name = "SYMINSZ"; break;
case DT_SYMINENT: name = "SYMINENT"; break;
case DT_CONFIG: name = "CONFIG"; stringp = TRUE; break;
case DT_DEPAUDIT: name = "DEPAUDIT"; stringp = TRUE; break;
case DT_AUDIT: name = "AUDIT"; stringp = TRUE; break;
case DT_PLTPAD: name = "PLTPAD"; break;
case DT_MOVETAB: name = "MOVETAB"; break;
case DT_SYMINFO: name = "SYMINFO"; break;
case DT_RELACOUNT: name = "RELACOUNT"; break;
case DT_RELCOUNT: name = "RELCOUNT"; break;
case DT_FLAGS_1: name = "FLAGS_1"; break;
1999-05-03 09:29:11 +02:00
case DT_VERSYM: name = "VERSYM"; break;
case DT_VERDEF: name = "VERDEF"; break;
case DT_VERDEFNUM: name = "VERDEFNUM"; break;
case DT_VERNEED: name = "VERNEED"; break;
case DT_VERNEEDNUM: name = "VERNEEDNUM"; break;
case DT_AUXILIARY: name = "AUXILIARY"; stringp = TRUE; break;
case DT_USED: name = "USED"; break;
case DT_FILTER: name = "FILTER"; stringp = TRUE; break;
include/ * bfdlink.h (struct bfd_link_info): Add emit_hash and emit_gnu_hash bitfields. include/elf/ * common.h (SHT_GNU_HASH, DT_GNU_HASH): Define. ld/ * scripttempl/elf.sc: Add .gnu.hash section. * emultempl/elf32.em (OPTION_HASH_STYLE): Define. (gld${EMULATION_NAME}_add_options): Register --hash-style option. (gld${EMULATION_NAME}_handle_option): Handle it. (gld${EMULATION_NAME}_list_options): Document it. * ldmain.c (main): Initialize emit_hash and emit_gnu_hash. * ld.texinfo: Document --hash-style option. bfd/ * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_GNU_HASH. (bfd_section_from_shdr, elf_fake_sections, assign_section_numbers): Handle SHT_GNU_HASH. (special_sections_g): Include .gnu.hash section. (bfd_elf_gnu_hash): New function. * elf-bfd.h (bfd_elf_gnu_hash, _bfd_elf_hash_symbol): New prototypes. (struct elf_backend_data): Add elf_hash_symbol method. * elflink.c (_bfd_elf_link_create_dynamic_sections): Create .hash only if info->emit_hash, create .gnu.hash section if info->emit_gnu_hash. (struct collect_gnu_hash_codes): New type. (elf_collect_gnu_hash_codes, elf_renumber_gnu_hash_syms, _bfd_elf_hash_symbol): New functions. (compute_bucket_count): Don't compute HASHCODES array, instead add that and NSYMS as arguments. Use bed->s->sizeof_hash_entry instead of bed->s->arch_size / 8. Fix .hash size estimation. When not optimizing, use the number of hashed symbols rather than dynsymcount. (bfd_elf_size_dynamic_sections): Only add DT_HASH if info->emit_hash, and ADD DT_GNU_HASH if info->emit_gnu_hash. (bfd_elf_size_dynsym_hash_dynstr): Size .hash only if info->emit_hash, adjust compute_bucket_count caller. Create and populate .gnu.hash section if info->emit_gnu_hash. (elf_link_output_extsym): Only populate .hash section if finfo->hash_sec != NULL. (bfd_elf_final_link): Adjust assertion. Handle DT_GNU_HASH. * elfxx-target.h (elf_backend_hash_symbol): Define if not yet defined. (elfNN_bed): Add elf_backend_hash_symbol. * elf64-x86-64.c (elf64_x86_64_hash_symbol): New function. (elf_backend_hash_symbol): Define. * elf32-i386.c (elf_i386_hash_symbol): New function. (elf_backend_hash_symbol): Define. binutils/ * readelf.c (get_dynamic_type): Handle DT_GNU_HASH. (get_section_type_name): Handle SHT_GNU_HASH. (dynamic_info_DT_GNU_HASH): New variable. (process_dynamic_section): Handle DT_GNU_HASH. (process_symbol_table): Print also DT_GNU_HASH histogram. ld/testsuite/ * ld-powerpc/tlsso32.r: Adjust. * ld-powerpc/tlsso32.d: Adjust. * ld-powerpc/tlsso32.g: Adjust. * ld-powerpc/tlsso.r: Adjust. * ld-powerpc/tlsso.g: Adjust. * ld-powerpc/tlstocso.g: Adjust.
2006-07-10 23:40:25 +02:00
case DT_GNU_HASH: name = "GNU_HASH"; break;
1999-05-03 09:29:11 +02:00
}
fprintf (f, " %-20s ", name);
1999-05-03 09:29:11 +02:00
if (! stringp)
{
fprintf (f, "0x");
bfd_fprintf_vma (abfd, f, dyn.d_un.d_val);
}
1999-05-03 09:29:11 +02:00
else
{
const char *string;
unsigned int tagv = dyn.d_un.d_val;
1999-05-03 09:29:11 +02:00
string = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
1999-05-03 09:29:11 +02:00
if (string == NULL)
goto error_return;
fprintf (f, "%s", string);
}
fprintf (f, "\n");
}
free (dynbuf);
dynbuf = NULL;
}
if ((elf_dynverdef (abfd) != 0 && elf_tdata (abfd)->verdef == NULL)
|| (elf_dynverref (abfd) != 0 && elf_tdata (abfd)->verref == NULL))
{
if (! _bfd_elf_slurp_version_tables (abfd, FALSE))
return FALSE;
1999-05-03 09:29:11 +02:00
}
if (elf_dynverdef (abfd) != 0)
{
Elf_Internal_Verdef *t;
fprintf (f, _("\nVersion definitions:\n"));
for (t = elf_tdata (abfd)->verdef; t != NULL; t = t->vd_nextdef)
{
fprintf (f, "%d 0x%2.2x 0x%8.8lx %s\n", t->vd_ndx,
t->vd_flags, t->vd_hash,
t->vd_nodename ? t->vd_nodename : "<corrupt>");
if (t->vd_auxptr != NULL && t->vd_auxptr->vda_nextptr != NULL)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Verdaux *a;
fprintf (f, "\t");
for (a = t->vd_auxptr->vda_nextptr;
a != NULL;
a = a->vda_nextptr)
fprintf (f, "%s ",
a->vda_nodename ? a->vda_nodename : "<corrupt>");
1999-05-03 09:29:11 +02:00
fprintf (f, "\n");
}
}
}
if (elf_dynverref (abfd) != 0)
{
Elf_Internal_Verneed *t;
fprintf (f, _("\nVersion References:\n"));
for (t = elf_tdata (abfd)->verref; t != NULL; t = t->vn_nextref)
{
Elf_Internal_Vernaux *a;
fprintf (f, _(" required from %s:\n"),
t->vn_filename ? t->vn_filename : "<corrupt>");
1999-05-03 09:29:11 +02:00
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
fprintf (f, " 0x%8.8lx 0x%2.2x %2.2d %s\n", a->vna_hash,
a->vna_flags, a->vna_other,
a->vna_nodename ? a->vna_nodename : "<corrupt>");
1999-05-03 09:29:11 +02:00
}
}
return TRUE;
1999-05-03 09:29:11 +02:00
error_return:
if (dynbuf != NULL)
free (dynbuf);
return FALSE;
1999-05-03 09:29:11 +02:00
}
/* Display ELF-specific fields of a symbol. */
void
bfd_elf_print_symbol (bfd *abfd,
void *filep,
asymbol *symbol,
bfd_print_symbol_type how)
1999-05-03 09:29:11 +02:00
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
FILE *file = (FILE *) filep;
1999-05-03 09:29:11 +02:00
switch (how)
{
case bfd_print_symbol_name:
fprintf (file, "%s", symbol->name);
break;
case bfd_print_symbol_more:
fprintf (file, "elf ");
bfd_fprintf_vma (abfd, file, symbol->value);
2008-07-30 06:34:58 +02:00
fprintf (file, " %lx", (unsigned long) symbol->flags);
1999-05-03 09:29:11 +02:00
break;
case bfd_print_symbol_all:
{
const char *section_name;
const char *name = NULL;
const struct elf_backend_data *bed;
unsigned char st_other;
bfd_vma val;
1999-05-03 09:29:11 +02:00
section_name = symbol->section ? symbol->section->name : "(*none*)";
bed = get_elf_backend_data (abfd);
if (bed->elf_backend_print_symbol_all)
name = (*bed->elf_backend_print_symbol_all) (abfd, filep, symbol);
if (name == NULL)
{
name = symbol->name;
bfd_print_symbol_vandf (abfd, file, symbol);
}
1999-05-03 09:29:11 +02:00
fprintf (file, " %s\t", section_name);
/* Print the "other" value for a symbol. For common symbols,
we've already printed the size; now print the alignment.
For other symbols, we have no specified alignment, and
we've printed the address; now print the size. */
if (symbol->section && bfd_is_com_section (symbol->section))
val = ((elf_symbol_type *) symbol)->internal_elf_sym.st_value;
else
val = ((elf_symbol_type *) symbol)->internal_elf_sym.st_size;
bfd_fprintf_vma (abfd, file, val);
1999-05-03 09:29:11 +02:00
/* If we have version information, print it. */
if (elf_tdata (abfd)->dynversym_section != 0
&& (elf_tdata (abfd)->dynverdef_section != 0
|| elf_tdata (abfd)->dynverref_section != 0))
{
unsigned int vernum;
const char *version_string;
vernum = ((elf_symbol_type *) symbol)->version & VERSYM_VERSION;
if (vernum == 0)
version_string = "";
else if (vernum == 1)
version_string = "Base";
else if (vernum <= elf_tdata (abfd)->cverdefs)
version_string =
elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
else
{
Elf_Internal_Verneed *t;
version_string = "";
for (t = elf_tdata (abfd)->verref;
t != NULL;
t = t->vn_nextref)
{
Elf_Internal_Vernaux *a;
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
{
if (a->vna_other == vernum)
{
version_string = a->vna_nodename;
break;
}
}
}
}
if ((((elf_symbol_type *) symbol)->version & VERSYM_HIDDEN) == 0)
fprintf (file, " %-11s", version_string);
else
{
int i;
fprintf (file, " (%s)", version_string);
for (i = 10 - strlen (version_string); i > 0; --i)
putc (' ', file);
}
}
/* If the st_other field is not zero, print it. */
st_other = ((elf_symbol_type *) symbol)->internal_elf_sym.st_other;
switch (st_other)
{
case 0: break;
case STV_INTERNAL: fprintf (file, " .internal"); break;
case STV_HIDDEN: fprintf (file, " .hidden"); break;
case STV_PROTECTED: fprintf (file, " .protected"); break;
default:
/* Some other non-defined flags are also present, so print
everything hex. */
fprintf (file, " 0x%02x", (unsigned int) st_other);
}
1999-05-03 09:29:11 +02:00
fprintf (file, " %s", name);
1999-05-03 09:29:11 +02:00
}
break;
}
}
/* Allocate an ELF string table--force the first byte to be zero. */
struct bfd_strtab_hash *
_bfd_elf_stringtab_init (void)
1999-05-03 09:29:11 +02:00
{
struct bfd_strtab_hash *ret;
ret = _bfd_stringtab_init ();
if (ret != NULL)
{
bfd_size_type loc;
loc = _bfd_stringtab_add (ret, "", TRUE, FALSE);
1999-05-03 09:29:11 +02:00
BFD_ASSERT (loc == 0 || loc == (bfd_size_type) -1);
if (loc == (bfd_size_type) -1)
{
_bfd_stringtab_free (ret);
ret = NULL;
}
}
return ret;
}
/* ELF .o/exec file reading */
/* Create a new bfd section from an ELF section header. */
1999-05-03 09:29:11 +02:00
bfd_boolean
bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
1999-05-03 09:29:11 +02:00
{
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
Elf_Internal_Shdr *hdr;
Elf_Internal_Ehdr *ehdr;
const struct elf_backend_data *bed;
const char *name;
1999-05-03 09:29:11 +02:00
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
if (shindex >= elf_numsections (abfd))
return FALSE;
hdr = elf_elfsections (abfd)[shindex];
ehdr = elf_elfheader (abfd);
name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx,
hdr->sh_name);
if (name == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
switch (hdr->sh_type)
{
case SHT_NULL:
/* Inactive section. Throw it away. */
return TRUE;
1999-05-03 09:29:11 +02:00
case SHT_PROGBITS: /* Normal section with contents. */
case SHT_NOBITS: /* .bss section. */
case SHT_HASH: /* .hash section. */
case SHT_NOTE: /* .note section. */
case SHT_INIT_ARRAY: /* .init_array section. */
case SHT_FINI_ARRAY: /* .fini_array section. */
case SHT_PREINIT_ARRAY: /* .preinit_array section. */
case SHT_GNU_LIBLIST: /* .gnu.liblist section. */
include/ * bfdlink.h (struct bfd_link_info): Add emit_hash and emit_gnu_hash bitfields. include/elf/ * common.h (SHT_GNU_HASH, DT_GNU_HASH): Define. ld/ * scripttempl/elf.sc: Add .gnu.hash section. * emultempl/elf32.em (OPTION_HASH_STYLE): Define. (gld${EMULATION_NAME}_add_options): Register --hash-style option. (gld${EMULATION_NAME}_handle_option): Handle it. (gld${EMULATION_NAME}_list_options): Document it. * ldmain.c (main): Initialize emit_hash and emit_gnu_hash. * ld.texinfo: Document --hash-style option. bfd/ * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_GNU_HASH. (bfd_section_from_shdr, elf_fake_sections, assign_section_numbers): Handle SHT_GNU_HASH. (special_sections_g): Include .gnu.hash section. (bfd_elf_gnu_hash): New function. * elf-bfd.h (bfd_elf_gnu_hash, _bfd_elf_hash_symbol): New prototypes. (struct elf_backend_data): Add elf_hash_symbol method. * elflink.c (_bfd_elf_link_create_dynamic_sections): Create .hash only if info->emit_hash, create .gnu.hash section if info->emit_gnu_hash. (struct collect_gnu_hash_codes): New type. (elf_collect_gnu_hash_codes, elf_renumber_gnu_hash_syms, _bfd_elf_hash_symbol): New functions. (compute_bucket_count): Don't compute HASHCODES array, instead add that and NSYMS as arguments. Use bed->s->sizeof_hash_entry instead of bed->s->arch_size / 8. Fix .hash size estimation. When not optimizing, use the number of hashed symbols rather than dynsymcount. (bfd_elf_size_dynamic_sections): Only add DT_HASH if info->emit_hash, and ADD DT_GNU_HASH if info->emit_gnu_hash. (bfd_elf_size_dynsym_hash_dynstr): Size .hash only if info->emit_hash, adjust compute_bucket_count caller. Create and populate .gnu.hash section if info->emit_gnu_hash. (elf_link_output_extsym): Only populate .hash section if finfo->hash_sec != NULL. (bfd_elf_final_link): Adjust assertion. Handle DT_GNU_HASH. * elfxx-target.h (elf_backend_hash_symbol): Define if not yet defined. (elfNN_bed): Add elf_backend_hash_symbol. * elf64-x86-64.c (elf64_x86_64_hash_symbol): New function. (elf_backend_hash_symbol): Define. * elf32-i386.c (elf_i386_hash_symbol): New function. (elf_backend_hash_symbol): Define. binutils/ * readelf.c (get_dynamic_type): Handle DT_GNU_HASH. (get_section_type_name): Handle SHT_GNU_HASH. (dynamic_info_DT_GNU_HASH): New variable. (process_dynamic_section): Handle DT_GNU_HASH. (process_symbol_table): Print also DT_GNU_HASH histogram. ld/testsuite/ * ld-powerpc/tlsso32.r: Adjust. * ld-powerpc/tlsso32.d: Adjust. * ld-powerpc/tlsso32.g: Adjust. * ld-powerpc/tlsso.r: Adjust. * ld-powerpc/tlsso.g: Adjust. * ld-powerpc/tlstocso.g: Adjust.
2006-07-10 23:40:25 +02:00
case SHT_GNU_HASH: /* .gnu.hash section. */
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1999-05-03 09:29:11 +02:00
case SHT_DYNAMIC: /* Dynamic linking information. */
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
return FALSE;
if (hdr->sh_link > elf_numsections (abfd))
{
/* PR 10478: Accept Solaris binaries with a sh_link
field set to SHN_BEFORE or SHN_AFTER. */
switch (bfd_get_arch (abfd))
{
case bfd_arch_i386:
case bfd_arch_sparc:
if (hdr->sh_link == (SHN_LORESERVE & 0xffff) /* SHN_BEFORE */
|| hdr->sh_link == ((SHN_LORESERVE + 1) & 0xffff) /* SHN_AFTER */)
break;
/* Otherwise fall through. */
default:
return FALSE;
}
}
else if (elf_elfsections (abfd)[hdr->sh_link] == NULL)
return FALSE;
else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
{
Elf_Internal_Shdr *dynsymhdr;
/* The shared libraries distributed with hpux11 have a bogus
sh_link field for the ".dynamic" section. Find the
string table for the ".dynsym" section instead. */
if (elf_dynsymtab (abfd) != 0)
{
dynsymhdr = elf_elfsections (abfd)[elf_dynsymtab (abfd)];
hdr->sh_link = dynsymhdr->sh_link;
}
else
{
unsigned int i, num_sec;
num_sec = elf_numsections (abfd);
for (i = 1; i < num_sec; i++)
{
dynsymhdr = elf_elfsections (abfd)[i];
if (dynsymhdr->sh_type == SHT_DYNSYM)
{
hdr->sh_link = dynsymhdr->sh_link;
break;
}
}
}
}
break;
1999-05-03 09:29:11 +02:00
case SHT_SYMTAB: /* A symbol table */
if (elf_onesymtab (abfd) == shindex)
return TRUE;
1999-05-03 09:29:11 +02:00
if (hdr->sh_entsize != bed->s->sizeof_sym)
return FALSE;
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
{
if (hdr->sh_size != 0)
return FALSE;
/* Some assemblers erroneously set sh_info to one with a
zero sh_size. ld sees this as a global symbol count
of (unsigned) -1. Fix it here. */
hdr->sh_info = 0;
return TRUE;
}
1999-05-03 09:29:11 +02:00
BFD_ASSERT (elf_onesymtab (abfd) == 0);
elf_onesymtab (abfd) = shindex;
elf_tdata (abfd)->symtab_hdr = *hdr;
elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->symtab_hdr;
abfd->flags |= HAS_SYMS;
/* Sometimes a shared object will map in the symbol table. If
SHF_ALLOC is set, and this is a shared object, then we also
treat this section as a BFD section. We can not base the
decision purely on SHF_ALLOC, because that flag is sometimes
set in a relocatable object file, which would confuse the
linker. */
1999-05-03 09:29:11 +02:00
if ((hdr->sh_flags & SHF_ALLOC) != 0
&& (abfd->flags & DYNAMIC) != 0
&& ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
shindex))
return FALSE;
1999-05-03 09:29:11 +02:00
/* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
can't read symbols without that section loaded as well. It
is most likely specified by the next section header. */
if (elf_elfsections (abfd)[elf_symtab_shndx (abfd)]->sh_link != shindex)
{
unsigned int i, num_sec;
num_sec = elf_numsections (abfd);
for (i = shindex + 1; i < num_sec; i++)
{
Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
if (hdr2->sh_type == SHT_SYMTAB_SHNDX
&& hdr2->sh_link == shindex)
break;
}
if (i == num_sec)
for (i = 1; i < shindex; i++)
{
Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
if (hdr2->sh_type == SHT_SYMTAB_SHNDX
&& hdr2->sh_link == shindex)
break;
}
if (i != shindex)
return bfd_section_from_shdr (abfd, i);
}
return TRUE;
1999-05-03 09:29:11 +02:00
case SHT_DYNSYM: /* A dynamic symbol table */
if (elf_dynsymtab (abfd) == shindex)
return TRUE;
1999-05-03 09:29:11 +02:00
if (hdr->sh_entsize != bed->s->sizeof_sym)
return FALSE;
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
{
if (hdr->sh_size != 0)
return FALSE;
/* Some linkers erroneously set sh_info to one with a
zero sh_size. ld sees this as a global symbol count
of (unsigned) -1. Fix it here. */
hdr->sh_info = 0;
return TRUE;
}
1999-05-03 09:29:11 +02:00
BFD_ASSERT (elf_dynsymtab (abfd) == 0);
elf_dynsymtab (abfd) = shindex;
elf_tdata (abfd)->dynsymtab_hdr = *hdr;
elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->dynsymtab_hdr;
abfd->flags |= HAS_SYMS;
/* Besides being a symbol table, we also treat this as a regular
section, so that objcopy can handle it. */
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1999-05-03 09:29:11 +02:00
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */
if (elf_symtab_shndx (abfd) == shindex)
return TRUE;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
BFD_ASSERT (elf_symtab_shndx (abfd) == 0);
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
elf_symtab_shndx (abfd) = shindex;
elf_tdata (abfd)->symtab_shndx_hdr = *hdr;
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr;
return TRUE;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
1999-05-03 09:29:11 +02:00
case SHT_STRTAB: /* A string table */
if (hdr->bfd_section != NULL)
return TRUE;
1999-05-03 09:29:11 +02:00
if (ehdr->e_shstrndx == shindex)
{
elf_tdata (abfd)->shstrtab_hdr = *hdr;
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
return TRUE;
1999-05-03 09:29:11 +02:00
}
if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex)
{
symtab_strtab:
elf_tdata (abfd)->strtab_hdr = *hdr;
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr;
return TRUE;
}
if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex)
{
dynsymtab_strtab:
elf_tdata (abfd)->dynstrtab_hdr = *hdr;
hdr = &elf_tdata (abfd)->dynstrtab_hdr;
elf_elfsections (abfd)[shindex] = hdr;
/* We also treat this as a regular section, so that objcopy
can handle it. */
return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
shindex);
}
1999-05-03 09:29:11 +02:00
/* If the string table isn't one of the above, then treat it as a
regular section. We need to scan all the headers to be sure,
just in case this strtab section appeared before the above. */
if (elf_onesymtab (abfd) == 0 || elf_dynsymtab (abfd) == 0)
{
unsigned int i, num_sec;
1999-05-03 09:29:11 +02:00
num_sec = elf_numsections (abfd);
for (i = 1; i < num_sec; i++)
{
Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
if (hdr2->sh_link == shindex)
{
/* Prevent endless recursion on broken objects. */
if (i == shindex)
return FALSE;
if (! bfd_section_from_shdr (abfd, i))
return FALSE;
if (elf_onesymtab (abfd) == i)
goto symtab_strtab;
if (elf_dynsymtab (abfd) == i)
goto dynsymtab_strtab;
}
}
}
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1999-05-03 09:29:11 +02:00
case SHT_REL:
case SHT_RELA:
/* *These* do a lot of work -- but build no sections! */
{
asection *target_sect;
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
Elf_Internal_Shdr *hdr2, **p_hdr;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
unsigned int num_sec = elf_numsections (abfd);
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
struct bfd_elf_section_data *esdt;
bfd_size_type amt;
1999-05-03 09:29:11 +02:00
if (hdr->sh_entsize
!= (bfd_size_type) (hdr->sh_type == SHT_REL
? bed->s->sizeof_rel : bed->s->sizeof_rela))
return FALSE;
/* Check for a bogus link to avoid crashing. */
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
if (hdr->sh_link >= num_sec)
{
((*_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 05:16:01 +02:00
(_("%B: invalid link %lu for reloc section %s (index %u)"),
abfd, hdr->sh_link, name, shindex));
return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
shindex);
}
1999-05-03 09:29:11 +02:00
/* For some incomprehensible reason Oracle distributes
libraries for Solaris in which some of the objects have
bogus sh_link fields. It would be nice if we could just
reject them, but, unfortunately, some people need to use
them. We scan through the section headers; if we find only
one suitable symbol table, we clobber the sh_link to point
to it. I hope this doesn't break anything.
Don't do it on executable nor shared library. */
if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0
&& elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
1999-05-03 09:29:11 +02:00
&& elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)
{
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
unsigned int scan;
1999-05-03 09:29:11 +02:00
int found;
found = 0;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
for (scan = 1; scan < num_sec; scan++)
1999-05-03 09:29:11 +02:00
{
if (elf_elfsections (abfd)[scan]->sh_type == SHT_SYMTAB
|| elf_elfsections (abfd)[scan]->sh_type == SHT_DYNSYM)
{
if (found != 0)
{
found = 0;
break;
}
found = scan;
}
}
if (found != 0)
hdr->sh_link = found;
}
/* Get the symbol table. */
if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
|| elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)
1999-05-03 09:29:11 +02:00
&& ! bfd_section_from_shdr (abfd, hdr->sh_link))
return FALSE;
1999-05-03 09:29:11 +02:00
/* If this reloc section does not use the main symbol table we
don't treat it as a reloc section. BFD can't adequately
represent such a section, so at least for now, we don't
try. We just present it as a normal section. We also
can't use it as a reloc section if it points to the null
section, an invalid section, another reloc section, or its
sh_link points to the null section. */
if (hdr->sh_link != elf_onesymtab (abfd)
|| hdr->sh_link == SHN_UNDEF
|| hdr->sh_info == SHN_UNDEF
|| hdr->sh_info >= num_sec
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA)
return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
shindex);
1999-05-03 09:29:11 +02:00
if (! bfd_section_from_shdr (abfd, hdr->sh_info))
return FALSE;
1999-05-03 09:29:11 +02:00
target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
if (target_sect == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
esdt = elf_section_data (target_sect);
if (hdr->sh_type == SHT_RELA)
p_hdr = &esdt->rela.hdr;
1999-05-03 09:29:11 +02:00
else
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
p_hdr = &esdt->rel.hdr;
BFD_ASSERT (*p_hdr == NULL);
amt = sizeof (*hdr2);
hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
if (hdr2 == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
*hdr2 = *hdr;
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
*p_hdr = hdr2;
1999-05-03 09:29:11 +02:00
elf_elfsections (abfd)[shindex] = hdr2;
target_sect->reloc_count += NUM_SHDR_ENTRIES (hdr);
1999-05-03 09:29:11 +02:00
target_sect->flags |= SEC_RELOC;
target_sect->relocation = NULL;
target_sect->rel_filepos = hdr->sh_offset;
/* In the section to which the relocations apply, mark whether
its relocations are of the REL or RELA variety. */
2000-05-09 02:43:44 +02:00
if (hdr->sh_size != 0)
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
{
if (hdr->sh_type == SHT_RELA)
target_sect->use_rela_p = 1;
}
1999-05-03 09:29:11 +02:00
abfd->flags |= HAS_RELOC;
return TRUE;
1999-05-03 09:29:11 +02:00
}
case SHT_GNU_verdef:
elf_dynverdef (abfd) = shindex;
elf_tdata (abfd)->dynverdef_hdr = *hdr;
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1999-05-03 09:29:11 +02:00
case SHT_GNU_versym:
if (hdr->sh_entsize != sizeof (Elf_External_Versym))
return FALSE;
1999-05-03 09:29:11 +02:00
elf_dynversym (abfd) = shindex;
elf_tdata (abfd)->dynversym_hdr = *hdr;
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1999-05-03 09:29:11 +02:00
case SHT_GNU_verneed:
elf_dynverref (abfd) = shindex;
elf_tdata (abfd)->dynverref_hdr = *hdr;
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
1999-05-03 09:29:11 +02:00
case SHT_SHLIB:
return TRUE;
1999-05-03 09:29:11 +02:00
case SHT_GROUP:
if (! IS_VALID_GROUP_SECTION_HEADER (hdr))
return FALSE;
if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
return FALSE;
if (hdr->contents != NULL)
{
Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents;
unsigned int n_elt = hdr->sh_size / GRP_ENTRY_SIZE;
asection *s;
if (idx->flags & GRP_COMDAT)
hdr->bfd_section->flags
|= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
/* We try to keep the same section order as it comes in. */
idx += n_elt;
while (--n_elt != 0)
{
--idx;
if (idx->shdr != NULL
&& (s = idx->shdr->bfd_section) != NULL
&& elf_next_in_group (s) != NULL)
{
elf_next_in_group (hdr->bfd_section) = s;
break;
}
}
}
break;
1999-05-03 09:29:11 +02:00
default:
bfd: * elf-attrs.c: New. * Makefile.am (BFD32_BACKENDS): Add elf-attrs.lo. (BFD32_BACKENDS_CFILES): Add elf-attrs.c. (elf-attrs.lo): Generate dependencies. * Makefile.in: Regenerate. * configure.in (elf): Add elf-attrs.lo. * configure: Regenerate. * elf-bfd.h (struct elf_backend_data): Add entries for object attributes. (NUM_KNOWN_OBJ_ATTRIBUTES, obj_attribute, obj_attribute_list, OBJ_ATTR_PROC, OBJ_ATTR_GNU, OBJ_ATTR_FIRST, OBJ_ATTR_LAST, Tag_NULL, Tag_File, Tag_Section, Tag_Symbol, Tag_compatibility): New. (struct elf_obj_tdata): Add entries for object attributes. (elf_known_obj_attributes, elf_other_obj_attributes, elf_known_obj_attributes_proc, elf_other_obj_attributes_proc): New. (bfd_elf_obj_attr_size, bfd_elf_set_obj_attr_contents, bfd_elf_get_obj_attr_int, bfd_elf_add_obj_attr_int, bfd_elf_add_proc_attr_int, bfd_elf_add_obj_attr_string, bfd_elf_add_proc_attr_string, bfd_elf_add_obj_attr_compat, bfd_elf_add_proc_attr_compat, _bfd_elf_attr_strdup, _bfd_elf_copy_obj_attributes, _bfd_elf_obj_attrs_arg_type, _bfd_elf_parse_attributes, _bfd_elf_merge_object_attributes): New. * elf.c (_bfd_elf_copy_private_bfd_data): Copy object attributes. (bfd_section_from_shdr): Handle attributes sections. * elflink.c (bfd_elf_final_link): Handle attributes sections. * elfxx-target.h (elf_backend_obj_attrs_vendor, elf_backend_obj_attrs_section, elf_backend_obj_attrs_arg_type, elf_backend_obj_attrs_section_type): New. (elfNN_bed): Update. * elf32-arm.c (NUM_KNOWN_ATTRIBUTES, aeabi_attribute, aeabi_attribute_list): Remove. (struct elf32_arm_obj_tdata): Remove object attributes fields. (check_use_blx, bfd_elf32_arm_set_vfp11_fix, using_thumb2, elf32_arm_copy_private_bfd_data, elf32_arm_merge_eabi_attributes): Update for new object attributes interfaces. (uleb128_size, is_default_attr, eabi_attr_size, elf32_arm_eabi_attr_size, write_uleb128, write_eabi_attribute, elf32_arm_set_eabi_attr_contents, elf32_arm_bfd_final_link, elf32_arm_new_eabi_attr, elf32_arm_get_eabi_attr_int, elf32_arm_add_eabi_attr_int, attr_strdup, elf32_arm_add_eabi_attr_string, elf32_arm_add_eabi_attr_compat, copy_eabi_attributes, elf32_arm_parse_attributes): Remove. Moved to generic code in elf-attrs.c. (elf32_arm_obj_attrs_arg_type): New. (elf32_arm_fake_sections): Do not handle .ARM.attributes. (elf32_arm_section_from_shdr): Do not handle SHT_ARM_ATTRIBUTES. (bfd_elf32_bfd_final_link): Remove. (elf_backend_obj_attrs_vendor, elf_backend_obj_attrs_section, elf_backend_obj_attrs_arg_type, elf_backend_obj_attrs_section_type): New. * elf32-bfin.c (bfin_elf_copy_private_bfd_data): Copy object attributes. * elf32-frv.c (frv_elf_copy_private_bfd_data): Likewise. * elf32-iq2000.c (iq2000_elf_copy_private_bfd_data): Likewise. * elf32-mep.c (mep_elf_copy_private_bfd_data): Likewise. * elf32-mt.c (mt_elf_copy_private_bfd_data): Likewise. * elf32-sh.c (sh_elf_copy_private_data): Likewise. * elf64-sh64.c (sh_elf64_copy_private_data_internal): Likewise. binutils: * readelf.c (display_gnu_attribute): New. (process_arm_specific): Rearrange as process_attributes. (process_arm_specific): Replace by wrapper of process_attributes. gas: * as.c (create_obj_attrs_section): New. (main): Call create_obj_attrs_section for ELF. * read.c (s_gnu_attribute, skip_whitespace, skip_past_char, skip_past_comma, s_vendor_attribute): New. (potable): Add gnu_attribute for ELF. * read.h (s_vendor_attribute): Declare. * config/tc-arm.c (s_arm_eabi_attribute): Replace by wrapper round s_vendor_attribute. (aeabi_set_public_attributes): Update for new attributes interfaces. (arm_md_end): Remove attributes contents setting now done generically. include/elf: * arm.h (elf32_arm_add_eabi_attr_int, elf32_arm_add_eabi_attr_string, elf32_arm_add_eabi_attr_compat, elf32_arm_get_eabi_attr_int, elf32_arm_set_eabi_attr_contents, elf32_arm_eabi_attr_size, Tag_NULL, Tag_File, Tag_Section, Tag_Symbol, Tag_compatibility): Remove. * common.h (SHT_GNU_ATTRIBUTES): Define. ld: * emulparams/armelf.sh (OTHER_SECTIONS): Remove .ARM.attributes. (ATTRS_SECTIONS): Define. * scripttempl/elf.sc, scripttempl/elf32sh-symbian.sc, scripttempl/elf_chaos.sc, scripttempl/elfi370.sc, scripttempl/elfxtensa.sc: Handle ATTRS_SECTIONS.
2007-06-29 18:29:17 +02:00
/* Possibly an attributes section. */
if (hdr->sh_type == SHT_GNU_ATTRIBUTES
|| hdr->sh_type == bed->obj_attrs_section_type)
{
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
return FALSE;
_bfd_elf_parse_attributes (abfd, hdr);
return TRUE;
}
1999-05-03 09:29:11 +02:00
/* Check for any processor-specific section types. */
if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex))
return TRUE;
if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER)
{
if ((hdr->sh_flags & SHF_ALLOC) != 0)
/* FIXME: How to properly handle allocated section reserved
for applications? */
(*_bfd_error_handler)
(_("%B: don't know how to handle allocated, application "
"specific section `%s' [0x%8x]"),
abfd, name, hdr->sh_type);
else
/* Allow sections reserved for applications. */
return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
shindex);
}
else if (hdr->sh_type >= SHT_LOPROC
&& hdr->sh_type <= SHT_HIPROC)
/* FIXME: We should handle this section. */
(*_bfd_error_handler)
(_("%B: don't know how to handle processor specific section "
"`%s' [0x%8x]"),
abfd, name, hdr->sh_type);
else if (hdr->sh_type >= SHT_LOOS && hdr->sh_type <= SHT_HIOS)
{
/* Unrecognised OS-specific sections. */
if ((hdr->sh_flags & SHF_OS_NONCONFORMING) != 0)
/* SHF_OS_NONCONFORMING indicates that special knowledge is
required to correctly process the section and the file should
be rejected with an error message. */
(*_bfd_error_handler)
(_("%B: don't know how to handle OS specific section "
"`%s' [0x%8x]"),
abfd, name, hdr->sh_type);
else
/* Otherwise it should be processed. */
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
}
else
/* FIXME: We should handle this section. */
(*_bfd_error_handler)
(_("%B: don't know how to handle section `%s' [0x%8x]"),
abfd, name, hdr->sh_type);
return FALSE;
1999-05-03 09:29:11 +02:00
}
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Return the local symbol specified by ABFD, R_SYMNDX. */
* elf32-arm.h (elf32_arm_final_link_relocate): Don't copy STN_UNDEF relocs into shared libs. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_calculate_relocation): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf.c (bfd_section_from_r_symndx): New function. * elf-bfd.h (LOCAL_SYM_CACHE_SIZE): Define. (struct sym_sec_cache): New. (bfd_section_from_r_symndx): Declare. (struct bfd_elf_section_data): Change local_dynrel type to PTR. * elflink.h (elf_link_input_bfd): Don't test for removed linkonce relocs when relocatable. Don't zero entire reloc, just zero the addend and sym. * elf32-i386.c (struct elf_i386_link_hash_table): Add sym_sec. (elf_i386_link_hash_table_create): Init it. (elf_i386_check_relocs): Track dynamic relocs needed for local syms on a per-section basis as we do for globals. (elf_i386_gc_sweep_hook): Update for local_dynrel change. Remove dead code. (allocate_dynrelocs): Warning fix. (elf_i386_size_dynamic_sections): Don't allocate relocs when section has been discarded. (elf_i386_relocate_section): Don't copy STN_UNDEF relocs into shared libs. * elf32-hppa.c: Likewise. * elf32-s390.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise.
2001-11-10 01:23:35 +01:00
Elf_Internal_Sym *
bfd_sym_from_r_symndx (struct sym_cache *cache,
bfd *abfd,
unsigned long r_symndx)
* elf32-arm.h (elf32_arm_final_link_relocate): Don't copy STN_UNDEF relocs into shared libs. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_calculate_relocation): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf.c (bfd_section_from_r_symndx): New function. * elf-bfd.h (LOCAL_SYM_CACHE_SIZE): Define. (struct sym_sec_cache): New. (bfd_section_from_r_symndx): Declare. (struct bfd_elf_section_data): Change local_dynrel type to PTR. * elflink.h (elf_link_input_bfd): Don't test for removed linkonce relocs when relocatable. Don't zero entire reloc, just zero the addend and sym. * elf32-i386.c (struct elf_i386_link_hash_table): Add sym_sec. (elf_i386_link_hash_table_create): Init it. (elf_i386_check_relocs): Track dynamic relocs needed for local syms on a per-section basis as we do for globals. (elf_i386_gc_sweep_hook): Update for local_dynrel change. Remove dead code. (allocate_dynrelocs): Warning fix. (elf_i386_size_dynamic_sections): Don't allocate relocs when section has been discarded. (elf_i386_relocate_section): Don't copy STN_UNDEF relocs into shared libs. * elf32-hppa.c: Likewise. * elf32-s390.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise.
2001-11-10 01:23:35 +01:00
{
unsigned int ent = r_symndx % LOCAL_SYM_CACHE_SIZE;
if (cache->abfd != abfd || cache->indx[ent] != r_symndx)
{
Elf_Internal_Shdr *symtab_hdr;
unsigned char esym[sizeof (Elf64_External_Sym)];
Elf_External_Sym_Shndx eshndx;
* elf32-arm.h (elf32_arm_final_link_relocate): Don't copy STN_UNDEF relocs into shared libs. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_calculate_relocation): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf.c (bfd_section_from_r_symndx): New function. * elf-bfd.h (LOCAL_SYM_CACHE_SIZE): Define. (struct sym_sec_cache): New. (bfd_section_from_r_symndx): Declare. (struct bfd_elf_section_data): Change local_dynrel type to PTR. * elflink.h (elf_link_input_bfd): Don't test for removed linkonce relocs when relocatable. Don't zero entire reloc, just zero the addend and sym. * elf32-i386.c (struct elf_i386_link_hash_table): Add sym_sec. (elf_i386_link_hash_table_create): Init it. (elf_i386_check_relocs): Track dynamic relocs needed for local syms on a per-section basis as we do for globals. (elf_i386_gc_sweep_hook): Update for local_dynrel change. Remove dead code. (allocate_dynrelocs): Warning fix. (elf_i386_size_dynamic_sections): Don't allocate relocs when section has been discarded. (elf_i386_relocate_section): Don't copy STN_UNDEF relocs into shared libs. * elf32-hppa.c: Likewise. * elf32-s390.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise.
2001-11-10 01:23:35 +01:00
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
if (bfd_elf_get_elf_syms (abfd, symtab_hdr, 1, r_symndx,
&cache->sym[ent], esym, &eshndx) == NULL)
return NULL;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if (cache->abfd != abfd)
{
memset (cache->indx, -1, sizeof (cache->indx));
cache->abfd = abfd;
}
cache->indx[ent] = r_symndx;
* elf32-arm.h (elf32_arm_final_link_relocate): Don't copy STN_UNDEF relocs into shared libs. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_calculate_relocation): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf.c (bfd_section_from_r_symndx): New function. * elf-bfd.h (LOCAL_SYM_CACHE_SIZE): Define. (struct sym_sec_cache): New. (bfd_section_from_r_symndx): Declare. (struct bfd_elf_section_data): Change local_dynrel type to PTR. * elflink.h (elf_link_input_bfd): Don't test for removed linkonce relocs when relocatable. Don't zero entire reloc, just zero the addend and sym. * elf32-i386.c (struct elf_i386_link_hash_table): Add sym_sec. (elf_i386_link_hash_table_create): Init it. (elf_i386_check_relocs): Track dynamic relocs needed for local syms on a per-section basis as we do for globals. (elf_i386_gc_sweep_hook): Update for local_dynrel change. Remove dead code. (allocate_dynrelocs): Warning fix. (elf_i386_size_dynamic_sections): Don't allocate relocs when section has been discarded. (elf_i386_relocate_section): Don't copy STN_UNDEF relocs into shared libs. * elf32-hppa.c: Likewise. * elf32-s390.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise.
2001-11-10 01:23:35 +01:00
}
return &cache->sym[ent];
* elf32-arm.h (elf32_arm_final_link_relocate): Don't copy STN_UNDEF relocs into shared libs. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_calculate_relocation): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf.c (bfd_section_from_r_symndx): New function. * elf-bfd.h (LOCAL_SYM_CACHE_SIZE): Define. (struct sym_sec_cache): New. (bfd_section_from_r_symndx): Declare. (struct bfd_elf_section_data): Change local_dynrel type to PTR. * elflink.h (elf_link_input_bfd): Don't test for removed linkonce relocs when relocatable. Don't zero entire reloc, just zero the addend and sym. * elf32-i386.c (struct elf_i386_link_hash_table): Add sym_sec. (elf_i386_link_hash_table_create): Init it. (elf_i386_check_relocs): Track dynamic relocs needed for local syms on a per-section basis as we do for globals. (elf_i386_gc_sweep_hook): Update for local_dynrel change. Remove dead code. (allocate_dynrelocs): Warning fix. (elf_i386_size_dynamic_sections): Don't allocate relocs when section has been discarded. (elf_i386_relocate_section): Don't copy STN_UNDEF relocs into shared libs. * elf32-hppa.c: Likewise. * elf32-s390.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise.
2001-11-10 01:23:35 +01:00
}
1999-05-03 09:29:11 +02:00
/* Given an ELF section number, retrieve the corresponding BFD
section. */
asection *
bfd_section_from_elf_index (bfd *abfd, unsigned int sec_index)
1999-05-03 09:29:11 +02:00
{
if (sec_index >= elf_numsections (abfd))
1999-05-03 09:29:11 +02:00
return NULL;
return elf_elfsections (abfd)[sec_index]->bfd_section;
1999-05-03 09:29:11 +02:00
}
static const struct bfd_elf_special_section special_sections_b[] =
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
{
{ STRING_COMMA_LEN (".bss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_c[] =
{
{ STRING_COMMA_LEN (".comment"), 0, SHT_PROGBITS, 0 },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_d[] =
{
{ STRING_COMMA_LEN (".data"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
{ STRING_COMMA_LEN (".data1"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
{ STRING_COMMA_LEN (".debug"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".debug_line"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".debug_info"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".debug_abbrev"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".debug_aranges"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC, SHF_ALLOC },
{ STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB, SHF_ALLOC },
{ STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM, SHF_ALLOC },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_f[] =
{
{ STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
{ STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_g[] =
{
{ STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
{ STRING_COMMA_LEN (".gnu.lto_"), -1, SHT_PROGBITS, SHF_EXCLUDE },
{ STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
{ STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 },
{ STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 },
{ STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 },
{ STRING_COMMA_LEN (".gnu.liblist"), 0, SHT_GNU_LIBLIST, SHF_ALLOC },
{ STRING_COMMA_LEN (".gnu.conflict"), 0, SHT_RELA, SHF_ALLOC },
{ STRING_COMMA_LEN (".gnu.hash"), 0, SHT_GNU_HASH, SHF_ALLOC },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_h[] =
{
{ STRING_COMMA_LEN (".hash"), 0, SHT_HASH, SHF_ALLOC },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_i[] =
{
{ STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
{ STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE },
{ STRING_COMMA_LEN (".interp"), 0, SHT_PROGBITS, 0 },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_l[] =
{
{ STRING_COMMA_LEN (".line"), 0, SHT_PROGBITS, 0 },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_n[] =
{
{ STRING_COMMA_LEN (".note.GNU-stack"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".note"), -1, SHT_NOTE, 0 },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_p[] =
{
{ STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE },
{ STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_r[] =
{
{ STRING_COMMA_LEN (".rodata"), -2, SHT_PROGBITS, SHF_ALLOC },
{ STRING_COMMA_LEN (".rodata1"), 0, SHT_PROGBITS, SHF_ALLOC },
{ STRING_COMMA_LEN (".rela"), -1, SHT_RELA, 0 },
{ STRING_COMMA_LEN (".rel"), -1, SHT_REL, 0 },
{ NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_s[] =
{
{ STRING_COMMA_LEN (".shstrtab"), 0, SHT_STRTAB, 0 },
{ STRING_COMMA_LEN (".strtab"), 0, SHT_STRTAB, 0 },
{ STRING_COMMA_LEN (".symtab"), 0, SHT_SYMTAB, 0 },
/* See struct bfd_elf_special_section declaration for the semantics of
this special case where .prefix_length != strlen (.prefix). */
{ ".stabstr", 5, 3, SHT_STRTAB, 0 },
{ NULL, 0, 0, 0, 0 }
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
};
static const struct bfd_elf_special_section special_sections_t[] =
{
{ STRING_COMMA_LEN (".text"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
{ STRING_COMMA_LEN (".tbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS },
{ STRING_COMMA_LEN (".tdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS },
{ NULL, 0, 0, 0, 0 }
};
bfd/ * Makefile.am (BFD32_LIBS): Add compress.lo. (BFD32_LIBS_CFILES): Add compress.c. (BFD_H_FILES): Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf2.c (read_section): New function. (read_indirect_string): Call new function read_section. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Call new function read_section when just one .zdebug_info section is found, otherwise read and compress multiple sections. (_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr. * elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix. (special_sections_z): New struct. (special_sections): Refer to special_sections_z. * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize sections named .zdebug_*. (_bfd_mips_elf_fake_sections): Likewise. * compress.c: New file. (bfd_uncompress_section_contents): New function. bfd/doc/ * Makefile.am (BFD_H_DEP): Add ../compress.c. * Makefile.in: Regenerate. binutils/ * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf.c (debug_displays): Add .zdebug_* strings. * dwarf.h (struct dwarf_section): Add fields uncompressed_namd and compressed_name. * objdump.c (load_debug_section): Call bfd_uncompress_section_contents when loading a compressed section. (dump_dwarf_section): Recognize compressed section name. (mach_o_dwarf_sections): Rename as mach_o_uncompressed_dwarf_sections. (mach_o_compressed_dwarf_sections): New variable. (generic_dwarf_section): Rename as generic_uncompressed_dwarf_sections. (generic_compressed_dwarf_sections): New variable. (check_mach_o_dwarf): Save and restore mach_o_compressed_dwarf_sections. * readelf.c: Add #include for config.h and zlib.h (process_section_headers): Recognize compressed section name. (uncompress_section_contents): New function. (load_debug_section): Call uncompress_section_contents when loading a compressed section. (display_debug_section): Recognize compressed section name. binutils/testsuite: * binutils-all/objdump.exp: Add test for objdump -s on a file with a compressed debug section. Add test for objdump -W on a file that contains a compressed debug section. * binutils-all/readelf.exp: Call readelf_compressed_wa_test. (readelf_compressed_wa_test): New function. * binutils-all/dw2-compressed.S: New file. * binutils-all/objdump.W: New file. * binutils-all/objdump.s: New file. * binutils-all/readelf.wa: New file.
2008-07-10 03:32:23 +02:00
static const struct bfd_elf_special_section special_sections_z[] =
{
{ STRING_COMMA_LEN (".zdebug_line"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".zdebug_info"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".zdebug_abbrev"), 0, SHT_PROGBITS, 0 },
{ STRING_COMMA_LEN (".zdebug_aranges"), 0, SHT_PROGBITS, 0 },
{ NULL, 0, 0, 0, 0 }
};
2011-04-28 14:50:32 +02:00
static const struct bfd_elf_special_section * const special_sections[] =
{
special_sections_b, /* 'b' */
special_sections_c, /* 'c' */
special_sections_d, /* 'd' */
NULL, /* 'e' */
special_sections_f, /* 'f' */
special_sections_g, /* 'g' */
special_sections_h, /* 'h' */
special_sections_i, /* 'i' */
NULL, /* 'j' */
NULL, /* 'k' */
special_sections_l, /* 'l' */
NULL, /* 'm' */
special_sections_n, /* 'n' */
NULL, /* 'o' */
special_sections_p, /* 'p' */
NULL, /* 'q' */
special_sections_r, /* 'r' */
special_sections_s, /* 's' */
special_sections_t, /* 't' */
bfd/ * Makefile.am (BFD32_LIBS): Add compress.lo. (BFD32_LIBS_CFILES): Add compress.c. (BFD_H_FILES): Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf2.c (read_section): New function. (read_indirect_string): Call new function read_section. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Call new function read_section when just one .zdebug_info section is found, otherwise read and compress multiple sections. (_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr. * elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix. (special_sections_z): New struct. (special_sections): Refer to special_sections_z. * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize sections named .zdebug_*. (_bfd_mips_elf_fake_sections): Likewise. * compress.c: New file. (bfd_uncompress_section_contents): New function. bfd/doc/ * Makefile.am (BFD_H_DEP): Add ../compress.c. * Makefile.in: Regenerate. binutils/ * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf.c (debug_displays): Add .zdebug_* strings. * dwarf.h (struct dwarf_section): Add fields uncompressed_namd and compressed_name. * objdump.c (load_debug_section): Call bfd_uncompress_section_contents when loading a compressed section. (dump_dwarf_section): Recognize compressed section name. (mach_o_dwarf_sections): Rename as mach_o_uncompressed_dwarf_sections. (mach_o_compressed_dwarf_sections): New variable. (generic_dwarf_section): Rename as generic_uncompressed_dwarf_sections. (generic_compressed_dwarf_sections): New variable. (check_mach_o_dwarf): Save and restore mach_o_compressed_dwarf_sections. * readelf.c: Add #include for config.h and zlib.h (process_section_headers): Recognize compressed section name. (uncompress_section_contents): New function. (load_debug_section): Call uncompress_section_contents when loading a compressed section. (display_debug_section): Recognize compressed section name. binutils/testsuite: * binutils-all/objdump.exp: Add test for objdump -s on a file with a compressed debug section. Add test for objdump -W on a file that contains a compressed debug section. * binutils-all/readelf.exp: Call readelf_compressed_wa_test. (readelf_compressed_wa_test): New function. * binutils-all/dw2-compressed.S: New file. * binutils-all/objdump.W: New file. * binutils-all/objdump.s: New file. * binutils-all/readelf.wa: New file.
2008-07-10 03:32:23 +02:00
NULL, /* 'u' */
NULL, /* 'v' */
NULL, /* 'w' */
NULL, /* 'x' */
NULL, /* 'y' */
special_sections_z /* 'z' */
};
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
const struct bfd_elf_special_section *
_bfd_elf_get_special_section (const char *name,
const struct bfd_elf_special_section *spec,
unsigned int rela)
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
{
int i;
int len;
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
len = strlen (name);
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
for (i = 0; spec[i].prefix != NULL; i++)
{
int suffix_len;
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
int prefix_len = spec[i].prefix_length;
if (len < prefix_len)
continue;
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
if (memcmp (name, spec[i].prefix, prefix_len) != 0)
continue;
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
suffix_len = spec[i].suffix_length;
if (suffix_len <= 0)
{
if (name[prefix_len] != 0)
{
if (suffix_len == 0)
continue;
if (name[prefix_len] != '.'
&& (suffix_len == -2
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
|| (rela && spec[i].type == SHT_REL)))
continue;
}
}
else
{
if (len < prefix_len + suffix_len)
continue;
if (memcmp (name + len - suffix_len,
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
spec[i].prefix + prefix_len,
suffix_len) != 0)
continue;
}
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
return &spec[i];
}
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
return NULL;
}
const struct bfd_elf_special_section *
_bfd_elf_get_sec_type_attr (bfd *abfd, asection *sec)
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
{
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
int i;
const struct bfd_elf_special_section *spec;
const struct elf_backend_data *bed;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
/* See if this is one of the special sections. */
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
if (sec->name == NULL)
return NULL;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
bed = get_elf_backend_data (abfd);
spec = bed->special_sections;
if (spec)
{
spec = _bfd_elf_get_special_section (sec->name,
bed->special_sections,
sec->use_rela_p);
if (spec != NULL)
return spec;
}
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
if (sec->name[0] != '.')
return NULL;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
i = sec->name[1] - 'b';
bfd/ * Makefile.am (BFD32_LIBS): Add compress.lo. (BFD32_LIBS_CFILES): Add compress.c. (BFD_H_FILES): Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf2.c (read_section): New function. (read_indirect_string): Call new function read_section. (read_abbrevs): Likewise. (decode_line_info): Likewise. (read_debug_ranges): Likewise. (find_line): Call new function read_section when just one .zdebug_info section is found, otherwise read and compress multiple sections. (_bfd_dwarf2_cleanup_debug_info): Free sec_info_ptr. * elf.c (_bfd_elf_make_section_from_shdr): Add zdebug prefix. (special_sections_z): New struct. (special_sections): Refer to special_sections_z. * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Recognize sections named .zdebug_*. (_bfd_mips_elf_fake_sections): Likewise. * compress.c: New file. (bfd_uncompress_section_contents): New function. bfd/doc/ * Makefile.am (BFD_H_DEP): Add ../compress.c. * Makefile.in: Regenerate. binutils/ * config.in: Add HAVE_ZLIB_H * configure.in: Add test for libz and zlib.h * configure: Regenerate. * dwarf.c (debug_displays): Add .zdebug_* strings. * dwarf.h (struct dwarf_section): Add fields uncompressed_namd and compressed_name. * objdump.c (load_debug_section): Call bfd_uncompress_section_contents when loading a compressed section. (dump_dwarf_section): Recognize compressed section name. (mach_o_dwarf_sections): Rename as mach_o_uncompressed_dwarf_sections. (mach_o_compressed_dwarf_sections): New variable. (generic_dwarf_section): Rename as generic_uncompressed_dwarf_sections. (generic_compressed_dwarf_sections): New variable. (check_mach_o_dwarf): Save and restore mach_o_compressed_dwarf_sections. * readelf.c: Add #include for config.h and zlib.h (process_section_headers): Recognize compressed section name. (uncompress_section_contents): New function. (load_debug_section): Call uncompress_section_contents when loading a compressed section. (display_debug_section): Recognize compressed section name. binutils/testsuite: * binutils-all/objdump.exp: Add test for objdump -s on a file with a compressed debug section. Add test for objdump -W on a file that contains a compressed debug section. * binutils-all/readelf.exp: Call readelf_compressed_wa_test. (readelf_compressed_wa_test): New function. * binutils-all/dw2-compressed.S: New file. * binutils-all/objdump.W: New file. * binutils-all/objdump.s: New file. * binutils-all/readelf.wa: New file.
2008-07-10 03:32:23 +02:00
if (i < 0 || i > 'z' - 'b')
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
return NULL;
spec = special_sections[i];
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
if (spec == NULL)
return NULL;
return _bfd_elf_get_special_section (sec->name, spec, sec->use_rela_p);
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
}
bfd_boolean
_bfd_elf_new_section_hook (bfd *abfd, asection *sec)
1999-05-03 09:29:11 +02:00
{
struct bfd_elf_section_data *sdata;
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
const struct elf_backend_data *bed;
const struct bfd_elf_special_section *ssect;
1999-05-03 09:29:11 +02:00
include/elf/ChangeLog * sh.h: Split out various bits to bfd/elf32-sh64.h. include/opcode/ChangeLog * m68hc11.h (cpu6812s): Define. bfd/ChangeLog * elf-bfd.h (struct bfd_elf_section_data): Remove tdata. Change dynindx to an int. Rearrange for better packing. * elf.c (_bfd_elf_new_section_hook): Don't alloc if already done. * elf32-mips.c (bfd_elf32_new_section_hook): Define. * elf32-sh64.h: New. Split out from include/elf/sh.h. (struct _sh64_elf_section_data): New struct. (sh64_elf_section_data): Don't dereference sh64_info (was tdata). * elf32-sh64-com.c: Include elf32-sh64.h. * elf32-sh64.c: Likewise. (sh64_elf_new_section_hook): New function. (bfd_elf32_new_section_hook): Define. (sh64_elf_fake_sections): Adjust for sh64_elf_section_data change. (sh64_bfd_elf_copy_private_section_data): Likewise. (sh64_elf_final_write_processing): Likewise. * elf32-sparc.c (struct elf32_sparc_section_data): New. (elf32_sparc_new_section_hook): New function. (SET_SEC_DO_RELAX, SEC_DO_RELAX): Delete. (sec_do_relax): Define. (elf32_sparc_relax_section): Adjust to use sec_do_relax. (elf32_sparc_relocate_section): Likewise. * elf64-mips.c (bfd_elf64_new_section_hook): Define. * elf64-mmix.c (struct _mmix_elf_section_data): New. (mmix_elf_section_data): Define. Use throughout file. (mmix_elf_new_section_hook): New function. (bfd_elf64_new_section_hook): Define. * elf64-ppc.c (struct _ppc64_elf_section_data): New. (ppc64_elf_section_data): Define. Use throughout. (ppc64_elf_new_section_hook): New function. (bfd_elf64_new_section_hook): Define. * elf64-sparc.c (struct sparc64_elf_section_data): New. (sparc64_elf_new_section_hook): New function. (SET_SEC_DO_RELAX, SEC_DO_RELAX): Delete. (sec_do_relax): Define. (sparc64_elf_relax_section): Adjust to use sec_do_relax. (sparc64_elf_relocate_section): Likewise. (bfd_elf64_new_section_hook): Define. * elfn32-mips.c (bfd_elf32_new_section_hook): Define. * elfxx-mips.c (struct _mips_elf_section_data): New. (mips_elf_section_data): Define. Use throughout. (_bfd_mips_elf_new_section_hook): New function. (mips_elf_create_got_section): Don't alloc used_by_bfd. * elfxx-mips.h (_bfd_mips_elf_new_section_hook): Declare. * elfxx-target.h (bfd_elfNN_new_section_hook): Add #ifndef. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. opcodes/ChangeLog * sh64-dis.c: Include elf32-sh64.h. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. gas/ChangeLog * config/tc-sh64.c (shmedia_frob_section_type): Adjust for changed sh64_elf_section_data. * config/tc-sh64.h: Include elf32-sh64.h. * config/tc-m68hc11.c: Don't include stdio.h. (md_show_usage): Fix missing continuation. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. ld/ChangeLog * emultempl/sh64elf.em: Include elf32-sh64.h. (sh64_elf_${EMULATION_NAME}_before_allocation): Adjust for changed sh64_elf_section_data. (sh64_elf_${EMULATION_NAME}_after_allocation): Likewise.
2003-01-23 12:51:35 +01:00
sdata = (struct bfd_elf_section_data *) sec->used_by_bfd;
if (sdata == NULL)
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
sdata = (struct bfd_elf_section_data *) bfd_zalloc (abfd,
sizeof (*sdata));
include/elf/ChangeLog * sh.h: Split out various bits to bfd/elf32-sh64.h. include/opcode/ChangeLog * m68hc11.h (cpu6812s): Define. bfd/ChangeLog * elf-bfd.h (struct bfd_elf_section_data): Remove tdata. Change dynindx to an int. Rearrange for better packing. * elf.c (_bfd_elf_new_section_hook): Don't alloc if already done. * elf32-mips.c (bfd_elf32_new_section_hook): Define. * elf32-sh64.h: New. Split out from include/elf/sh.h. (struct _sh64_elf_section_data): New struct. (sh64_elf_section_data): Don't dereference sh64_info (was tdata). * elf32-sh64-com.c: Include elf32-sh64.h. * elf32-sh64.c: Likewise. (sh64_elf_new_section_hook): New function. (bfd_elf32_new_section_hook): Define. (sh64_elf_fake_sections): Adjust for sh64_elf_section_data change. (sh64_bfd_elf_copy_private_section_data): Likewise. (sh64_elf_final_write_processing): Likewise. * elf32-sparc.c (struct elf32_sparc_section_data): New. (elf32_sparc_new_section_hook): New function. (SET_SEC_DO_RELAX, SEC_DO_RELAX): Delete. (sec_do_relax): Define. (elf32_sparc_relax_section): Adjust to use sec_do_relax. (elf32_sparc_relocate_section): Likewise. * elf64-mips.c (bfd_elf64_new_section_hook): Define. * elf64-mmix.c (struct _mmix_elf_section_data): New. (mmix_elf_section_data): Define. Use throughout file. (mmix_elf_new_section_hook): New function. (bfd_elf64_new_section_hook): Define. * elf64-ppc.c (struct _ppc64_elf_section_data): New. (ppc64_elf_section_data): Define. Use throughout. (ppc64_elf_new_section_hook): New function. (bfd_elf64_new_section_hook): Define. * elf64-sparc.c (struct sparc64_elf_section_data): New. (sparc64_elf_new_section_hook): New function. (SET_SEC_DO_RELAX, SEC_DO_RELAX): Delete. (sec_do_relax): Define. (sparc64_elf_relax_section): Adjust to use sec_do_relax. (sparc64_elf_relocate_section): Likewise. (bfd_elf64_new_section_hook): Define. * elfn32-mips.c (bfd_elf32_new_section_hook): Define. * elfxx-mips.c (struct _mips_elf_section_data): New. (mips_elf_section_data): Define. Use throughout. (_bfd_mips_elf_new_section_hook): New function. (mips_elf_create_got_section): Don't alloc used_by_bfd. * elfxx-mips.h (_bfd_mips_elf_new_section_hook): Declare. * elfxx-target.h (bfd_elfNN_new_section_hook): Add #ifndef. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. opcodes/ChangeLog * sh64-dis.c: Include elf32-sh64.h. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. gas/ChangeLog * config/tc-sh64.c (shmedia_frob_section_type): Adjust for changed sh64_elf_section_data. * config/tc-sh64.h: Include elf32-sh64.h. * config/tc-m68hc11.c: Don't include stdio.h. (md_show_usage): Fix missing continuation. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. ld/ChangeLog * emultempl/sh64elf.em: Include elf32-sh64.h. (sh64_elf_${EMULATION_NAME}_before_allocation): Adjust for changed sh64_elf_section_data. (sh64_elf_${EMULATION_NAME}_after_allocation): Likewise.
2003-01-23 12:51:35 +01:00
if (sdata == NULL)
return FALSE;
sec->used_by_bfd = sdata;
include/elf/ChangeLog * sh.h: Split out various bits to bfd/elf32-sh64.h. include/opcode/ChangeLog * m68hc11.h (cpu6812s): Define. bfd/ChangeLog * elf-bfd.h (struct bfd_elf_section_data): Remove tdata. Change dynindx to an int. Rearrange for better packing. * elf.c (_bfd_elf_new_section_hook): Don't alloc if already done. * elf32-mips.c (bfd_elf32_new_section_hook): Define. * elf32-sh64.h: New. Split out from include/elf/sh.h. (struct _sh64_elf_section_data): New struct. (sh64_elf_section_data): Don't dereference sh64_info (was tdata). * elf32-sh64-com.c: Include elf32-sh64.h. * elf32-sh64.c: Likewise. (sh64_elf_new_section_hook): New function. (bfd_elf32_new_section_hook): Define. (sh64_elf_fake_sections): Adjust for sh64_elf_section_data change. (sh64_bfd_elf_copy_private_section_data): Likewise. (sh64_elf_final_write_processing): Likewise. * elf32-sparc.c (struct elf32_sparc_section_data): New. (elf32_sparc_new_section_hook): New function. (SET_SEC_DO_RELAX, SEC_DO_RELAX): Delete. (sec_do_relax): Define. (elf32_sparc_relax_section): Adjust to use sec_do_relax. (elf32_sparc_relocate_section): Likewise. * elf64-mips.c (bfd_elf64_new_section_hook): Define. * elf64-mmix.c (struct _mmix_elf_section_data): New. (mmix_elf_section_data): Define. Use throughout file. (mmix_elf_new_section_hook): New function. (bfd_elf64_new_section_hook): Define. * elf64-ppc.c (struct _ppc64_elf_section_data): New. (ppc64_elf_section_data): Define. Use throughout. (ppc64_elf_new_section_hook): New function. (bfd_elf64_new_section_hook): Define. * elf64-sparc.c (struct sparc64_elf_section_data): New. (sparc64_elf_new_section_hook): New function. (SET_SEC_DO_RELAX, SEC_DO_RELAX): Delete. (sec_do_relax): Define. (sparc64_elf_relax_section): Adjust to use sec_do_relax. (sparc64_elf_relocate_section): Likewise. (bfd_elf64_new_section_hook): Define. * elfn32-mips.c (bfd_elf32_new_section_hook): Define. * elfxx-mips.c (struct _mips_elf_section_data): New. (mips_elf_section_data): Define. Use throughout. (_bfd_mips_elf_new_section_hook): New function. (mips_elf_create_got_section): Don't alloc used_by_bfd. * elfxx-mips.h (_bfd_mips_elf_new_section_hook): Declare. * elfxx-target.h (bfd_elfNN_new_section_hook): Add #ifndef. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. opcodes/ChangeLog * sh64-dis.c: Include elf32-sh64.h. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. gas/ChangeLog * config/tc-sh64.c (shmedia_frob_section_type): Adjust for changed sh64_elf_section_data. * config/tc-sh64.h: Include elf32-sh64.h. * config/tc-m68hc11.c: Don't include stdio.h. (md_show_usage): Fix missing continuation. * Makefile.am: Run "make dep-am". * Makefile.in: Regenerate. ld/ChangeLog * emultempl/sh64elf.em: Include elf32-sh64.h. (sh64_elf_${EMULATION_NAME}_before_allocation): Adjust for changed sh64_elf_section_data. (sh64_elf_${EMULATION_NAME}_after_allocation): Likewise.
2003-01-23 12:51:35 +01:00
}
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
/* Indicate whether or not this section should use RELA relocations. */
bed = get_elf_backend_data (abfd);
sec->use_rela_p = bed->default_use_rela_p;
/* When we read a file, we don't need to set ELF section type and
flags. They will be overridden in _bfd_elf_make_section_from_shdr
anyway. We will set ELF section type and flags for all linker
created sections. If user specifies BFD section flags, we will
set ELF section type and flags based on BFD section flags in
elf_fake_sections. Special handling for .init_array/.fini_array
output sections since they may contain .ctors/.dtors input
sections. We don't want _bfd_elf_init_private_section_data to
copy ELF section type from .ctors/.dtors input sections. */
if (abfd->direction != read_direction
2005-05-05 H.J. Lu <hongjiu.lu@intel.com> * section.c (bfd_make_section_anyway_with_flags): New. (bfd_make_section_anyway): Call bfd_make_section_anyway_with_flags, (bfd_make_section_with_flags): New. (bfd_make_section): Call bfd_make_section_with_flags. * elf-m10300.c (_bfd_mn10300_elf_create_got_section): Call bfd_make_section_with_flags/bfd_make_section_anyway_with_flags instead of bfd_make_section/bfd_make_section and don't call bfd_set_section_flags. (mn10300_elf_check_relocs): Likewise. (_bfd_mn10300_elf_create_dynamic_sections): Likewise. * elf32-arm.c (create_got_section): Likewise. (bfd_elf32_arm_add_glue_sections_to_bfd): Likewise. (elf32_arm_check_relocs): Likewise. * elf32-cris.c (cris_elf_check_relocs): Likewise. * elf32-frv.c (elf32_frv_add_symbol_hook): Likewise. (_frv_create_got_section): Likewise. (elf32_frvfdpic_create_dynamic_sections): Likewise. * elf32-hppa.c (elf32_hppa_create_dynamic_sections): Likewise. (elf32_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_create_dynamic_sections): Likewise. (i370_elf_check_relocs): Likewise. * elf32-i386.c (create_got_section): Likewise. (elf_i386_check_relocs): Likewise. * elf32-m32r.c (m32r_elf_add_symbol_hook): Likewise. (create_got_section): Likewise. (m32r_elf_create_dynamic_sections): Likewise. (m32r_elf_check_relocs): Likewise. * elf32-m68k.c (elf_m68k_check_relocs): Likewise. * elf32-ppc.c (ppc_elf_create_got): Likewise. (ppc_elf_create_dynamic_sections): Likewise. (ppc_elf_add_symbol_hook): Likewise. (ppc_elf_check_relocs): Likewise. * elf32-s390.c (create_got_section): Likewise. (elf_s390_check_relocs): Likewise. * elf32-sh.c (create_got_section): Likewise. (sh_elf_create_dynamic_sections): Likewise. (sh_elf_check_relocs): Likewise. * elf32-vax.c (elf_vax_check_relocs): Likewise. * elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise. * elf32-xtensa.c (elf_xtensa_create_dynamic_sections): Likewise. (add_extra_plt_sections): Likewise. * elf64-alpha.c (elf64_alpha_add_symbol_hook): Likewise. (elf64_alpha_create_got_section): Likewise. (elf64_alpha_create_dynamic_sections): Likewise. (elf64_alpha_check_relocs): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. (get_opd): Likewise. (get_plt): Likewise. (get_dlt): Likewise. (get_stub): Likewise. (elf64_hppa_create_dynamic_sectionso): Likewise. * elf64-mmix.c (mmix_elf_check_common_relocs): Likewise. * elf64-ppc.c (create_linkage_sections): Likewise. (ppc64_elf_check_relocs): Likewise. * elf64-s390.c (create_got_section): Likewise. (elf_s390_check_relocs): Likewise. * elf64-sh64.c (sh_elf64_check_relocs): Likewise. (sh64_elf64_create_dynamic_sections): Likewise. * elf64-x86-64.c (create_got_section): Likewise. (elf64_x86_64_check_relocs): Likewise. * elflink.c (_bfd_elf_create_got_section): Likewise. (_bfd_elf_link_create_dynamic_sections): Likewise. (elf_link_add_object_symbols): Likewise. * elfxx-ia64.c (elfNN_ia64_add_symbol_hook): Likewise. (elfNN_ia64_create_dynamic_sections): Likewise. (get_fptr): Likewise. (get_pltoff): Likewise. (get_reloc_section): Likewise. (elfNN_ia64_object_p): Likewise. * elfxx-mips.c (mips_elf_rel_dyn_section): Likewise. (mips_elf_create_compact_rel_section): Likewise. (mips_elf_create_got_section): Likewise. (_bfd_mips_elf_create_dynamic_sections): Likewise. * elfxx-sparc.c (create_got_section): Likewise. (_bfd_sparc_elf_check_relocs): Likewise. * elf.c (_bfd_elf_new_section_hook): Call _bfd_elf_get_sec_type_attr on linker created sections.
2005-05-05 16:34:04 +02:00
|| (sec->flags & SEC_LINKER_CREATED) != 0)
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
{
PR 1004 bfd/ * elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr. Delete special_sections. (_bfd_elf_get_special_section): Declare. (bfd_elf_special_section): Update prototype. * elf.c (special_sections): Remove unused outer entries. (get_special_section): Delete. (_bfd_elf_get_special_section): New function. (_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec". Update special_sections indexing. (_bfd_elf_new_section_hook): Call backend get_sec_type_attr. * elf32-arm.c (symbian_special_sections_d): Delete. (symbian_special_sections_g, symbian_special_sections_h): Delete. (symbian_special_sections_i, symbian_special_sections_f): Delete. (symbian_special_sections_p): Delete. (elf32_arm_symbian_special_sections): Merge above to here. (elf32_arm_symbian_get_sec_type_attr): New function. (elf_backend_special_sections): Don't define. (elf_backend_get_sec_type_attr): Define. * elf32-m32r.c: Similarly to elf32-arm.c. * elf32-m68hc11.c: Likewise. * elf32-m68hc12.c: Likewise. * elf32-mcore.c: Likewise. * elf32-sh64.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elf32-ppc.c: Likewise. (bfd_elf_special_section ppc_alt_plt): New. Use it if .plt loadable. * elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare. (_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete. (elf_backend_get_sec_type_attr): Define. * elfxx-target.h (elf_backend_get_sec_type_attr): Define. (elf_backend_special_sections): Don't define. (elfNN_bed): Update. binutils/ * objcopy.c (copy_object): Use bfd_make_section_with_flags. (write_debugging_info): Likewise. (setup_section): Use bfd_make_section_anyway_with_flags. gas/ * config/obj-elf.c (obj_elf_change_section): Use backend get_sec_type_attr.
2005-07-04 03:53:44 +02:00
ssect = (*bed->get_sec_type_attr) (abfd, sec);
if (ssect != NULL
&& (!sec->flags
|| (sec->flags & SEC_LINKER_CREATED) != 0
|| ssect->type == SHT_INIT_ARRAY
|| ssect->type == SHT_FINI_ARRAY))
{
elf_section_type (sec) = ssect->type;
elf_section_flags (sec) = ssect->attr;
}
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
}
bfd/ * libbfd-in.h (_bfd_generic_new_section_hook): Declare. * section.c (bfd_abs_symbol, bfd_com_symbol): Delete. (bfd_und_symbol, bfd_ind_symbol): Delete. (BFD_FAKE_SECTION): Remove SYM_PTR param, set symbol_ptr_ptr to &SEC.symbol. (STD_SECTION): Adjust. (_bfd_generic_new_section_hook): New function, extracted from.. (bfd_section_init): ..here. (bfd_make_section_old_way): Call new_section_hook for abs, com, und and ind sections. * elf.c (_bfd_elf_large_com_section): Adjust. * aoutx.h (new_section_hook): Call _bfd_generic_new_section_hook. * pdp11.c (new_section_hook): Likewise. * coffcode.h (coff_new_section_hook): Likewise. * ecoff.c (_bfd_ecoff_new_section_hook): Likewise. * elf.c (_bfd_elf_new_section_hook): Likewise. * vms.c (vms_new_section_hook): Likwise. * elf32-arm.c (elf32_arm_new_section_hook): Check used_by_bfd isn't already set. * elf32-sh64.c (sh64_elf_new_section_hook): Likewise. * elf32-xtensa.c (elf_xtensa_new_section_hook): Likewise. * elf64-mmix.c (mmix_elf_new_section_hook): Likewise. * elf64-ppc.c (ppc64_elf_new_section_hook): Likewise. * elfxx-mips.c (_bfd_mips_elf_new_section_hook): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_new_section_hook): Likewise. * ieee.c (ieee_new_section_hook): Likewise. Call _bfd_generic_new_section_hook too. * mmo.c (mmo_new_section_hook): Likewise. * oasys.c (oasys_new_section_hook): Likewise. * som.c (som_new_section_hook): Likewise. * coff-w65.c (reloc_processing): Don't use bfd_abs_symbol. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. gas/ * subsegs.c (subseg_get): Don't call obj_sec_set_private_data. * config/obj-elf.h (obj_sec_set_private_data): Delete. * config/tc-hppa.c (tc_gen_reloc): Don't use bfd_abs_symbol. * config/tc-mn10300.c (tc_gen_reloc): Likewise.
2006-05-03 16:26:41 +02:00
return _bfd_generic_new_section_hook (abfd, sec);
1999-05-03 09:29:11 +02:00
}
/* Create a new bfd section from an ELF program header.
Since program segments have no names, we generate a synthetic name
of the form segment<NUM>, where NUM is generally the index in the
program header table. For segments that are split (see below) we
generate the names segment<NUM>a and segment<NUM>b.
Note that some program segments may have a file size that is different than
(less than) the memory size. All this means is that at execution the
system must allocate the amount of memory specified by the memory size,
but only initialize it with the first "file size" bytes read from the
file. This would occur for example, with program segments consisting
of combined data+bss.
To handle the above situation, this routine generates TWO bfd sections
for the single program segment. The first has the length specified by
the file size of the segment, and the second has the length specified
by the difference between the two sizes. In effect, the segment is split
into its initialized and uninitialized parts.
1999-05-03 09:29:11 +02:00
*/
bfd_boolean
_bfd_elf_make_section_from_phdr (bfd *abfd,
Elf_Internal_Phdr *hdr,
int hdr_index,
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
const char *type_name)
1999-05-03 09:29:11 +02:00
{
asection *newsect;
char *name;
char namebuf[64];
2002-06-25 11:40:45 +02:00
size_t len;
1999-05-03 09:29:11 +02:00
int split;
split = ((hdr->p_memsz > 0)
&& (hdr->p_filesz > 0)
&& (hdr->p_memsz > hdr->p_filesz));
if (hdr->p_filesz > 0)
1999-05-03 09:29:11 +02:00
{
sprintf (namebuf, "%s%d%s", type_name, hdr_index, split ? "a" : "");
len = strlen (namebuf) + 1;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, len);
if (!name)
return FALSE;
memcpy (name, namebuf, len);
newsect = bfd_make_section (abfd, name);
if (newsect == NULL)
return FALSE;
newsect->vma = hdr->p_vaddr;
newsect->lma = hdr->p_paddr;
newsect->size = hdr->p_filesz;
newsect->filepos = hdr->p_offset;
newsect->flags |= SEC_HAS_CONTENTS;
newsect->alignment_power = bfd_log2 (hdr->p_align);
if (hdr->p_type == PT_LOAD)
1999-05-03 09:29:11 +02:00
{
newsect->flags |= SEC_ALLOC;
newsect->flags |= SEC_LOAD;
if (hdr->p_flags & PF_X)
{
/* FIXME: all we known is that it has execute PERMISSION,
may be data. */
newsect->flags |= SEC_CODE;
}
}
if (!(hdr->p_flags & PF_W))
{
newsect->flags |= SEC_READONLY;
1999-05-03 09:29:11 +02:00
}
}
if (hdr->p_memsz > hdr->p_filesz)
1999-05-03 09:29:11 +02:00
{
bfd_vma align;
sprintf (namebuf, "%s%d%s", type_name, hdr_index, split ? "b" : "");
2002-06-25 11:40:45 +02:00
len = strlen (namebuf) + 1;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, len);
1999-05-03 09:29:11 +02:00
if (!name)
return FALSE;
2002-06-25 11:40:45 +02:00
memcpy (name, namebuf, len);
1999-05-03 09:29:11 +02:00
newsect = bfd_make_section (abfd, name);
if (newsect == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
newsect->vma = hdr->p_vaddr + hdr->p_filesz;
newsect->lma = hdr->p_paddr + hdr->p_filesz;
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 06:46:28 +02:00
newsect->size = hdr->p_memsz - hdr->p_filesz;
newsect->filepos = hdr->p_offset + hdr->p_filesz;
align = newsect->vma & -newsect->vma;
if (align == 0 || align > hdr->p_align)
align = hdr->p_align;
newsect->alignment_power = bfd_log2 (align);
1999-05-03 09:29:11 +02:00
if (hdr->p_type == PT_LOAD)
{
/* Hack for gdb. Segments that have not been modified do
not have their contents written to a core file, on the
assumption that a debugger can find the contents in the
executable. We flag this case by setting the fake
section size to zero. Note that "real" bss sections will
always have their contents dumped to the core file. */
if (bfd_get_format (abfd) == bfd_core)
newsect->size = 0;
1999-05-03 09:29:11 +02:00
newsect->flags |= SEC_ALLOC;
if (hdr->p_flags & PF_X)
newsect->flags |= SEC_CODE;
}
if (!(hdr->p_flags & PF_W))
newsect->flags |= SEC_READONLY;
}
return TRUE;
1999-05-03 09:29:11 +02:00
}
bfd_boolean
bfd_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int hdr_index)
{
const struct elf_backend_data *bed;
switch (hdr->p_type)
{
case PT_NULL:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "null");
case PT_LOAD:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "load");
case PT_DYNAMIC:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "dynamic");
case PT_INTERP:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "interp");
case PT_NOTE:
if (! _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "note"))
return FALSE;
if (! elf_read_notes (abfd, hdr->p_offset, hdr->p_filesz))
return FALSE;
return TRUE;
case PT_SHLIB:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "shlib");
case PT_PHDR:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "phdr");
case PT_GNU_EH_FRAME:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index,
"eh_frame_hdr");
case PT_GNU_STACK:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "stack");
bfd/ * elflink.c (elf_bfd_final_link): Don't output STT_SECTION symbol into .dynsym if elf_section_data (sec)->dynindx <= 0. Adjust counting of last_local. (_bfd_elf_link_renumber_dynsyms): Don't assign dynindx to sections other than SHT_PROGBITS/SHT_NOBITS and neither for .got/.got.plt/.plt created by the linker nor !SHF_ALLOC. * elf32-i386.c (elf_i386_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. Set sh_entsize for .got section in addition to .got.plt. (elf_i386_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. (elf64_x86_64_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. Set sh_entsize for .got section in addition to .got.plt. * elf.c (_bfd_elf_print_private_bfd_data): Handle PT_GNU_RELRO. (bfd_section_from_phdr): Likewise. (map_sections_to_segments): Likewise. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Likewise. * elflink.c (bfd_elf_size_dynamic_sections): Set elf_tdata (output_bfd)->relro from info->relro. * elf-bfd.h (struct elf_obj_tdata): Add relro field. include/ * bfdlink.h (struct bfd_link_info): Add relro, relro_start and relro_end fields. * elf/common.h (PT_GNU_EH_FRAME, PT_GNU_STACK): Add comments. (PT_GNU_RELRO): Define. binutils/ * readelf.c (get_segment_type): Handle PT_GNU_RELRO. ld/ * genscripts.sh: Generate -z combreloc -z now -z relro scripts for binaries, -shared and -pie. * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Set. * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Set. * emulparams/elf32ppc.sh (OTHER_READWRITE_SECTIONS): Rename to... (OTHER_RELRO_SECTIONS): ... this. * ldlex.l (DATA_SEGMENT_RELRO_END): Add. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z relro and -z norelro. (gld${EMULATION_NAME}_list_options): Add it to usage. (gld${EMULATION_NAME}_get_script): Return -z combreloc -z now -z relro scripts when appropriate. * scripttempl/elf.sc: Unset SEPARATE_GOTPLT if RELRO_NOW is set. Create separate .got.plt section if SEPARATE_GOTPLT. Move sections which are only written during relocation handling to the beginning of RW segment. If NO_SMALL_DATA, move .got before .data. Add DATA_SEGMENT_RELRO_END directive. Include OTHER_RELRO_SECTIONS. * ldgram.y (DATA_SEGMENT_RELRO_END): Add. * ldexp.c (exp_print_token): Handle DATA_SEGMENT_RELRO_END. (fold_unary): Likewise. (fold_binary): Handle -z relro. * ldexp.h (struct exp_data_seg): Add exp_dataseg_relro_seen and exp_dataseg_relro_adjust phases. Add relro_end field. * ldmain.c (main): Initialize link_info.relro to FALSE. * ldlang.c (lang_size_sections): Handle -z relro. ld/testsuite/ * ld-i386/tlspic.rd: Adjust for section reordering changes and removal of unneeded STT_SECTION symbols from .dynsym. * ld-i386/tlspic.dd: Likewise. * ld-i386/tlspic.sd: Likewise. * ld-i386/tlsbin.rd: Likewise. * ld-i386/tlsbinpic.s: Likewise. * ld-i386/tlsbin.dd: Likewise. * ld-i386/tlsbin.sd: Likewise. * ld-i386/tlsnopic.rd: Likewise. * ld-i386/tlsnopic1.s: Likewise. * ld-i386/combreloc.d: Likewise. * ld-i386/tlsnopic.dd: Likewise. * ld-i386/tlsnopic.sd: Likewise. * ld-x86-64/tlspic.rd: Likewise. * ld-x86-64/tlspic.dd: Likewise. * ld-x86-64/tlsbin.dd: Likewise. * ld-x86-64/tlspic.sd: Likewise. * ld-x86-64/tlsbin.sd: Likewise. * ld-x86-64/tlspic.td: Likewise. * ld-x86-64/tlsbin.td: Likewise. * ld-x86-64/tlsbin.rd: Likewise. * ld-s390/tlspic1.s: Likewise. * ld-s390/tlsbinpic.s: Likewise. * ld-s390/tlspic.rd: Likewise. * ld-s390/tlsbin.rd: Likewise. * ld-s390/tlspic.dd: Likewise. * ld-s390/tlsbin.dd: Likewise. * ld-s390/tlsbin.sd: Likewise. * ld-s390/tlsbin.td: Likewise. * ld-s390/tlspic.sd: Likewise. * ld-s390/tlspic.td: Likewise. * ld-s390/tlspic1_64.s: Likewise. * ld-s390/tlsbinpic_64.s: Likewise. * ld-s390/tlspic_64.rd: Likewise. * ld-s390/tlsbin_64.rd: Likewise. * ld-s390/tlspic_64.dd: Likewise. * ld-s390/tlsbin_64.dd: Likewise. * ld-s390/tlspic_64.sd: Likewise. * ld-s390/tlspic_64.td: Likewise. * ld-s390/tlsbin_64.td: Likewise. * ld-s390/tlsbin_64.sd: Likewise. * ld-powerpc/tlsexe32.r: Likewise. * ld-powerpc/tlsso32.r: Likewise. * ld-powerpc/tlsso32.d: Likewise. * ld-powerpc/tlsso32.g: Likewise. * ld-powerpc/tlsso32.t: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlsso.g: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-powerpc/tlstocso.g: Likewise. * ld-ia64/tlspic.rd: Likewise. * ld-ia64/tlspic.dd: Likewise. * ld-ia64/tlspic.sd: Likewise. * ld-ia64/tlspic.td: Likewise. * ld-ia64/tlsbin.rd: Likewise. * ld-ia64/tlsbin.sd: Likewise. * ld-ia64/tlsbin.td: Likewise. * ld-elfvsb/elfvsb.exp: XFAIL non-PIC load offset tests on s390x. * ld-shared/shared.exp: Likewise.
2004-05-11 19:08:38 +02:00
case PT_GNU_RELRO:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "relro");
bfd/ * elflink.c (elf_bfd_final_link): Don't output STT_SECTION symbol into .dynsym if elf_section_data (sec)->dynindx <= 0. Adjust counting of last_local. (_bfd_elf_link_renumber_dynsyms): Don't assign dynindx to sections other than SHT_PROGBITS/SHT_NOBITS and neither for .got/.got.plt/.plt created by the linker nor !SHF_ALLOC. * elf32-i386.c (elf_i386_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. Set sh_entsize for .got section in addition to .got.plt. (elf_i386_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. (elf64_x86_64_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. Set sh_entsize for .got section in addition to .got.plt. * elf.c (_bfd_elf_print_private_bfd_data): Handle PT_GNU_RELRO. (bfd_section_from_phdr): Likewise. (map_sections_to_segments): Likewise. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Likewise. * elflink.c (bfd_elf_size_dynamic_sections): Set elf_tdata (output_bfd)->relro from info->relro. * elf-bfd.h (struct elf_obj_tdata): Add relro field. include/ * bfdlink.h (struct bfd_link_info): Add relro, relro_start and relro_end fields. * elf/common.h (PT_GNU_EH_FRAME, PT_GNU_STACK): Add comments. (PT_GNU_RELRO): Define. binutils/ * readelf.c (get_segment_type): Handle PT_GNU_RELRO. ld/ * genscripts.sh: Generate -z combreloc -z now -z relro scripts for binaries, -shared and -pie. * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Set. * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Set. * emulparams/elf32ppc.sh (OTHER_READWRITE_SECTIONS): Rename to... (OTHER_RELRO_SECTIONS): ... this. * ldlex.l (DATA_SEGMENT_RELRO_END): Add. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z relro and -z norelro. (gld${EMULATION_NAME}_list_options): Add it to usage. (gld${EMULATION_NAME}_get_script): Return -z combreloc -z now -z relro scripts when appropriate. * scripttempl/elf.sc: Unset SEPARATE_GOTPLT if RELRO_NOW is set. Create separate .got.plt section if SEPARATE_GOTPLT. Move sections which are only written during relocation handling to the beginning of RW segment. If NO_SMALL_DATA, move .got before .data. Add DATA_SEGMENT_RELRO_END directive. Include OTHER_RELRO_SECTIONS. * ldgram.y (DATA_SEGMENT_RELRO_END): Add. * ldexp.c (exp_print_token): Handle DATA_SEGMENT_RELRO_END. (fold_unary): Likewise. (fold_binary): Handle -z relro. * ldexp.h (struct exp_data_seg): Add exp_dataseg_relro_seen and exp_dataseg_relro_adjust phases. Add relro_end field. * ldmain.c (main): Initialize link_info.relro to FALSE. * ldlang.c (lang_size_sections): Handle -z relro. ld/testsuite/ * ld-i386/tlspic.rd: Adjust for section reordering changes and removal of unneeded STT_SECTION symbols from .dynsym. * ld-i386/tlspic.dd: Likewise. * ld-i386/tlspic.sd: Likewise. * ld-i386/tlsbin.rd: Likewise. * ld-i386/tlsbinpic.s: Likewise. * ld-i386/tlsbin.dd: Likewise. * ld-i386/tlsbin.sd: Likewise. * ld-i386/tlsnopic.rd: Likewise. * ld-i386/tlsnopic1.s: Likewise. * ld-i386/combreloc.d: Likewise. * ld-i386/tlsnopic.dd: Likewise. * ld-i386/tlsnopic.sd: Likewise. * ld-x86-64/tlspic.rd: Likewise. * ld-x86-64/tlspic.dd: Likewise. * ld-x86-64/tlsbin.dd: Likewise. * ld-x86-64/tlspic.sd: Likewise. * ld-x86-64/tlsbin.sd: Likewise. * ld-x86-64/tlspic.td: Likewise. * ld-x86-64/tlsbin.td: Likewise. * ld-x86-64/tlsbin.rd: Likewise. * ld-s390/tlspic1.s: Likewise. * ld-s390/tlsbinpic.s: Likewise. * ld-s390/tlspic.rd: Likewise. * ld-s390/tlsbin.rd: Likewise. * ld-s390/tlspic.dd: Likewise. * ld-s390/tlsbin.dd: Likewise. * ld-s390/tlsbin.sd: Likewise. * ld-s390/tlsbin.td: Likewise. * ld-s390/tlspic.sd: Likewise. * ld-s390/tlspic.td: Likewise. * ld-s390/tlspic1_64.s: Likewise. * ld-s390/tlsbinpic_64.s: Likewise. * ld-s390/tlspic_64.rd: Likewise. * ld-s390/tlsbin_64.rd: Likewise. * ld-s390/tlspic_64.dd: Likewise. * ld-s390/tlsbin_64.dd: Likewise. * ld-s390/tlspic_64.sd: Likewise. * ld-s390/tlspic_64.td: Likewise. * ld-s390/tlsbin_64.td: Likewise. * ld-s390/tlsbin_64.sd: Likewise. * ld-powerpc/tlsexe32.r: Likewise. * ld-powerpc/tlsso32.r: Likewise. * ld-powerpc/tlsso32.d: Likewise. * ld-powerpc/tlsso32.g: Likewise. * ld-powerpc/tlsso32.t: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlsso.g: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-powerpc/tlstocso.g: Likewise. * ld-ia64/tlspic.rd: Likewise. * ld-ia64/tlspic.dd: Likewise. * ld-ia64/tlspic.sd: Likewise. * ld-ia64/tlspic.td: Likewise. * ld-ia64/tlsbin.rd: Likewise. * ld-ia64/tlsbin.sd: Likewise. * ld-ia64/tlsbin.td: Likewise. * ld-elfvsb/elfvsb.exp: XFAIL non-PIC load offset tests on s390x. * ld-shared/shared.exp: Likewise.
2004-05-11 19:08:38 +02:00
default:
/* Check for any processor-specific program segment types. */
bed = get_elf_backend_data (abfd);
return bed->elf_backend_section_from_phdr (abfd, hdr, hdr_index, "proc");
}
}
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
/* Return the REL_HDR for SEC, assuming there is only a single one, either
REL or RELA. */
Elf_Internal_Shdr *
_bfd_elf_single_rel_hdr (asection *sec)
{
if (elf_section_data (sec)->rel.hdr)
{
BFD_ASSERT (elf_section_data (sec)->rela.hdr == NULL);
return elf_section_data (sec)->rel.hdr;
}
else
return elf_section_data (sec)->rela.hdr;
}
/* Allocate and initialize a section-header for a new reloc section,
containing relocations against ASECT. It is stored in RELDATA. If
USE_RELA_P is TRUE, we use RELA relocations; otherwise, we use REL
relocations. */
bfd_boolean
_bfd_elf_init_reloc_shdr (bfd *abfd,
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
struct bfd_elf_section_reloc_data *reldata,
asection *asect,
bfd_boolean use_rela_p)
{
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
Elf_Internal_Shdr *rel_hdr;
char *name;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
bfd_size_type amt;
amt = sizeof (Elf_Internal_Shdr);
BFD_ASSERT (reldata->hdr == NULL);
rel_hdr = bfd_zalloc (abfd, amt);
reldata->hdr = rel_hdr;
amt = sizeof ".rela" + strlen (asect->name);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, amt);
if (name == NULL)
return FALSE;
sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
rel_hdr->sh_name =
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
(unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name,
FALSE);
if (rel_hdr->sh_name == (unsigned int) -1)
return FALSE;
rel_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL;
rel_hdr->sh_entsize = (use_rela_p
? bed->s->sizeof_rela
: bed->s->sizeof_rel);
rel_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align;
rel_hdr->sh_flags = 0;
rel_hdr->sh_addr = 0;
rel_hdr->sh_size = 0;
rel_hdr->sh_offset = 0;
return TRUE;
}
/* Return the default section type based on the passed in section flags. */
int
bfd_elf_get_default_section_type (flagword flags)
{
if ((flags & SEC_ALLOC) != 0
&& (flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
return SHT_NOBITS;
return SHT_PROGBITS;
}
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
struct fake_section_arg
{
struct bfd_link_info *link_info;
bfd_boolean failed;
};
1999-05-03 09:29:11 +02:00
/* Set up an ELF internal section header for a section. */
static void
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
1999-05-03 09:29:11 +02:00
{
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
struct fake_section_arg *arg = (struct fake_section_arg *)fsarg;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
struct bfd_elf_section_data *esd = elf_section_data (asect);
1999-05-03 09:29:11 +02:00
Elf_Internal_Shdr *this_hdr;
unsigned int sh_type;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
if (arg->failed)
1999-05-03 09:29:11 +02:00
{
/* We already failed; just get out of the bfd_map_over_sections
loop. */
1999-05-03 09:29:11 +02:00
return;
}
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
this_hdr = &esd->this_hdr;
1999-05-03 09:29:11 +02:00
this_hdr->sh_name = (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
asect->name, FALSE);
if (this_hdr->sh_name == (unsigned int) -1)
1999-05-03 09:29:11 +02:00
{
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
arg->failed = TRUE;
1999-05-03 09:29:11 +02:00
return;
}
/* Don't clear sh_flags. Assembler may set additional bits. */
1999-05-03 09:29:11 +02:00
if ((asect->flags & SEC_ALLOC) != 0
|| asect->user_set_vma)
this_hdr->sh_addr = asect->vma;
else
this_hdr->sh_addr = 0;
this_hdr->sh_offset = 0;
bfd/ * section.c (struct sec): Rename "_cooked_size" to "size". Rename "_raw_size" to "rawsize". (STD_SECTION): Adjust comments. (bfd_set_section_size, bfd_get_section_contents): Use size. (bfd_malloc_and_get_section): New function. * bfd-in.h (bfd_section_size, bfd_get_section_size): Use size. * coff-sh.c (sh_relax_section): Alloc coff_section_data struct early. Correctly free reloc and contents memory. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME and fake CIE now that we can shink section size to zero. (_bfd_elf_write_section_eh_frame): Likewise.. * elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents. * elf-m10300.c (mn10300_elf_final_link_relocate): Don't use _bfd_stab_section_offset. Use _bfd_elf_section_offset. * stabs.c (_bfd_stab_section_offset_): Remove unused args and unneeded indirection. * elf.c (_bfd_elf_section_offset): .. and update call. * libbfd-in.h (_bfd_stab_section_offset): Update prototype. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. Replace occurrences of "_raw_size" and "_cooked_size" in most places with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE sections. Use "rawsize", if non-zero, for bfd_get_section_contents calls if the section might be a stabs, eh_frame, or SEC_MERGE section. Similarly use "rawsize", if non-zero, in reloc functions to validate reloc addresses. Use new bfd_malloc_and_get_section in most places where bfd_get_section_contents was called. Expand all occurrences of bfd_section_size and bfd_get_section_size. Rename "raw_size" var in grok_prstatus and similar functions to "size". * aix386-core.c (aix386_core_file_p): .. * aix5ppc-core.c (xcoff64_core_p): .. * aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents, aout_adobe_set_section_contents): .. * aout-target.h (callback): .. * aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate, MY_bfd_final_link): .. * aoutf1.h (sunos4_core_file_p): .. * aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic, adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags, final_link, aout_link_input_section): .. * binary.c (binary_object_p, binary_canonicalize_symtab, binary_set_section_contents): .. * bout.c (b_out_callback, b_out_write_object_contents, b_out_set_section_contents, b_out_bfd_relax_section, b_out_bfd_get_relocated_section_contents): .. * cisco-core.c (cisco_core_file_validate): .. * coff-alpha.c (alpha_ecoff_object_p, alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): .. * coff-arm.c (coff_arm_relocate_section, bfd_arm_allocate_interworking_sections): .. * coff-h8300.c (h8300_reloc16_extra_cases, h8300_bfd_link_add_symbols): .. * coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): .. * coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section, ppc_bfd_coff_final_link): .. * coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): .. * coff-sh.c (sh_relax_section, sh_relax_delete_bytes, sh_align_loads, sh_coff_get_relocated_section_contents): .. * coff64-rs6000.c (xcoff64_write_object_contents, xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): .. * coffcode.h (coff_compute_section_file_positions, coff_write_object_contents): .. * coffgen.c (make_a_section_from_file, coff_write_symbols, coff_section_symbol, build_debug_section): .. * cofflink.c (coff_link_add_symbols, _bfd_coff_final_link, process_embedded_commands, _bfd_coff_link_input_bfd, _bfd_coff_write_global_sym): .. * cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): .. * cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): .. * dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): .. * dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info, _bfd_dwarf2_find_nearest_line): .. * ecoff.c (bfd_debug_section, ecoff_set_symbol_info, ecoff_compute_section_file_positions, _bfd_ecoff_write_object_contents, ecoff_indirect_link_order): .. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame, _bfd_elf_discard_section_eh_frame_hdr, _bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset, _bfd_elf_write_section_eh_frame, _bfd_elf_write_section_eh_frame_hdr): .. * elf-hppa.h (elf_hppa_sort_unwind): .. * elf-m10200.c (mn10200_elf_relax_section, mn10200_elf_relax_delete_bytes, mn10200_elf_get_relocated_section_contents): .. * elf-m10300.c (_bfd_mn10300_elf_create_got_section, mn10300_elf_check_relocs, mn10300_elf_relax_section, mn10300_elf_relax_delete_bytes, mn10300_elf_get_relocated_section_contents, _bfd_mn10300_elf_adjust_dynamic_symbol, _bfd_mn10300_elf_discard_copies, _bfd_mn10300_elf_size_dynamic_sections, _bfd_mn10300_elf_finish_dynamic_sections): .. * elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list, _bfd_elf_make_section_from_phdr, elf_fake_sections, bfd_elf_set_group_contents, map_sections_to_segments, elf_sort_sections, assign_file_positions_for_segments, SECTION_SIZE, copy_private_bfd_data, _bfd_elf_get_dynamic_reloc_upper_bound, _bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect, _bfd_elfcore_make_pseudosection, elfcore_grok_prstatus, elfcore_grok_lwpstatus, elfcore_grok_win32pstatus, elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs, _bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): .. * elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect, bfd_elf32_arm_process_before_allocation, elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs, elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections, elf32_arm_write_section): .. * elf32-cris.c (cris_elf_grok_prstatus, elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook, elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol, cris_elf_check_relocs, elf_cris_size_dynamic_sections, elf_cris_discard_excess_dso_dynamics, elf_cris_discard_excess_program_dynamics): .. * elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): .. * elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): .. * elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup, _frv_create_got_section, _frvfdpic_assign_plt_entries, elf32_frvfdpic_size_dynamic_sections, elf32_frvfdpic_modify_segment_map, elf32_frvfdpic_finish_dynamic_sections): .. * elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes, elf32_h8_get_relocated_section_contents): .. * elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub, elf32_hppa_adjust_dynamic_symbol, allocate_plt_static, allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections, elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs, elf32_hppa_finish_dynamic_sections): .. * elf32-i370.c (i370_elf_adjust_dynamic_symbol, i370_elf_size_dynamic_sections, i370_elf_check_relocs, i370_elf_finish_dynamic_sections): .. * elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol, allocate_dynrelocs, elf_i386_size_dynamic_sections, elf_i386_relocate_section, elf_i386_finish_dynamic_sections): .. * elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc, i860_howto_highadj_reloc, i860_howto_splitn_reloc): .. * elf32-ip2k.c (ip2k_is_switch_table_128, ip2k_relax_switch_table_128, ip2k_is_switch_table_256, ip2k_relax_switch_table_256, ip2k_elf_relax_section, adjust_all_relocations, ip2k_elf_relax_delete_bytes): .. * elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc, m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol, allocate_dynrelocs, m32r_elf_size_dynamic_sections, m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections, m32r_elf_relax_section, m32r_elf_relax_delete_bytes, m32r_elf_get_relocated_section_contents): .. * elf32-m68hc11.c (m68hc11_elf_build_one_stub, m68hc11_elf_size_one_stub, m68hc11_elf_relax_section, m68hc11_elf_relax_delete_bytes): .. * elf32-m68hc12.c (m68hc12_elf_build_one_stub, m68hc12_elf_size_one_stub): .. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs, elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): .. * elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook, elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections, elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): .. * elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc, elf32_mips_grok_prstatus): .. * elf32-or32.c (or32_elf_consth_reloc): .. * elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc, elf_create_pointer_linker_section, ppc_elf_create_linker_section, ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol, allocate_dynrelocs, ppc_elf_size_dynamic_sections, ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus, ppc_elf_final_write_processing): .. * elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol, allocate_dynrelocs, elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): .. * elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section, sh_elf_relax_delete_bytes, sh_elf_align_loads, sh_elf_adjust_dynamic_symbol, allocate_dynrelocs, sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents, sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): .. * elf32-sh64-com.c (sh64_address_in_cranges, sh64_get_contents_type): .. * elf32-sh64.c (sh64_find_section_for_address, sh64_elf_final_write_processing): .. * elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc, sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol, allocate_dynrelocs, elf32_sparc_size_dynamic_sections, elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): .. * elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): .. * elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol, elf_vax_size_dynamic_sections, elf_vax_discard_copies, elf_vax_instantiate_got_entries, elf_vax_relocate_section, elf_vax_finish_dynamic_sections): .. * elf32-xstormy16.c (xstormy16_elf_24_reloc, xstormy16_elf_check_relocs, xstormy16_relax_plt_check, xstormy16_elf_relax_section, xstormy16_elf_always_size_sections, xstormy16_elf_finish_dynamic_sections): .. * elf32-xtensa.c (xtensa_read_table_entries, elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size, elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc, bfd_elf_xtensa_reloc, elf_xtensa_relocate_section, elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections, elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus, get_relocation_opcode, retrieve_contents, find_relaxable_sections, collect_source_relocs, is_resolvable_asm_expansion, remove_literals, relax_section, shrink_dynamic_reloc_sections, relax_property_section, xtensa_callback_required_dependence): .. * elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section, elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol, elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets, elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1, elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes, elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1, elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel, elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): .. * elf64-hppa.c (allocate_dynrel_entries, elf64_hppa_size_dynamic_sections, elf64_hppa_finish_dynamic_sections): .. * elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc, mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table, elf64_mips_grok_prstatus): .. * elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc, mmix_elf_relocate_section, mmix_elf_final_link, mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation, mmix_elf_relax_section, mmix_elf_get_section_contents): .. * elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus, ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust, ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd, allocate_dynrelocs, ppc64_elf_size_dynamic_sections, ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section, toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs, ppc64_elf_build_stubs, ppc64_elf_relocate_section, ppc64_elf_finish_dynamic_sections): .. * elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol, allocate_dynrelocs, elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_sections): .. * elf64-sh64.c (sh_elf64_get_relocated_section_contents, sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol, sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections, sh64_elf64_finish_dynamic_sections): .. * elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc, sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol, sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section, sparc64_elf_finish_dynamic_symbol, sparc64_elf_finish_dynamic_sections): .. * elf64-x86-64.c (elf64_x86_64_grok_prstatus, elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs, elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section, elf64_x86_64_finish_dynamic_sections): .. * elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): .. * elfcode.h (elf_slurp_reloc_table): .. * elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag, elf_finalize_dynstr, elf_link_add_object_symbols, bfd_elf_size_dynamic_sections, elf_link_sort_relocs, elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): .. * elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc, elf32_mips_grok_prstatus): .. * elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries, elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc, elfNN_ia64_choose_gp, elfNN_ia64_final_link, elfNN_ia64_finish_dynamic_sections): .. * elfxx-mips.c (mips_elf_create_procedure_table, mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp, _bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc, mips_elf_global_got_index, mips_elf_multi_got, mips_elf_create_compact_rel_section, mips_elf_calculate_relocation, mips_elf_allocate_dynamic_relocations, mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections, _bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol, _bfd_mips_elf_always_size_sections, _bfd_mips_elf_size_dynamic_sections, _bfd_mips_elf_finish_dynamic_symbol, _bfd_mips_elf_finish_dynamic_sections, _bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info, _bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents, _bfd_elf_mips_get_relocated_section_contents, _bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): .. * hp300hpux.c (callback): .. * hppabsd-core.c (make_bfd_asection): .. * hpux-core.c (make_bfd_asection): .. * i386linux.c (linux_link_create_dynamic_sections, bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): .. * i386msdos.c (msdos_write_object_contents): .. * i386os9k.c (os9k_callback, os9k_write_object_contents, os9k_set_section_contents): .. * ieee.c (parse_expression, ieee_slurp_external_symbols, ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data, ieee_write_section_part, do_with_relocs, do_as_repeat, do_without_relocs, ieee_write_debug_part, init_for_output, ieee_set_section_contents): .. * ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): .. * irix-core.c (do_sections, make_bfd_asection): .. * libaout.h (aout_section_merge_with_text_p): .. * libbfd.c (_bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window): .. * linker.c (default_indirect_link_order): .. * lynx-core.c (make_bfd_asection): .. * m68klinux.c (linux_link_create_dynamic_sections, bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): .. * mach-o.c (bfd_mach_o_make_bfd_section, bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib, bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab, bfd_mach_o_scan_read_segment): .. * merge.c (_bfd_add_merge_section, record_section, merge_strings, _bfd_merge_sections): .. * mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc, mmo_map_set_sizes, mmo_canonicalize_symtab, mmo_internal_write_section, mmo_write_object_contents): .. * netbsd-core.c (netbsd_core_file_p): .. * nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import, nlm_alpha_set_public_section): .. * nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): .. * nlm32-sparc.c (nlm_sparc_write_import): .. * nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in, nlm_compute_section_file_positions): .. * oasys.c (oasys_object_p, oasys_slurp_section_data, oasys_write_sections, oasys_write_data, oasys_set_section_contents): .. * opncls.c (get_debug_link_info): .. * osf-core.c (make_bfd_asection): .. * pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic, adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs, final_link, aout_link_input_section): .. * peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out, pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): .. * pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section, bfd_pef_scan_start_address, bfd_pef_parse_symbols): .. * ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): .. * ptrace-core.c (ptrace_unix_core_file_p): .. * reloc.c (bfd_perform_relocation, bfd_install_relocation, _bfd_final_link_relocate, bfd_generic_relax_section, bfd_generic_get_relocated_section_contents): .. * reloc16.c (bfd_coff_reloc16_relax_section, bfd_coff_reloc16_get_relocated_section_c): .. * riscix.c (riscix_some_aout_object_p): .. * rs6000-core.c (read_hdr, make_bfd_asection): .. * sco5-core.c (make_bfd_asection): .. * simple.c (bfd_simple_get_relocated_section_contents): .. * som.c (som_object_setup, setup_sections, som_prep_headers, som_write_fixups, som_begin_writing, bfd_section_from_som_symbol, som_set_reloc_info, som_get_section_contents, som_bfd_link_split_section): .. * sparclinux.c (linux_link_create_dynamic_sections, bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): .. * srec.c (srec_scan, srec_read_section, srec_get_section_contents): .. * stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs, _bfd_write_stab_strings, _bfd_stab_section_offset): .. * sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections, bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs, sunos_scan_ext_relocs, sunos_scan_dynamic_symbol, sunos_write_dynamic_symbol, sunos_check_dynamic_reloc, sunos_finish_dynamic_link): .. * syms.c (_bfd_stab_section_find_nearest_line): .. * tekhex.c (first_phase, tekhex_set_section_contents, tekhex_write_object_contents): .. * trad-core.c (trad_unix_core_file_p): .. * versados.c (process_esd, process_otr, process_otr): .. * vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): .. * vms-misc.c (add_new_contents): .. * vms-tir.c (check_section, new_section, _bfd_vms_write_tir): .. * vms.c (vms_set_section_contents): .. * xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols, xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms, _bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): .. * xsym.c (bfd_sym_scan): .. See above. binutils/ * objcopy.c (copy_section): Don't set _cooked_size. include/ * bfdlink.h (struct bfd_link_order): Update comment. ld/ * ldlang.c (print_output_section_statement): Don't print size before relaxation. (IGNORE_SECTION): Remove bfd arg. Update all callers. * ldexp.c (fold_name): .. See below. * ldlang.c (section_already_linked, print_output_section_statement, print_input_section, insert_pad, size_input_section, lang_check_section_addresses, lang_size_sections_1, lang_size_sections, lang_do_assignments_1, lang_set_startof, lang_one_common, lang_reset_memory_regions, lang_process, lang_abs_symbol_at_end_of, lang_do_version_exports_section): .. * ldwrite.c (build_link_order, clone_section, ds, split_sections): .. * pe-dll.c (process_def_file, generate_reloc): .. * emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment, gld${EMULATION_NAME}_before_allocation): .. * emultempl/mmix-elfnmmo.em (mmix_after_allocation): .. * emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation, sh64_elf_${EMULATION_NAME}_after_allocation): .. * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): .. * emultempl/xtensaelf.em (ld_assign_relative_paged_dot, ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use "size" instead of "_raw_size" and "_cooked_size". Expand bfd_section_size macro invocations.
2004-06-24 06:46:28 +02:00
this_hdr->sh_size = asect->size;
1999-05-03 09:29:11 +02:00
this_hdr->sh_link = 0;
this_hdr->sh_addralign = (bfd_vma) 1 << asect->alignment_power;
1999-05-03 09:29:11 +02:00
/* The sh_entsize and sh_info fields may have been set already by
copy_private_section_data. */
this_hdr->bfd_section = asect;
this_hdr->contents = NULL;
/* If the section type is unspecified, we set it based on
asect->flags. */
if ((asect->flags & SEC_GROUP) != 0)
sh_type = SHT_GROUP;
else
sh_type = bfd_elf_get_default_section_type (asect->flags);
if (this_hdr->sh_type == SHT_NULL)
this_hdr->sh_type = sh_type;
else if (this_hdr->sh_type == SHT_NOBITS
&& sh_type == SHT_PROGBITS
&& (asect->flags & SEC_ALLOC) != 0)
{
/* Warn if we are changing a NOBITS section to PROGBITS, but
allow the link to proceed. This can happen when users link
non-bss input sections to bss output sections, or emit data
to a bss output section via a linker script. */
(*_bfd_error_handler)
(_("warning: section `%A' type changed to PROGBITS"), asect);
this_hdr->sh_type = sh_type;
}
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
switch (this_hdr->sh_type)
1999-05-03 09:29:11 +02:00
{
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
default:
break;
case SHT_STRTAB:
case SHT_INIT_ARRAY:
case SHT_FINI_ARRAY:
case SHT_PREINIT_ARRAY:
case SHT_NOTE:
case SHT_NOBITS:
case SHT_PROGBITS:
break;
case SHT_HASH:
this_hdr->sh_entsize = bed->s->sizeof_hash_entry;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
break;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
case SHT_DYNSYM:
1999-05-03 09:29:11 +02:00
this_hdr->sh_entsize = bed->s->sizeof_sym;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
break;
case SHT_DYNAMIC:
1999-05-03 09:29:11 +02:00
this_hdr->sh_entsize = bed->s->sizeof_dyn;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
break;
case SHT_RELA:
if (get_elf_backend_data (abfd)->may_use_rela_p)
this_hdr->sh_entsize = bed->s->sizeof_rela;
break;
case SHT_REL:
if (get_elf_backend_data (abfd)->may_use_rel_p)
this_hdr->sh_entsize = bed->s->sizeof_rel;
break;
case SHT_GNU_versym:
1999-05-03 09:29:11 +02:00
this_hdr->sh_entsize = sizeof (Elf_External_Versym);
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
break;
case SHT_GNU_verdef:
1999-05-03 09:29:11 +02:00
this_hdr->sh_entsize = 0;
/* objcopy or strip will copy over sh_info, but may not set
cverdefs. The linker will set cverdefs, but sh_info will be
zero. */
1999-05-03 09:29:11 +02:00
if (this_hdr->sh_info == 0)
this_hdr->sh_info = elf_tdata (abfd)->cverdefs;
else
BFD_ASSERT (elf_tdata (abfd)->cverdefs == 0
|| this_hdr->sh_info == elf_tdata (abfd)->cverdefs);
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
break;
case SHT_GNU_verneed:
1999-05-03 09:29:11 +02:00
this_hdr->sh_entsize = 0;
/* objcopy or strip will copy over sh_info, but may not set
cverrefs. The linker will set cverrefs, but sh_info will be
zero. */
1999-05-03 09:29:11 +02:00
if (this_hdr->sh_info == 0)
this_hdr->sh_info = elf_tdata (abfd)->cverrefs;
else
BFD_ASSERT (elf_tdata (abfd)->cverrefs == 0
|| this_hdr->sh_info == elf_tdata (abfd)->cverrefs);
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
break;
case SHT_GROUP:
this_hdr->sh_entsize = GRP_ENTRY_SIZE;
bfd/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (bfd_elf_special_section): New. (elf_backend_data): Add special_sections, a pointer to bfd_elf_special_section. (elf_section_type). New. (elf_section_flags): New. (_bfd_elf_get_sec_type_attr): New. * elf.c (_bfd_elf_make_section_from_shdr): Always use the real section type/flags. (special_sections): New. (get_special_section): New. (_bfd_elf_get_sec_type_attr): New. (_bfd_elf_new_section_hook): Check special_section to set elf_section_type and elf_section_flags. (elf_fake_sections): Don't use section name to set ELF section data. * elf32-m32r.c (m32r_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-m68hc11.c (elf32_m68hc11_special_sections): New. (elf_backend_special_sections): Defined. * elf32-mcore.c (mcore_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-ppc.c (ppc_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-sh64.c (sh64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-v850.c (v850_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf32-xtensa.c (elf_xtensa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-alpha.c (elf64_alpha_special_sections): New. (elf_backend_special_sections): Defined. * elf64-hppa.c (elf64_hppa_special_sections): New. (elf_backend_special_sections): Defined. * elf64-ppc.c (ppc64_elf_special_sections): New. (elf_backend_special_sections): Defined. * elf64-sh64.c (sh64_elf64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-ia64.c (elfNN_ia64_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-mips.c (_bfd_mips_elf_special_sections): New. * elfxx-mips.h (_bfd_mips_elf_special_sections): New. (elf_backend_special_sections): Defined. * elfxx-target.h (elf_backend_special_sections): New. Default to NULL. (elfNN_bed): Initialize special_sections. * section.c (bfd_abs_section): Remove const. (bfd_und_section): Likewise. (bfd_com_section): Likewise. (bfd_ind_section): Likewise. gas/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c (special_sections): Removed. (obj_elf_change_section): Call _bfd_elf_get_sec_type_attr. Set elf_section_type and elf_section_flags. (elf_frob_file): Set SHT_GROUP. * config/obj-elf.h (obj_sec_set_private_data): New. * config/tc-alpha.h (ELF_TC_SPECIAL_SECTIONS): Removed. * config/tc-ia64.h: Likewise. * config/tc-m32r.h: Likewise. * config/tc-m68hc11.h: Likewise. * config/tc-mcore.h: Likewise. * config/tc-mips.h: Likewise. * config/tc-ppc.h: Likewise. * config/tc-sh64.h: Likewise. * config/tc-v850.h: Likewise. * config/tc-xtensa.h: Likewise. * config/tc-v850.h (SHF_V850_GPREL): Removed. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise. * subsegs.c (subseg_get): Call obj_sec_set_private_data if it is defined. include/elf/ 2003-07-25 H.J. Lu <hongjiu.lu@intel.com> * v850.h (SHF_V850_GPREL): New. (SHF_V850_EPREL): Likewise. (SHF_V850_R0REL): Likewise.
2003-07-25 16:35:56 +02:00
break;
include/ * bfdlink.h (struct bfd_link_info): Add emit_hash and emit_gnu_hash bitfields. include/elf/ * common.h (SHT_GNU_HASH, DT_GNU_HASH): Define. ld/ * scripttempl/elf.sc: Add .gnu.hash section. * emultempl/elf32.em (OPTION_HASH_STYLE): Define. (gld${EMULATION_NAME}_add_options): Register --hash-style option. (gld${EMULATION_NAME}_handle_option): Handle it. (gld${EMULATION_NAME}_list_options): Document it. * ldmain.c (main): Initialize emit_hash and emit_gnu_hash. * ld.texinfo: Document --hash-style option. bfd/ * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_GNU_HASH. (bfd_section_from_shdr, elf_fake_sections, assign_section_numbers): Handle SHT_GNU_HASH. (special_sections_g): Include .gnu.hash section. (bfd_elf_gnu_hash): New function. * elf-bfd.h (bfd_elf_gnu_hash, _bfd_elf_hash_symbol): New prototypes. (struct elf_backend_data): Add elf_hash_symbol method. * elflink.c (_bfd_elf_link_create_dynamic_sections): Create .hash only if info->emit_hash, create .gnu.hash section if info->emit_gnu_hash. (struct collect_gnu_hash_codes): New type. (elf_collect_gnu_hash_codes, elf_renumber_gnu_hash_syms, _bfd_elf_hash_symbol): New functions. (compute_bucket_count): Don't compute HASHCODES array, instead add that and NSYMS as arguments. Use bed->s->sizeof_hash_entry instead of bed->s->arch_size / 8. Fix .hash size estimation. When not optimizing, use the number of hashed symbols rather than dynsymcount. (bfd_elf_size_dynamic_sections): Only add DT_HASH if info->emit_hash, and ADD DT_GNU_HASH if info->emit_gnu_hash. (bfd_elf_size_dynsym_hash_dynstr): Size .hash only if info->emit_hash, adjust compute_bucket_count caller. Create and populate .gnu.hash section if info->emit_gnu_hash. (elf_link_output_extsym): Only populate .hash section if finfo->hash_sec != NULL. (bfd_elf_final_link): Adjust assertion. Handle DT_GNU_HASH. * elfxx-target.h (elf_backend_hash_symbol): Define if not yet defined. (elfNN_bed): Add elf_backend_hash_symbol. * elf64-x86-64.c (elf64_x86_64_hash_symbol): New function. (elf_backend_hash_symbol): Define. * elf32-i386.c (elf_i386_hash_symbol): New function. (elf_backend_hash_symbol): Define. binutils/ * readelf.c (get_dynamic_type): Handle DT_GNU_HASH. (get_section_type_name): Handle SHT_GNU_HASH. (dynamic_info_DT_GNU_HASH): New variable. (process_dynamic_section): Handle DT_GNU_HASH. (process_symbol_table): Print also DT_GNU_HASH histogram. ld/testsuite/ * ld-powerpc/tlsso32.r: Adjust. * ld-powerpc/tlsso32.d: Adjust. * ld-powerpc/tlsso32.g: Adjust. * ld-powerpc/tlsso.r: Adjust. * ld-powerpc/tlsso.g: Adjust. * ld-powerpc/tlstocso.g: Adjust.
2006-07-10 23:40:25 +02:00
case SHT_GNU_HASH:
this_hdr->sh_entsize = bed->s->arch_size == 64 ? 0 : 4;
break;
}
1999-05-03 09:29:11 +02:00
if ((asect->flags & SEC_ALLOC) != 0)
this_hdr->sh_flags |= SHF_ALLOC;
if ((asect->flags & SEC_READONLY) == 0)
this_hdr->sh_flags |= SHF_WRITE;
if ((asect->flags & SEC_CODE) != 0)
this_hdr->sh_flags |= SHF_EXECINSTR;
bfd/ * libbfd-in.h (_bfd_merge_section): New. (_bfd_write_merged_section): New. (_bfd_merged_section_offset): New. * libbfd.h: Rebuilt. * linker.c (_bfd_generic_link_output_symbols): Handle discard_sec_merge. * aoutx.h (aout_link_write_symbols): Likewise. * pdp11.c (aout_link_write_symbols): Likewise. * elflink.h (elf_link_add_object_symbols): Call _bfd_merge_section. (elf_bfd_final_link): Adjust global symbols pointing into SEC_MERGE sections. (elf_link_sec_merge_syms): New. (elf_link_input_bfd): Call _bfd_merged_section_offset and _bfd_write_merged_section. Handle discard_sec_merge. * elf-bfd.h (struct elf_link_hash_table): Add merge_info field. (struct bfd_elf_section_data): Likewise. * elf.c (_bfd_elf_make_section_from_shdr): Set SEC_MERGE and SEC_STRINGS section flags and entsize from their ELF counterparts. (_bfd_elf_link_hash_table_init): Initialize merge_info. (elf_fake_sections): Set SHF_MERGE, SHF_STRINGS and sh_entsize from their BFD counterparts. * merge.c: New file. * Makefile.am: Add strtab.lo. * Makefile.in: Rebuilt. include/ * bfdlink.h (bfd_link_discard): Add discard_sec_merge. gas/ * config/obj-elf.c (obj_elf_change_section): Add entsize argument, handle SHF_MERGE and SHF_STRINGS. (obj_elf_parse_section_letters): Set SHF_MERGE and SHF_STRINGS. (obj_elf_section): Allow additional argument specifying entity size. * write.c (adjust_reloc_syms): Keep relocations against local symbols in SEC_MERGE sections. ld/ * ldmain.c (main): Default to discard_sec_merge. * lexsup.c (OPTION_DISCARD_NONE): Define. (ld_options): Add --discard-none. (parse_args): Handle OPTION_DISCARD_NONE. * ldlang.c (wild_doit): SEC_MERGE should be set in the output section only if SEC_MERGE and SEC_STRINGS flags and entsize of all its input sections match.
2001-04-13 02:34:36 +02:00
if ((asect->flags & SEC_MERGE) != 0)
{
this_hdr->sh_flags |= SHF_MERGE;
this_hdr->sh_entsize = asect->entsize;
if ((asect->flags & SEC_STRINGS) != 0)
this_hdr->sh_flags |= SHF_STRINGS;
}
if ((asect->flags & SEC_GROUP) == 0 && elf_group_name (asect) != NULL)
this_hdr->sh_flags |= SHF_GROUP;
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
if ((asect->flags & SEC_THREAD_LOCAL) != 0)
{
this_hdr->sh_flags |= SHF_TLS;
if (asect->size == 0
&& (asect->flags & SEC_HAS_CONTENTS) == 0)
{
struct bfd_link_order *o = asect->map_tail.link_order;
this_hdr->sh_size = 0;
if (o != NULL)
{
this_hdr->sh_size = o->offset + o->size;
if (this_hdr->sh_size != 0)
this_hdr->sh_type = SHT_NOBITS;
}
}
}
Implement generic SHF_EXCLUDE. bfd/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * elf.c (_bfd_elf_make_section_from_shdr): Handle SHF_EXCLUDE (elf_fake_sections): Likewise. * elf32-i370.c (i370_elf_section_from_shdr): Don't handle SHF_EXCLUDE here. * elf32-ppc.c (ppc_elf_fake_sections): Likewise. binutils/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * readelf.c (get_elf_section_flags): Treat SHF_EXCLUDE as a generic flag. binutils/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * binutils-all/objcopy.exp: Run exclude-1a and exclude-1b for ELF targets. * binutils-all/exclude-1.s: New. * binutils-all/exclude-1a.d: Likewise. * binutils-all/exclude-1b.d: Likewise. gas/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * obj-elf.c (obj_elf_change_section): Handle SHF_EXCLUDE. (obj_elf_parse_section_letters): Likewise. (obj_elf_section_word): Likewise. * config/tc-ppc.c (ppc_section_letter): Removed. (ppc_section_word): Likewise. * config/tc-ppc.h (ppc_section_letter): Likewise. (ppc_section_word): Likewise. (md_elf_section_letter): Likewise. (md_elf_section_word): Likewise. * doc/as.texinfo: Document `e' and `#exclude'. gas/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * gas/elf/elf.exp: Run section8. * gas/elf/section8.d: New. * gas/elf/section8.s: Likewise. include/elf/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * common.h (SHF_EXCLUDE): New. * i370.h (SHF_EXCLUDE): Removed. * or32.h (SHF_EXCLUDE): Likewise. * ppc.h (SHF_EXCLUDE): Likewise. * sparc.h (SHF_EXCLUDE): Likewise. ld/testsuite/ 2010-05-18 H.J. Lu <hongjiu.lu@intel.com> PR gas/11600 * ld-elf/exclude3.s: New. * ld-elf/exclude3a.d: Likewise. * ld-elf/exclude3b.d: Likewise. * ld-elf/exclude3c.d: Likewise.
2010-05-18 05:31:07 +02:00
if ((asect->flags & (SEC_GROUP | SEC_EXCLUDE)) == SEC_EXCLUDE)
this_hdr->sh_flags |= SHF_EXCLUDE;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
/* If the section has relocs, set up a section header for the
SHT_REL[A] section. If two relocation sections are required for
this section, it is up to the processor-specific back-end to
create the other. */
if ((asect->flags & SEC_RELOC) != 0)
{
/* When doing a relocatable link, create both REL and RELA sections if
needed. */
if (arg->link_info
/* Do the normal setup if we wouldn't create any sections here. */
&& esd->rel.count + esd->rela.count > 0
&& (arg->link_info->relocatable || arg->link_info->emitrelocations))
{
if (esd->rel.count && esd->rel.hdr == NULL
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rel, asect, FALSE))
{
arg->failed = TRUE;
return;
}
if (esd->rela.count && esd->rela.hdr == NULL
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rela, asect, TRUE))
{
arg->failed = TRUE;
return;
}
}
else if (!_bfd_elf_init_reloc_shdr (abfd,
(asect->use_rela_p
? &esd->rela : &esd->rel),
asect,
asect->use_rela_p))
arg->failed = TRUE;
}
1999-05-03 09:29:11 +02:00
/* Check for processor-specific section types. */
sh_type = this_hdr->sh_type;
if (bed->elf_backend_fake_sections
&& !(*bed->elf_backend_fake_sections) (abfd, this_hdr, asect))
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
arg->failed = TRUE;
1999-05-03 09:29:11 +02:00
if (sh_type == SHT_NOBITS && asect->size != 0)
{
/* Don't change the header type from NOBITS if we are being
called for objcopy --only-keep-debug. */
this_hdr->sh_type = sh_type;
}
1999-05-03 09:29:11 +02:00
}
/* Fill in the contents of a SHT_GROUP section. Called from
_bfd_elf_compute_section_file_positions for gas, objcopy, and
when ELF targets use the generic linker, ld. Called for ld -r
from bfd_elf_final_link. */
void
bfd_elf_set_group_contents (bfd *abfd, asection *sec, void *failedptrarg)
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
bfd_boolean *failedptr = (bfd_boolean *) failedptrarg;
asection *elt, *first;
unsigned char *loc;
bfd_boolean gas;
/* Ignore linker created group section. See elfNN_ia64_object_p in
elfxx-ia64.c. */
if (((sec->flags & (SEC_GROUP | SEC_LINKER_CREATED)) != SEC_GROUP)
|| *failedptr)
return;
if (elf_section_data (sec)->this_hdr.sh_info == 0)
{
unsigned long symindx = 0;
/* elf_group_id will have been set up by objcopy and the
generic linker. */
if (elf_group_id (sec) != NULL)
symindx = elf_group_id (sec)->udata.i;
if (symindx == 0)
{
/* If called from the assembler, swap_out_syms will have set up
elf_section_syms. */
BFD_ASSERT (elf_section_syms (abfd) != NULL);
symindx = elf_section_syms (abfd)[sec->index]->udata.i;
}
elf_section_data (sec)->this_hdr.sh_info = symindx;
}
else if (elf_section_data (sec)->this_hdr.sh_info == (unsigned int) -2)
{
/* The ELF backend linker sets sh_info to -2 when the group
signature symbol is global, and thus the index can't be
set until all local symbols are output. */
asection *igroup = elf_sec_group (elf_next_in_group (sec));
struct bfd_elf_section_data *sec_data = elf_section_data (igroup);
unsigned long symndx = sec_data->this_hdr.sh_info;
unsigned long extsymoff = 0;
struct elf_link_hash_entry *h;
if (!elf_bad_symtab (igroup->owner))
{
Elf_Internal_Shdr *symtab_hdr;
symtab_hdr = &elf_tdata (igroup->owner)->symtab_hdr;
extsymoff = symtab_hdr->sh_info;
}
h = elf_sym_hashes (igroup->owner)[symndx - extsymoff];
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
elf_section_data (sec)->this_hdr.sh_info = h->indx;
}
/* The contents won't be allocated for "ld -r" or objcopy. */
gas = TRUE;
if (sec->contents == NULL)
{
gas = FALSE;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
sec->contents = (unsigned char *) bfd_alloc (abfd, sec->size);
/* Arrange for the section to be written out. */
elf_section_data (sec)->this_hdr.contents = sec->contents;
if (sec->contents == NULL)
{
*failedptr = TRUE;
return;
}
}
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 06:46:28 +02:00
loc = sec->contents + sec->size;
/* Get the pointer to the first section in the group that gas
squirreled away here. objcopy arranges for this to be set to the
start of the input section group. */
first = elt = elf_next_in_group (sec);
/* First element is a flag word. Rest of section is elf section
indices for all the sections of the group. Write them backwards
just to keep the group in the same order as given in .section
directives, not that it matters. */
while (elt != NULL)
{
asection *s;
s = elt;
if (!gas)
s = s->output_section;
if (s != NULL
&& !bfd_is_abs_section (s))
* include/elf/ia64.h (SHT_IA_64_VMS_DISPLAY_NAME_INFO, EF_IA_64_ARCHVER_1): New macros. Minor reformatting. * bfd/Makefile.am (BFD32_BACKENDS): Add new object vmsutil.lo (BFD32_BACKENDS_CFILES): Add new file vmsutil.c (vmsutil.lo): Add dependency rule * bfd/Makefile.in: Regenerate * bfd/config.bfd (ia64*-*-*vms*): Add case. * bfd/configure.in (bfd_elf64_ia64_vms_vec): Add case. * bfd/configure: Regenerate * bfd/vmsutil.[ch]: New files * bfd/elf-bfd.h (struct bfd_elf_special_section): Change type of attr to bfd_vma. * bfd/elfxx-ia64.c (elfNN_vms_post_process_headers, elfNN_vms_section_processing, elfNN_vms_final_write_processing, elfNN_vms_close_and_cleanup, elfNN_vms_section_from_shdr, elfNN_vms_object_p): New functions * bfd/targets.c (bfd_elf64_ia64_vms_vec): New target. * gas/configure.tgt(ia64-*-*vms*): New target. * gas/dwarf2dbg.h (dwarf2_loc_mark_labels): Make extern. * gas/tc.h (md_number_to_chars): Declare iff undefined. * gas/config/obj-elf.c (obj_elf_change_section): Change type of arg attr to bfd_vma. (obj_elf_parse_section_letters): Return a bfd_vma. Change type of variables attr, md_attr to bfd_vma. (obj_elf_section_word): Likewise. (obj_elf_section): Change type of variable attr to bfd_vma * gas/config/obj-elf.h (obj_elf_change_section): Change type of arg attr to bfd_vma * gas/config/tc-ia64.c (bfdver.h,time.h): Include. (ia64_elf_section_letter): Now returns a bfd_vma. Handle VMS specific attributes. (ia64_elf_section_flags): Arg attr now a bfd_vma. (ia64_init): Don't turn on dependency checking for VMS. (ia64_target_format): Check for VMS flag bit. (do_alias): Hande decc$ functions. (get_vms_time): New function. (ia64_vms_note): New function. * gas/config/tc-ia64.h (ia64_elf_section_letter): Now returns a bfd_vma. (ia64_elf_section_flags): Arg attr now a bfd_vma. (tc_init_after_args): Define for VMS. * gas/config/tc-alpha.c (alpha_elf_section_letter): Return a bfd_vma. (alpha_elf_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-alpha.h: Likewise. * gas/config/tc-i386.c (x86_64_section_letter): Return a bfd_vma. (x86_64_section_word): Return a bfd_vma. * gas/config/tc-i386.h: Likewise. * gas/config/tc-ip2k.c (ip2k_elf_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-ip2k.h: Likewise. * gas/config/tc-mep.c (mep_elf_section_letter): Return a bfd_vma. (mep_elf_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-mep.h: Likewise. * gas/config/tc-ppc.c (ppc_section_letter): Return a bfd_vma. (ppc_section_word): Return a bfd_vma. (ppc_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-ppc.h: Likewise. * gas/config/te-vms.h (DWARF2_DIR_SHOULD_END_WITH_SEPARATOR, DWAR2_FILE_TIME_NAME, DWARF2_FILE_SIZE_NAME, DWARF2_FILEN_NAME): New file with new macros * gas/dwarf2dbg.c (get_filenum, out_file_list): Default and call new macros.
2009-01-15 13:42:52 +01:00
{
unsigned int idx = elf_section_data (s)->this_idx;
* include/elf/ia64.h (SHT_IA_64_VMS_DISPLAY_NAME_INFO, EF_IA_64_ARCHVER_1): New macros. Minor reformatting. * bfd/Makefile.am (BFD32_BACKENDS): Add new object vmsutil.lo (BFD32_BACKENDS_CFILES): Add new file vmsutil.c (vmsutil.lo): Add dependency rule * bfd/Makefile.in: Regenerate * bfd/config.bfd (ia64*-*-*vms*): Add case. * bfd/configure.in (bfd_elf64_ia64_vms_vec): Add case. * bfd/configure: Regenerate * bfd/vmsutil.[ch]: New files * bfd/elf-bfd.h (struct bfd_elf_special_section): Change type of attr to bfd_vma. * bfd/elfxx-ia64.c (elfNN_vms_post_process_headers, elfNN_vms_section_processing, elfNN_vms_final_write_processing, elfNN_vms_close_and_cleanup, elfNN_vms_section_from_shdr, elfNN_vms_object_p): New functions * bfd/targets.c (bfd_elf64_ia64_vms_vec): New target. * gas/configure.tgt(ia64-*-*vms*): New target. * gas/dwarf2dbg.h (dwarf2_loc_mark_labels): Make extern. * gas/tc.h (md_number_to_chars): Declare iff undefined. * gas/config/obj-elf.c (obj_elf_change_section): Change type of arg attr to bfd_vma. (obj_elf_parse_section_letters): Return a bfd_vma. Change type of variables attr, md_attr to bfd_vma. (obj_elf_section_word): Likewise. (obj_elf_section): Change type of variable attr to bfd_vma * gas/config/obj-elf.h (obj_elf_change_section): Change type of arg attr to bfd_vma * gas/config/tc-ia64.c (bfdver.h,time.h): Include. (ia64_elf_section_letter): Now returns a bfd_vma. Handle VMS specific attributes. (ia64_elf_section_flags): Arg attr now a bfd_vma. (ia64_init): Don't turn on dependency checking for VMS. (ia64_target_format): Check for VMS flag bit. (do_alias): Hande decc$ functions. (get_vms_time): New function. (ia64_vms_note): New function. * gas/config/tc-ia64.h (ia64_elf_section_letter): Now returns a bfd_vma. (ia64_elf_section_flags): Arg attr now a bfd_vma. (tc_init_after_args): Define for VMS. * gas/config/tc-alpha.c (alpha_elf_section_letter): Return a bfd_vma. (alpha_elf_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-alpha.h: Likewise. * gas/config/tc-i386.c (x86_64_section_letter): Return a bfd_vma. (x86_64_section_word): Return a bfd_vma. * gas/config/tc-i386.h: Likewise. * gas/config/tc-ip2k.c (ip2k_elf_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-ip2k.h: Likewise. * gas/config/tc-mep.c (mep_elf_section_letter): Return a bfd_vma. (mep_elf_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-mep.h: Likewise. * gas/config/tc-ppc.c (ppc_section_letter): Return a bfd_vma. (ppc_section_word): Return a bfd_vma. (ppc_section_flags): Change type of arg attr to bfd_vma. * gas/config/tc-ppc.h: Likewise. * gas/config/te-vms.h (DWARF2_DIR_SHOULD_END_WITH_SEPARATOR, DWAR2_FILE_TIME_NAME, DWARF2_FILE_SIZE_NAME, DWARF2_FILEN_NAME): New file with new macros * gas/dwarf2dbg.c (get_filenum, out_file_list): Default and call new macros.
2009-01-15 13:42:52 +01:00
loc -= 4;
H_PUT_32 (abfd, idx, loc);
}
elt = elf_next_in_group (elt);
if (elt == first)
break;
}
if ((loc -= 4) != sec->contents)
abort ();
H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc);
}
1999-05-03 09:29:11 +02:00
/* Assign all ELF section numbers. The dummy first section is handled here
too. The link/info pointers for the standard section types are filled
in here too, while we're at it. */
static bfd_boolean
assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
1999-05-03 09:29:11 +02:00
{
struct elf_obj_tdata *t = elf_tdata (abfd);
asection *sec;
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
unsigned int section_number, secn;
1999-05-03 09:29:11 +02:00
Elf_Internal_Shdr **i_shdrp;
struct bfd_elf_section_data *d;
bfd_boolean need_symtab;
1999-05-03 09:29:11 +02:00
section_number = 1;
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
_bfd_elf_strtab_clear_all_refs (elf_shstrtab (abfd));
/* SHT_GROUP sections are in relocatable files only. */
if (link_info == NULL || link_info->relocatable)
1999-05-03 09:29:11 +02:00
{
/* Put SHT_GROUP sections first. */
for (sec = abfd->sections; sec != NULL; sec = sec->next)
{
bfd/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * bfd.c (bfd): Remove section_tail and add section_last. (bfd_preserve): Likewise. (bfd_preserve_save): Likewise. (bfd_preserve_restore): Likewise. * opncls.c (_bfd_new_bfd): Likewise. * coffcode.h (coff_compute_section_file_positions): Updated. (coff_compute_section_file_positions): Likewise. * elf.c (assign_section_numbers): Likewise. * elf32-i370.c (i370_elf_size_dynamic_sections): Likewise. * elf64-mmix.c (mmix_elf_final_link): Likewise. * elfxx-ia64.c (elfNN_ia64_object_p): Likewise. * elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise. * sunos.c (sunos_add_dynamic_symbols): Likewise. * xcofflink.c (_bfd_xcoff_bfd_final_link): Likewise. * ecoff.c (bfd_debug_section): Initialize prev. * section.c (bfd_section): Add prev. (bfd_section_list_remove): Updated. (bfd_section_list_append): New. (bfd_section_list_insert_after): New. (bfd_section_list_insert_before): New. (bfd_section_list_insert): Removed. (bfd_section_removed_from_list): Updated. (STD_SECTION): Initialize prev. (bfd_section_init): Updated. (bfd_section_list_clear): Updated. * bfd-in2.h: Regenerated. gas/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * write.c (write_object_file): Use bfd_section_double_list_remove to remove sections. ld/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * emultempl/elf32.em (gld${EMULATION_NAME}_strip_empty_section): Updated for bfd_section_list_remove change. * ldlang.c (lang_insert_orphan): Likewise. (strip_excluded_output_sections): Likewise. (sort_sections_by_lma): New. (lang_check_section_addresses): Sort the sections before checking addresses.
2005-05-03 03:05:03 +02:00
d = elf_section_data (sec);
if (d->this_hdr.sh_type == SHT_GROUP)
{
bfd/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * bfd.c (bfd): Remove section_tail and add section_last. (bfd_preserve): Likewise. (bfd_preserve_save): Likewise. (bfd_preserve_restore): Likewise. * opncls.c (_bfd_new_bfd): Likewise. * coffcode.h (coff_compute_section_file_positions): Updated. (coff_compute_section_file_positions): Likewise. * elf.c (assign_section_numbers): Likewise. * elf32-i370.c (i370_elf_size_dynamic_sections): Likewise. * elf64-mmix.c (mmix_elf_final_link): Likewise. * elfxx-ia64.c (elfNN_ia64_object_p): Likewise. * elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise. * sunos.c (sunos_add_dynamic_symbols): Likewise. * xcofflink.c (_bfd_xcoff_bfd_final_link): Likewise. * ecoff.c (bfd_debug_section): Initialize prev. * section.c (bfd_section): Add prev. (bfd_section_list_remove): Updated. (bfd_section_list_append): New. (bfd_section_list_insert_after): New. (bfd_section_list_insert_before): New. (bfd_section_list_insert): Removed. (bfd_section_removed_from_list): Updated. (STD_SECTION): Initialize prev. (bfd_section_init): Updated. (bfd_section_list_clear): Updated. * bfd-in2.h: Regenerated. gas/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * write.c (write_object_file): Use bfd_section_double_list_remove to remove sections. ld/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * emultempl/elf32.em (gld${EMULATION_NAME}_strip_empty_section): Updated for bfd_section_list_remove change. * ldlang.c (lang_insert_orphan): Likewise. (strip_excluded_output_sections): Likewise. (sort_sections_by_lma): New. (lang_check_section_addresses): Sort the sections before checking addresses.
2005-05-03 03:05:03 +02:00
if (sec->flags & SEC_LINKER_CREATED)
{
/* Remove the linker created SHT_GROUP sections. */
bfd/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * bfd.c (bfd): Remove section_tail and add section_last. (bfd_preserve): Likewise. (bfd_preserve_save): Likewise. (bfd_preserve_restore): Likewise. * opncls.c (_bfd_new_bfd): Likewise. * coffcode.h (coff_compute_section_file_positions): Updated. (coff_compute_section_file_positions): Likewise. * elf.c (assign_section_numbers): Likewise. * elf32-i370.c (i370_elf_size_dynamic_sections): Likewise. * elf64-mmix.c (mmix_elf_final_link): Likewise. * elfxx-ia64.c (elfNN_ia64_object_p): Likewise. * elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise. * sunos.c (sunos_add_dynamic_symbols): Likewise. * xcofflink.c (_bfd_xcoff_bfd_final_link): Likewise. * ecoff.c (bfd_debug_section): Initialize prev. * section.c (bfd_section): Add prev. (bfd_section_list_remove): Updated. (bfd_section_list_append): New. (bfd_section_list_insert_after): New. (bfd_section_list_insert_before): New. (bfd_section_list_insert): Removed. (bfd_section_removed_from_list): Updated. (STD_SECTION): Initialize prev. (bfd_section_init): Updated. (bfd_section_list_clear): Updated. * bfd-in2.h: Regenerated. gas/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * write.c (write_object_file): Use bfd_section_double_list_remove to remove sections. ld/ 2005-05-02 H.J. Lu <hongjiu.lu@intel.com> * emultempl/elf32.em (gld${EMULATION_NAME}_strip_empty_section): Updated for bfd_section_list_remove change. * ldlang.c (lang_insert_orphan): Likewise. (strip_excluded_output_sections): Likewise. (sort_sections_by_lma): New. (lang_check_section_addresses): Sort the sections before checking addresses.
2005-05-03 03:05:03 +02:00
bfd_section_list_remove (abfd, sec);
abfd->section_count--;
}
else
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
d->this_idx = section_number++;
}
}
}
for (sec = abfd->sections; sec; sec = sec->next)
{
d = elf_section_data (sec);
if (d->this_hdr.sh_type != SHT_GROUP)
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
d->this_idx = section_number++;
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->this_hdr.sh_name);
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
if (d->rel.hdr)
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
{
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
d->rel.idx = section_number++;
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rel.hdr->sh_name);
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
}
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
else
d->rel.idx = 0;
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
if (d->rela.hdr)
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
{
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
d->rela.idx = section_number++;
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rela.hdr->sh_name);
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
}
else
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
d->rela.idx = 0;
1999-05-03 09:29:11 +02:00
}
t->shstrtab_section = section_number++;
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
_bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name);
1999-05-03 09:29:11 +02:00
elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
need_symtab = (bfd_get_symcount (abfd) > 0
|| (link_info == NULL
&& ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC))
== HAS_RELOC)));
if (need_symtab)
1999-05-03 09:29:11 +02:00
{
t->symtab_section = section_number++;
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
_bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name);
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
if (section_number > ((SHN_LORESERVE - 2) & 0xFFFF))
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
{
t->symtab_shndx_section = section_number++;
t->symtab_shndx_hdr.sh_name
= (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
".symtab_shndx", FALSE);
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if (t->symtab_shndx_hdr.sh_name == (unsigned int) -1)
return FALSE;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
}
1999-05-03 09:29:11 +02:00
t->strtab_section = section_number++;
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
_bfd_elf_strtab_addref (elf_shstrtab (abfd), t->strtab_hdr.sh_name);
1999-05-03 09:29:11 +02:00
}
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
_bfd_elf_strtab_finalize (elf_shstrtab (abfd));
t->shstrtab_hdr.sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
elf_numsections (abfd) = section_number;
1999-05-03 09:29:11 +02:00
elf_elfheader (abfd)->e_shnum = section_number;
/* Set up the list of section header pointers, in agreement with the
indices. */
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
i_shdrp = (Elf_Internal_Shdr **) bfd_zalloc2 (abfd, section_number,
sizeof (Elf_Internal_Shdr *));
1999-05-03 09:29:11 +02:00
if (i_shdrp == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
i_shdrp[0] = (Elf_Internal_Shdr *) bfd_zalloc (abfd,
sizeof (Elf_Internal_Shdr));
1999-05-03 09:29:11 +02:00
if (i_shdrp[0] == NULL)
{
bfd_release (abfd, i_shdrp);
return FALSE;
1999-05-03 09:29:11 +02:00
}
elf_elfsections (abfd) = i_shdrp;
i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;
if (need_symtab)
1999-05-03 09:29:11 +02:00
{
i_shdrp[t->symtab_section] = &t->symtab_hdr;
include/elf/ PR 5900 * common.h (SHN_BAD): Delete. (SHN_LORESERVE .. SHN_HIRESERVE): Move to.. * external.h: ..here. * internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define. (SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define. (SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define. bfd/ PR 5900 * elf-bfd.h: Include elf/internal.h after elf/external.h. * elfcode.h (elf_swap_symbol_in): Map reserved shndx range. (elf_swap_symbol_out): Adjust SHN_XINDEX test. (elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. (valid_section_index_p): Delete. (elf_object_p): Don't increment section numbers over reserved range. Simplify test for valid sh_link, sh_info and e_shstrndx fields. (elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values seen in external structs. Don't increment section numbers over reserved range. * elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx. (bfd_section_from_shdr): Likewise. (group_signature): Range check before accessing elf_elfsections. (_bfd_elf_setup_sections): Likewise. (bfd_section_from_shdr): Likewise. (bfd_section_from_shdr): Don't increment section number over reserved sections. (assign_file_positions_for_non_load_sections): Likewise. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_write_object_contents): Likewise. (assign_section_numbers): Likewise. Adjust for changed SHN_*. (prep_headers): Delete unused variable. * elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust for changed SHN_* values. (check_dynsym, elf_link_input_bfd): Likewise. (bfd_elf_final_link): Likewise. Don't skip over reserved section range. (elf_fixup_link_order): Check that sh_link field is valid. * elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned. * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before accesssing elf_elfsections. * elf32-avr.c (elf32_avr_size_stubs): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Likewise. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed SHN_* defines. Test for SHN_BAD return from _bfd_elf_section_from_bfd_section binutils/ PR 5900 * readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete. Remove use throughout file. (SECTION_HEADER): Likewise. (dump_relocations): Don't adjust st_shndx for reserved range. (process_file_header): Mask SHN_XINDEX to values seen in external elf structs. Simplify valid section index tests. (get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX. Map reserved st_shndx to internal form. (process_section_groups): Test that group symbol st_shndx is in range, not just non-zero. Delete reserved range check. (get_symbol_index_type): Mask "type" to 16 bits when printing PRC, OS or RSV. gdb/ PR 5900 * elfread.c (elf_symtab_read): Make shndx an unsigned int. * mipsread.c: Include elf/internal.h. (read_alphacoff_dynamic_symtab): Map external reserved sym_shndx to internal range. ld/testsuite/ PR 5900 * ld-elf/sec64k.exp: Update.
2008-03-12 09:37:09 +01:00
if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF))
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
{
i_shdrp[t->symtab_shndx_section] = &t->symtab_shndx_hdr;
t->symtab_shndx_hdr.sh_link = t->symtab_section;
}
1999-05-03 09:29:11 +02:00
i_shdrp[t->strtab_section] = &t->strtab_hdr;
t->symtab_hdr.sh_link = t->strtab_section;
}
1999-05-03 09:29:11 +02:00
for (sec = abfd->sections; sec; sec = sec->next)
{
asection *s;
const char *name;
d = elf_section_data (sec);
1999-05-03 09:29:11 +02:00
i_shdrp[d->this_idx] = &d->this_hdr;
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
if (d->rel.idx != 0)
i_shdrp[d->rel.idx] = d->rel.hdr;
if (d->rela.idx != 0)
i_shdrp[d->rela.idx] = d->rela.hdr;
1999-05-03 09:29:11 +02:00
/* Fill in the sh_link and sh_info fields while we're at it. */
/* sh_link of a reloc section is the section index of the symbol
table. sh_info is the section index of the section to which
the relocation entries apply. */
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
if (d->rel.idx != 0)
1999-05-03 09:29:11 +02:00
{
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
d->rel.hdr->sh_link = t->symtab_section;
d->rel.hdr->sh_info = d->this_idx;
1999-05-03 09:29:11 +02:00
}
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
if (d->rela.idx != 0)
{
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
d->rela.hdr->sh_link = t->symtab_section;
d->rela.hdr->sh_info = d->this_idx;
}
1999-05-03 09:29:11 +02:00
/* We need to set up sh_link for SHF_LINK_ORDER. */
if ((d->this_hdr.sh_flags & SHF_LINK_ORDER) != 0)
{
s = elf_linked_to_section (sec);
if (s)
{
/* elf_linked_to_section points to the input section. */
if (link_info != NULL)
{
/* Check discarded linkonce section. */
PR ld/13991 bfd/ * bfd/elf-bfd.h (_bfd_elf_link_just_syms): Define as _bfd_generic_link_just_syms. * bfd/elflink.c (_bfd_elf_link_just_syms): Delete. * bfd/linker.c (_bfd_generic_link_just_syms): Set sec_info_type. * bfd/bfd-in.h (discarded_section): Renamed from elf_discarded_section. * bfd/section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS, SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME, SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE. * bfd/elf-eh-frame.c, * bfd/elf-m10200.c, * bfd/elf-m10300.c, * bfd/elf.c, * bfd/elf32-arm.c, * bfd/elf32-avr.c, * bfd/elf32-bfin.c, * bfd/elf32-cr16.c, * bfd/elf32-cr16c.c, * bfd/elf32-cris.c, * bfd/elf32-crx.c, * bfd/elf32-d10v.c, * bfd/elf32-epiphany.c, * bfd/elf32-fr30.c, * bfd/elf32-frv.c, * bfd/elf32-h8300.c, * bfd/elf32-hppa.c, * bfd/elf32-i370.c, * bfd/elf32-i386.c, * bfd/elf32-i860.c, * bfd/elf32-ip2k.c, * bfd/elf32-iq2000.c, * bfd/elf32-lm32.c, * bfd/elf32-m32c.c, * bfd/elf32-m32r.c, * bfd/elf32-m68hc1x.c, * bfd/elf32-m68k.c, * bfd/elf32-mcore.c, * bfd/elf32-mep.c, * bfd/elf32-moxie.c, * bfd/elf32-msp430.c, * bfd/elf32-mt.c, * bfd/elf32-openrisc.c, * bfd/elf32-ppc.c, * bfd/elf32-rl78.c, * bfd/elf32-rx.c, * bfd/elf32-s390.c, * bfd/elf32-score.c, * bfd/elf32-score7.c, * bfd/elf32-sh.c, * bfd/elf32-spu.c, * bfd/elf32-tic6x.c, * bfd/elf32-tilepro.c, * bfd/elf32-v850.c, * bfd/elf32-vax.c, * bfd/elf32-xc16x.c, * bfd/elf32-xstormy16.c, * bfd/elf32-xtensa.c, * bfd/elf64-alpha.c, * bfd/elf64-hppa.c, * bfd/elf64-ia64-vms.c, * bfd/elf64-mmix.c, * bfd/elf64-ppc.c, * bfd/elf64-s390.c, * bfd/elf64-sh64.c, * bfd/elf64-x86-64.c, * bfd/elflink.c, * bfd/elfnn-ia64.c, * bfd/elfxx-mips.c, * bfd/elfxx-sparc.c, * bfd/elfxx-tilegx.c, * bfd/reloc.c: Update all references. * bfd/bfd-in2.h: Regenerate. ld/ * ld/ldlang.c (size_input_section): Use sec_info_type rather than usrdata->flags.just_syms. * ld/ldwrite.c (build_link_order): Likewise. * ld/emultempl/hppaelf.em (build_section_lists): Likewise. * ld/emultempl/ppc64elf.em (build_toc_list): Likewise. * ld/emultempl/armelf.em (build_section_lists): Likewise. (after_allocation): Update for renamed sec_info_type value. * ld/emultempl/tic6xdsbt.em: Likewise.
2012-04-24 07:12:40 +02:00
if (discarded_section (s))
{
asection *kept;
(*_bfd_error_handler)
(_("%B: sh_link of section `%A' points to discarded section `%A' of `%B'"),
abfd, d->this_hdr.bfd_section,
s, s->owner);
/* Point to the kept section if it has the same
size as the discarded one. */
2006-10-31 00:25:51 +01:00
kept = _bfd_elf_check_kept_section (s, link_info);
if (kept == NULL)
{
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
s = kept;
}
s = s->output_section;
BFD_ASSERT (s != NULL);
}
else
{
/* Handle objcopy. */
if (s->output_section == NULL)
{
(*_bfd_error_handler)
(_("%B: sh_link of section `%A' points to removed section `%A' of `%B'"),
abfd, d->this_hdr.bfd_section, s, s->owner);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
s = s->output_section;
}
d->this_hdr.sh_link = elf_section_data (s)->this_idx;
}
else
{
/* PR 290:
The Intel C compiler generates SHT_IA_64_UNWIND with
SHF_LINK_ORDER. But it doesn't set the sh_link or
sh_info fields. Hence we could get the situation
where s is NULL. */
const struct elf_backend_data *bed
= get_elf_backend_data (abfd);
if (bed->link_order_error_handler)
bed->link_order_error_handler
(_("%B: warning: sh_link not set for section `%A'"),
abfd, sec);
}
}
1999-05-03 09:29:11 +02:00
switch (d->this_hdr.sh_type)
{
case SHT_REL:
case SHT_RELA:
/* A reloc section which we are treating as a normal BFD
section. sh_link is the section index of the symbol
table. sh_info is the section index of the section to
which the relocation entries apply. We assume that an
allocated reloc section uses the dynamic symbol table.
FIXME: How can we be sure? */
s = bfd_get_section_by_name (abfd, ".dynsym");
if (s != NULL)
d->this_hdr.sh_link = elf_section_data (s)->this_idx;
/* We look up the section the relocs apply to by name. */
name = sec->name;
if (d->this_hdr.sh_type == SHT_REL)
name += 4;
else
name += 5;
s = bfd_get_section_by_name (abfd, name);
if (s != NULL)
d->this_hdr.sh_info = elf_section_data (s)->this_idx;
break;
case SHT_STRTAB:
/* We assume that a section named .stab*str is a stabs
string section. We look for a section with the same name
but without the trailing ``str'', and set its sh_link
field to point to this section. */
if (CONST_STRNEQ (sec->name, ".stab")
1999-05-03 09:29:11 +02:00
&& strcmp (sec->name + strlen (sec->name) - 3, "str") == 0)
{
size_t len;
char *alc;
len = strlen (sec->name);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
alc = (char *) bfd_malloc (len - 2);
1999-05-03 09:29:11 +02:00
if (alc == NULL)
return FALSE;
2002-06-25 11:40:45 +02:00
memcpy (alc, sec->name, len - 3);
1999-05-03 09:29:11 +02:00
alc[len - 3] = '\0';
s = bfd_get_section_by_name (abfd, alc);
free (alc);
if (s != NULL)
{
elf_section_data (s)->this_hdr.sh_link = d->this_idx;
/* This is a .stab section. */
if (elf_section_data (s)->this_hdr.sh_entsize == 0)
elf_section_data (s)->this_hdr.sh_entsize
= 4 + 2 * bfd_get_arch_size (abfd) / 8;
1999-05-03 09:29:11 +02:00
}
}
break;
case SHT_DYNAMIC:
case SHT_DYNSYM:
case SHT_GNU_verneed:
case SHT_GNU_verdef:
/* sh_link is the section header index of the string table
used for the dynamic entries, or the symbol table, or the
version strings. */
s = bfd_get_section_by_name (abfd, ".dynstr");
if (s != NULL)
d->this_hdr.sh_link = elf_section_data (s)->this_idx;
break;
case SHT_GNU_LIBLIST:
/* sh_link is the section header index of the prelink library
list used for the dynamic entries, or the symbol table, or
the version strings. */
s = bfd_get_section_by_name (abfd, (sec->flags & SEC_ALLOC)
? ".dynstr" : ".gnu.libstr");
if (s != NULL)
d->this_hdr.sh_link = elf_section_data (s)->this_idx;
break;
1999-05-03 09:29:11 +02:00
case SHT_HASH:
include/ * bfdlink.h (struct bfd_link_info): Add emit_hash and emit_gnu_hash bitfields. include/elf/ * common.h (SHT_GNU_HASH, DT_GNU_HASH): Define. ld/ * scripttempl/elf.sc: Add .gnu.hash section. * emultempl/elf32.em (OPTION_HASH_STYLE): Define. (gld${EMULATION_NAME}_add_options): Register --hash-style option. (gld${EMULATION_NAME}_handle_option): Handle it. (gld${EMULATION_NAME}_list_options): Document it. * ldmain.c (main): Initialize emit_hash and emit_gnu_hash. * ld.texinfo: Document --hash-style option. bfd/ * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_GNU_HASH. (bfd_section_from_shdr, elf_fake_sections, assign_section_numbers): Handle SHT_GNU_HASH. (special_sections_g): Include .gnu.hash section. (bfd_elf_gnu_hash): New function. * elf-bfd.h (bfd_elf_gnu_hash, _bfd_elf_hash_symbol): New prototypes. (struct elf_backend_data): Add elf_hash_symbol method. * elflink.c (_bfd_elf_link_create_dynamic_sections): Create .hash only if info->emit_hash, create .gnu.hash section if info->emit_gnu_hash. (struct collect_gnu_hash_codes): New type. (elf_collect_gnu_hash_codes, elf_renumber_gnu_hash_syms, _bfd_elf_hash_symbol): New functions. (compute_bucket_count): Don't compute HASHCODES array, instead add that and NSYMS as arguments. Use bed->s->sizeof_hash_entry instead of bed->s->arch_size / 8. Fix .hash size estimation. When not optimizing, use the number of hashed symbols rather than dynsymcount. (bfd_elf_size_dynamic_sections): Only add DT_HASH if info->emit_hash, and ADD DT_GNU_HASH if info->emit_gnu_hash. (bfd_elf_size_dynsym_hash_dynstr): Size .hash only if info->emit_hash, adjust compute_bucket_count caller. Create and populate .gnu.hash section if info->emit_gnu_hash. (elf_link_output_extsym): Only populate .hash section if finfo->hash_sec != NULL. (bfd_elf_final_link): Adjust assertion. Handle DT_GNU_HASH. * elfxx-target.h (elf_backend_hash_symbol): Define if not yet defined. (elfNN_bed): Add elf_backend_hash_symbol. * elf64-x86-64.c (elf64_x86_64_hash_symbol): New function. (elf_backend_hash_symbol): Define. * elf32-i386.c (elf_i386_hash_symbol): New function. (elf_backend_hash_symbol): Define. binutils/ * readelf.c (get_dynamic_type): Handle DT_GNU_HASH. (get_section_type_name): Handle SHT_GNU_HASH. (dynamic_info_DT_GNU_HASH): New variable. (process_dynamic_section): Handle DT_GNU_HASH. (process_symbol_table): Print also DT_GNU_HASH histogram. ld/testsuite/ * ld-powerpc/tlsso32.r: Adjust. * ld-powerpc/tlsso32.d: Adjust. * ld-powerpc/tlsso32.g: Adjust. * ld-powerpc/tlsso.r: Adjust. * ld-powerpc/tlsso.g: Adjust. * ld-powerpc/tlstocso.g: Adjust.
2006-07-10 23:40:25 +02:00
case SHT_GNU_HASH:
1999-05-03 09:29:11 +02:00
case SHT_GNU_versym:
/* sh_link is the section header index of the symbol table
this hash table or version table is for. */
s = bfd_get_section_by_name (abfd, ".dynsym");
if (s != NULL)
d->this_hdr.sh_link = elf_section_data (s)->this_idx;
break;
case SHT_GROUP:
d->this_hdr.sh_link = t->symtab_section;
1999-05-03 09:29:11 +02:00
}
}
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
for (secn = 1; secn < section_number; ++secn)
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if (i_shdrp[secn] == NULL)
i_shdrp[secn] = i_shdrp[0];
else
i_shdrp[secn]->sh_name = _bfd_elf_strtab_offset (elf_shstrtab (abfd),
i_shdrp[secn]->sh_name);
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Map symbol from it's internal number to the external number, moving
all local symbols to be at the head of the list. */
static bfd_boolean
sym_is_global (bfd *abfd, asymbol *sym)
1999-05-03 09:29:11 +02:00
{
/* If the backend has a special mapping, use it. */
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->elf_backend_sym_is_global)
return (*bed->elf_backend_sym_is_global) (abfd, sym);
1999-05-03 09:29:11 +02:00
return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
1999-05-03 09:29:11 +02:00
|| bfd_is_und_section (bfd_get_section (sym))
|| bfd_is_com_section (bfd_get_section (sym)));
}
/* Don't output section symbols for sections that are not going to be
output. */
static bfd_boolean
ignore_section_sym (bfd *abfd, asymbol *sym)
{
return ((sym->flags & BSF_SECTION_SYM) != 0
&& !(sym->section->owner == abfd
|| (sym->section->output_section->owner == abfd
&& sym->section->output_offset == 0)));
}
static bfd_boolean
elf_map_symbols (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
unsigned int symcount = bfd_get_symcount (abfd);
1999-05-03 09:29:11 +02:00
asymbol **syms = bfd_get_outsymbols (abfd);
asymbol **sect_syms;
unsigned int num_locals = 0;
unsigned int num_globals = 0;
unsigned int num_locals2 = 0;
unsigned int num_globals2 = 0;
1999-05-03 09:29:11 +02:00
int max_index = 0;
unsigned int idx;
1999-05-03 09:29:11 +02:00
asection *asect;
asymbol **new_syms;
#ifdef DEBUG
fprintf (stderr, "elf_map_symbols\n");
fflush (stderr);
#endif
for (asect = abfd->sections; asect; asect = asect->next)
{
if (max_index < asect->index)
max_index = asect->index;
}
max_index++;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
sect_syms = (asymbol **) bfd_zalloc2 (abfd, max_index, sizeof (asymbol *));
1999-05-03 09:29:11 +02:00
if (sect_syms == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
elf_section_syms (abfd) = sect_syms;
elf_num_section_syms (abfd) = max_index;
1999-05-03 09:29:11 +02:00
/* Init sect_syms entries for any section symbols we have already
decided to output. */
1999-05-03 09:29:11 +02:00
for (idx = 0; idx < symcount; idx++)
{
asymbol *sym = syms[idx];
1999-05-03 09:29:11 +02:00
if ((sym->flags & BSF_SECTION_SYM) != 0
&& sym->value == 0
&& !ignore_section_sym (abfd, sym))
1999-05-03 09:29:11 +02:00
{
asection *sec = sym->section;
1999-05-03 09:29:11 +02:00
if (sec->owner != abfd)
sec = sec->output_section;
1999-05-03 09:29:11 +02:00
sect_syms[sec->index] = syms[idx];
1999-05-03 09:29:11 +02:00
}
}
/* Classify all of the symbols. */
for (idx = 0; idx < symcount; idx++)
{
if (ignore_section_sym (abfd, syms[idx]))
continue;
1999-05-03 09:29:11 +02:00
if (!sym_is_global (abfd, syms[idx]))
num_locals++;
else
num_globals++;
}
/* We will be adding a section symbol for each normal BFD section. Most
sections will already have a section symbol in outsymbols, but
eg. SHT_GROUP sections will not, and we need the section symbol mapped
at least in that case. */
1999-05-03 09:29:11 +02:00
for (asect = abfd->sections; asect; asect = asect->next)
{
if (sect_syms[asect->index] == NULL)
1999-05-03 09:29:11 +02:00
{
if (!sym_is_global (abfd, asect->symbol))
1999-05-03 09:29:11 +02:00
num_locals++;
else
num_globals++;
}
}
/* Now sort the symbols so the local symbols are first. */
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
new_syms = (asymbol **) bfd_alloc2 (abfd, num_locals + num_globals,
sizeof (asymbol *));
1999-05-03 09:29:11 +02:00
if (new_syms == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
for (idx = 0; idx < symcount; idx++)
{
asymbol *sym = syms[idx];
unsigned int i;
1999-05-03 09:29:11 +02:00
if (ignore_section_sym (abfd, sym))
continue;
1999-05-03 09:29:11 +02:00
if (!sym_is_global (abfd, sym))
i = num_locals2++;
else
i = num_locals + num_globals2++;
new_syms[i] = sym;
sym->udata.i = i + 1;
}
for (asect = abfd->sections; asect; asect = asect->next)
{
if (sect_syms[asect->index] == NULL)
1999-05-03 09:29:11 +02:00
{
asymbol *sym = asect->symbol;
unsigned int i;
1999-05-03 09:29:11 +02:00
sect_syms[asect->index] = sym;
1999-05-03 09:29:11 +02:00
if (!sym_is_global (abfd, sym))
i = num_locals2++;
else
i = num_locals + num_globals2++;
new_syms[i] = sym;
sym->udata.i = i + 1;
}
}
bfd_set_symtab (abfd, new_syms, num_locals + num_globals);
elf_num_locals (abfd) = num_locals;
elf_num_globals (abfd) = num_globals;
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Align to the maximum file alignment that could be required for any
ELF data structure. */
static inline file_ptr
align_file_position (file_ptr off, int align)
1999-05-03 09:29:11 +02:00
{
return (off + align - 1) & ~(align - 1);
}
/* Assign a file position to a section, optionally aligning to the
required section alignment. */
file_ptr
_bfd_elf_assign_file_position_for_section (Elf_Internal_Shdr *i_shdrp,
file_ptr offset,
bfd_boolean align)
1999-05-03 09:29:11 +02:00
{
if (align && i_shdrp->sh_addralign > 1)
offset = BFD_ALIGN (offset, i_shdrp->sh_addralign);
1999-05-03 09:29:11 +02:00
i_shdrp->sh_offset = offset;
if (i_shdrp->bfd_section != NULL)
i_shdrp->bfd_section->filepos = offset;
if (i_shdrp->sh_type != SHT_NOBITS)
offset += i_shdrp->sh_size;
return offset;
}
/* Compute the file positions we are going to put the sections at, and
otherwise prepare to begin writing out the ELF file. If LINK_INFO
is not NULL, this is being called by the ELF backend linker. */
bfd_boolean
_bfd_elf_compute_section_file_positions (bfd *abfd,
struct bfd_link_info *link_info)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
struct fake_section_arg fsargs;
bfd_boolean failed;
struct bfd_strtab_hash *strtab = NULL;
1999-05-03 09:29:11 +02:00
Elf_Internal_Shdr *shstrtab_hdr;
bfd_boolean need_symtab;
1999-05-03 09:29:11 +02:00
if (abfd->output_has_begun)
return TRUE;
1999-05-03 09:29:11 +02:00
/* Do any elf backend specific processing first. */
if (bed->elf_backend_begin_write_processing)
(*bed->elf_backend_begin_write_processing) (abfd, link_info);
if (! prep_headers (abfd))
return FALSE;
1999-05-03 09:29:11 +02:00
/* Post process the headers if necessary. */
if (bed->elf_backend_post_process_headers)
(*bed->elf_backend_post_process_headers) (abfd, link_info);
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
fsargs.failed = FALSE;
fsargs.link_info = link_info;
bfd_map_over_sections (abfd, elf_fake_sections, &fsargs);
if (fsargs.failed)
return FALSE;
1999-05-03 09:29:11 +02:00
if (!assign_section_numbers (abfd, link_info))
return FALSE;
1999-05-03 09:29:11 +02:00
/* The backend linker builds symbol table information itself. */
need_symtab = (link_info == NULL
&& (bfd_get_symcount (abfd) > 0
|| ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC))
== HAS_RELOC)));
if (need_symtab)
1999-05-03 09:29:11 +02:00
{
/* Non-zero if doing a relocatable link. */
int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC));
if (! swap_out_syms (abfd, &strtab, relocatable_p))
return FALSE;
1999-05-03 09:29:11 +02:00
}
bfd/ * elf-bfd.h (struct bfd_elf_section_reloc_data): New structure. (struct bfd_elf_section_data): New members REL and RELA; delete members REL_HDR, REL_HDR2, REL_COUNT, REL_COUNT2, REL_IDX, REL_IDX2, REL_HASHES. (_bfd_elf_init_reloc_shdr): Adjust declaration. (_bfd_elf_single_rel_hdr): Declare. (RELOC_AGAINST_DISCARDED_SECTION): Use it. * elf.c (bfd_section_from_shdr): Adjusted to match changes in data structures. (_bfd_elf_init_reloc_shdr): New arg RELDATA. Remove arg REL_HDR. All callers changed. Allocate memory for the Elf_Internal_Shdr structure. (_bfd_elf_single_rel_hdr): New function. (struct fake_section_arg): New structure. (elf_fake_section): Expect to see a pointer to it in the third argument. If doing a relocatable link, allocate both REL and RELA sections as needed. (assign_section_numbers): Adjusted to match changes in data structures. (_bfd_elf_compute_section_file_positions): Call elf_fake_sections with a struct fake_section_args argument. * elfcode.h (elf_write_relocs): Adjusted to match changes in data structures. (elf_slurp_reloc_table): Likewise. * elflink.c (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Remove arg REL_HDR, replace with RELDATA. Remove argument O. All callers changed. Remove code to discover the right rel_hdr and count. (_bfd_elf_link_output_relocs): Adjusted to match changes in data structures. (elf_link_adjust_relocs): Remove args REL_HDR, COUNT and REL_HASH; replace with RELDATA. All callers changed. (elf_link_input_bfd): Correctly generate rel_hash data when both REL and RELA sections are present. (elf_reloc_link_order): Adjusted to match changes in data structures. (bfd_elf_final_link): Simplify code to count relocs. Free the hashes array for both REL and RELA. (get_dynamic_reloc_section_name): Use _bfd_elf_single_reloc_hdr * elf32-m32r.c (m32r_elf_fake_sections, elf_backend_fake_sections): Delete. * elf32-tic6x.c (elf32_tic6x_fake_sections, elf_backend_fake_sections): Delete. (elf32_tic6x_rel_relocation_p): Adjusted to match changes in data structures. * elf32-microblaze.c (microblaze_elf_check_relocs): Use _bfd_elf_single_rel_hdr. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-hppa.c (get_reloc_section): Likewise. * elf64-mips.c (mips_elf64_slurp_reloc_table): Adjusted to match changes in data structures. (mips_elf64_write_relocs): Use _bfd_elf_single_rel_hdr. * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. (ppc64_elf_edit_toc): Likewise. (get_relocs): Adjusted to match changes in data structures. Allocate an Elf_Internal_Shdr structure if necessary. (ppc64_elf_finish_dynamic_sections): Use _bfd_elf_single_rel_hdr. * elf64-sparc.c (elf64_sparc_slurp_reloc_table): Adjusted to match changes in data structures. * elfxx-ia64.c (get_reloc_section): Use _bfd_elf_single_rel_hdr. * elfxx-mips.c (MIPS_RELOC_RELA_P): Remove macro. (mips_elf_rel_relocation_p): Adjusted to match changes in data structures. (_bfd_mips_elf_relocate_section): Use mips_elf_rel_relocation_p rather than MIPS_RELOC_RELOCA_P. * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Use _bfd_elf_single_rel_hdr. (_bfd_sparc_elf_relocate_section): Likewise. ld/ * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Use _bfd_elf_single_rel_hdr.
2010-10-04 16:13:10 +02:00
failed = FALSE;
if (link_info == NULL)
{
bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed);
if (failed)
return FALSE;
}
1999-05-03 09:29:11 +02:00
shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
/* sh_name was set in prep_headers. */
shstrtab_hdr->sh_type = SHT_STRTAB;
shstrtab_hdr->sh_flags = 0;
shstrtab_hdr->sh_addr = 0;
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
shstrtab_hdr->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
1999-05-03 09:29:11 +02:00
shstrtab_hdr->sh_entsize = 0;
shstrtab_hdr->sh_link = 0;
shstrtab_hdr->sh_info = 0;
/* sh_offset is set in assign_file_positions_except_relocs. */
shstrtab_hdr->sh_addralign = 1;
if (!assign_file_positions_except_relocs (abfd, link_info))
return FALSE;
1999-05-03 09:29:11 +02:00
if (need_symtab)
1999-05-03 09:29:11 +02:00
{
file_ptr off;
Elf_Internal_Shdr *hdr;
off = elf_tdata (abfd)->next_file_pos;
hdr = &elf_tdata (abfd)->symtab_hdr;
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
1999-05-03 09:29:11 +02:00
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
if (hdr->sh_size != 0)
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
1999-05-03 09:29:11 +02:00
hdr = &elf_tdata (abfd)->strtab_hdr;
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
1999-05-03 09:29:11 +02:00
elf_tdata (abfd)->next_file_pos = off;
/* Now that we know where the .strtab section goes, write it
out. */
1999-05-03 09:29:11 +02:00
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
|| ! _bfd_stringtab_emit (abfd, strtab))
return FALSE;
1999-05-03 09:29:11 +02:00
_bfd_stringtab_free (strtab);
}
abfd->output_has_begun = TRUE;
1999-05-03 09:29:11 +02:00
return TRUE;
1999-05-03 09:29:11 +02:00
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* Make an initial estimate of the size of the program header. If we
get the number wrong here, we'll redo section placement. */
static bfd_size_type
get_program_header_size (bfd *abfd, struct bfd_link_info *info)
{
size_t segs;
asection *s;
const struct elf_backend_data *bed;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* Assume we will need exactly two PT_LOAD segments: one for text
and one for data. */
segs = 2;
s = bfd_get_section_by_name (abfd, ".interp");
if (s != NULL && (s->flags & SEC_LOAD) != 0)
{
/* If we have a loadable interpreter section, we need a
PT_INTERP segment. In this case, assume we also need a
PT_PHDR segment, although that may not be true for all
targets. */
segs += 2;
}
if (bfd_get_section_by_name (abfd, ".dynamic") != NULL)
{
/* We need a PT_DYNAMIC segment. */
++segs;
}
if (info != NULL && info->relro)
{
/* We need a PT_GNU_RELRO segment. */
++segs;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
}
if (elf_tdata (abfd)->eh_frame_hdr)
{
/* We need a PT_GNU_EH_FRAME segment. */
++segs;
}
if (elf_tdata (abfd)->stack_flags)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
/* We need a PT_GNU_STACK segment. */
++segs;
}
for (s = abfd->sections; s != NULL; s = s->next)
{
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if ((s->flags & SEC_LOAD) != 0
&& CONST_STRNEQ (s->name, ".note"))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
/* We need a PT_NOTE segment. */
++segs;
/* Try to create just one PT_NOTE segment
for all adjacent loadable .note* sections.
gABI requires that within a PT_NOTE segment
(and also inside of each SHT_NOTE section)
each note is padded to a multiple of 4 size,
so we check whether the sections are correctly
aligned. */
if (s->alignment_power == 2)
while (s->next != NULL
&& s->next->alignment_power == 2
&& (s->next->flags & SEC_LOAD) != 0
&& CONST_STRNEQ (s->next->name, ".note"))
s = s->next;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
}
}
for (s = abfd->sections; s != NULL; s = s->next)
{
if (s->flags & SEC_THREAD_LOCAL)
{
/* We need a PT_TLS segment. */
++segs;
break;
}
}
/* Let the backend count up any program headers it might need. */
bed = get_elf_backend_data (abfd);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (bed->elf_backend_additional_program_headers)
{
int a;
a = (*bed->elf_backend_additional_program_headers) (abfd, info);
if (a == -1)
abort ();
segs += a;
}
return segs * bed->s->sizeof_phdr;
}
/* Find the segment that contains the output_section of section. */
Elf_Internal_Phdr *
_bfd_elf_find_segment_containing_section (bfd * abfd, asection * section)
{
struct elf_segment_map *m;
Elf_Internal_Phdr *p;
for (m = elf_tdata (abfd)->segment_map,
p = elf_tdata (abfd)->phdr;
m != NULL;
m = m->next, p++)
{
int i;
for (i = m->count - 1; i >= 0; i--)
if (m->sections[i] == section)
return p;
}
return NULL;
}
1999-05-03 09:29:11 +02:00
/* Create a mapping from a set of sections to a program segment. */
static struct elf_segment_map *
make_mapping (bfd *abfd,
asection **sections,
unsigned int from,
unsigned int to,
bfd_boolean phdr)
1999-05-03 09:29:11 +02:00
{
struct elf_segment_map *m;
unsigned int i;
asection **hdrpp;
bfd_size_type amt;
1999-05-03 09:29:11 +02:00
amt = sizeof (struct elf_segment_map);
amt += (to - from - 1) * sizeof (asection *);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
1999-05-03 09:29:11 +02:00
if (m == NULL)
return NULL;
m->next = NULL;
m->p_type = PT_LOAD;
for (i = from, hdrpp = sections + from; i < to; i++, hdrpp++)
m->sections[i - from] = *hdrpp;
m->count = to - from;
if (from == 0 && phdr)
{
/* Include the headers in the first PT_LOAD segment. */
m->includes_filehdr = 1;
m->includes_phdrs = 1;
}
return m;
}
/* Create the PT_DYNAMIC segment, which includes DYNSEC. Returns NULL
on failure. */
struct elf_segment_map *
_bfd_elf_make_dynamic_segment (bfd *abfd, asection *dynsec)
{
struct elf_segment_map *m;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd,
sizeof (struct elf_segment_map));
if (m == NULL)
return NULL;
m->next = NULL;
m->p_type = PT_DYNAMIC;
m->count = 1;
m->sections[0] = dynsec;
return m;
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* Possibly add or remove segments from the segment map. */
1999-05-03 09:29:11 +02:00
static bfd_boolean
elf_modify_segment_map (bfd *abfd,
struct bfd_link_info *info,
bfd_boolean remove_empty_load)
1999-05-03 09:29:11 +02:00
{
struct elf_segment_map **m;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
const struct elf_backend_data *bed;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* The placement algorithm assumes that non allocated sections are
not in PT_LOAD segments. We ensure this here by removing such
sections from the segment map. We also remove excluded
sections. Finally, any PT_LOAD segment without sections is
removed. */
m = &elf_tdata (abfd)->segment_map;
while (*m)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
unsigned int i, new_count;
1999-05-03 09:29:11 +02:00
for (new_count = 0, i = 0; i < (*m)->count; i++)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
if (((*m)->sections[i]->flags & SEC_EXCLUDE) == 0
&& (((*m)->sections[i]->flags & SEC_ALLOC) != 0
|| (*m)->p_type != PT_LOAD))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
(*m)->sections[new_count] = (*m)->sections[i];
new_count++;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
}
}
(*m)->count = new_count;
1999-05-03 09:29:11 +02:00
if (remove_empty_load && (*m)->p_type == PT_LOAD && (*m)->count == 0)
*m = (*m)->next;
else
m = &(*m)->next;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
}
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
bed = get_elf_backend_data (abfd);
if (bed->elf_backend_modify_segment_map != NULL)
1999-05-03 09:29:11 +02:00
{
if (!(*bed->elf_backend_modify_segment_map) (abfd, info))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
return FALSE;
1999-05-03 09:29:11 +02:00
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
return TRUE;
}
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* Set up a mapping from BFD sections to program segments. */
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
bfd_boolean
_bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
{
unsigned int count;
struct elf_segment_map *m;
asection **sections = NULL;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd_boolean no_user_phdrs;
1999-05-03 09:29:11 +02:00
no_user_phdrs = elf_tdata (abfd)->segment_map == NULL;
if (info != NULL)
info->user_phdrs = !no_user_phdrs;
if (no_user_phdrs && bfd_count_sections (abfd) != 0)
1999-05-03 09:29:11 +02:00
{
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
asection *s;
unsigned int i;
struct elf_segment_map *mfirst;
struct elf_segment_map **pm;
asection *last_hdr;
bfd_vma last_size;
unsigned int phdr_index;
bfd_vma maxpagesize;
asection **hdrpp;
bfd_boolean phdr_in_segment = TRUE;
bfd_boolean writable;
int tls_count = 0;
asection *first_tls = NULL;
asection *dynsec, *eh_frame_hdr;
bfd_size_type amt;
bfd_vma addr_mask, wrap_to = 0;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* Select the allocated sections, and sort them. */
1999-05-03 09:29:11 +02:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
sections = (asection **) bfd_malloc2 (bfd_count_sections (abfd),
sizeof (asection *));
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (sections == NULL)
1999-05-03 09:29:11 +02:00
goto error_return;
/* Calculate top address, avoiding undefined behaviour of shift
left operator when shift count is equal to size of type
being shifted. */
addr_mask = ((bfd_vma) 1 << (bfd_arch_bits_per_address (abfd) - 1)) - 1;
addr_mask = (addr_mask << 1) + 1;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
i = 0;
for (s = abfd->sections; s != NULL; s = s->next)
{
if ((s->flags & SEC_ALLOC) != 0)
{
sections[i] = s;
++i;
/* A wrapping section potentially clashes with header. */
if (((s->lma + s->size) & addr_mask) < (s->lma & addr_mask))
wrap_to = (s->lma + s->size) & addr_mask;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
}
}
BFD_ASSERT (i <= bfd_count_sections (abfd));
count = i;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
qsort (sections, (size_t) count, sizeof (asection *), elf_sort_sections);
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* Build the mapping. */
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
mfirst = NULL;
pm = &mfirst;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* If we have a .interp section, then create a PT_PHDR segment for
the program headers and a PT_INTERP segment for the .interp
section. */
s = bfd_get_section_by_name (abfd, ".interp");
if (s != NULL && (s->flags & SEC_LOAD) != 0)
{
amt = sizeof (struct elf_segment_map);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (m == NULL)
goto error_return;
m->next = NULL;
m->p_type = PT_PHDR;
/* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not. */
m->p_flags = PF_R | PF_X;
m->p_flags_valid = 1;
m->includes_phdrs = 1;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
*pm = m;
pm = &m->next;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
amt = sizeof (struct elf_segment_map);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (m == NULL)
goto error_return;
m->next = NULL;
m->p_type = PT_INTERP;
m->count = 1;
m->sections[0] = s;
*pm = m;
pm = &m->next;
1999-05-03 09:29:11 +02:00
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* Look through the sections. We put sections in the same program
segment when the start of the second section can be placed within
a few bytes of the end of the first section. */
last_hdr = NULL;
last_size = 0;
phdr_index = 0;
maxpagesize = bed->maxpagesize;
writable = FALSE;
dynsec = bfd_get_section_by_name (abfd, ".dynamic");
if (dynsec != NULL
&& (dynsec->flags & SEC_LOAD) == 0)
dynsec = NULL;
/* Deal with -Ttext or something similar such that the first section
is not adjacent to the program headers. This is an
approximation, since at this point we don't know exactly how many
program headers we will need. */
if (count > 0)
1999-05-03 09:29:11 +02:00
{
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
if (phdr_size == (bfd_size_type) -1)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
phdr_size = get_program_header_size (abfd, info);
if ((abfd->flags & D_PAGED) == 0
|| (sections[0]->lma & addr_mask) < phdr_size
|| ((sections[0]->lma & addr_mask) % maxpagesize
< phdr_size % maxpagesize)
|| (sections[0]->lma & addr_mask & -maxpagesize) < wrap_to)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
phdr_in_segment = FALSE;
1999-05-03 09:29:11 +02:00
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
for (i = 0, hdrpp = sections; i < count; i++, hdrpp++)
1999-05-03 09:29:11 +02:00
{
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
asection *hdr;
bfd_boolean new_segment;
hdr = *hdrpp;
/* See if this section and the last one will fit in the same
segment. */
if (last_hdr == NULL)
{
/* If we don't have a segment yet, then we don't need a new
one (we build the last one after this loop). */
new_segment = FALSE;
}
else if (last_hdr->lma - last_hdr->vma != hdr->lma - hdr->vma)
{
/* If this section has a different relation between the
virtual address and the load address, then we need a new
segment. */
new_segment = TRUE;
}
else if (hdr->lma < last_hdr->lma + last_size
|| last_hdr->lma + last_size < last_hdr->lma)
{
/* If this section has a load address that makes it overlap
the previous section, then we need a new segment. */
new_segment = TRUE;
}
/* In the next test we have to be careful when last_hdr->lma is close
to the end of the address space. If the aligned address wraps
around to the start of the address space, then there are no more
pages left in memory and it is OK to assume that the current
section can be included in the current segment. */
else if ((BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
> last_hdr->lma)
&& (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
<= hdr->lma))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
/* If putting this section in this segment would force us to
skip a page in the segment, then we need a new segment. */
new_segment = TRUE;
}
else if ((last_hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0
&& (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0)
{
/* We don't want to put a loadable section after a
nonloadable section in the same segment.
Consider .tbss sections as loadable for this purpose. */
new_segment = TRUE;
}
else if ((abfd->flags & D_PAGED) == 0)
{
/* If the file is not demand paged, which means that we
don't require the sections to be correctly aligned in the
file, then there is no other reason for a new segment. */
new_segment = FALSE;
}
else if (! writable
&& (hdr->flags & SEC_READONLY) == 0
&& (((last_hdr->lma + last_size - 1) & -maxpagesize)
!= (hdr->lma & -maxpagesize)))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
/* We don't want to put a writable section in a read only
segment, unless they are on the same page in memory
anyhow. We already know that the last section does not
bring us past the current section on the page, so the
only case in which the new section is not on the same
page as the previous section is when the previous section
ends precisely on a page boundary. */
new_segment = TRUE;
}
else
{
/* Otherwise, we can use the same segment. */
new_segment = FALSE;
}
/* Allow interested parties a chance to override our decision. */
if (last_hdr != NULL
&& info != NULL
&& info->callbacks->override_segment_assignment != NULL)
new_segment
= info->callbacks->override_segment_assignment (info, abfd, hdr,
last_hdr,
new_segment);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (! new_segment)
{
if ((hdr->flags & SEC_READONLY) == 0)
writable = TRUE;
last_hdr = hdr;
/* .tbss sections effectively have zero size. */
if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD))
!= SEC_THREAD_LOCAL)
last_size = hdr->size;
else
last_size = 0;
continue;
}
/* We need a new program segment. We must create a new program
header holding all the sections from phdr_index until hdr. */
m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
if (m == NULL)
goto error_return;
*pm = m;
pm = &m->next;
1999-05-03 09:29:11 +02:00
if ((hdr->flags & SEC_READONLY) == 0)
writable = TRUE;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
else
writable = FALSE;
last_hdr = hdr;
/* .tbss sections effectively have zero size. */
if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL)
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 06:46:28 +02:00
last_size = hdr->size;
else
last_size = 0;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
phdr_index = i;
phdr_in_segment = FALSE;
1999-05-03 09:29:11 +02:00
}
/* Create a final PT_LOAD program segment, but not if it's just
for .tbss. */
if (last_hdr != NULL
&& (i - phdr_index != 1
|| ((last_hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD))
!= SEC_THREAD_LOCAL)))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
if (m == NULL)
goto error_return;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
*pm = m;
pm = &m->next;
}
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* If there is a .dynamic section, throw in a PT_DYNAMIC segment. */
if (dynsec != NULL)
{
m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
if (m == NULL)
goto error_return;
*pm = m;
pm = &m->next;
}
1999-05-03 09:29:11 +02:00
/* For each batch of consecutive loadable .note sections,
add a PT_NOTE segment. We don't use bfd_get_section_by_name,
because if we link together nonloadable .note sections and
loadable .note sections, we will generate two .note sections
in the output file. FIXME: Using names for section types is
bogus anyhow. */
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
for (s = abfd->sections; s != NULL; s = s->next)
{
if ((s->flags & SEC_LOAD) != 0
&& CONST_STRNEQ (s->name, ".note"))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
asection *s2;
count = 1;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
amt = sizeof (struct elf_segment_map);
if (s->alignment_power == 2)
for (s2 = s; s2->next != NULL; s2 = s2->next)
{
if (s2->next->alignment_power == 2
&& (s2->next->flags & SEC_LOAD) != 0
&& CONST_STRNEQ (s2->next->name, ".note")
&& align_power (s2->lma + s2->size, 2)
== s2->next->lma)
count++;
else
break;
}
amt += (count - 1) * sizeof (asection *);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (m == NULL)
goto error_return;
m->next = NULL;
m->p_type = PT_NOTE;
m->count = count;
while (count > 1)
{
m->sections[m->count - count--] = s;
BFD_ASSERT ((s->flags & SEC_THREAD_LOCAL) == 0);
s = s->next;
}
m->sections[m->count - 1] = s;
BFD_ASSERT ((s->flags & SEC_THREAD_LOCAL) == 0);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
*pm = m;
pm = &m->next;
}
if (s->flags & SEC_THREAD_LOCAL)
{
if (! tls_count)
first_tls = s;
tls_count++;
}
}
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* If there are any SHF_TLS output sections, add PT_TLS segment. */
if (tls_count > 0)
{
amt = sizeof (struct elf_segment_map);
amt += (tls_count - 1) * sizeof (asection *);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (m == NULL)
goto error_return;
m->next = NULL;
m->p_type = PT_TLS;
m->count = tls_count;
/* Mandated PF_R. */
m->p_flags = PF_R;
m->p_flags_valid = 1;
for (i = 0; i < (unsigned int) tls_count; ++i)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
BFD_ASSERT (first_tls->flags & SEC_THREAD_LOCAL);
m->sections[i] = first_tls;
first_tls = first_tls->next;
}
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
*pm = m;
pm = &m->next;
}
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
/* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME
segment. */
eh_frame_hdr = elf_tdata (abfd)->eh_frame_hdr;
if (eh_frame_hdr != NULL
&& (eh_frame_hdr->output_section->flags & SEC_LOAD) != 0)
1999-05-03 09:29:11 +02:00
{
amt = sizeof (struct elf_segment_map);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
1999-05-03 09:29:11 +02:00
if (m == NULL)
goto error_return;
m->next = NULL;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
m->p_type = PT_GNU_EH_FRAME;
1999-05-03 09:29:11 +02:00
m->count = 1;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
m->sections[0] = eh_frame_hdr->output_section;
1999-05-03 09:29:11 +02:00
*pm = m;
pm = &m->next;
}
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (elf_tdata (abfd)->stack_flags)
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
{
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
amt = sizeof (struct elf_segment_map);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (m == NULL)
goto error_return;
m->next = NULL;
m->p_type = PT_GNU_STACK;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
m->p_flags = elf_tdata (abfd)->stack_flags;
m->p_flags_valid = 1;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
*pm = m;
pm = &m->next;
}
* elf-bfd.h (enum elf_link_info_type): New. (struct bfd_elf_section_data): Remove stab_info and merge_info fields, add sec_info and sec_info_type. (struct elf_obj_tdata): Add eh_frame_hdr field. (_bfd_elf_discard_section_eh_frame): New prototype. (_bfd_elf_discard_section_eh_frame_hdr): Likewise. (_bfd_elf_eh_frame_section_offset): Likewise. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_write_section_eh_frame_hdr): Likewise. * Makefile.am (BFD32_BACKENDS): Add elf-eh-frame.lo. (BFD32_BACKENDS_CFILES): Add elf-eh-frame.c. (elf-eh-frame.lo): New. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-eh-frame.lo. * configure: Rebuilt. * elf.c (_bfd_elf_print_private_bfd_data): Support PT_GNU_EH_FRAME. (map_sections_to_segments): Create PT_GNU_EH_FRAME if requested. (get_program_header_size): Take into account PT_GNU_EH_FRAME segment. (_bfd_elf_rela_local_sym): Use sec_info_type and sec_info. (_bfd_elf_rel_local_sym): Likewise. (_bfd_elf_section_offset): Likewise. Call _bfd_elf_eh_frame_section_offset too. * elfxx-ia64.c (elfNN_ia64_relocate_section): Use sec_info_type and sec_info. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf-eh-frame.c: New file. * elflink.h (elf_link_add_object_symbols): Don't optimize SHF_MERGE .stab sections. Set sec_info_type, use sec_info instead of merge_info and stab_info. (elf_link_create_dynamic_sections): Create .eh_frame_hdr section if --eh-frame-hdr. (elf_bfd_final_link): Write .eh_frame_hdr section. (elf_link_sec_merge_syms): Use sec_info_type and sec_info. (elf_link_input_bfd): Likewise. Call _bfd_elf_write_section_eh_frame to write .eh_frame sections. (elf_bfd_discard_info): Add output_bfd argument. Call _bfd_elf_discard_section_eh_frame and _bfd_elf_discard_section_eh_frame_hdr. (elf_section_ignore_discarded_relocs): Use sec_info_type, not section names. * bfd-in.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Adjust prototypes. * bfd-in2.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Likewise. * elf/common.h (PT_GNU_EH_FRAME): Define. * bfdlink.h (struct bfd_link_info): Add eh_frame_hdr field. * emultempl/elf32.em (finish): Supply output_bfd to bfd_elf*_discard_info. (OPTION_EH_FRAME_HDR): Define. (longopts): Add --eh-frame-hdr. (parse_args): Handle it. (list_options): Add --eh-frame-hdr to help. * emultempl/hppaelf.em (finish): Supply output_bfd to bfd_elf*_discard_info. * scripttempl/elf.sc (.eh_frame_hdr): Add. * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME.
2001-12-13 12:09:34 +01:00
if (info != NULL && info->relro)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
for (m = mfirst; m != NULL; m = m->next)
{
if (m->p_type == PT_LOAD)
{
asection *last = m->sections[m->count - 1];
bfd_vma vaddr = m->sections[0]->vma;
bfd_vma filesz = last->vma - vaddr + last->size;
* elf-bfd.h (enum elf_link_info_type): New. (struct bfd_elf_section_data): Remove stab_info and merge_info fields, add sec_info and sec_info_type. (struct elf_obj_tdata): Add eh_frame_hdr field. (_bfd_elf_discard_section_eh_frame): New prototype. (_bfd_elf_discard_section_eh_frame_hdr): Likewise. (_bfd_elf_eh_frame_section_offset): Likewise. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_write_section_eh_frame_hdr): Likewise. * Makefile.am (BFD32_BACKENDS): Add elf-eh-frame.lo. (BFD32_BACKENDS_CFILES): Add elf-eh-frame.c. (elf-eh-frame.lo): New. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-eh-frame.lo. * configure: Rebuilt. * elf.c (_bfd_elf_print_private_bfd_data): Support PT_GNU_EH_FRAME. (map_sections_to_segments): Create PT_GNU_EH_FRAME if requested. (get_program_header_size): Take into account PT_GNU_EH_FRAME segment. (_bfd_elf_rela_local_sym): Use sec_info_type and sec_info. (_bfd_elf_rel_local_sym): Likewise. (_bfd_elf_section_offset): Likewise. Call _bfd_elf_eh_frame_section_offset too. * elfxx-ia64.c (elfNN_ia64_relocate_section): Use sec_info_type and sec_info. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf-eh-frame.c: New file. * elflink.h (elf_link_add_object_symbols): Don't optimize SHF_MERGE .stab sections. Set sec_info_type, use sec_info instead of merge_info and stab_info. (elf_link_create_dynamic_sections): Create .eh_frame_hdr section if --eh-frame-hdr. (elf_bfd_final_link): Write .eh_frame_hdr section. (elf_link_sec_merge_syms): Use sec_info_type and sec_info. (elf_link_input_bfd): Likewise. Call _bfd_elf_write_section_eh_frame to write .eh_frame sections. (elf_bfd_discard_info): Add output_bfd argument. Call _bfd_elf_discard_section_eh_frame and _bfd_elf_discard_section_eh_frame_hdr. (elf_section_ignore_discarded_relocs): Use sec_info_type, not section names. * bfd-in.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Adjust prototypes. * bfd-in2.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Likewise. * elf/common.h (PT_GNU_EH_FRAME): Define. * bfdlink.h (struct bfd_link_info): Add eh_frame_hdr field. * emultempl/elf32.em (finish): Supply output_bfd to bfd_elf*_discard_info. (OPTION_EH_FRAME_HDR): Define. (longopts): Add --eh-frame-hdr. (parse_args): Handle it. (list_options): Add --eh-frame-hdr to help. * emultempl/hppaelf.em (finish): Supply output_bfd to bfd_elf*_discard_info. * scripttempl/elf.sc (.eh_frame_hdr): Add. * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME.
2001-12-13 12:09:34 +01:00
if (vaddr < info->relro_end
&& vaddr >= info->relro_start
&& (vaddr + filesz) >= info->relro_end)
break;
}
}
/* Make a PT_GNU_RELRO segment only when it isn't empty. */
if (m != NULL)
{
amt = sizeof (struct elf_segment_map);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
goto error_return;
m->next = NULL;
m->p_type = PT_GNU_RELRO;
m->p_flags = PF_R;
m->p_flags_valid = 1;
*pm = m;
pm = &m->next;
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
free (sections);
elf_tdata (abfd)->segment_map = mfirst;
}
if (!elf_modify_segment_map (abfd, info, no_user_phdrs))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
return FALSE;
bfd/ * elflink.c (elf_bfd_final_link): Don't output STT_SECTION symbol into .dynsym if elf_section_data (sec)->dynindx <= 0. Adjust counting of last_local. (_bfd_elf_link_renumber_dynsyms): Don't assign dynindx to sections other than SHT_PROGBITS/SHT_NOBITS and neither for .got/.got.plt/.plt created by the linker nor !SHF_ALLOC. * elf32-i386.c (elf_i386_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. Set sh_entsize for .got section in addition to .got.plt. (elf_i386_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. (elf64_x86_64_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. Set sh_entsize for .got section in addition to .got.plt. * elf.c (_bfd_elf_print_private_bfd_data): Handle PT_GNU_RELRO. (bfd_section_from_phdr): Likewise. (map_sections_to_segments): Likewise. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Likewise. * elflink.c (bfd_elf_size_dynamic_sections): Set elf_tdata (output_bfd)->relro from info->relro. * elf-bfd.h (struct elf_obj_tdata): Add relro field. include/ * bfdlink.h (struct bfd_link_info): Add relro, relro_start and relro_end fields. * elf/common.h (PT_GNU_EH_FRAME, PT_GNU_STACK): Add comments. (PT_GNU_RELRO): Define. binutils/ * readelf.c (get_segment_type): Handle PT_GNU_RELRO. ld/ * genscripts.sh: Generate -z combreloc -z now -z relro scripts for binaries, -shared and -pie. * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Set. * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Set. * emulparams/elf32ppc.sh (OTHER_READWRITE_SECTIONS): Rename to... (OTHER_RELRO_SECTIONS): ... this. * ldlex.l (DATA_SEGMENT_RELRO_END): Add. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z relro and -z norelro. (gld${EMULATION_NAME}_list_options): Add it to usage. (gld${EMULATION_NAME}_get_script): Return -z combreloc -z now -z relro scripts when appropriate. * scripttempl/elf.sc: Unset SEPARATE_GOTPLT if RELRO_NOW is set. Create separate .got.plt section if SEPARATE_GOTPLT. Move sections which are only written during relocation handling to the beginning of RW segment. If NO_SMALL_DATA, move .got before .data. Add DATA_SEGMENT_RELRO_END directive. Include OTHER_RELRO_SECTIONS. * ldgram.y (DATA_SEGMENT_RELRO_END): Add. * ldexp.c (exp_print_token): Handle DATA_SEGMENT_RELRO_END. (fold_unary): Likewise. (fold_binary): Handle -z relro. * ldexp.h (struct exp_data_seg): Add exp_dataseg_relro_seen and exp_dataseg_relro_adjust phases. Add relro_end field. * ldmain.c (main): Initialize link_info.relro to FALSE. * ldlang.c (lang_size_sections): Handle -z relro. ld/testsuite/ * ld-i386/tlspic.rd: Adjust for section reordering changes and removal of unneeded STT_SECTION symbols from .dynsym. * ld-i386/tlspic.dd: Likewise. * ld-i386/tlspic.sd: Likewise. * ld-i386/tlsbin.rd: Likewise. * ld-i386/tlsbinpic.s: Likewise. * ld-i386/tlsbin.dd: Likewise. * ld-i386/tlsbin.sd: Likewise. * ld-i386/tlsnopic.rd: Likewise. * ld-i386/tlsnopic1.s: Likewise. * ld-i386/combreloc.d: Likewise. * ld-i386/tlsnopic.dd: Likewise. * ld-i386/tlsnopic.sd: Likewise. * ld-x86-64/tlspic.rd: Likewise. * ld-x86-64/tlspic.dd: Likewise. * ld-x86-64/tlsbin.dd: Likewise. * ld-x86-64/tlspic.sd: Likewise. * ld-x86-64/tlsbin.sd: Likewise. * ld-x86-64/tlspic.td: Likewise. * ld-x86-64/tlsbin.td: Likewise. * ld-x86-64/tlsbin.rd: Likewise. * ld-s390/tlspic1.s: Likewise. * ld-s390/tlsbinpic.s: Likewise. * ld-s390/tlspic.rd: Likewise. * ld-s390/tlsbin.rd: Likewise. * ld-s390/tlspic.dd: Likewise. * ld-s390/tlsbin.dd: Likewise. * ld-s390/tlsbin.sd: Likewise. * ld-s390/tlsbin.td: Likewise. * ld-s390/tlspic.sd: Likewise. * ld-s390/tlspic.td: Likewise. * ld-s390/tlspic1_64.s: Likewise. * ld-s390/tlsbinpic_64.s: Likewise. * ld-s390/tlspic_64.rd: Likewise. * ld-s390/tlsbin_64.rd: Likewise. * ld-s390/tlspic_64.dd: Likewise. * ld-s390/tlsbin_64.dd: Likewise. * ld-s390/tlspic_64.sd: Likewise. * ld-s390/tlspic_64.td: Likewise. * ld-s390/tlsbin_64.td: Likewise. * ld-s390/tlsbin_64.sd: Likewise. * ld-powerpc/tlsexe32.r: Likewise. * ld-powerpc/tlsso32.r: Likewise. * ld-powerpc/tlsso32.d: Likewise. * ld-powerpc/tlsso32.g: Likewise. * ld-powerpc/tlsso32.t: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlsso.g: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-powerpc/tlstocso.g: Likewise. * ld-ia64/tlspic.rd: Likewise. * ld-ia64/tlspic.dd: Likewise. * ld-ia64/tlspic.sd: Likewise. * ld-ia64/tlspic.td: Likewise. * ld-ia64/tlsbin.rd: Likewise. * ld-ia64/tlsbin.sd: Likewise. * ld-ia64/tlsbin.td: Likewise. * ld-elfvsb/elfvsb.exp: XFAIL non-PIC load offset tests on s390x. * ld-shared/shared.exp: Likewise.
2004-05-11 19:08:38 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
for (count = 0, m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
++count;
elf_tdata (abfd)->program_header_size = count * bed->s->sizeof_phdr;
1999-05-03 09:29:11 +02:00
return TRUE;
1999-05-03 09:29:11 +02:00
error_return:
if (sections != NULL)
free (sections);
return FALSE;
1999-05-03 09:29:11 +02:00
}
/* Sort sections by address. */
static int
elf_sort_sections (const void *arg1, const void *arg2)
1999-05-03 09:29:11 +02:00
{
const asection *sec1 = *(const asection **) arg1;
const asection *sec2 = *(const asection **) arg2;
bfd_size_type size1, size2;
1999-05-03 09:29:11 +02:00
/* Sort by LMA first, since this is the address used to
place the section into a segment. */
if (sec1->lma < sec2->lma)
return -1;
else if (sec1->lma > sec2->lma)
return 1;
/* Then sort by VMA. Normally the LMA and the VMA will be
the same, and this will do nothing. */
if (sec1->vma < sec2->vma)
return -1;
else if (sec1->vma > sec2->vma)
return 1;
/* Put !SEC_LOAD sections after SEC_LOAD ones. */
2003-02-24 19:07:22 +01:00
#define TOEND(x) (((x)->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0)
1999-05-03 09:29:11 +02:00
if (TOEND (sec1))
{
if (TOEND (sec2))
{
/* If the indicies are the same, do not return 0
here, but continue to try the next comparison. */
if (sec1->target_index - sec2->target_index != 0)
return sec1->target_index - sec2->target_index;
}
1999-05-03 09:29:11 +02:00
else
return 1;
}
else if (TOEND (sec2))
1999-05-03 09:29:11 +02:00
return -1;
#undef TOEND
/* Sort by size, to put zero sized sections
before others at the same address. */
1999-05-03 09:29:11 +02:00
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 06:46:28 +02:00
size1 = (sec1->flags & SEC_LOAD) ? sec1->size : 0;
size2 = (sec2->flags & SEC_LOAD) ? sec2->size : 0;
if (size1 < size2)
1999-05-03 09:29:11 +02:00
return -1;
if (size1 > size2)
1999-05-03 09:29:11 +02:00
return 1;
return sec1->target_index - sec2->target_index;
}
/* Ian Lance Taylor writes:
We shouldn't be using % with a negative signed number. That's just
not good. We have to make sure either that the number is not
negative, or that the number has an unsigned type. When the types
are all the same size they wind up as unsigned. When file_ptr is a
larger signed type, the arithmetic winds up as signed long long,
which is wrong.
What we're trying to say here is something like ``increase OFF by
the least amount that will cause it to be equal to the VMA modulo
the page size.'' */
/* In other words, something like:
vma_offset = m->sections[0]->vma % bed->maxpagesize;
off_offset = off % bed->maxpagesize;
if (vma_offset < off_offset)
adjustment = vma_offset + bed->maxpagesize - off_offset;
else
adjustment = vma_offset - off_offset;
which can can be collapsed into the expression below. */
static file_ptr
vma_page_aligned_bias (bfd_vma vma, ufile_ptr off, bfd_vma maxpagesize)
{
return ((vma - off) % maxpagesize);
}
static void
print_segment_map (const struct elf_segment_map *m)
{
unsigned int j;
const char *pt = get_segment_type (m->p_type);
char buf[32];
if (pt == NULL)
{
if (m->p_type >= PT_LOPROC && m->p_type <= PT_HIPROC)
sprintf (buf, "LOPROC+%7.7x",
(unsigned int) (m->p_type - PT_LOPROC));
else if (m->p_type >= PT_LOOS && m->p_type <= PT_HIOS)
sprintf (buf, "LOOS+%7.7x",
(unsigned int) (m->p_type - PT_LOOS));
else
snprintf (buf, sizeof (buf), "%8.8x",
(unsigned int) m->p_type);
pt = buf;
}
fflush (stdout);
fprintf (stderr, "%s:", pt);
for (j = 0; j < m->count; j++)
fprintf (stderr, " %s", m->sections [j]->name);
putc ('\n',stderr);
fflush (stderr);
}
static bfd_boolean
write_zeros (bfd *abfd, file_ptr pos, bfd_size_type len)
{
void *buf;
bfd_boolean ret;
if (bfd_seek (abfd, pos, SEEK_SET) != 0)
return FALSE;
buf = bfd_zmalloc (len);
if (buf == NULL)
return FALSE;
ret = bfd_bwrite (buf, len, abfd) == len;
free (buf);
return ret;
}
1999-05-03 09:29:11 +02:00
/* Assign file positions to the sections based on the mapping from
sections to segments. This function also sets up some fields in
the file header. */
1999-05-03 09:29:11 +02:00
static bfd_boolean
assign_file_positions_for_load_sections (bfd *abfd,
struct bfd_link_info *link_info)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
struct elf_segment_map *m;
Elf_Internal_Phdr *phdrs;
Elf_Internal_Phdr *p;
file_ptr off;
bfd_size_type maxpagesize;
unsigned int alloc;
unsigned int i, j;
bfd_vma header_pad = 0;
1999-05-03 09:29:11 +02:00
if (link_info == NULL
&& !_bfd_elf_map_sections_to_segments (abfd, link_info))
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
return FALSE;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
alloc = 0;
1999-05-03 09:29:11 +02:00
for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
{
++alloc;
if (m->header_size)
header_pad = m->header_size;
}
1999-05-03 09:29:11 +02:00
if (alloc)
{
elf_elfheader (abfd)->e_phoff = bed->s->sizeof_ehdr;
elf_elfheader (abfd)->e_phentsize = bed->s->sizeof_phdr;
}
else
{
/* PR binutils/12467. */
elf_elfheader (abfd)->e_phoff = 0;
elf_elfheader (abfd)->e_phentsize = 0;
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
elf_elfheader (abfd)->e_phnum = alloc;
1999-05-03 09:29:11 +02:00
if (elf_tdata (abfd)->program_header_size == (bfd_size_type) -1)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
elf_tdata (abfd)->program_header_size = alloc * bed->s->sizeof_phdr;
else
BFD_ASSERT (elf_tdata (abfd)->program_header_size
>= alloc * bed->s->sizeof_phdr);
1999-05-03 09:29:11 +02:00
if (alloc == 0)
{
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
elf_tdata (abfd)->next_file_pos = bed->s->sizeof_ehdr;
return TRUE;
}
1999-05-03 09:29:11 +02:00
/* We're writing the size in elf_tdata (abfd)->program_header_size,
see assign_file_positions_except_relocs, so make sure we have
that amount allocated, with trailing space cleared.
The variable alloc contains the computed need, while elf_tdata
(abfd)->program_header_size contains the size used for the
layout.
See ld/emultempl/elf-generic.em:gld${EMULATION_NAME}_map_segments
where the layout is forced to according to a larger size in the
last iterations for the testcase ld-elf/header. */
BFD_ASSERT (elf_tdata (abfd)->program_header_size % bed->s->sizeof_phdr
== 0);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
phdrs = (Elf_Internal_Phdr *)
bfd_zalloc2 (abfd,
(elf_tdata (abfd)->program_header_size / bed->s->sizeof_phdr),
sizeof (Elf_Internal_Phdr));
elf_tdata (abfd)->phdr = phdrs;
1999-05-03 09:29:11 +02:00
if (phdrs == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
maxpagesize = 1;
if ((abfd->flags & D_PAGED) != 0)
maxpagesize = bed->maxpagesize;
1999-05-03 09:29:11 +02:00
off = bed->s->sizeof_ehdr;
off += alloc * bed->s->sizeof_phdr;
if (header_pad < (bfd_vma) off)
header_pad = 0;
else
header_pad -= off;
off += header_pad;
1999-05-03 09:29:11 +02:00
for (m = elf_tdata (abfd)->segment_map, p = phdrs, j = 0;
1999-05-03 09:29:11 +02:00
m != NULL;
m = m->next, p++, j++)
1999-05-03 09:29:11 +02:00
{
asection **secpp;
bfd_vma off_adjust;
bfd_boolean no_contents;
1999-05-03 09:29:11 +02:00
/* If elf_segment_map is not from map_sections_to_segments, the
sections may not be correctly ordered. NOTE: sorting should
not be done to the PT_NOTE section of a corefile, which may
contain several pseudo-sections artificially created by bfd.
Sorting these pseudo-sections breaks things badly. */
if (m->count > 1
&& !(elf_elfheader (abfd)->e_type == ET_CORE
&& m->p_type == PT_NOTE))
1999-05-03 09:29:11 +02:00
qsort (m->sections, (size_t) m->count, sizeof (asection *),
elf_sort_sections);
/* An ELF segment (described by Elf_Internal_Phdr) may contain a
number of sections with contents contributing to both p_filesz
and p_memsz, followed by a number of sections with no contents
that just contribute to p_memsz. In this loop, OFF tracks next
available file offset for PT_LOAD and PT_NOTE segments. */
1999-05-03 09:29:11 +02:00
p->p_type = m->p_type;
p->p_flags = m->p_flags;
1999-05-03 09:29:11 +02:00
if (m->count == 0)
p->p_vaddr = 0;
else
p->p_vaddr = m->sections[0]->vma - m->p_vaddr_offset;
if (m->p_paddr_valid)
p->p_paddr = m->p_paddr;
else if (m->count == 0)
p->p_paddr = 0;
else
p->p_paddr = m->sections[0]->lma - m->p_vaddr_offset;
if (p->p_type == PT_LOAD
&& (abfd->flags & D_PAGED) != 0)
{
/* p_align in demand paged PT_LOAD segments effectively stores
the maximum page size. When copying an executable with
objcopy, we set m->p_align from the input file. Use this
value for maxpagesize rather than bed->maxpagesize, which
may be different. Note that we use maxpagesize for PT_TLS
segment alignment later in this function, so we are relying
on at least one PT_LOAD segment appearing before a PT_TLS
segment. */
if (m->p_align_valid)
maxpagesize = m->p_align;
p->p_align = maxpagesize;
}
else if (m->p_align_valid)
p->p_align = m->p_align;
else if (m->count == 0)
p->p_align = 1 << bed->s->log_file_align;
else
p->p_align = 0;
no_contents = FALSE;
off_adjust = 0;
1999-05-03 09:29:11 +02:00
if (p->p_type == PT_LOAD
&& m->count > 0)
1999-05-03 09:29:11 +02:00
{
bfd_size_type align;
unsigned int align_power = 0;
if (m->p_align_valid)
align = p->p_align;
else
1999-05-03 09:29:11 +02:00
{
for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
{
unsigned int secalign;
secalign = bfd_get_section_alignment (abfd, *secpp);
if (secalign > align_power)
align_power = secalign;
}
align = (bfd_size_type) 1 << align_power;
if (align < maxpagesize)
align = maxpagesize;
}
1999-05-03 09:29:11 +02:00
for (i = 0; i < m->count; i++)
if ((m->sections[i]->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
/* If we aren't making room for this section, then
it must be SHT_NOBITS regardless of what we've
set via struct bfd_elf_special_section. */
elf_section_type (m->sections[i]) = SHT_NOBITS;
/* Find out whether this segment contains any loadable
sections. */
no_contents = TRUE;
for (i = 0; i < m->count; i++)
if (elf_section_type (m->sections[i]) != SHT_NOBITS)
{
no_contents = FALSE;
break;
}
off_adjust = vma_page_aligned_bias (p->p_vaddr, off, align);
off += off_adjust;
if (no_contents)
{
/* We shouldn't need to align the segment on disk since
the segment doesn't need file space, but the gABI
arguably requires the alignment and glibc ld.so
checks it. So to comply with the alignment
requirement but not waste file space, we adjust
p_offset for just this segment. (OFF_ADJUST is
subtracted from OFF later.) This may put p_offset
past the end of file, but that shouldn't matter. */
}
else
off_adjust = 0;
1999-05-03 09:29:11 +02:00
}
/* Make sure the .dynamic section is the first section in the
PT_DYNAMIC segment. */
else if (p->p_type == PT_DYNAMIC
&& m->count > 1
&& strcmp (m->sections[0]->name, ".dynamic") != 0)
{
_bfd_error_handler
(_("%B: The first section in the PT_DYNAMIC segment is not the .dynamic section"),
abfd);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
/* Set the note section type to SHT_NOTE. */
else if (p->p_type == PT_NOTE)
for (i = 0; i < m->count; i++)
elf_section_type (m->sections[i]) = SHT_NOTE;
1999-05-03 09:29:11 +02:00
p->p_offset = 0;
p->p_filesz = 0;
p->p_memsz = 0;
if (m->includes_filehdr)
{
if (!m->p_flags_valid)
1999-05-03 09:29:11 +02:00
p->p_flags |= PF_R;
p->p_filesz = bed->s->sizeof_ehdr;
p->p_memsz = bed->s->sizeof_ehdr;
if (m->count > 0)
{
BFD_ASSERT (p->p_type == PT_LOAD);
if (p->p_vaddr < (bfd_vma) off)
{
(*_bfd_error_handler)
(_("%B: Not enough room for program headers, try linking with -N"),
abfd);
1999-05-03 09:29:11 +02:00
bfd_set_error (bfd_error_bad_value);
return FALSE;
1999-05-03 09:29:11 +02:00
}
p->p_vaddr -= off;
if (!m->p_paddr_valid)
1999-05-03 09:29:11 +02:00
p->p_paddr -= off;
}
}
if (m->includes_phdrs)
{
if (!m->p_flags_valid)
1999-05-03 09:29:11 +02:00
p->p_flags |= PF_R;
if (!m->includes_filehdr)
1999-05-03 09:29:11 +02:00
{
p->p_offset = bed->s->sizeof_ehdr;
if (m->count > 0)
{
BFD_ASSERT (p->p_type == PT_LOAD);
p->p_vaddr -= off - p->p_offset;
if (!m->p_paddr_valid)
1999-05-03 09:29:11 +02:00
p->p_paddr -= off - p->p_offset;
}
}
p->p_filesz += alloc * bed->s->sizeof_phdr;
p->p_memsz += alloc * bed->s->sizeof_phdr;
if (m->count)
{
p->p_filesz += header_pad;
p->p_memsz += header_pad;
}
1999-05-03 09:29:11 +02:00
}
if (p->p_type == PT_LOAD
|| (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core))
{
if (!m->includes_filehdr && !m->includes_phdrs)
p->p_offset = off;
1999-05-03 09:29:11 +02:00
else
{
file_ptr adjust;
adjust = off - (p->p_offset + p->p_filesz);
if (!no_contents)
p->p_filesz += adjust;
1999-05-03 09:29:11 +02:00
p->p_memsz += adjust;
}
}
/* Set up p_filesz, p_memsz, p_align and p_flags from the section
maps. Set filepos for sections in PT_LOAD segments, and in
core files, for sections in PT_NOTE segments.
assign_file_positions_for_non_load_sections will set filepos
for other sections and update p_filesz for other segments. */
1999-05-03 09:29:11 +02:00
for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
{
asection *sec;
bfd_size_type align;
Elf_Internal_Shdr *this_hdr;
1999-05-03 09:29:11 +02:00
sec = *secpp;
this_hdr = &elf_section_data (sec)->this_hdr;
align = (bfd_size_type) 1 << bfd_get_section_alignment (abfd, sec);
1999-05-03 09:29:11 +02:00
if ((p->p_type == PT_LOAD
|| p->p_type == PT_TLS)
&& (this_hdr->sh_type != SHT_NOBITS
|| ((this_hdr->sh_flags & SHF_ALLOC) != 0
&& ((this_hdr->sh_flags & SHF_TLS) == 0
|| p->p_type == PT_TLS))))
1999-05-03 09:29:11 +02:00
{
bfd_vma p_start = p->p_paddr;
bfd_vma p_end = p_start + p->p_memsz;
bfd_vma s_start = sec->lma;
bfd_vma adjust = s_start - p_end;
1999-05-03 09:29:11 +02:00
if (adjust != 0
&& (s_start < p_end
|| p_end < p_start))
1999-05-03 09:29:11 +02:00
{
(*_bfd_error_handler)
(_("%B: section %A lma %#lx adjusted to %#lx"), abfd, sec,
(unsigned long) s_start, (unsigned long) p_end);
adjust = 0;
sec->lma = p_end;
}
p->p_memsz += adjust;
if (this_hdr->sh_type != SHT_NOBITS)
{
if (p->p_filesz + adjust < p->p_memsz)
{
/* We have a PROGBITS section following NOBITS ones.
Allocate file space for the NOBITS section(s) and
zero it. */
adjust = p->p_memsz - p->p_filesz;
if (!write_zeros (abfd, off, adjust))
return FALSE;
}
off += adjust;
p->p_filesz += adjust;
1999-05-03 09:29:11 +02:00
}
}
if (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core)
{
/* The section at i == 0 is the one that actually contains
everything. */
if (i == 0)
{
this_hdr->sh_offset = sec->filepos = off;
off += this_hdr->sh_size;
p->p_filesz = this_hdr->sh_size;
p->p_memsz = 0;
p->p_align = 1;
1999-05-03 09:29:11 +02:00
}
else
1999-05-03 09:29:11 +02:00
{
/* The rest are fake sections that shouldn't be written. */
1999-05-03 09:29:11 +02:00
sec->filepos = 0;
bfd/ * section.c (struct sec): Rename "_cooked_size" to "size". Rename "_raw_size" to "rawsize". (STD_SECTION): Adjust comments. (bfd_set_section_size, bfd_get_section_contents): Use size. (bfd_malloc_and_get_section): New function. * bfd-in.h (bfd_section_size, bfd_get_section_size): Use size. * coff-sh.c (sh_relax_section): Alloc coff_section_data struct early. Correctly free reloc and contents memory. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME and fake CIE now that we can shink section size to zero. (_bfd_elf_write_section_eh_frame): Likewise.. * elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents. * elf-m10300.c (mn10300_elf_final_link_relocate): Don't use _bfd_stab_section_offset. Use _bfd_elf_section_offset. * stabs.c (_bfd_stab_section_offset_): Remove unused args and unneeded indirection. * elf.c (_bfd_elf_section_offset): .. and update call. * libbfd-in.h (_bfd_stab_section_offset): Update prototype. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. Replace occurrences of "_raw_size" and "_cooked_size" in most places with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE sections. Use "rawsize", if non-zero, for bfd_get_section_contents calls if the section might be a stabs, eh_frame, or SEC_MERGE section. Similarly use "rawsize", if non-zero, in reloc functions to validate reloc addresses. Use new bfd_malloc_and_get_section in most places where bfd_get_section_contents was called. Expand all occurrences of bfd_section_size and bfd_get_section_size. Rename "raw_size" var in grok_prstatus and similar functions to "size". * aix386-core.c (aix386_core_file_p): .. * aix5ppc-core.c (xcoff64_core_p): .. * aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents, aout_adobe_set_section_contents): .. * aout-target.h (callback): .. * aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate, MY_bfd_final_link): .. * aoutf1.h (sunos4_core_file_p): .. * aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic, adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags, final_link, aout_link_input_section): .. * binary.c (binary_object_p, binary_canonicalize_symtab, binary_set_section_contents): .. * bout.c (b_out_callback, b_out_write_object_contents, b_out_set_section_contents, b_out_bfd_relax_section, b_out_bfd_get_relocated_section_contents): .. * cisco-core.c (cisco_core_file_validate): .. * coff-alpha.c (alpha_ecoff_object_p, alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): .. * coff-arm.c (coff_arm_relocate_section, bfd_arm_allocate_interworking_sections): .. * coff-h8300.c (h8300_reloc16_extra_cases, h8300_bfd_link_add_symbols): .. * coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): .. * coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section, ppc_bfd_coff_final_link): .. * coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): .. * coff-sh.c (sh_relax_section, sh_relax_delete_bytes, sh_align_loads, sh_coff_get_relocated_section_contents): .. * coff64-rs6000.c (xcoff64_write_object_contents, xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): .. * coffcode.h (coff_compute_section_file_positions, coff_write_object_contents): .. * coffgen.c (make_a_section_from_file, coff_write_symbols, coff_section_symbol, build_debug_section): .. * cofflink.c (coff_link_add_symbols, _bfd_coff_final_link, process_embedded_commands, _bfd_coff_link_input_bfd, _bfd_coff_write_global_sym): .. * cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): .. * cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): .. * dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): .. * dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info, _bfd_dwarf2_find_nearest_line): .. * ecoff.c (bfd_debug_section, ecoff_set_symbol_info, ecoff_compute_section_file_positions, _bfd_ecoff_write_object_contents, ecoff_indirect_link_order): .. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame, _bfd_elf_discard_section_eh_frame_hdr, _bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset, _bfd_elf_write_section_eh_frame, _bfd_elf_write_section_eh_frame_hdr): .. * elf-hppa.h (elf_hppa_sort_unwind): .. * elf-m10200.c (mn10200_elf_relax_section, mn10200_elf_relax_delete_bytes, mn10200_elf_get_relocated_section_contents): .. * elf-m10300.c (_bfd_mn10300_elf_create_got_section, mn10300_elf_check_relocs, mn10300_elf_relax_section, mn10300_elf_relax_delete_bytes, mn10300_elf_get_relocated_section_contents, _bfd_mn10300_elf_adjust_dynamic_symbol, _bfd_mn10300_elf_discard_copies, _bfd_mn10300_elf_size_dynamic_sections, _bfd_mn10300_elf_finish_dynamic_sections): .. * elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list, _bfd_elf_make_section_from_phdr, elf_fake_sections, bfd_elf_set_group_contents, map_sections_to_segments, elf_sort_sections, assign_file_positions_for_segments, SECTION_SIZE, copy_private_bfd_data, _bfd_elf_get_dynamic_reloc_upper_bound, _bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect, _bfd_elfcore_make_pseudosection, elfcore_grok_prstatus, elfcore_grok_lwpstatus, elfcore_grok_win32pstatus, elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs, _bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): .. * elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect, bfd_elf32_arm_process_before_allocation, elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs, elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections, elf32_arm_write_section): .. * elf32-cris.c (cris_elf_grok_prstatus, elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook, elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol, cris_elf_check_relocs, elf_cris_size_dynamic_sections, elf_cris_discard_excess_dso_dynamics, elf_cris_discard_excess_program_dynamics): .. * elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): .. * elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): .. * elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup, _frv_create_got_section, _frvfdpic_assign_plt_entries, elf32_frvfdpic_size_dynamic_sections, elf32_frvfdpic_modify_segment_map, elf32_frvfdpic_finish_dynamic_sections): .. * elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes, elf32_h8_get_relocated_section_contents): .. * elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub, elf32_hppa_adjust_dynamic_symbol, allocate_plt_static, allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections, elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs, elf32_hppa_finish_dynamic_sections): .. * elf32-i370.c (i370_elf_adjust_dynamic_symbol, i370_elf_size_dynamic_sections, i370_elf_check_relocs, i370_elf_finish_dynamic_sections): .. * elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol, allocate_dynrelocs, elf_i386_size_dynamic_sections, elf_i386_relocate_section, elf_i386_finish_dynamic_sections): .. * elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc, i860_howto_highadj_reloc, i860_howto_splitn_reloc): .. * elf32-ip2k.c (ip2k_is_switch_table_128, ip2k_relax_switch_table_128, ip2k_is_switch_table_256, ip2k_relax_switch_table_256, ip2k_elf_relax_section, adjust_all_relocations, ip2k_elf_relax_delete_bytes): .. * elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc, m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol, allocate_dynrelocs, m32r_elf_size_dynamic_sections, m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections, m32r_elf_relax_section, m32r_elf_relax_delete_bytes, m32r_elf_get_relocated_section_contents): .. * elf32-m68hc11.c (m68hc11_elf_build_one_stub, m68hc11_elf_size_one_stub, m68hc11_elf_relax_section, m68hc11_elf_relax_delete_bytes): .. * elf32-m68hc12.c (m68hc12_elf_build_one_stub, m68hc12_elf_size_one_stub): .. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs, elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): .. * elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook, elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections, elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): .. * elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc, elf32_mips_grok_prstatus): .. * elf32-or32.c (or32_elf_consth_reloc): .. * elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc, elf_create_pointer_linker_section, ppc_elf_create_linker_section, ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol, allocate_dynrelocs, ppc_elf_size_dynamic_sections, ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus, ppc_elf_final_write_processing): .. * elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol, allocate_dynrelocs, elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): .. * elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section, sh_elf_relax_delete_bytes, sh_elf_align_loads, sh_elf_adjust_dynamic_symbol, allocate_dynrelocs, sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents, sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): .. * elf32-sh64-com.c (sh64_address_in_cranges, sh64_get_contents_type): .. * elf32-sh64.c (sh64_find_section_for_address, sh64_elf_final_write_processing): .. * elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc, sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol, allocate_dynrelocs, elf32_sparc_size_dynamic_sections, elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): .. * elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): .. * elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol, elf_vax_size_dynamic_sections, elf_vax_discard_copies, elf_vax_instantiate_got_entries, elf_vax_relocate_section, elf_vax_finish_dynamic_sections): .. * elf32-xstormy16.c (xstormy16_elf_24_reloc, xstormy16_elf_check_relocs, xstormy16_relax_plt_check, xstormy16_elf_relax_section, xstormy16_elf_always_size_sections, xstormy16_elf_finish_dynamic_sections): .. * elf32-xtensa.c (xtensa_read_table_entries, elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size, elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc, bfd_elf_xtensa_reloc, elf_xtensa_relocate_section, elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections, elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus, get_relocation_opcode, retrieve_contents, find_relaxable_sections, collect_source_relocs, is_resolvable_asm_expansion, remove_literals, relax_section, shrink_dynamic_reloc_sections, relax_property_section, xtensa_callback_required_dependence): .. * elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section, elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol, elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets, elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1, elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes, elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1, elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel, elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): .. * elf64-hppa.c (allocate_dynrel_entries, elf64_hppa_size_dynamic_sections, elf64_hppa_finish_dynamic_sections): .. * elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc, mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table, elf64_mips_grok_prstatus): .. * elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc, mmix_elf_relocate_section, mmix_elf_final_link, mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation, mmix_elf_relax_section, mmix_elf_get_section_contents): .. * elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus, ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust, ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd, allocate_dynrelocs, ppc64_elf_size_dynamic_sections, ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section, toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs, ppc64_elf_build_stubs, ppc64_elf_relocate_section, ppc64_elf_finish_dynamic_sections): .. * elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol, allocate_dynrelocs, elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_sections): .. * elf64-sh64.c (sh_elf64_get_relocated_section_contents, sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol, sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections, sh64_elf64_finish_dynamic_sections): .. * elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc, sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol, sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section, sparc64_elf_finish_dynamic_symbol, sparc64_elf_finish_dynamic_sections): .. * elf64-x86-64.c (elf64_x86_64_grok_prstatus, elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs, elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section, elf64_x86_64_finish_dynamic_sections): .. * elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): .. * elfcode.h (elf_slurp_reloc_table): .. * elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag, elf_finalize_dynstr, elf_link_add_object_symbols, bfd_elf_size_dynamic_sections, elf_link_sort_relocs, elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): .. * elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc, elf32_mips_grok_prstatus): .. * elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries, elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc, elfNN_ia64_choose_gp, elfNN_ia64_final_link, elfNN_ia64_finish_dynamic_sections): .. * elfxx-mips.c (mips_elf_create_procedure_table, mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp, _bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc, mips_elf_global_got_index, mips_elf_multi_got, mips_elf_create_compact_rel_section, mips_elf_calculate_relocation, mips_elf_allocate_dynamic_relocations, mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections, _bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol, _bfd_mips_elf_always_size_sections, _bfd_mips_elf_size_dynamic_sections, _bfd_mips_elf_finish_dynamic_symbol, _bfd_mips_elf_finish_dynamic_sections, _bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info, _bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents, _bfd_elf_mips_get_relocated_section_contents, _bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): .. * hp300hpux.c (callback): .. * hppabsd-core.c (make_bfd_asection): .. * hpux-core.c (make_bfd_asection): .. * i386linux.c (linux_link_create_dynamic_sections, bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): .. * i386msdos.c (msdos_write_object_contents): .. * i386os9k.c (os9k_callback, os9k_write_object_contents, os9k_set_section_contents): .. * ieee.c (parse_expression, ieee_slurp_external_symbols, ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data, ieee_write_section_part, do_with_relocs, do_as_repeat, do_without_relocs, ieee_write_debug_part, init_for_output, ieee_set_section_contents): .. * ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): .. * irix-core.c (do_sections, make_bfd_asection): .. * libaout.h (aout_section_merge_with_text_p): .. * libbfd.c (_bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window): .. * linker.c (default_indirect_link_order): .. * lynx-core.c (make_bfd_asection): .. * m68klinux.c (linux_link_create_dynamic_sections, bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): .. * mach-o.c (bfd_mach_o_make_bfd_section, bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib, bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab, bfd_mach_o_scan_read_segment): .. * merge.c (_bfd_add_merge_section, record_section, merge_strings, _bfd_merge_sections): .. * mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc, mmo_map_set_sizes, mmo_canonicalize_symtab, mmo_internal_write_section, mmo_write_object_contents): .. * netbsd-core.c (netbsd_core_file_p): .. * nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import, nlm_alpha_set_public_section): .. * nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): .. * nlm32-sparc.c (nlm_sparc_write_import): .. * nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in, nlm_compute_section_file_positions): .. * oasys.c (oasys_object_p, oasys_slurp_section_data, oasys_write_sections, oasys_write_data, oasys_set_section_contents): .. * opncls.c (get_debug_link_info): .. * osf-core.c (make_bfd_asection): .. * pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic, adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs, final_link, aout_link_input_section): .. * peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out, pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): .. * pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section, bfd_pef_scan_start_address, bfd_pef_parse_symbols): .. * ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): .. * ptrace-core.c (ptrace_unix_core_file_p): .. * reloc.c (bfd_perform_relocation, bfd_install_relocation, _bfd_final_link_relocate, bfd_generic_relax_section, bfd_generic_get_relocated_section_contents): .. * reloc16.c (bfd_coff_reloc16_relax_section, bfd_coff_reloc16_get_relocated_section_c): .. * riscix.c (riscix_some_aout_object_p): .. * rs6000-core.c (read_hdr, make_bfd_asection): .. * sco5-core.c (make_bfd_asection): .. * simple.c (bfd_simple_get_relocated_section_contents): .. * som.c (som_object_setup, setup_sections, som_prep_headers, som_write_fixups, som_begin_writing, bfd_section_from_som_symbol, som_set_reloc_info, som_get_section_contents, som_bfd_link_split_section): .. * sparclinux.c (linux_link_create_dynamic_sections, bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): .. * srec.c (srec_scan, srec_read_section, srec_get_section_contents): .. * stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs, _bfd_write_stab_strings, _bfd_stab_section_offset): .. * sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections, bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs, sunos_scan_ext_relocs, sunos_scan_dynamic_symbol, sunos_write_dynamic_symbol, sunos_check_dynamic_reloc, sunos_finish_dynamic_link): .. * syms.c (_bfd_stab_section_find_nearest_line): .. * tekhex.c (first_phase, tekhex_set_section_contents, tekhex_write_object_contents): .. * trad-core.c (trad_unix_core_file_p): .. * versados.c (process_esd, process_otr, process_otr): .. * vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): .. * vms-misc.c (add_new_contents): .. * vms-tir.c (check_section, new_section, _bfd_vms_write_tir): .. * vms.c (vms_set_section_contents): .. * xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols, xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms, _bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): .. * xsym.c (bfd_sym_scan): .. See above. binutils/ * objcopy.c (copy_section): Don't set _cooked_size. include/ * bfdlink.h (struct bfd_link_order): Update comment. ld/ * ldlang.c (print_output_section_statement): Don't print size before relaxation. (IGNORE_SECTION): Remove bfd arg. Update all callers. * ldexp.c (fold_name): .. See below. * ldlang.c (section_already_linked, print_output_section_statement, print_input_section, insert_pad, size_input_section, lang_check_section_addresses, lang_size_sections_1, lang_size_sections, lang_do_assignments_1, lang_set_startof, lang_one_common, lang_reset_memory_regions, lang_process, lang_abs_symbol_at_end_of, lang_do_version_exports_section): .. * ldwrite.c (build_link_order, clone_section, ds, split_sections): .. * pe-dll.c (process_def_file, generate_reloc): .. * emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment, gld${EMULATION_NAME}_before_allocation): .. * emultempl/mmix-elfnmmo.em (mmix_after_allocation): .. * emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation, sh64_elf_${EMULATION_NAME}_after_allocation): .. * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): .. * emultempl/xtensaelf.em (ld_assign_relative_paged_dot, ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use "size" instead of "_raw_size" and "_cooked_size". Expand bfd_section_size macro invocations.
2004-06-24 06:46:28 +02:00
sec->size = 0;
sec->flags = 0;
continue;
1999-05-03 09:29:11 +02:00
}
}
else
{
if (p->p_type == PT_LOAD)
{
this_hdr->sh_offset = sec->filepos = off;
if (this_hdr->sh_type != SHT_NOBITS)
off += this_hdr->sh_size;
}
else if (this_hdr->sh_type == SHT_NOBITS
&& (this_hdr->sh_flags & SHF_TLS) != 0
&& this_hdr->sh_offset == 0)
{
/* This is a .tbss section that didn't get a PT_LOAD.
(See _bfd_elf_map_sections_to_segments "Create a
final PT_LOAD".) Set sh_offset to the value it
would have if we had created a zero p_filesz and
p_memsz PT_LOAD header for the section. This
also makes the PT_TLS header have the same
p_offset value. */
bfd_vma adjust = vma_page_aligned_bias (this_hdr->sh_addr,
off, align);
this_hdr->sh_offset = sec->filepos = off + adjust;
}
1999-05-03 09:29:11 +02:00
if (this_hdr->sh_type != SHT_NOBITS)
{
p->p_filesz += this_hdr->sh_size;
/* A load section without SHF_ALLOC is something like
a note section in a PT_NOTE segment. These take
file space but are not loaded into memory. */
if ((this_hdr->sh_flags & SHF_ALLOC) != 0)
p->p_memsz += this_hdr->sh_size;
}
else if ((this_hdr->sh_flags & SHF_ALLOC) != 0)
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
{
if (p->p_type == PT_TLS)
p->p_memsz += this_hdr->sh_size;
/* .tbss is special. It doesn't contribute to p_memsz of
normal segments. */
else if ((this_hdr->sh_flags & SHF_TLS) == 0)
p->p_memsz += this_hdr->sh_size;
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
}
bfd/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * elf-bfd.h (elf_obj_tdata): Remove relro. * elf.c (get_program_header_size): Check info->relro instead of elf_tdata (abfd)->relro. (_bfd_elf_map_sections_to_segments): Likewise. (assign_file_positions_for_load_sections): Don't set PT_GNU_RELRO segment alignment here. (assign_file_positions_for_non_load_sections): Properly set up PT_GNU_RELRO segment for copying executable/shared library. (rewrite_elf_program_header): Remove PT_GNU_RELRO segment. (copy_elf_program_header): Set p_size and p_size_valid fields for PT_GNU_RELRO segment. include/elf/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * internal.h (elf_segment_map): Add p_size and p_size_valid. (ELF_IS_SECTION_IN_SEGMENT): Allow SHF_TLS sections in PT_GNU_RELRO segments. ld/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ldexp.h (ldexp_control): Add relro, relro_start_stat and relro_end_stat. * ldexp.c (fold_binary): Set expld.dataseg.relro to exp_dataseg_relro_start or exp_dataseg_relro_end when seeing DATA_SEGMENT_ALIGN or DATA_SEGMENT_RELRO_END, respectively. * ldlang.c (lang_size_sections_1): Properly set expld.dataseg.relro_start_stat and expld.dataseg.relro_end_stat. (find_relro_section_callback): New function. (lang_find_relro_sections_1): Likewise. (lang_find_relro_sections): Likewise. (lang_process): Call lang_find_relro_sections for non-relocatable link. ld/testsuite/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ld-elf/binutils.exp: Update "-z relro" tests to use relro1.s. Add "-z relro" tests with relro2.s. Add "-z relro" tests with TLS for objcopy. * ld-elf/relro1.s: New file. * ld-elf/relro2.s: Likewise.
2007-09-18 02:25:07 +02:00
if (align > p->p_align
&& !m->p_align_valid
&& (p->p_type != PT_LOAD
|| (abfd->flags & D_PAGED) == 0))
1999-05-03 09:29:11 +02:00
p->p_align = align;
}
if (!m->p_flags_valid)
1999-05-03 09:29:11 +02:00
{
p->p_flags |= PF_R;
if ((this_hdr->sh_flags & SHF_EXECINSTR) != 0)
1999-05-03 09:29:11 +02:00
p->p_flags |= PF_X;
if ((this_hdr->sh_flags & SHF_WRITE) != 0)
1999-05-03 09:29:11 +02:00
p->p_flags |= PF_W;
}
}
off -= off_adjust;
/* Check that all sections are in a PT_LOAD segment.
Don't check funky gdb generated core files. */
if (p->p_type == PT_LOAD && bfd_get_format (abfd) != bfd_core)
{
bfd_boolean check_vma = TRUE;
for (i = 1; i < m->count; i++)
if (m->sections[i]->vma == m->sections[i - 1]->vma
&& ELF_SECTION_SIZE (&(elf_section_data (m->sections[i])
->this_hdr), p) != 0
&& ELF_SECTION_SIZE (&(elf_section_data (m->sections[i - 1])
->this_hdr), p) != 0)
{
/* Looks like we have overlays packed into the segment. */
check_vma = FALSE;
break;
}
for (i = 0; i < m->count; i++)
{
Elf_Internal_Shdr *this_hdr;
asection *sec;
sec = m->sections[i];
this_hdr = &(elf_section_data(sec)->this_hdr);
if (!ELF_SECTION_IN_SEGMENT_1 (this_hdr, p, check_vma, 0)
&& !ELF_TBSS_SPECIAL (this_hdr, p))
{
(*_bfd_error_handler)
(_("%B: section `%A' can't be allocated in segment %d"),
abfd, sec, j);
print_segment_map (m);
}
}
}
1999-05-03 09:29:11 +02:00
}
elf_tdata (abfd)->next_file_pos = off;
return TRUE;
}
/* Assign file positions for the other sections. */
static bfd_boolean
assign_file_positions_for_non_load_sections (bfd *abfd,
struct bfd_link_info *link_info)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
Elf_Internal_Shdr **i_shdrpp;
Elf_Internal_Shdr **hdrpp;
Elf_Internal_Phdr *phdrs;
Elf_Internal_Phdr *p;
struct elf_segment_map *m;
bfd_vma filehdr_vaddr, filehdr_paddr;
bfd_vma phdrs_vaddr, phdrs_paddr;
file_ptr off;
unsigned int num_sec;
unsigned int i;
unsigned int count;
i_shdrpp = elf_elfsections (abfd);
num_sec = elf_numsections (abfd);
off = elf_tdata (abfd)->next_file_pos;
for (i = 1, hdrpp = i_shdrpp + 1; i < num_sec; i++, hdrpp++)
{
struct elf_obj_tdata *tdata = elf_tdata (abfd);
Elf_Internal_Shdr *hdr;
hdr = *hdrpp;
if (hdr->bfd_section != NULL
&& (hdr->bfd_section->filepos != 0
|| (hdr->sh_type == SHT_NOBITS
&& hdr->contents == NULL)))
BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos);
else if ((hdr->sh_flags & SHF_ALLOC) != 0)
{
if (hdr->sh_size != 0)
(*_bfd_error_handler)
(_("%B: warning: allocated section `%s' not in segment"),
abfd,
(hdr->bfd_section == NULL
? "*unknown*"
: hdr->bfd_section->name));
/* We don't need to page align empty sections. */
if ((abfd->flags & D_PAGED) != 0 && hdr->sh_size != 0)
off += vma_page_aligned_bias (hdr->sh_addr, off,
bed->maxpagesize);
else
off += vma_page_aligned_bias (hdr->sh_addr, off,
hdr->sh_addralign);
off = _bfd_elf_assign_file_position_for_section (hdr, off,
FALSE);
}
else if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
&& hdr->bfd_section == NULL)
|| hdr == i_shdrpp[tdata->symtab_section]
|| hdr == i_shdrpp[tdata->symtab_shndx_section]
|| hdr == i_shdrpp[tdata->strtab_section])
hdr->sh_offset = -1;
else
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
}
1999-05-03 09:29:11 +02:00
/* Now that we have set the section file positions, we can set up
the file positions for the non PT_LOAD segments. */
count = 0;
filehdr_vaddr = 0;
filehdr_paddr = 0;
phdrs_vaddr = bed->maxpagesize + bed->s->sizeof_ehdr;
phdrs_paddr = 0;
phdrs = elf_tdata (abfd)->phdr;
for (m = elf_tdata (abfd)->segment_map, p = phdrs;
m != NULL;
m = m->next, p++)
{
++count;
if (p->p_type != PT_LOAD)
continue;
if (m->includes_filehdr)
{
filehdr_vaddr = p->p_vaddr;
filehdr_paddr = p->p_paddr;
}
if (m->includes_phdrs)
{
phdrs_vaddr = p->p_vaddr;
phdrs_paddr = p->p_paddr;
if (m->includes_filehdr)
{
phdrs_vaddr += bed->s->sizeof_ehdr;
phdrs_paddr += bed->s->sizeof_ehdr;
}
}
}
1999-05-03 09:29:11 +02:00
for (m = elf_tdata (abfd)->segment_map, p = phdrs;
m != NULL;
m = m->next, p++)
{
if (p->p_type == PT_GNU_RELRO)
1999-05-03 09:29:11 +02:00
{
const Elf_Internal_Phdr *lp;
BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs);
if (link_info != NULL)
bfd/ * elflink.c (elf_bfd_final_link): Don't output STT_SECTION symbol into .dynsym if elf_section_data (sec)->dynindx <= 0. Adjust counting of last_local. (_bfd_elf_link_renumber_dynsyms): Don't assign dynindx to sections other than SHT_PROGBITS/SHT_NOBITS and neither for .got/.got.plt/.plt created by the linker nor !SHF_ALLOC. * elf32-i386.c (elf_i386_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. Set sh_entsize for .got section in addition to .got.plt. (elf_i386_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. (elf64_x86_64_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. Set sh_entsize for .got section in addition to .got.plt. * elf.c (_bfd_elf_print_private_bfd_data): Handle PT_GNU_RELRO. (bfd_section_from_phdr): Likewise. (map_sections_to_segments): Likewise. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Likewise. * elflink.c (bfd_elf_size_dynamic_sections): Set elf_tdata (output_bfd)->relro from info->relro. * elf-bfd.h (struct elf_obj_tdata): Add relro field. include/ * bfdlink.h (struct bfd_link_info): Add relro, relro_start and relro_end fields. * elf/common.h (PT_GNU_EH_FRAME, PT_GNU_STACK): Add comments. (PT_GNU_RELRO): Define. binutils/ * readelf.c (get_segment_type): Handle PT_GNU_RELRO. ld/ * genscripts.sh: Generate -z combreloc -z now -z relro scripts for binaries, -shared and -pie. * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Set. * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Set. * emulparams/elf32ppc.sh (OTHER_READWRITE_SECTIONS): Rename to... (OTHER_RELRO_SECTIONS): ... this. * ldlex.l (DATA_SEGMENT_RELRO_END): Add. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z relro and -z norelro. (gld${EMULATION_NAME}_list_options): Add it to usage. (gld${EMULATION_NAME}_get_script): Return -z combreloc -z now -z relro scripts when appropriate. * scripttempl/elf.sc: Unset SEPARATE_GOTPLT if RELRO_NOW is set. Create separate .got.plt section if SEPARATE_GOTPLT. Move sections which are only written during relocation handling to the beginning of RW segment. If NO_SMALL_DATA, move .got before .data. Add DATA_SEGMENT_RELRO_END directive. Include OTHER_RELRO_SECTIONS. * ldgram.y (DATA_SEGMENT_RELRO_END): Add. * ldexp.c (exp_print_token): Handle DATA_SEGMENT_RELRO_END. (fold_unary): Likewise. (fold_binary): Handle -z relro. * ldexp.h (struct exp_data_seg): Add exp_dataseg_relro_seen and exp_dataseg_relro_adjust phases. Add relro_end field. * ldmain.c (main): Initialize link_info.relro to FALSE. * ldlang.c (lang_size_sections): Handle -z relro. ld/testsuite/ * ld-i386/tlspic.rd: Adjust for section reordering changes and removal of unneeded STT_SECTION symbols from .dynsym. * ld-i386/tlspic.dd: Likewise. * ld-i386/tlspic.sd: Likewise. * ld-i386/tlsbin.rd: Likewise. * ld-i386/tlsbinpic.s: Likewise. * ld-i386/tlsbin.dd: Likewise. * ld-i386/tlsbin.sd: Likewise. * ld-i386/tlsnopic.rd: Likewise. * ld-i386/tlsnopic1.s: Likewise. * ld-i386/combreloc.d: Likewise. * ld-i386/tlsnopic.dd: Likewise. * ld-i386/tlsnopic.sd: Likewise. * ld-x86-64/tlspic.rd: Likewise. * ld-x86-64/tlspic.dd: Likewise. * ld-x86-64/tlsbin.dd: Likewise. * ld-x86-64/tlspic.sd: Likewise. * ld-x86-64/tlsbin.sd: Likewise. * ld-x86-64/tlspic.td: Likewise. * ld-x86-64/tlsbin.td: Likewise. * ld-x86-64/tlsbin.rd: Likewise. * ld-s390/tlspic1.s: Likewise. * ld-s390/tlsbinpic.s: Likewise. * ld-s390/tlspic.rd: Likewise. * ld-s390/tlsbin.rd: Likewise. * ld-s390/tlspic.dd: Likewise. * ld-s390/tlsbin.dd: Likewise. * ld-s390/tlsbin.sd: Likewise. * ld-s390/tlsbin.td: Likewise. * ld-s390/tlspic.sd: Likewise. * ld-s390/tlspic.td: Likewise. * ld-s390/tlspic1_64.s: Likewise. * ld-s390/tlsbinpic_64.s: Likewise. * ld-s390/tlspic_64.rd: Likewise. * ld-s390/tlsbin_64.rd: Likewise. * ld-s390/tlspic_64.dd: Likewise. * ld-s390/tlsbin_64.dd: Likewise. * ld-s390/tlspic_64.sd: Likewise. * ld-s390/tlspic_64.td: Likewise. * ld-s390/tlsbin_64.td: Likewise. * ld-s390/tlsbin_64.sd: Likewise. * ld-powerpc/tlsexe32.r: Likewise. * ld-powerpc/tlsso32.r: Likewise. * ld-powerpc/tlsso32.d: Likewise. * ld-powerpc/tlsso32.g: Likewise. * ld-powerpc/tlsso32.t: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlsso.g: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-powerpc/tlstocso.g: Likewise. * ld-ia64/tlspic.rd: Likewise. * ld-ia64/tlspic.dd: Likewise. * ld-ia64/tlspic.sd: Likewise. * ld-ia64/tlspic.td: Likewise. * ld-ia64/tlsbin.rd: Likewise. * ld-ia64/tlsbin.sd: Likewise. * ld-ia64/tlsbin.td: Likewise. * ld-elfvsb/elfvsb.exp: XFAIL non-PIC load offset tests on s390x. * ld-shared/shared.exp: Likewise.
2004-05-11 19:08:38 +02:00
{
/* During linking the range of the RELRO segment is passed
in link_info. */
bfd/ * elflink.c (elf_bfd_final_link): Don't output STT_SECTION symbol into .dynsym if elf_section_data (sec)->dynindx <= 0. Adjust counting of last_local. (_bfd_elf_link_renumber_dynsyms): Don't assign dynindx to sections other than SHT_PROGBITS/SHT_NOBITS and neither for .got/.got.plt/.plt created by the linker nor !SHF_ALLOC. * elf32-i386.c (elf_i386_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. Set sh_entsize for .got section in addition to .got.plt. (elf_i386_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. (elf64_x86_64_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. Set sh_entsize for .got section in addition to .got.plt. * elf.c (_bfd_elf_print_private_bfd_data): Handle PT_GNU_RELRO. (bfd_section_from_phdr): Likewise. (map_sections_to_segments): Likewise. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Likewise. * elflink.c (bfd_elf_size_dynamic_sections): Set elf_tdata (output_bfd)->relro from info->relro. * elf-bfd.h (struct elf_obj_tdata): Add relro field. include/ * bfdlink.h (struct bfd_link_info): Add relro, relro_start and relro_end fields. * elf/common.h (PT_GNU_EH_FRAME, PT_GNU_STACK): Add comments. (PT_GNU_RELRO): Define. binutils/ * readelf.c (get_segment_type): Handle PT_GNU_RELRO. ld/ * genscripts.sh: Generate -z combreloc -z now -z relro scripts for binaries, -shared and -pie. * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Set. * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Set. * emulparams/elf32ppc.sh (OTHER_READWRITE_SECTIONS): Rename to... (OTHER_RELRO_SECTIONS): ... this. * ldlex.l (DATA_SEGMENT_RELRO_END): Add. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z relro and -z norelro. (gld${EMULATION_NAME}_list_options): Add it to usage. (gld${EMULATION_NAME}_get_script): Return -z combreloc -z now -z relro scripts when appropriate. * scripttempl/elf.sc: Unset SEPARATE_GOTPLT if RELRO_NOW is set. Create separate .got.plt section if SEPARATE_GOTPLT. Move sections which are only written during relocation handling to the beginning of RW segment. If NO_SMALL_DATA, move .got before .data. Add DATA_SEGMENT_RELRO_END directive. Include OTHER_RELRO_SECTIONS. * ldgram.y (DATA_SEGMENT_RELRO_END): Add. * ldexp.c (exp_print_token): Handle DATA_SEGMENT_RELRO_END. (fold_unary): Likewise. (fold_binary): Handle -z relro. * ldexp.h (struct exp_data_seg): Add exp_dataseg_relro_seen and exp_dataseg_relro_adjust phases. Add relro_end field. * ldmain.c (main): Initialize link_info.relro to FALSE. * ldlang.c (lang_size_sections): Handle -z relro. ld/testsuite/ * ld-i386/tlspic.rd: Adjust for section reordering changes and removal of unneeded STT_SECTION symbols from .dynsym. * ld-i386/tlspic.dd: Likewise. * ld-i386/tlspic.sd: Likewise. * ld-i386/tlsbin.rd: Likewise. * ld-i386/tlsbinpic.s: Likewise. * ld-i386/tlsbin.dd: Likewise. * ld-i386/tlsbin.sd: Likewise. * ld-i386/tlsnopic.rd: Likewise. * ld-i386/tlsnopic1.s: Likewise. * ld-i386/combreloc.d: Likewise. * ld-i386/tlsnopic.dd: Likewise. * ld-i386/tlsnopic.sd: Likewise. * ld-x86-64/tlspic.rd: Likewise. * ld-x86-64/tlspic.dd: Likewise. * ld-x86-64/tlsbin.dd: Likewise. * ld-x86-64/tlspic.sd: Likewise. * ld-x86-64/tlsbin.sd: Likewise. * ld-x86-64/tlspic.td: Likewise. * ld-x86-64/tlsbin.td: Likewise. * ld-x86-64/tlsbin.rd: Likewise. * ld-s390/tlspic1.s: Likewise. * ld-s390/tlsbinpic.s: Likewise. * ld-s390/tlspic.rd: Likewise. * ld-s390/tlsbin.rd: Likewise. * ld-s390/tlspic.dd: Likewise. * ld-s390/tlsbin.dd: Likewise. * ld-s390/tlsbin.sd: Likewise. * ld-s390/tlsbin.td: Likewise. * ld-s390/tlspic.sd: Likewise. * ld-s390/tlspic.td: Likewise. * ld-s390/tlspic1_64.s: Likewise. * ld-s390/tlsbinpic_64.s: Likewise. * ld-s390/tlspic_64.rd: Likewise. * ld-s390/tlsbin_64.rd: Likewise. * ld-s390/tlspic_64.dd: Likewise. * ld-s390/tlsbin_64.dd: Likewise. * ld-s390/tlspic_64.sd: Likewise. * ld-s390/tlspic_64.td: Likewise. * ld-s390/tlsbin_64.td: Likewise. * ld-s390/tlsbin_64.sd: Likewise. * ld-powerpc/tlsexe32.r: Likewise. * ld-powerpc/tlsso32.r: Likewise. * ld-powerpc/tlsso32.d: Likewise. * ld-powerpc/tlsso32.g: Likewise. * ld-powerpc/tlsso32.t: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlsso.g: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-powerpc/tlstocso.g: Likewise. * ld-ia64/tlspic.rd: Likewise. * ld-ia64/tlspic.dd: Likewise. * ld-ia64/tlspic.sd: Likewise. * ld-ia64/tlspic.td: Likewise. * ld-ia64/tlsbin.rd: Likewise. * ld-ia64/tlsbin.sd: Likewise. * ld-ia64/tlsbin.td: Likewise. * ld-elfvsb/elfvsb.exp: XFAIL non-PIC load offset tests on s390x. * ld-shared/shared.exp: Likewise.
2004-05-11 19:08:38 +02:00
for (lp = phdrs; lp < phdrs + count; ++lp)
{
if (lp->p_type == PT_LOAD
&& lp->p_vaddr >= link_info->relro_start
&& lp->p_vaddr < link_info->relro_end
&& lp->p_vaddr + lp->p_filesz >= link_info->relro_end)
bfd/ * elflink.c (elf_bfd_final_link): Don't output STT_SECTION symbol into .dynsym if elf_section_data (sec)->dynindx <= 0. Adjust counting of last_local. (_bfd_elf_link_renumber_dynsyms): Don't assign dynindx to sections other than SHT_PROGBITS/SHT_NOBITS and neither for .got/.got.plt/.plt created by the linker nor !SHF_ALLOC. * elf32-i386.c (elf_i386_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. Set sh_entsize for .got section in addition to .got.plt. (elf_i386_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Point DT_PLTGOT to the start of the .got.plt section instead of the .got output section. (elf64_x86_64_relocate_section): Don't assume _GLOBAL_OFFSET_TABLE_ is at sgot->output_section->vma. Set sh_entsize for .got section in addition to .got.plt. * elf.c (_bfd_elf_print_private_bfd_data): Handle PT_GNU_RELRO. (bfd_section_from_phdr): Likewise. (map_sections_to_segments): Likewise. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Likewise. * elflink.c (bfd_elf_size_dynamic_sections): Set elf_tdata (output_bfd)->relro from info->relro. * elf-bfd.h (struct elf_obj_tdata): Add relro field. include/ * bfdlink.h (struct bfd_link_info): Add relro, relro_start and relro_end fields. * elf/common.h (PT_GNU_EH_FRAME, PT_GNU_STACK): Add comments. (PT_GNU_RELRO): Define. binutils/ * readelf.c (get_segment_type): Handle PT_GNU_RELRO. ld/ * genscripts.sh: Generate -z combreloc -z now -z relro scripts for binaries, -shared and -pie. * emulparams/elf_i386.sh (SEPARATE_GOTPLT): Set. * emulparams/elf_x86_64.sh (SEPARATE_GOTPLT): Set. * emulparams/elf32ppc.sh (OTHER_READWRITE_SECTIONS): Rename to... (OTHER_RELRO_SECTIONS): ... this. * ldlex.l (DATA_SEGMENT_RELRO_END): Add. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z relro and -z norelro. (gld${EMULATION_NAME}_list_options): Add it to usage. (gld${EMULATION_NAME}_get_script): Return -z combreloc -z now -z relro scripts when appropriate. * scripttempl/elf.sc: Unset SEPARATE_GOTPLT if RELRO_NOW is set. Create separate .got.plt section if SEPARATE_GOTPLT. Move sections which are only written during relocation handling to the beginning of RW segment. If NO_SMALL_DATA, move .got before .data. Add DATA_SEGMENT_RELRO_END directive. Include OTHER_RELRO_SECTIONS. * ldgram.y (DATA_SEGMENT_RELRO_END): Add. * ldexp.c (exp_print_token): Handle DATA_SEGMENT_RELRO_END. (fold_unary): Likewise. (fold_binary): Handle -z relro. * ldexp.h (struct exp_data_seg): Add exp_dataseg_relro_seen and exp_dataseg_relro_adjust phases. Add relro_end field. * ldmain.c (main): Initialize link_info.relro to FALSE. * ldlang.c (lang_size_sections): Handle -z relro. ld/testsuite/ * ld-i386/tlspic.rd: Adjust for section reordering changes and removal of unneeded STT_SECTION symbols from .dynsym. * ld-i386/tlspic.dd: Likewise. * ld-i386/tlspic.sd: Likewise. * ld-i386/tlsbin.rd: Likewise. * ld-i386/tlsbinpic.s: Likewise. * ld-i386/tlsbin.dd: Likewise. * ld-i386/tlsbin.sd: Likewise. * ld-i386/tlsnopic.rd: Likewise. * ld-i386/tlsnopic1.s: Likewise. * ld-i386/combreloc.d: Likewise. * ld-i386/tlsnopic.dd: Likewise. * ld-i386/tlsnopic.sd: Likewise. * ld-x86-64/tlspic.rd: Likewise. * ld-x86-64/tlspic.dd: Likewise. * ld-x86-64/tlsbin.dd: Likewise. * ld-x86-64/tlspic.sd: Likewise. * ld-x86-64/tlsbin.sd: Likewise. * ld-x86-64/tlspic.td: Likewise. * ld-x86-64/tlsbin.td: Likewise. * ld-x86-64/tlsbin.rd: Likewise. * ld-s390/tlspic1.s: Likewise. * ld-s390/tlsbinpic.s: Likewise. * ld-s390/tlspic.rd: Likewise. * ld-s390/tlsbin.rd: Likewise. * ld-s390/tlspic.dd: Likewise. * ld-s390/tlsbin.dd: Likewise. * ld-s390/tlsbin.sd: Likewise. * ld-s390/tlsbin.td: Likewise. * ld-s390/tlspic.sd: Likewise. * ld-s390/tlspic.td: Likewise. * ld-s390/tlspic1_64.s: Likewise. * ld-s390/tlsbinpic_64.s: Likewise. * ld-s390/tlspic_64.rd: Likewise. * ld-s390/tlsbin_64.rd: Likewise. * ld-s390/tlspic_64.dd: Likewise. * ld-s390/tlsbin_64.dd: Likewise. * ld-s390/tlspic_64.sd: Likewise. * ld-s390/tlspic_64.td: Likewise. * ld-s390/tlsbin_64.td: Likewise. * ld-s390/tlsbin_64.sd: Likewise. * ld-powerpc/tlsexe32.r: Likewise. * ld-powerpc/tlsso32.r: Likewise. * ld-powerpc/tlsso32.d: Likewise. * ld-powerpc/tlsso32.g: Likewise. * ld-powerpc/tlsso32.t: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlsso.g: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-powerpc/tlstocso.g: Likewise. * ld-ia64/tlspic.rd: Likewise. * ld-ia64/tlspic.dd: Likewise. * ld-ia64/tlspic.sd: Likewise. * ld-ia64/tlspic.td: Likewise. * ld-ia64/tlsbin.rd: Likewise. * ld-ia64/tlsbin.sd: Likewise. * ld-ia64/tlsbin.td: Likewise. * ld-elfvsb/elfvsb.exp: XFAIL non-PIC load offset tests on s390x. * ld-shared/shared.exp: Likewise.
2004-05-11 19:08:38 +02:00
break;
}
}
else
{
/* Otherwise we are copying an executable or shared
library, but we need to use the same linker logic. */
for (lp = phdrs; lp < phdrs + count; ++lp)
{
if (lp->p_type == PT_LOAD
&& lp->p_paddr == p->p_paddr)
break;
}
}
if (lp < phdrs + count)
{
p->p_vaddr = lp->p_vaddr;
p->p_paddr = lp->p_paddr;
p->p_offset = lp->p_offset;
if (link_info != NULL)
p->p_filesz = link_info->relro_end - lp->p_vaddr;
else if (m->p_size_valid)
p->p_filesz = m->p_size;
else
abort ();
p->p_memsz = p->p_filesz;
/* Preserve the alignment and flags if they are valid. The gold
linker generates RW/4 for the PT_GNU_RELRO section. It is better
for objcopy/strip to honor these attributes otherwise gdb will
choke when using separate debug files. */
if (!m->p_align_valid)
p->p_align = 1;
if (!m->p_flags_valid)
p->p_flags = (lp->p_flags & ~PF_W);
}
else
{
memset (p, 0, sizeof *p);
p->p_type = PT_NULL;
}
}
else if (m->count != 0)
{
if (p->p_type != PT_LOAD
&& (p->p_type != PT_NOTE
|| bfd_get_format (abfd) != bfd_core))
{
BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs);
p->p_filesz = 0;
p->p_offset = m->sections[0]->filepos;
for (i = m->count; i-- != 0;)
{
asection *sect = m->sections[i];
Elf_Internal_Shdr *hdr = &elf_section_data (sect)->this_hdr;
if (hdr->sh_type != SHT_NOBITS)
{
p->p_filesz = (sect->filepos - m->sections[0]->filepos
+ hdr->sh_size);
break;
}
}
}
}
else if (m->includes_filehdr)
{
p->p_vaddr = filehdr_vaddr;
if (! m->p_paddr_valid)
p->p_paddr = filehdr_paddr;
}
else if (m->includes_phdrs)
{
p->p_vaddr = phdrs_vaddr;
if (! m->p_paddr_valid)
p->p_paddr = phdrs_paddr;
1999-05-03 09:29:11 +02:00
}
}
elf_tdata (abfd)->next_file_pos = off;
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Work out the file positions of all the sections. This is called by
_bfd_elf_compute_section_file_positions. All the section sizes and
VMAs must be known before this is called.
Reloc sections come in two flavours: Those processed specially as
"side-channel" data attached to a section to which they apply, and
those that bfd doesn't process as relocations. The latter sort are
stored in a normal bfd section by bfd_section_from_shdr. We don't
consider the former sort here, unless they form part of the loadable
image. Reloc sections not assigned here will be handled later by
assign_file_positions_for_relocs.
1999-05-03 09:29:11 +02:00
We also don't set the positions of the .symtab and .strtab here. */
static bfd_boolean
assign_file_positions_except_relocs (bfd *abfd,
struct bfd_link_info *link_info)
1999-05-03 09:29:11 +02:00
{
struct elf_obj_tdata *tdata = elf_tdata (abfd);
Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
1999-05-03 09:29:11 +02:00
file_ptr off;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
&& bfd_get_format (abfd) != bfd_core)
{
Elf_Internal_Shdr ** const i_shdrpp = elf_elfsections (abfd);
unsigned int num_sec = elf_numsections (abfd);
1999-05-03 09:29:11 +02:00
Elf_Internal_Shdr **hdrpp;
unsigned int i;
/* Start after the ELF header. */
off = i_ehdrp->e_ehsize;
/* We are not creating an executable, which means that we are
not creating a program header, and that the actual order of
the sections in the file is unimportant. */
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
for (i = 1, hdrpp = i_shdrpp + 1; i < num_sec; i++, hdrpp++)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Shdr *hdr;
hdr = *hdrpp;
if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
&& hdr->bfd_section == NULL)
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
|| i == tdata->symtab_section
|| i == tdata->symtab_shndx_section
1999-05-03 09:29:11 +02:00
|| i == tdata->strtab_section)
{
hdr->sh_offset = -1;
}
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
else
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
1999-05-03 09:29:11 +02:00
}
}
else
{
unsigned int alloc;
1999-05-03 09:29:11 +02:00
/* Assign file positions for the loaded sections based on the
assignment of sections to segments. */
if (!assign_file_positions_for_load_sections (abfd, link_info))
return FALSE;
/* And for non-load sections. */
if (!assign_file_positions_for_non_load_sections (abfd, link_info))
return FALSE;
if (bed->elf_backend_modify_program_headers != NULL)
{
if (!(*bed->elf_backend_modify_program_headers) (abfd, link_info))
return FALSE;
}
/* Write out the program headers. */
alloc = tdata->program_header_size / bed->s->sizeof_phdr;
if (bfd_seek (abfd, (bfd_signed_vma) bed->s->sizeof_ehdr, SEEK_SET) != 0
|| bed->s->write_out_phdrs (abfd, tdata->phdr, alloc) != 0)
return FALSE;
1999-05-03 09:29:11 +02:00
off = tdata->next_file_pos;
1999-05-03 09:29:11 +02:00
}
/* Place the section headers. */
* elflink.c (_bfd_elf_link_create_dynamic_sections): Move from elflink.h. Replace LOG_FILE_ALIGN with bed->s->log_file_align. (_bfd_elf_create_dynamic_sections): Use bed->s->log_file_align. (bfd_elf_record_link_assignment): Move from elflink.h. (_bfd_elf_merge_symbol): Likewise. (_bfd_elf_add_default_symbol): Likewise. (_bfd_elf_export_symbol): Likewise. (_bfd_elf_link_find_version_dependencies): Likewise. (_bfd_elf_link_assign_sym_version): Likewise. (_bfd_elf_link_read_relocs): Likewise. (_bfd_elf_link_size_reloc_section): Likewise. (_bfd_elf_fix_symbol_flags): Likewise. (_bfd_elf_adjust_dynamic_symbol): Likewise. (_bfd_elf_link_sec_merge_syms): Likewise. (elf_link_read_relocs_from_section): Likewise. Use bed->s->sizeof_rel and bed->s->sizeof_rela. (_bfd_elf_link_output_relocs): Likewise. * elf-bfd.h (struct elf_size_info): Rename file_align to log_file_align. (struct elf_info_failed): Move from elflink.h. (struct elf_assign_sym_version_info): Likewise. (struct elf_find_verdep_info): Likewise. (_bfd_elf_create_dynamic_sections): Delete duplicate declaration. (_bfd_elf_merge_symbol, _bfd_elf_add_default_symbol, _bfd_elf_export_symbol, _bfd_elf_link_find_version_dependencies, _bfd_elf_link_assign_sym_version, _bfd_elf_link_create_dynamic_sections, _bfd_elf_link_read_relocs, _bfd_elf_link_size_reloc_section, _bfd_elf_link_output_relocs, _bfd_elf_fix_symbol_flags, _bfd_elf_adjust_dynamic_symbol, _bfd_elf_link_sec_merge_syms): Declare. (bfd_elf32_link_create_dynamic_sections): Don't declare. (_bfd_elf32_link_read_relocs): Likewise. (bfd_elf64_link_create_dynamic_sections): Likewise. (_bfd_elf64_link_read_relocs): Likewise. * elflink.h: Move lots o' stuff elsewhere. * bfd-in.h (bfd_elf32_record_link_assignment): Don't declare. (bfd_elf64_record_link_assignment): Likewise. (bfd_elf_record_link_assignment): Declare. * bfd-in2.h: Regenerate. * elfcode.h (elf_link_create_dynamic_sections): Don't declare. (NAME(_bfd_elf,size_info)): Adjust for log_file_align. * elf.c (_bfd_elf_init_reloc_shdr): Adjust for bed->s->log_file_align. (assign_file_positions_for_segments): Likewise. (assign_file_positions_except_relocs): Likewise. (swap_out_syms, elfcore_write_note): Likewise. * elf-m10200.c: Adjust for changed function names. * elf-m10300.c: Likewise. * elf32-arm.h: Likewise. * elf32-h8300.c: Likewise. * elf32-hppa.c: Likewise. * elf32-ip2k.c: Likewise. * elf32-m32r.c: Likewise. * elf32-m68hc11.c: Likewise. * elf32-m68hc1x.c: Likewise. * elf32-m68k.c: Likewise. * elf32-mips.c: Likewise. * elf32-ppc.c: Likewise. * elf32-sh.c: Likewise. * elf32-v850.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-mmix.c: Likewise. * elf64-ppc.c: Likewise. * elf64-sh64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. (MIPS_ELF_LOG_FILE_ALIGN): Use log_file_align. * elf64-alpha.c (alpha_elf_size_info): Adjust for log_file_align. * elf64-hppa.c (hppa64_elf_size_info): Likewise. * elf64-mips.c (mips_elf64_size_info): Likewise. * elf64-s390.c (s390_elf64_size_info): Likewise. * elf64-sparc.c (sparc64_elf_size_info): Likewise.
2003-05-09 04:27:11 +02:00
off = align_file_position (off, 1 << bed->s->log_file_align);
1999-05-03 09:29:11 +02:00
i_ehdrp->e_shoff = off;
off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
tdata->next_file_pos = off;
1999-05-03 09:29:11 +02:00
return TRUE;
1999-05-03 09:29:11 +02:00
}
static bfd_boolean
prep_headers (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
bfd/ChangeLog 2010-04-09 Nick Clifton <nickc@redhat.com> * aoutx.h (aout_link_input_bfd): Remove unused variable sym_count. * elf-eh-frame.c (_bfd_elf_eh_frame_section_offset): Remove unused variables htab and hdr_info and mark info parameter as unused. * elf.c (prep_headers): Remove unused variable i_phdrp. (_bfd_elf_write_object_contents): Remove unused variable i_ehdrp. * elf32-i386.c (elf_i386_relocate_section): Mark variabled warned as unused. * peXXigen.c (pe_print_reloc): Remove unused variable datasize. * verilog.c (verilog_write_section): Remove unused variable address. binutils/ChangeLog 2010-04-09 Nick Clifton <nickc@redhat.com> * dwarf.c (process_debug_info): Remove unused variable cu_abbrev_offset_ptr. (display_debug_lines_decoded): Remove unused variable prev_line. * elfedit.c (process_archive): Remove unused variable file_name_size. * ieee.c (ieee_start_compilation_unit): Remove unused variable nindx. (ieee_set_type): Remove unused variables info, targetindx and baseindx. * objdump.c (disassmble_byte): Remove unused variable done_dot. * rddbg.c (read_section_stabs_debugging_info): Remove unused variable other. * readelf.c (dump_section_as_strings): Remove unused variable addr. (process_archive): Remove unused variable file_name_size. * stabs.c (parse_stab_string): Mark desc parameter as unused. Remove unused variable lineno. (parse_stab_struct_type): Remove unused variable orig. (stab_demangle_type): Remove unused variables constp, volatilep and hold. gas/ChangeLog 2010-04-09 Nick Clifton <nickc@redhat.com> * as.c (create_obj_attrs_section): Remove unused variable addr. * listing.c (listing_listing): Remove unused variable message. * read.c: Remove unnecessary register type qualifiers. (s_mri): Only define/use old_flag variable if MRI_MODE_CHANGE is defined. ld/ChangeLog 2010-04-09 Nick Clifton <nickc@redhat.com> * ldlang.c (wild_sort): Remove unused variable section_name. opcodes/ChangeLog 2010-04-09 Nick Clifton <nickc@redhat.com> * i386-dis.c (print_insn): Remove unused variable op. (OP_sI): Remove unused variable mask.
2010-04-09 16:40:18 +02:00
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form. */
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
struct elf_strtab_hash *shstrtab;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
i_ehdrp = elf_elfheader (abfd);
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
shstrtab = _bfd_elf_strtab_init ();
1999-05-03 09:29:11 +02:00
if (shstrtab == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
elf_shstrtab (abfd) = shstrtab;
i_ehdrp->e_ident[EI_MAG0] = ELFMAG0;
i_ehdrp->e_ident[EI_MAG1] = ELFMAG1;
i_ehdrp->e_ident[EI_MAG2] = ELFMAG2;
i_ehdrp->e_ident[EI_MAG3] = ELFMAG3;
i_ehdrp->e_ident[EI_CLASS] = bed->s->elfclass;
i_ehdrp->e_ident[EI_DATA] =
bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current;
if ((abfd->flags & DYNAMIC) != 0)
i_ehdrp->e_type = ET_DYN;
else if ((abfd->flags & EXEC_P) != 0)
i_ehdrp->e_type = ET_EXEC;
else if (bfd_get_format (abfd) == bfd_core)
i_ehdrp->e_type = ET_CORE;
else
i_ehdrp->e_type = ET_REL;
switch (bfd_get_arch (abfd))
{
case bfd_arch_unknown:
i_ehdrp->e_machine = EM_NONE;
break;
/* There used to be a long list of cases here, each one setting
e_machine to the same EM_* macro #defined as ELF_MACHINE_CODE
in the corresponding bfd definition. To avoid duplication,
the switch was removed. Machines that need special handling
can generally do it in elf_backend_final_write_processing(),
unless they need the information earlier than the final write.
Such need can generally be supplied by replacing the tests for
e_machine with the conditions used to determine it. */
1999-05-03 09:29:11 +02:00
default:
i_ehdrp->e_machine = bed->elf_machine_code;
}
1999-05-03 09:29:11 +02:00
i_ehdrp->e_version = bed->s->ev_current;
i_ehdrp->e_ehsize = bed->s->sizeof_ehdr;
/* No program header, for now. */
1999-05-03 09:29:11 +02:00
i_ehdrp->e_phoff = 0;
i_ehdrp->e_phentsize = 0;
i_ehdrp->e_phnum = 0;
/* Each bfd section is section header entry. */
1999-05-03 09:29:11 +02:00
i_ehdrp->e_entry = bfd_get_start_address (abfd);
i_ehdrp->e_shentsize = bed->s->sizeof_shdr;
/* If we're building an executable, we'll need a program header table. */
1999-05-03 09:29:11 +02:00
if (abfd->flags & EXEC_P)
/* It all happens later. */
;
1999-05-03 09:29:11 +02:00
else
{
i_ehdrp->e_phentsize = 0;
i_ehdrp->e_phoff = 0;
}
elf_tdata (abfd)->symtab_hdr.sh_name =
(unsigned int) _bfd_elf_strtab_add (shstrtab, ".symtab", FALSE);
1999-05-03 09:29:11 +02:00
elf_tdata (abfd)->strtab_hdr.sh_name =
(unsigned int) _bfd_elf_strtab_add (shstrtab, ".strtab", FALSE);
1999-05-03 09:29:11 +02:00
elf_tdata (abfd)->shstrtab_hdr.sh_name =
(unsigned int) _bfd_elf_strtab_add (shstrtab, ".shstrtab", FALSE);
1999-05-03 09:29:11 +02:00
if (elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
|| elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1
|| elf_tdata (abfd)->shstrtab_hdr.sh_name == (unsigned int) -1)
return FALSE;
1999-05-03 09:29:11 +02:00
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Assign file positions for all the reloc sections which are not part
of the loadable file image. */
void
_bfd_elf_assign_file_positions_for_relocs (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
file_ptr off;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
unsigned int i, num_sec;
1999-05-03 09:29:11 +02:00
Elf_Internal_Shdr **shdrpp;
off = elf_tdata (abfd)->next_file_pos;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
num_sec = elf_numsections (abfd);
for (i = 1, shdrpp = elf_elfsections (abfd) + 1; i < num_sec; i++, shdrpp++)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Shdr *shdrp;
shdrp = *shdrpp;
if ((shdrp->sh_type == SHT_REL || shdrp->sh_type == SHT_RELA)
&& shdrp->sh_offset == -1)
off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
1999-05-03 09:29:11 +02:00
}
elf_tdata (abfd)->next_file_pos = off;
}
bfd_boolean
_bfd_elf_write_object_contents (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
Elf_Internal_Shdr **i_shdrp;
bfd_boolean failed;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
unsigned int count, num_sec;
1999-05-03 09:29:11 +02:00
if (! abfd->output_has_begun
&& ! _bfd_elf_compute_section_file_positions (abfd, NULL))
return FALSE;
1999-05-03 09:29:11 +02:00
i_shdrp = elf_elfsections (abfd);
failed = FALSE;
1999-05-03 09:29:11 +02:00
bfd_map_over_sections (abfd, bed->s->write_relocs, &failed);
if (failed)
return FALSE;
1999-05-03 09:29:11 +02:00
_bfd_elf_assign_file_positions_for_relocs (abfd);
/* After writing the headers, we need to write the sections too... */
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
num_sec = elf_numsections (abfd);
for (count = 1; count < num_sec; count++)
1999-05-03 09:29:11 +02:00
{
if (bed->elf_backend_section_processing)
(*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
if (i_shdrp[count]->contents)
{
bfd_size_type amt = i_shdrp[count]->sh_size;
1999-05-03 09:29:11 +02:00
if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
|| bfd_bwrite (i_shdrp[count]->contents, amt, abfd) != amt)
return FALSE;
1999-05-03 09:29:11 +02:00
}
}
/* Write out the section header names. */
if (elf_shstrtab (abfd) != NULL
&& (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
|| !_bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd))))
return FALSE;
1999-05-03 09:29:11 +02:00
if (bed->elf_backend_final_write_processing)
(*bed->elf_backend_final_write_processing) (abfd,
elf_tdata (abfd)->linker);
if (!bed->s->write_shdrs_and_ehdr (abfd))
return FALSE;
/* This is last since write_shdrs_and_ehdr can touch i_shdrp[0]. */
if (elf_tdata (abfd)->after_write_object_contents)
return (*elf_tdata (abfd)->after_write_object_contents) (abfd);
return TRUE;
1999-05-03 09:29:11 +02:00
}
bfd_boolean
_bfd_elf_write_corefile_contents (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
/* Hopefully this can be done just like an object file. */
1999-05-03 09:29:11 +02:00
return _bfd_elf_write_object_contents (abfd);
}
/* Given a section, search the header to find them. */
unsigned int
_bfd_elf_section_from_bfd_section (bfd *abfd, struct bfd_section *asect)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed;
unsigned int sec_index;
1999-05-03 09:29:11 +02:00
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if (elf_section_data (asect) != NULL
&& elf_section_data (asect)->this_idx != 0)
return elf_section_data (asect)->this_idx;
if (bfd_is_abs_section (asect))
sec_index = SHN_ABS;
else if (bfd_is_com_section (asect))
sec_index = SHN_COMMON;
else if (bfd_is_und_section (asect))
sec_index = SHN_UNDEF;
else
sec_index = SHN_BAD;
1999-05-03 09:29:11 +02:00
bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
if (bed->elf_backend_section_from_bfd_section)
{
int retval = sec_index;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if ((*bed->elf_backend_section_from_bfd_section) (abfd, asect, &retval))
return retval;
1999-05-03 09:29:11 +02:00
}
if (sec_index == SHN_BAD)
bfd_set_error (bfd_error_nonrepresentable_section);
1999-05-03 09:29:11 +02:00
return sec_index;
1999-05-03 09:29:11 +02:00
}
/* Given a BFD symbol, return the index in the ELF symbol table, or -1
on error. */
int
_bfd_elf_symbol_from_bfd_symbol (bfd *abfd, asymbol **asym_ptr_ptr)
1999-05-03 09:29:11 +02:00
{
asymbol *asym_ptr = *asym_ptr_ptr;
int idx;
flagword flags = asym_ptr->flags;
/* When gas creates relocations against local labels, it creates its
own symbol for the section, but does put the symbol into the
symbol chain, so udata is 0. When the linker is generating
relocatable output, this section symbol may be for one of the
input sections rather than the output section. */
if (asym_ptr->udata.i == 0
&& (flags & BSF_SECTION_SYM)
&& asym_ptr->section)
{
asection *sec;
1999-05-03 09:29:11 +02:00
int indx;
sec = asym_ptr->section;
if (sec->owner != abfd && sec->output_section != NULL)
sec = sec->output_section;
if (sec->owner == abfd
&& (indx = sec->index) < elf_num_section_syms (abfd)
&& elf_section_syms (abfd)[indx] != NULL)
1999-05-03 09:29:11 +02:00
asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
}
idx = asym_ptr->udata.i;
if (idx == 0)
{
/* This case can occur when using --strip-symbol on a symbol
which is used in a relocation entry. */
1999-05-03 09:29:11 +02:00
(*_bfd_error_handler)
bfd/ * bfd.c (_bfd_default_error_handler): Handle %A and %B. (bfd_archive_filename, bfd_get_section_ident): Delete. * ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call bfd_archive_filename. * elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler to warn about symbols in discarded sections. Use _bfd_error_handler. * aout-adobe.c (aout_adobe_callback): See below. * aout-cris.c (swap_ext_reloc_in): .. * coff-arm.c (find_thumb_glue, find_arm_glue, coff_arm_relocate_section, bfd_arm_process_before_allocation, coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags, coff_arm_copy_private_bfd_data): .. * coff-i860.c (i860_reloc_processing): .. * coff-mcore.c (mcore_coff_unsupported_reloc, coff_mcore_relocate_section): .. * coff-ppc.c (coff_ppc_relocate_section): .. * coff-rs6000.c (xcoff_create_csect_from_smclas * coff-sh.c (sh_relax_section, sh_relax_delete_bytes, sh_swap_insns, sh_relocate_section): .. * coff-tic54x.c (tic54x_reloc_processing): .. * coff-tic80.c (coff_tic80_relocate_section): .. * coff64-rs6000.c (xcoff64_create_csect_from_smclas): .. * coffcode.h (styp_to_sec_flags, coff_slurp_line_table, coff_slurp_symbol_table, coff_classify_symbol, coff_slurp_reloc_table): .. * coffgen.c (_bfd_coff_read_string_table): .. * cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd, _bfd_coff_generic_relocate_section): .. * cpu-arm.c (bfd_arm_merge_machines): .. * cpu-sh.c (sh_merge_bfd_arch): .. * elf-hppa.h (elf_hppa_relocate_section): .. * elf.c (bfd_elf_string_from_elf_section, setup_group, _bfd_elf_setup_group_pointers, bfd_section_from_shdr, assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol, copy_private_bfd_data, _bfd_elf_validate_reloc): .. * elf32-arm.h (find_thumb_glue, find_arm_glue, bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub, elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate, elf32_arm_relocate_section, elf32_arm_set_private_flags, elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): .. * elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs, cris_elf_merge_private_bfd_data * elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): .. * elf32-gen.c (elf32_generic_link_add_symbols): .. * elf32-hppa.c (hppa_add_stub, hppa_build_one_stub, elf32_hppa_check_relocs, get_local_syms, final_link_relocate, elf32_hppa_relocate_section): .. * elf32-i370.c (i370_elf_merge_private_bfd_data, i370_elf_check_relocs, i370_elf_relocate_section): .. * elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs, elf_i386_relocate_section): .. * elf32-m32r.c (m32r_elf_relocate_section, m32r_elf_merge_private_bfd_data): .. * elf32-m68hc1x.c (m68hc12_add_stub, _bfd_m68hc11_elf_merge_private_bfd_data): .. * elf32-m68k.c (elf_m68k_relocate_section): .. * elf32-mcore.c (mcore_elf_unsupported_reloc, mcore_elf_relocate_section): .. * elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc, ppc_elf_check_relocs, ppc_elf_relocate_section, ppc_elf_begin_write_processing): .. * elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn, elf_s390_relocate_section): .. * elf32-sh-symbian.c (sh_symbian_import_as, sh_symbian_process_embedded_commands, sh_symbian_relocate_section): .. * elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes, sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs, sh_elf_merge_private_data): .. * elf32-sparc.c (elf32_sparc_check_relocs, elf32_sparc_relocate_section, elf32_sparc_merge_private_bfd_data): .. * elf32-v850.c (v850_elf_check_relocs, v850_elf_merge_private_bfd_data): .. * elf32-xtensa.c (elf_xtensa_check_relocs, elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): .. * elf64-alpha.c (elf64_alpha_relax_with_lituse, elf64_alpha_relax_got_load, elf64_alpha_size_got_sections, elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): .. * elf64-gen.c (elf64_generic_link_add_symbols): .. * elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub, ppc64_elf_check_relocs, ppc64_elf_edit_opd, ppc64_elf_relocate_section): .. * elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn, elf_s390_relocate_section): .. * elf64-sh64.c (sh_elf64_relocate_section): .. * elf64-sparc.c (sparc64_elf_check_relocs, sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section, sparc64_elf_merge_private_bfd_data): .. * elf64-x86-64.c (elf64_x86_64_check_relocs, elf64_x86_64_relocate_section): .. * elflink.c (_bfd_elf_add_default_symbol, _bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section, _bfd_elf_link_output_relocs, elf_link_add_object_symbols, bfd_elf_size_dynamic_sections, elf_link_output_extsym, elf_get_linked_section_vma, elf_fixup_link_order, bfd_elf_final_link, bfd_elf_gc_record_vtinherit, bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): .. * elfxx-ia64.c (elfNN_ia64_relax_section, elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): .. * elfxx-mips.c (mips_elf_perform_relocation, _bfd_mips_elf_check_relocs, _bfd_mips_elf_merge_private_bfd_data): .. * ieee.c (ieee_slurp_external_symbols): .. * ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): .. * libbfd.c (_bfd_generic_verify_endian_match): .. * linker.c (_bfd_generic_link_add_one_symbol, _bfd_generic_section_already_linked): .. * pdp11.c (translate_to_native_sym_flags): .. * pe-mips.c (coff_pe_mips_relocate_section): .. * peicode.h (pe_ILF_build_a_bfd): .. * srec.c (srec_bad_byte): .. * stabs.c (_bfd_link_section_stabs): .. * xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): .. Replace all uses of bfd_archive_filename and bfd_get_section_ident with corresponding %B and %A in _bfd_error_handler format string. Replace occurrences of "fprintf (stderr," with _bfd_error_handler calls to use %A and %B. Fix "against symbol .. from section" and similar error messages. Combine multiple _bfd_error_handler calls where they were separated due to bfd_archive_filename deficiencies. * bfd-in2.h: Regenerate. include/ * bfdlink.h (struct bfd_link_callbacks): Remove "error_handler". (LD_DEFINITION_IN_DISCARDED_SECTION): Delete. ld/ * ldmain.c (link_callbacks): Remove "error_handler". * ldmisc.c: Include elf-bfd.h. (vfinfo): Sort comment. Handle %A. Use %A instead of bfd_get_section_indent. (error_handler): Delete. * ldmisc.h (error_handler): Delete declaration.
2004-08-13 05:16:01 +02:00
(_("%B: symbol `%s' required but not present"),
abfd, bfd_asymbol_name (asym_ptr));
1999-05-03 09:29:11 +02:00
bfd_set_error (bfd_error_no_symbols);
return -1;
}
#if DEBUG & 4
{
fprintf (stderr,
2010-10-08 16:00:50 +02:00
"elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = 0x%.8lx\n",
(long) asym_ptr, asym_ptr->name, idx, (long) flags);
1999-05-03 09:29:11 +02:00
fflush (stderr);
}
#endif
return idx;
}
/* Rewrite program header information. */
1999-05-03 09:29:11 +02:00
static bfd_boolean
rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Ehdr *iehdr;
struct elf_segment_map *map;
struct elf_segment_map *map_first;
struct elf_segment_map **pointer_to_map;
Elf_Internal_Phdr *segment;
asection *section;
unsigned int i;
unsigned int num_segments;
bfd_boolean phdr_included = FALSE;
bfd_boolean p_paddr_valid;
bfd_vma maxpagesize;
struct elf_segment_map *phdr_adjust_seg = NULL;
unsigned int phdr_adjust_num = 0;
const struct elf_backend_data *bed;
bed = get_elf_backend_data (ibfd);
1999-05-03 09:29:11 +02:00
iehdr = elf_elfheader (ibfd);
map_first = NULL;
pointer_to_map = &map_first;
1999-05-03 09:29:11 +02:00
num_segments = elf_elfheader (ibfd)->e_phnum;
maxpagesize = get_elf_backend_data (obfd)->maxpagesize;
/* Returns the end address of the segment + 1. */
#define SEGMENT_END(segment, start) \
(start + (segment->p_memsz > segment->p_filesz \
? segment->p_memsz : segment->p_filesz))
#define SECTION_SIZE(section, segment) \
(((section->flags & (SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) \
!= SEC_THREAD_LOCAL || segment->p_type == PT_TLS) \
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 06:46:28 +02:00
? section->size : 0)
/* Returns TRUE if the given section is contained within
the given segment. VMA addresses are compared. */
#define IS_CONTAINED_BY_VMA(section, segment) \
(section->vma >= segment->p_vaddr \
&& (section->vma + SECTION_SIZE (section, segment) \
<= (SEGMENT_END (segment, segment->p_vaddr))))
/* Returns TRUE if the given section is contained within
the given segment. LMA addresses are compared. */
#define IS_CONTAINED_BY_LMA(section, segment, base) \
(section->lma >= base \
&& (section->lma + SECTION_SIZE (section, segment) \
<= SEGMENT_END (segment, base)))
1999-05-03 09:29:11 +02:00
/* Handle PT_NOTE segment. */
#define IS_NOTE(p, s) \
(p->p_type == PT_NOTE \
&& elf_section_type (s) == SHT_NOTE \
&& (bfd_vma) s->filepos >= p->p_offset \
&& ((bfd_vma) s->filepos + s->size \
<= p->p_offset + p->p_filesz))
1999-05-03 09:29:11 +02:00
/* Special case: corefile "NOTE" section containing regs, prpsinfo
etc. */
#define IS_COREFILE_NOTE(p, s) \
(IS_NOTE (p, s) \
&& bfd_get_format (ibfd) == bfd_core \
&& s->vma == 0 \
&& s->lma == 0)
1999-05-03 09:29:11 +02:00
/* The complicated case when p_vaddr is 0 is to handle the Solaris
linker, which generates a PT_INTERP section with p_vaddr and
p_memsz set to 0. */
#define IS_SOLARIS_PT_INTERP(p, s) \
(p->p_vaddr == 0 \
&& p->p_paddr == 0 \
&& p->p_memsz == 0 \
&& p->p_filesz > 0 \
&& (s->flags & SEC_HAS_CONTENTS) != 0 \
bfd/ * section.c (struct sec): Rename "_cooked_size" to "size". Rename "_raw_size" to "rawsize". (STD_SECTION): Adjust comments. (bfd_set_section_size, bfd_get_section_contents): Use size. (bfd_malloc_and_get_section): New function. * bfd-in.h (bfd_section_size, bfd_get_section_size): Use size. * coff-sh.c (sh_relax_section): Alloc coff_section_data struct early. Correctly free reloc and contents memory. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME and fake CIE now that we can shink section size to zero. (_bfd_elf_write_section_eh_frame): Likewise.. * elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents. * elf-m10300.c (mn10300_elf_final_link_relocate): Don't use _bfd_stab_section_offset. Use _bfd_elf_section_offset. * stabs.c (_bfd_stab_section_offset_): Remove unused args and unneeded indirection. * elf.c (_bfd_elf_section_offset): .. and update call. * libbfd-in.h (_bfd_stab_section_offset): Update prototype. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. Replace occurrences of "_raw_size" and "_cooked_size" in most places with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE sections. Use "rawsize", if non-zero, for bfd_get_section_contents calls if the section might be a stabs, eh_frame, or SEC_MERGE section. Similarly use "rawsize", if non-zero, in reloc functions to validate reloc addresses. Use new bfd_malloc_and_get_section in most places where bfd_get_section_contents was called. Expand all occurrences of bfd_section_size and bfd_get_section_size. Rename "raw_size" var in grok_prstatus and similar functions to "size". * aix386-core.c (aix386_core_file_p): .. * aix5ppc-core.c (xcoff64_core_p): .. * aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents, aout_adobe_set_section_contents): .. * aout-target.h (callback): .. * aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate, MY_bfd_final_link): .. * aoutf1.h (sunos4_core_file_p): .. * aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic, adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags, final_link, aout_link_input_section): .. * binary.c (binary_object_p, binary_canonicalize_symtab, binary_set_section_contents): .. * bout.c (b_out_callback, b_out_write_object_contents, b_out_set_section_contents, b_out_bfd_relax_section, b_out_bfd_get_relocated_section_contents): .. * cisco-core.c (cisco_core_file_validate): .. * coff-alpha.c (alpha_ecoff_object_p, alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): .. * coff-arm.c (coff_arm_relocate_section, bfd_arm_allocate_interworking_sections): .. * coff-h8300.c (h8300_reloc16_extra_cases, h8300_bfd_link_add_symbols): .. * coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): .. * coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section, ppc_bfd_coff_final_link): .. * coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): .. * coff-sh.c (sh_relax_section, sh_relax_delete_bytes, sh_align_loads, sh_coff_get_relocated_section_contents): .. * coff64-rs6000.c (xcoff64_write_object_contents, xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): .. * coffcode.h (coff_compute_section_file_positions, coff_write_object_contents): .. * coffgen.c (make_a_section_from_file, coff_write_symbols, coff_section_symbol, build_debug_section): .. * cofflink.c (coff_link_add_symbols, _bfd_coff_final_link, process_embedded_commands, _bfd_coff_link_input_bfd, _bfd_coff_write_global_sym): .. * cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): .. * cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): .. * dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): .. * dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info, _bfd_dwarf2_find_nearest_line): .. * ecoff.c (bfd_debug_section, ecoff_set_symbol_info, ecoff_compute_section_file_positions, _bfd_ecoff_write_object_contents, ecoff_indirect_link_order): .. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame, _bfd_elf_discard_section_eh_frame_hdr, _bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset, _bfd_elf_write_section_eh_frame, _bfd_elf_write_section_eh_frame_hdr): .. * elf-hppa.h (elf_hppa_sort_unwind): .. * elf-m10200.c (mn10200_elf_relax_section, mn10200_elf_relax_delete_bytes, mn10200_elf_get_relocated_section_contents): .. * elf-m10300.c (_bfd_mn10300_elf_create_got_section, mn10300_elf_check_relocs, mn10300_elf_relax_section, mn10300_elf_relax_delete_bytes, mn10300_elf_get_relocated_section_contents, _bfd_mn10300_elf_adjust_dynamic_symbol, _bfd_mn10300_elf_discard_copies, _bfd_mn10300_elf_size_dynamic_sections, _bfd_mn10300_elf_finish_dynamic_sections): .. * elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list, _bfd_elf_make_section_from_phdr, elf_fake_sections, bfd_elf_set_group_contents, map_sections_to_segments, elf_sort_sections, assign_file_positions_for_segments, SECTION_SIZE, copy_private_bfd_data, _bfd_elf_get_dynamic_reloc_upper_bound, _bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect, _bfd_elfcore_make_pseudosection, elfcore_grok_prstatus, elfcore_grok_lwpstatus, elfcore_grok_win32pstatus, elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs, _bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): .. * elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect, bfd_elf32_arm_process_before_allocation, elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs, elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections, elf32_arm_write_section): .. * elf32-cris.c (cris_elf_grok_prstatus, elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook, elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol, cris_elf_check_relocs, elf_cris_size_dynamic_sections, elf_cris_discard_excess_dso_dynamics, elf_cris_discard_excess_program_dynamics): .. * elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): .. * elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): .. * elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup, _frv_create_got_section, _frvfdpic_assign_plt_entries, elf32_frvfdpic_size_dynamic_sections, elf32_frvfdpic_modify_segment_map, elf32_frvfdpic_finish_dynamic_sections): .. * elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes, elf32_h8_get_relocated_section_contents): .. * elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub, elf32_hppa_adjust_dynamic_symbol, allocate_plt_static, allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections, elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs, elf32_hppa_finish_dynamic_sections): .. * elf32-i370.c (i370_elf_adjust_dynamic_symbol, i370_elf_size_dynamic_sections, i370_elf_check_relocs, i370_elf_finish_dynamic_sections): .. * elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol, allocate_dynrelocs, elf_i386_size_dynamic_sections, elf_i386_relocate_section, elf_i386_finish_dynamic_sections): .. * elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc, i860_howto_highadj_reloc, i860_howto_splitn_reloc): .. * elf32-ip2k.c (ip2k_is_switch_table_128, ip2k_relax_switch_table_128, ip2k_is_switch_table_256, ip2k_relax_switch_table_256, ip2k_elf_relax_section, adjust_all_relocations, ip2k_elf_relax_delete_bytes): .. * elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc, m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol, allocate_dynrelocs, m32r_elf_size_dynamic_sections, m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections, m32r_elf_relax_section, m32r_elf_relax_delete_bytes, m32r_elf_get_relocated_section_contents): .. * elf32-m68hc11.c (m68hc11_elf_build_one_stub, m68hc11_elf_size_one_stub, m68hc11_elf_relax_section, m68hc11_elf_relax_delete_bytes): .. * elf32-m68hc12.c (m68hc12_elf_build_one_stub, m68hc12_elf_size_one_stub): .. * elf32-m68hc1x.c (elf32_m68hc11_size_stubs, elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): .. * elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook, elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections, elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): .. * elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc, elf32_mips_grok_prstatus): .. * elf32-or32.c (or32_elf_consth_reloc): .. * elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc, elf_create_pointer_linker_section, ppc_elf_create_linker_section, ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol, allocate_dynrelocs, ppc_elf_size_dynamic_sections, ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus, ppc_elf_final_write_processing): .. * elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol, allocate_dynrelocs, elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): .. * elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section, sh_elf_relax_delete_bytes, sh_elf_align_loads, sh_elf_adjust_dynamic_symbol, allocate_dynrelocs, sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents, sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): .. * elf32-sh64-com.c (sh64_address_in_cranges, sh64_get_contents_type): .. * elf32-sh64.c (sh64_find_section_for_address, sh64_elf_final_write_processing): .. * elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc, sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol, allocate_dynrelocs, elf32_sparc_size_dynamic_sections, elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): .. * elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): .. * elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol, elf_vax_size_dynamic_sections, elf_vax_discard_copies, elf_vax_instantiate_got_entries, elf_vax_relocate_section, elf_vax_finish_dynamic_sections): .. * elf32-xstormy16.c (xstormy16_elf_24_reloc, xstormy16_elf_check_relocs, xstormy16_relax_plt_check, xstormy16_elf_relax_section, xstormy16_elf_always_size_sections, xstormy16_elf_finish_dynamic_sections): .. * elf32-xtensa.c (xtensa_read_table_entries, elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size, elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc, bfd_elf_xtensa_reloc, elf_xtensa_relocate_section, elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections, elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus, get_relocation_opcode, retrieve_contents, find_relaxable_sections, collect_source_relocs, is_resolvable_asm_expansion, remove_literals, relax_section, shrink_dynamic_reloc_sections, relax_property_section, xtensa_callback_required_dependence): .. * elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section, elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol, elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets, elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1, elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes, elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1, elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel, elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): .. * elf64-hppa.c (allocate_dynrel_entries, elf64_hppa_size_dynamic_sections, elf64_hppa_finish_dynamic_sections): .. * elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc, mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table, elf64_mips_grok_prstatus): .. * elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc, mmix_elf_relocate_section, mmix_elf_final_link, mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation, mmix_elf_relax_section, mmix_elf_get_section_contents): .. * elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus, ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust, ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd, allocate_dynrelocs, ppc64_elf_size_dynamic_sections, ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section, toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs, ppc64_elf_build_stubs, ppc64_elf_relocate_section, ppc64_elf_finish_dynamic_sections): .. * elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol, allocate_dynrelocs, elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_sections): .. * elf64-sh64.c (sh_elf64_get_relocated_section_contents, sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol, sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections, sh64_elf64_finish_dynamic_sections): .. * elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc, sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol, sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section, sparc64_elf_finish_dynamic_symbol, sparc64_elf_finish_dynamic_sections): .. * elf64-x86-64.c (elf64_x86_64_grok_prstatus, elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs, elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section, elf64_x86_64_finish_dynamic_sections): .. * elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): .. * elfcode.h (elf_slurp_reloc_table): .. * elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag, elf_finalize_dynstr, elf_link_add_object_symbols, bfd_elf_size_dynamic_sections, elf_link_sort_relocs, elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): .. * elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc, elf32_mips_grok_prstatus): .. * elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries, elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc, elfNN_ia64_choose_gp, elfNN_ia64_final_link, elfNN_ia64_finish_dynamic_sections): .. * elfxx-mips.c (mips_elf_create_procedure_table, mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp, _bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc, mips_elf_global_got_index, mips_elf_multi_got, mips_elf_create_compact_rel_section, mips_elf_calculate_relocation, mips_elf_allocate_dynamic_relocations, mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections, _bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol, _bfd_mips_elf_always_size_sections, _bfd_mips_elf_size_dynamic_sections, _bfd_mips_elf_finish_dynamic_symbol, _bfd_mips_elf_finish_dynamic_sections, _bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info, _bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents, _bfd_elf_mips_get_relocated_section_contents, _bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): .. * hp300hpux.c (callback): .. * hppabsd-core.c (make_bfd_asection): .. * hpux-core.c (make_bfd_asection): .. * i386linux.c (linux_link_create_dynamic_sections, bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): .. * i386msdos.c (msdos_write_object_contents): .. * i386os9k.c (os9k_callback, os9k_write_object_contents, os9k_set_section_contents): .. * ieee.c (parse_expression, ieee_slurp_external_symbols, ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data, ieee_write_section_part, do_with_relocs, do_as_repeat, do_without_relocs, ieee_write_debug_part, init_for_output, ieee_set_section_contents): .. * ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): .. * irix-core.c (do_sections, make_bfd_asection): .. * libaout.h (aout_section_merge_with_text_p): .. * libbfd.c (_bfd_generic_get_section_contents, _bfd_generic_get_section_contents_in_window): .. * linker.c (default_indirect_link_order): .. * lynx-core.c (make_bfd_asection): .. * m68klinux.c (linux_link_create_dynamic_sections, bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): .. * mach-o.c (bfd_mach_o_make_bfd_section, bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib, bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab, bfd_mach_o_scan_read_segment): .. * merge.c (_bfd_add_merge_section, record_section, merge_strings, _bfd_merge_sections): .. * mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc, mmo_map_set_sizes, mmo_canonicalize_symtab, mmo_internal_write_section, mmo_write_object_contents): .. * netbsd-core.c (netbsd_core_file_p): .. * nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import, nlm_alpha_set_public_section): .. * nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): .. * nlm32-sparc.c (nlm_sparc_write_import): .. * nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in, nlm_compute_section_file_positions): .. * oasys.c (oasys_object_p, oasys_slurp_section_data, oasys_write_sections, oasys_write_data, oasys_set_section_contents): .. * opncls.c (get_debug_link_info): .. * osf-core.c (make_bfd_asection): .. * pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic, adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs, final_link, aout_link_input_section): .. * peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out, pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): .. * pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section, bfd_pef_scan_start_address, bfd_pef_parse_symbols): .. * ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): .. * ptrace-core.c (ptrace_unix_core_file_p): .. * reloc.c (bfd_perform_relocation, bfd_install_relocation, _bfd_final_link_relocate, bfd_generic_relax_section, bfd_generic_get_relocated_section_contents): .. * reloc16.c (bfd_coff_reloc16_relax_section, bfd_coff_reloc16_get_relocated_section_c): .. * riscix.c (riscix_some_aout_object_p): .. * rs6000-core.c (read_hdr, make_bfd_asection): .. * sco5-core.c (make_bfd_asection): .. * simple.c (bfd_simple_get_relocated_section_contents): .. * som.c (som_object_setup, setup_sections, som_prep_headers, som_write_fixups, som_begin_writing, bfd_section_from_som_symbol, som_set_reloc_info, som_get_section_contents, som_bfd_link_split_section): .. * sparclinux.c (linux_link_create_dynamic_sections, bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): .. * srec.c (srec_scan, srec_read_section, srec_get_section_contents): .. * stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs, _bfd_write_stab_strings, _bfd_stab_section_offset): .. * sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections, bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs, sunos_scan_ext_relocs, sunos_scan_dynamic_symbol, sunos_write_dynamic_symbol, sunos_check_dynamic_reloc, sunos_finish_dynamic_link): .. * syms.c (_bfd_stab_section_find_nearest_line): .. * tekhex.c (first_phase, tekhex_set_section_contents, tekhex_write_object_contents): .. * trad-core.c (trad_unix_core_file_p): .. * versados.c (process_esd, process_otr, process_otr): .. * vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): .. * vms-misc.c (add_new_contents): .. * vms-tir.c (check_section, new_section, _bfd_vms_write_tir): .. * vms.c (vms_set_section_contents): .. * xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols, xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms, _bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): .. * xsym.c (bfd_sym_scan): .. See above. binutils/ * objcopy.c (copy_section): Don't set _cooked_size. include/ * bfdlink.h (struct bfd_link_order): Update comment. ld/ * ldlang.c (print_output_section_statement): Don't print size before relaxation. (IGNORE_SECTION): Remove bfd arg. Update all callers. * ldexp.c (fold_name): .. See below. * ldlang.c (section_already_linked, print_output_section_statement, print_input_section, insert_pad, size_input_section, lang_check_section_addresses, lang_size_sections_1, lang_size_sections, lang_do_assignments_1, lang_set_startof, lang_one_common, lang_reset_memory_regions, lang_process, lang_abs_symbol_at_end_of, lang_do_version_exports_section): .. * ldwrite.c (build_link_order, clone_section, ds, split_sections): .. * pe-dll.c (process_def_file, generate_reloc): .. * emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment, gld${EMULATION_NAME}_before_allocation): .. * emultempl/mmix-elfnmmo.em (mmix_after_allocation): .. * emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation, sh64_elf_${EMULATION_NAME}_after_allocation): .. * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): .. * emultempl/xtensaelf.em (ld_assign_relative_paged_dot, ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use "size" instead of "_raw_size" and "_cooked_size". Expand bfd_section_size macro invocations.
2004-06-24 06:46:28 +02:00
&& s->size > 0 \
&& (bfd_vma) s->filepos >= p->p_offset \
&& ((bfd_vma) s->filepos + s->size \
<= p->p_offset + p->p_filesz))
/* Decide if the given section should be included in the given segment.
A section will be included if:
1. It is within the address space of the segment -- we use the LMA
if that is set for the segment and the VMA otherwise,
2. It is an allocated section or a NOTE section in a PT_NOTE
segment.
3. There is an output section associated with it,
4. The section has not already been allocated to a previous segment.
5. PT_GNU_STACK segments do not include any sections.
6. PT_TLS segment includes only SHF_TLS sections.
7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments.
8. PT_DYNAMIC should not contain empty sections at the beginning
(with the possible exception of .dynamic). */
#define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \
((((segment->p_paddr \
? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
: IS_CONTAINED_BY_VMA (section, segment)) \
&& (section->flags & SEC_ALLOC) != 0) \
|| IS_NOTE (segment, section)) \
&& segment->p_type != PT_GNU_STACK \
&& (segment->p_type != PT_TLS \
|| (section->flags & SEC_THREAD_LOCAL)) \
&& (segment->p_type == PT_LOAD \
|| segment->p_type == PT_TLS \
|| (section->flags & SEC_THREAD_LOCAL) == 0) \
&& (segment->p_type != PT_DYNAMIC \
|| SECTION_SIZE (section, segment) > 0 \
|| (segment->p_paddr \
? segment->p_paddr != section->lma \
: segment->p_vaddr != section->vma) \
|| (strcmp (bfd_get_section_name (ibfd, section), ".dynamic") \
== 0)) \
&& !section->segment_mark)
/* If the output section of a section in the input segment is NULL,
it is removed from the corresponding output segment. */
#define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \
(IS_SECTION_IN_INPUT_SEGMENT (section, segment, bed) \
&& section->output_section != NULL)
/* Returns TRUE iff seg1 starts after the end of seg2. */
#define SEGMENT_AFTER_SEGMENT(seg1, seg2, field) \
(seg1->field >= SEGMENT_END (seg2, seg2->field))
/* Returns TRUE iff seg1 and seg2 overlap. Segments overlap iff both
their VMA address ranges and their LMA address ranges overlap.
It is possible to have overlapping VMA ranges without overlapping LMA
ranges. RedBoot images for example can have both .data and .bss mapped
to the same VMA range, but with the .data section mapped to a different
LMA. */
#define SEGMENT_OVERLAPS(seg1, seg2) \
( !(SEGMENT_AFTER_SEGMENT (seg1, seg2, p_vaddr) \
|| SEGMENT_AFTER_SEGMENT (seg2, seg1, p_vaddr)) \
&& !(SEGMENT_AFTER_SEGMENT (seg1, seg2, p_paddr) \
|| SEGMENT_AFTER_SEGMENT (seg2, seg1, p_paddr)))
/* Initialise the segment mark field. */
for (section = ibfd->sections; section != NULL; section = section->next)
section->segment_mark = FALSE;
/* The Solaris linker creates program headers in which all the
p_paddr fields are zero. When we try to objcopy or strip such a
file, we get confused. Check for this case, and if we find it
don't set the p_paddr_valid fields. */
p_paddr_valid = FALSE;
for (i = 0, segment = elf_tdata (ibfd)->phdr;
i < num_segments;
i++, segment++)
if (segment->p_paddr != 0)
{
p_paddr_valid = TRUE;
break;
}
1999-05-03 09:29:11 +02:00
/* Scan through the segments specified in the program header
of the input BFD. For this first scan we look for overlaps
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
in the loadable segments. These can be created by weird
parameters to objcopy. Also, fix some solaris weirdness. */
for (i = 0, segment = elf_tdata (ibfd)->phdr;
i < num_segments;
i++, segment++)
1999-05-03 09:29:11 +02:00
{
unsigned int j;
Elf_Internal_Phdr *segment2;
1999-05-03 09:29:11 +02:00
if (segment->p_type == PT_INTERP)
for (section = ibfd->sections; section; section = section->next)
if (IS_SOLARIS_PT_INTERP (segment, section))
{
/* Mininal change so that the normal section to segment
assignment code will work. */
segment->p_vaddr = section->vma;
break;
}
if (segment->p_type != PT_LOAD)
bfd/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * elf-bfd.h (elf_obj_tdata): Remove relro. * elf.c (get_program_header_size): Check info->relro instead of elf_tdata (abfd)->relro. (_bfd_elf_map_sections_to_segments): Likewise. (assign_file_positions_for_load_sections): Don't set PT_GNU_RELRO segment alignment here. (assign_file_positions_for_non_load_sections): Properly set up PT_GNU_RELRO segment for copying executable/shared library. (rewrite_elf_program_header): Remove PT_GNU_RELRO segment. (copy_elf_program_header): Set p_size and p_size_valid fields for PT_GNU_RELRO segment. include/elf/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * internal.h (elf_segment_map): Add p_size and p_size_valid. (ELF_IS_SECTION_IN_SEGMENT): Allow SHF_TLS sections in PT_GNU_RELRO segments. ld/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ldexp.h (ldexp_control): Add relro, relro_start_stat and relro_end_stat. * ldexp.c (fold_binary): Set expld.dataseg.relro to exp_dataseg_relro_start or exp_dataseg_relro_end when seeing DATA_SEGMENT_ALIGN or DATA_SEGMENT_RELRO_END, respectively. * ldlang.c (lang_size_sections_1): Properly set expld.dataseg.relro_start_stat and expld.dataseg.relro_end_stat. (find_relro_section_callback): New function. (lang_find_relro_sections_1): Likewise. (lang_find_relro_sections): Likewise. (lang_process): Call lang_find_relro_sections for non-relocatable link. ld/testsuite/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ld-elf/binutils.exp: Update "-z relro" tests to use relro1.s. Add "-z relro" tests with relro2.s. Add "-z relro" tests with TLS for objcopy. * ld-elf/relro1.s: New file. * ld-elf/relro2.s: Likewise.
2007-09-18 02:25:07 +02:00
{
/* Remove PT_GNU_RELRO segment. */
if (segment->p_type == PT_GNU_RELRO)
segment->p_type = PT_NULL;
continue;
}
/* Determine if this segment overlaps any previous segments. */
for (j = 0, segment2 = elf_tdata (ibfd)->phdr; j < i; j++, segment2++)
{
bfd_signed_vma extra_length;
if (segment2->p_type != PT_LOAD
|| !SEGMENT_OVERLAPS (segment, segment2))
continue;
/* Merge the two segments together. */
if (segment2->p_vaddr < segment->p_vaddr)
{
/* Extend SEGMENT2 to include SEGMENT and then delete
SEGMENT. */
extra_length = (SEGMENT_END (segment, segment->p_vaddr)
- SEGMENT_END (segment2, segment2->p_vaddr));
if (extra_length > 0)
{
segment2->p_memsz += extra_length;
segment2->p_filesz += extra_length;
}
segment->p_type = PT_NULL;
/* Since we have deleted P we must restart the outer loop. */
i = 0;
segment = elf_tdata (ibfd)->phdr;
break;
}
else
{
/* Extend SEGMENT to include SEGMENT2 and then delete
SEGMENT2. */
extra_length = (SEGMENT_END (segment2, segment2->p_vaddr)
- SEGMENT_END (segment, segment->p_vaddr));
if (extra_length > 0)
{
segment->p_memsz += extra_length;
segment->p_filesz += extra_length;
}
segment2->p_type = PT_NULL;
}
}
}
/* The second scan attempts to assign sections to segments. */
for (i = 0, segment = elf_tdata (ibfd)->phdr;
i < num_segments;
i++, segment++)
{
unsigned int section_count;
asection **sections;
asection *output_section;
unsigned int isec;
bfd_vma matching_lma;
bfd_vma suggested_lma;
unsigned int j;
bfd_size_type amt;
asection *first_section;
bfd_boolean first_matching_lma;
bfd_boolean first_suggested_lma;
if (segment->p_type == PT_NULL)
continue;
first_section = NULL;
/* Compute how many sections might be placed into this segment. */
for (section = ibfd->sections, section_count = 0;
section != NULL;
section = section->next)
{
/* Find the first section in the input segment, which may be
removed from the corresponding output segment. */
if (IS_SECTION_IN_INPUT_SEGMENT (section, segment, bed))
{
if (first_section == NULL)
first_section = section;
if (section->output_section != NULL)
++section_count;
}
}
/* Allocate a segment map big enough to contain
all of the sections we have selected. */
amt = sizeof (struct elf_segment_map);
amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
map = (struct elf_segment_map *) bfd_zalloc (obfd, amt);
if (map == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
/* Initialise the fields of the segment map. Default to
using the physical address of the segment in the input BFD. */
map->next = NULL;
map->p_type = segment->p_type;
map->p_flags = segment->p_flags;
map->p_flags_valid = 1;
/* If the first section in the input segment is removed, there is
no need to preserve segment physical address in the corresponding
output segment. */
if (!first_section || first_section->output_section != NULL)
{
map->p_paddr = segment->p_paddr;
map->p_paddr_valid = p_paddr_valid;
}
1999-05-03 09:29:11 +02:00
/* Determine if this segment contains the ELF file header
and if it contains the program headers themselves. */
map->includes_filehdr = (segment->p_offset == 0
&& segment->p_filesz >= iehdr->e_ehsize);
map->includes_phdrs = 0;
1999-05-03 09:29:11 +02:00
if (!phdr_included || segment->p_type != PT_LOAD)
1999-05-03 09:29:11 +02:00
{
map->includes_phdrs =
(segment->p_offset <= (bfd_vma) iehdr->e_phoff
&& (segment->p_offset + segment->p_filesz
1999-05-03 09:29:11 +02:00
>= ((bfd_vma) iehdr->e_phoff
+ iehdr->e_phnum * iehdr->e_phentsize)));
if (segment->p_type == PT_LOAD && map->includes_phdrs)
phdr_included = TRUE;
1999-05-03 09:29:11 +02:00
}
if (section_count == 0)
1999-05-03 09:29:11 +02:00
{
/* Special segments, such as the PT_PHDR segment, may contain
no sections, but ordinary, loadable segments should contain
something. They are allowed by the ELF spec however, so only
a warning is produced. */
if (segment->p_type == PT_LOAD)
(*_bfd_error_handler) (_("%B: warning: Empty loadable segment"
" detected, is this intentional ?\n"),
ibfd);
1999-05-03 09:29:11 +02:00
map->count = 0;
*pointer_to_map = map;
pointer_to_map = &map->next;
1999-05-03 09:29:11 +02:00
continue;
}
/* Now scan the sections in the input BFD again and attempt
to add their corresponding output sections to the segment map.
The problem here is how to handle an output section which has
been moved (ie had its LMA changed). There are four possibilities:
1. None of the sections have been moved.
In this case we can continue to use the segment LMA from the
input BFD.
2. All of the sections have been moved by the same amount.
In this case we can change the segment's LMA to match the LMA
of the first section.
3. Some of the sections have been moved, others have not.
In this case those sections which have not been moved can be
placed in the current segment which will have to have its size,
and possibly its LMA changed, and a new segment or segments will
have to be created to contain the other sections.
4. The sections have been moved, but not by the same amount.
1999-05-03 09:29:11 +02:00
In this case we can change the segment's LMA to match the LMA
of the first section and we will have to create a new segment
or segments to contain the other sections.
In order to save time, we allocate an array to hold the section
pointers that we are interested in. As these sections get assigned
to a segment, they are removed from this array. */
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
sections = (asection **) bfd_malloc2 (section_count, sizeof (asection *));
1999-05-03 09:29:11 +02:00
if (sections == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
/* Step One: Scan for segment vs section LMA conflicts.
Also add the sections to the section array allocated above.
Also add the sections to the current segment. In the common
case, where the sections have not been moved, this means that
we have completely filled the segment, and there is nothing
more to do. */
isec = 0;
2000-05-09 02:43:44 +02:00
matching_lma = 0;
1999-05-03 09:29:11 +02:00
suggested_lma = 0;
first_matching_lma = TRUE;
first_suggested_lma = TRUE;
1999-05-03 09:29:11 +02:00
for (section = ibfd->sections;
section != NULL;
section = section->next)
if (section == first_section)
break;
for (j = 0; section != NULL; section = section->next)
1999-05-03 09:29:11 +02:00
{
if (INCLUDE_SECTION_IN_SEGMENT (section, segment, bed))
{
output_section = section->output_section;
sections[j++] = section;
1999-05-03 09:29:11 +02:00
/* The Solaris native linker always sets p_paddr to 0.
We try to catch that case here, and set it to the
correct value. Note - some backends require that
p_paddr be left as zero. */
if (!p_paddr_valid
2002-07-23 20:02:32 +02:00
&& segment->p_vaddr != 0
&& !bed->want_p_paddr_set_to_zero
1999-05-03 09:29:11 +02:00
&& isec == 0
&& output_section->lma != 0
&& output_section->vma == (segment->p_vaddr
+ (map->includes_filehdr
? iehdr->e_ehsize
: 0)
+ (map->includes_phdrs
? (iehdr->e_phnum
* iehdr->e_phentsize)
: 0)))
map->p_paddr = segment->p_vaddr;
1999-05-03 09:29:11 +02:00
/* Match up the physical address of the segment with the
LMA address of the output section. */
if (IS_CONTAINED_BY_LMA (output_section, segment, map->p_paddr)
|| IS_COREFILE_NOTE (segment, section)
|| (bed->want_p_paddr_set_to_zero
&& IS_CONTAINED_BY_VMA (output_section, segment)))
1999-05-03 09:29:11 +02:00
{
if (first_matching_lma || output_section->lma < matching_lma)
{
matching_lma = output_section->lma;
first_matching_lma = FALSE;
}
1999-05-03 09:29:11 +02:00
/* We assume that if the section fits within the segment
then it does not overlap any other section within that
1999-05-03 09:29:11 +02:00
segment. */
map->sections[isec++] = output_section;
}
else if (first_suggested_lma)
{
suggested_lma = output_section->lma;
first_suggested_lma = FALSE;
1999-05-03 09:29:11 +02:00
}
if (j == section_count)
break;
1999-05-03 09:29:11 +02:00
}
}
BFD_ASSERT (j == section_count);
1999-05-03 09:29:11 +02:00
/* Step Two: Adjust the physical address of the current segment,
if necessary. */
if (isec == section_count)
1999-05-03 09:29:11 +02:00
{
/* All of the sections fitted within the segment as currently
specified. This is the default case. Add the segment to
the list of built segments and carry on to process the next
program header in the input BFD. */
map->count = section_count;
*pointer_to_map = map;
pointer_to_map = &map->next;
if (p_paddr_valid
&& !bed->want_p_paddr_set_to_zero
&& matching_lma != map->p_paddr
&& !map->includes_filehdr
&& !map->includes_phdrs)
/* There is some padding before the first section in the
segment. So, we must account for that in the output
segment's vma. */
map->p_vaddr_offset = matching_lma - map->p_paddr;
1999-05-03 09:29:11 +02:00
free (sections);
continue;
}
else
{
if (!first_matching_lma)
2000-05-09 02:43:44 +02:00
{
/* At least one section fits inside the current segment.
Keep it, but modify its physical address to match the
LMA of the first section that fitted. */
map->p_paddr = matching_lma;
2000-05-09 02:43:44 +02:00
}
else
{
/* None of the sections fitted inside the current segment.
Change the current segment's physical address to match
the LMA of the first section. */
map->p_paddr = suggested_lma;
2000-05-09 02:43:44 +02:00
}
/* Offset the segment physical address from the lma
to allow for space taken up by elf headers. */
if (map->includes_filehdr)
{
if (map->p_paddr >= iehdr->e_ehsize)
map->p_paddr -= iehdr->e_ehsize;
else
{
map->includes_filehdr = FALSE;
map->includes_phdrs = FALSE;
}
}
1999-05-03 09:29:11 +02:00
if (map->includes_phdrs)
{
if (map->p_paddr >= iehdr->e_phnum * iehdr->e_phentsize)
{
map->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize;
/* iehdr->e_phnum is just an estimate of the number
of program headers that we will need. Make a note
here of the number we used and the segment we chose
to hold these headers, so that we can adjust the
offset when we know the correct value. */
phdr_adjust_num = iehdr->e_phnum;
phdr_adjust_seg = map;
}
else
map->includes_phdrs = FALSE;
}
1999-05-03 09:29:11 +02:00
}
/* Step Three: Loop over the sections again, this time assigning
those that fit to the current segment and removing them from the
1999-05-03 09:29:11 +02:00
sections array; but making sure not to leave large gaps. Once all
possible sections have been assigned to the current segment it is
added to the list of built segments and if sections still remain
to be assigned, a new segment is constructed before repeating
the loop. */
isec = 0;
do
{
map->count = 0;
1999-05-03 09:29:11 +02:00
suggested_lma = 0;
first_suggested_lma = TRUE;
1999-05-03 09:29:11 +02:00
/* Fill the current segment with sections that fit. */
for (j = 0; j < section_count; j++)
1999-05-03 09:29:11 +02:00
{
section = sections[j];
1999-05-03 09:29:11 +02:00
if (section == NULL)
1999-05-03 09:29:11 +02:00
continue;
output_section = section->output_section;
1999-05-03 09:29:11 +02:00
BFD_ASSERT (output_section != NULL);
if (IS_CONTAINED_BY_LMA (output_section, segment, map->p_paddr)
|| IS_COREFILE_NOTE (segment, section))
1999-05-03 09:29:11 +02:00
{
if (map->count == 0)
1999-05-03 09:29:11 +02:00
{
/* If the first section in a segment does not start at
the beginning of the segment, then something is
wrong. */
if (output_section->lma
!= (map->p_paddr
+ (map->includes_filehdr ? iehdr->e_ehsize : 0)
+ (map->includes_phdrs
? iehdr->e_phnum * iehdr->e_phentsize
: 0)))
1999-05-03 09:29:11 +02:00
abort ();
}
else
{
asection *prev_sec;
1999-05-03 09:29:11 +02:00
prev_sec = map->sections[map->count - 1];
1999-05-03 09:29:11 +02:00
/* If the gap between the end of the previous section
and the start of this section is more than
maxpagesize then we need to start a new segment. */
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 06:46:28 +02:00
if ((BFD_ALIGN (prev_sec->lma + prev_sec->size,
maxpagesize)
< BFD_ALIGN (output_section->lma, maxpagesize))
|| (prev_sec->lma + prev_sec->size
> output_section->lma))
1999-05-03 09:29:11 +02:00
{
if (first_suggested_lma)
{
suggested_lma = output_section->lma;
first_suggested_lma = FALSE;
}
1999-05-03 09:29:11 +02:00
continue;
}
}
map->sections[map->count++] = output_section;
1999-05-03 09:29:11 +02:00
++isec;
sections[j] = NULL;
section->segment_mark = TRUE;
1999-05-03 09:29:11 +02:00
}
else if (first_suggested_lma)
{
suggested_lma = output_section->lma;
first_suggested_lma = FALSE;
}
1999-05-03 09:29:11 +02:00
}
BFD_ASSERT (map->count > 0);
1999-05-03 09:29:11 +02:00
/* Add the current segment to the list of built segments. */
*pointer_to_map = map;
pointer_to_map = &map->next;
1999-05-03 09:29:11 +02:00
if (isec < section_count)
1999-05-03 09:29:11 +02:00
{
/* We still have not allocated all of the sections to
segments. Create a new segment here, initialise it
and carry on looping. */
amt = sizeof (struct elf_segment_map);
amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
map = (struct elf_segment_map *) bfd_alloc (obfd, amt);
if (map == NULL)
2003-03-31 20:13:25 +02:00
{
free (sections);
return FALSE;
}
1999-05-03 09:29:11 +02:00
/* Initialise the fields of the segment map. Set the physical
physical address to the LMA of the first section that has
not yet been assigned. */
map->next = NULL;
map->p_type = segment->p_type;
map->p_flags = segment->p_flags;
map->p_flags_valid = 1;
map->p_paddr = suggested_lma;
map->p_paddr_valid = p_paddr_valid;
map->includes_filehdr = 0;
map->includes_phdrs = 0;
1999-05-03 09:29:11 +02:00
}
}
while (isec < section_count);
1999-05-03 09:29:11 +02:00
free (sections);
}
elf_tdata (obfd)->segment_map = map_first;
/* If we had to estimate the number of program headers that were
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
going to be needed, then check our estimate now and adjust
the offset if necessary. */
if (phdr_adjust_seg != NULL)
{
unsigned int count;
for (count = 0, map = map_first; map != NULL; map = map->next)
count++;
1999-05-03 09:29:11 +02:00
if (count > phdr_adjust_num)
phdr_adjust_seg->p_paddr
-= (count - phdr_adjust_num) * iehdr->e_phentsize;
}
#undef SEGMENT_END
#undef SECTION_SIZE
#undef IS_CONTAINED_BY_VMA
#undef IS_CONTAINED_BY_LMA
#undef IS_NOTE
1999-05-03 09:29:11 +02:00
#undef IS_COREFILE_NOTE
#undef IS_SOLARIS_PT_INTERP
#undef IS_SECTION_IN_INPUT_SEGMENT
#undef INCLUDE_SECTION_IN_SEGMENT
#undef SEGMENT_AFTER_SEGMENT
#undef SEGMENT_OVERLAPS
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Copy ELF program header information. */
static bfd_boolean
copy_elf_program_header (bfd *ibfd, bfd *obfd)
{
Elf_Internal_Ehdr *iehdr;
struct elf_segment_map *map;
struct elf_segment_map *map_first;
struct elf_segment_map **pointer_to_map;
Elf_Internal_Phdr *segment;
unsigned int i;
unsigned int num_segments;
bfd_boolean phdr_included = FALSE;
bfd_boolean p_paddr_valid;
iehdr = elf_elfheader (ibfd);
map_first = NULL;
pointer_to_map = &map_first;
/* If all the segment p_paddr fields are zero, don't set
map->p_paddr_valid. */
p_paddr_valid = FALSE;
num_segments = elf_elfheader (ibfd)->e_phnum;
for (i = 0, segment = elf_tdata (ibfd)->phdr;
i < num_segments;
i++, segment++)
if (segment->p_paddr != 0)
{
p_paddr_valid = TRUE;
break;
}
for (i = 0, segment = elf_tdata (ibfd)->phdr;
i < num_segments;
i++, segment++)
{
asection *section;
unsigned int section_count;
bfd_size_type amt;
Elf_Internal_Shdr *this_hdr;
asection *first_section = NULL;
asection *lowest_section;
/* Compute how many sections are in this segment. */
for (section = ibfd->sections, section_count = 0;
section != NULL;
section = section->next)
{
this_hdr = &(elf_section_data(section)->this_hdr);
if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
{
if (first_section == NULL)
first_section = section;
section_count++;
}
}
/* Allocate a segment map big enough to contain
all of the sections we have selected. */
amt = sizeof (struct elf_segment_map);
if (section_count != 0)
amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
map = (struct elf_segment_map *) bfd_zalloc (obfd, amt);
if (map == NULL)
return FALSE;
/* Initialize the fields of the output segment map with the
input segment. */
map->next = NULL;
map->p_type = segment->p_type;
map->p_flags = segment->p_flags;
map->p_flags_valid = 1;
map->p_paddr = segment->p_paddr;
map->p_paddr_valid = p_paddr_valid;
map->p_align = segment->p_align;
map->p_align_valid = 1;
map->p_vaddr_offset = 0;
if (map->p_type == PT_GNU_RELRO)
bfd/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * elf-bfd.h (elf_obj_tdata): Remove relro. * elf.c (get_program_header_size): Check info->relro instead of elf_tdata (abfd)->relro. (_bfd_elf_map_sections_to_segments): Likewise. (assign_file_positions_for_load_sections): Don't set PT_GNU_RELRO segment alignment here. (assign_file_positions_for_non_load_sections): Properly set up PT_GNU_RELRO segment for copying executable/shared library. (rewrite_elf_program_header): Remove PT_GNU_RELRO segment. (copy_elf_program_header): Set p_size and p_size_valid fields for PT_GNU_RELRO segment. include/elf/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * internal.h (elf_segment_map): Add p_size and p_size_valid. (ELF_IS_SECTION_IN_SEGMENT): Allow SHF_TLS sections in PT_GNU_RELRO segments. ld/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ldexp.h (ldexp_control): Add relro, relro_start_stat and relro_end_stat. * ldexp.c (fold_binary): Set expld.dataseg.relro to exp_dataseg_relro_start or exp_dataseg_relro_end when seeing DATA_SEGMENT_ALIGN or DATA_SEGMENT_RELRO_END, respectively. * ldlang.c (lang_size_sections_1): Properly set expld.dataseg.relro_start_stat and expld.dataseg.relro_end_stat. (find_relro_section_callback): New function. (lang_find_relro_sections_1): Likewise. (lang_find_relro_sections): Likewise. (lang_process): Call lang_find_relro_sections for non-relocatable link. ld/testsuite/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ld-elf/binutils.exp: Update "-z relro" tests to use relro1.s. Add "-z relro" tests with relro2.s. Add "-z relro" tests with TLS for objcopy. * ld-elf/relro1.s: New file. * ld-elf/relro2.s: Likewise.
2007-09-18 02:25:07 +02:00
{
/* The PT_GNU_RELRO segment may contain the first a few
bytes in the .got.plt section even if the whole .got.plt
section isn't in the PT_GNU_RELRO segment. We won't
change the size of the PT_GNU_RELRO segment. */
map->p_size = segment->p_memsz;
bfd/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * elf-bfd.h (elf_obj_tdata): Remove relro. * elf.c (get_program_header_size): Check info->relro instead of elf_tdata (abfd)->relro. (_bfd_elf_map_sections_to_segments): Likewise. (assign_file_positions_for_load_sections): Don't set PT_GNU_RELRO segment alignment here. (assign_file_positions_for_non_load_sections): Properly set up PT_GNU_RELRO segment for copying executable/shared library. (rewrite_elf_program_header): Remove PT_GNU_RELRO segment. (copy_elf_program_header): Set p_size and p_size_valid fields for PT_GNU_RELRO segment. include/elf/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * internal.h (elf_segment_map): Add p_size and p_size_valid. (ELF_IS_SECTION_IN_SEGMENT): Allow SHF_TLS sections in PT_GNU_RELRO segments. ld/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ldexp.h (ldexp_control): Add relro, relro_start_stat and relro_end_stat. * ldexp.c (fold_binary): Set expld.dataseg.relro to exp_dataseg_relro_start or exp_dataseg_relro_end when seeing DATA_SEGMENT_ALIGN or DATA_SEGMENT_RELRO_END, respectively. * ldlang.c (lang_size_sections_1): Properly set expld.dataseg.relro_start_stat and expld.dataseg.relro_end_stat. (find_relro_section_callback): New function. (lang_find_relro_sections_1): Likewise. (lang_find_relro_sections): Likewise. (lang_process): Call lang_find_relro_sections for non-relocatable link. ld/testsuite/ 2007-09-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3281 PR binutils/5037 * ld-elf/binutils.exp: Update "-z relro" tests to use relro1.s. Add "-z relro" tests with relro2.s. Add "-z relro" tests with TLS for objcopy. * ld-elf/relro1.s: New file. * ld-elf/relro2.s: Likewise.
2007-09-18 02:25:07 +02:00
map->p_size_valid = 1;
}
/* Determine if this segment contains the ELF file header
and if it contains the program headers themselves. */
map->includes_filehdr = (segment->p_offset == 0
&& segment->p_filesz >= iehdr->e_ehsize);
map->includes_phdrs = 0;
if (! phdr_included || segment->p_type != PT_LOAD)
{
map->includes_phdrs =
(segment->p_offset <= (bfd_vma) iehdr->e_phoff
&& (segment->p_offset + segment->p_filesz
>= ((bfd_vma) iehdr->e_phoff
+ iehdr->e_phnum * iehdr->e_phentsize)));
if (segment->p_type == PT_LOAD && map->includes_phdrs)
phdr_included = TRUE;
}
lowest_section = first_section;
if (section_count != 0)
{
unsigned int isec = 0;
for (section = first_section;
section != NULL;
section = section->next)
{
this_hdr = &(elf_section_data(section)->this_hdr);
if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
{
map->sections[isec++] = section->output_section;
if (section->lma < lowest_section->lma)
lowest_section = section;
if ((section->flags & SEC_ALLOC) != 0)
{
bfd_vma seg_off;
/* Section lmas are set up from PT_LOAD header
p_paddr in _bfd_elf_make_section_from_shdr.
If this header has a p_paddr that disagrees
with the section lma, flag the p_paddr as
invalid. */
if ((section->flags & SEC_LOAD) != 0)
seg_off = this_hdr->sh_offset - segment->p_offset;
else
seg_off = this_hdr->sh_addr - segment->p_vaddr;
if (section->lma - segment->p_paddr != seg_off)
map->p_paddr_valid = FALSE;
}
if (isec == section_count)
break;
}
}
}
if (map->includes_filehdr && lowest_section != NULL)
/* We need to keep the space used by the headers fixed. */
map->header_size = lowest_section->vma - segment->p_vaddr;
if (!map->includes_phdrs
&& !map->includes_filehdr
&& map->p_paddr_valid)
/* There is some other padding before the first section. */
map->p_vaddr_offset = ((lowest_section ? lowest_section->lma : 0)
- segment->p_paddr);
map->count = section_count;
*pointer_to_map = map;
pointer_to_map = &map->next;
}
elf_tdata (obfd)->segment_map = map_first;
return TRUE;
}
/* Copy private BFD data. This copies or rewrites ELF program header
information. */
static bfd_boolean
copy_private_bfd_data (bfd *ibfd, bfd *obfd)
{
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
if (elf_tdata (ibfd)->phdr == NULL)
return TRUE;
if (ibfd->xvec == obfd->xvec)
{
/* Check to see if any sections in the input BFD
covered by ELF program header have changed. */
Elf_Internal_Phdr *segment;
asection *section, *osec;
unsigned int i, num_segments;
Elf_Internal_Shdr *this_hdr;
const struct elf_backend_data *bed;
bed = get_elf_backend_data (ibfd);
/* Regenerate the segment map if p_paddr is set to 0. */
if (bed->want_p_paddr_set_to_zero)
goto rewrite;
/* Initialize the segment mark field. */
for (section = obfd->sections; section != NULL;
section = section->next)
section->segment_mark = FALSE;
num_segments = elf_elfheader (ibfd)->e_phnum;
for (i = 0, segment = elf_tdata (ibfd)->phdr;
i < num_segments;
i++, segment++)
{
/* PR binutils/3535. The Solaris linker always sets the p_paddr
and p_memsz fields of special segments (DYNAMIC, INTERP) to 0
which severly confuses things, so always regenerate the segment
map in this case. */
if (segment->p_paddr == 0
&& segment->p_memsz == 0
&& (segment->p_type == PT_INTERP || segment->p_type == PT_DYNAMIC))
goto rewrite;
for (section = ibfd->sections;
section != NULL; section = section->next)
{
/* We mark the output section so that we know it comes
from the input BFD. */
osec = section->output_section;
if (osec)
osec->segment_mark = TRUE;
/* Check if this section is covered by the segment. */
this_hdr = &(elf_section_data(section)->this_hdr);
if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
{
/* FIXME: Check if its output section is changed or
removed. What else do we need to check? */
if (osec == NULL
|| section->flags != osec->flags
|| section->lma != osec->lma
|| section->vma != osec->vma
|| section->size != osec->size
|| section->rawsize != osec->rawsize
|| section->alignment_power != osec->alignment_power)
goto rewrite;
}
}
}
/* Check to see if any output section do not come from the
input BFD. */
for (section = obfd->sections; section != NULL;
section = section->next)
{
if (section->segment_mark == FALSE)
goto rewrite;
else
section->segment_mark = FALSE;
}
return copy_elf_program_header (ibfd, obfd);
}
rewrite:
return rewrite_elf_program_header (ibfd, obfd);
}
/* Initialize private output section information from input section. */
bfd_boolean
_bfd_elf_init_private_section_data (bfd *ibfd,
asection *isec,
bfd *obfd,
asection *osec,
struct bfd_link_info *link_info)
{
Elf_Internal_Shdr *ihdr, *ohdr;
bfd_boolean final_link = link_info != NULL && !link_info->relocatable;
if (ibfd->xvec->flavour != bfd_target_elf_flavour
|| obfd->xvec->flavour != bfd_target_elf_flavour)
return TRUE;
BFD_ASSERT (elf_section_data (osec) != NULL);
/* For objcopy and relocatable link, don't copy the output ELF
section type from input if the output BFD section flags have been
set to something different. For a final link allow some flags
that the linker clears to differ. */
if (elf_section_type (osec) == SHT_NULL
&& (osec->flags == isec->flags
|| (final_link
&& ((osec->flags ^ isec->flags)
& ~(SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_RELOC)) == 0)))
elf_section_type (osec) = elf_section_type (isec);
/* FIXME: Is this correct for all OS/PROC specific flags? */
elf_section_flags (osec) |= (elf_section_flags (isec)
& (SHF_MASKOS | SHF_MASKPROC));
/* Set things up for objcopy and relocatable link. The output
SHT_GROUP section will have its elf_next_in_group pointing back
to the input group members. Ignore linker created group section.
See elfNN_ia64_object_p in elfxx-ia64.c. */
if (!final_link)
{
if (elf_sec_group (isec) == NULL
|| (elf_sec_group (isec)->flags & SEC_LINKER_CREATED) == 0)
{
if (elf_section_flags (isec) & SHF_GROUP)
elf_section_flags (osec) |= SHF_GROUP;
elf_next_in_group (osec) = elf_next_in_group (isec);
elf_section_data (osec)->group = elf_section_data (isec)->group;
}
}
ihdr = &elf_section_data (isec)->this_hdr;
/* We need to handle elf_linked_to_section for SHF_LINK_ORDER. We
don't use the output section of the linked-to section since it
may be NULL at this point. */
if ((ihdr->sh_flags & SHF_LINK_ORDER) != 0)
{
ohdr = &elf_section_data (osec)->this_hdr;
ohdr->sh_flags |= SHF_LINK_ORDER;
elf_linked_to_section (osec) = elf_linked_to_section (isec);
}
osec->use_rela_p = isec->use_rela_p;
return TRUE;
}
1999-05-03 09:29:11 +02:00
/* Copy private section information. This copies over the entsize
field, and sometimes the info field. */
bfd_boolean
_bfd_elf_copy_private_section_data (bfd *ibfd,
asection *isec,
bfd *obfd,
asection *osec)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Shdr *ihdr, *ohdr;
if (ibfd->xvec->flavour != bfd_target_elf_flavour
|| obfd->xvec->flavour != bfd_target_elf_flavour)
return TRUE;
1999-05-03 09:29:11 +02:00
ihdr = &elf_section_data (isec)->this_hdr;
ohdr = &elf_section_data (osec)->this_hdr;
ohdr->sh_entsize = ihdr->sh_entsize;
if (ihdr->sh_type == SHT_SYMTAB
|| ihdr->sh_type == SHT_DYNSYM
|| ihdr->sh_type == SHT_GNU_verneed
|| ihdr->sh_type == SHT_GNU_verdef)
ohdr->sh_info = ihdr->sh_info;
return _bfd_elf_init_private_section_data (ibfd, isec, obfd, osec,
NULL);
1999-05-03 09:29:11 +02:00
}
/* Look at all the SHT_GROUP sections in IBFD, making any adjustments
necessary if we are removing either the SHT_GROUP section or any of
the group member sections. DISCARDED is the value that a section's
output_section has if the section will be discarded, NULL when this
function is called from objcopy, bfd_abs_section_ptr when called
from the linker. */
bfd_boolean
_bfd_elf_fixup_group_sections (bfd *ibfd, asection *discarded)
{
asection *isec;
for (isec = ibfd->sections; isec != NULL; isec = isec->next)
if (elf_section_type (isec) == SHT_GROUP)
{
asection *first = elf_next_in_group (isec);
asection *s = first;
bfd_size_type removed = 0;
while (s != NULL)
{
/* If this member section is being output but the
SHT_GROUP section is not, then clear the group info
set up by _bfd_elf_copy_private_section_data. */
if (s->output_section != discarded
&& isec->output_section == discarded)
{
elf_section_flags (s->output_section) &= ~SHF_GROUP;
elf_group_name (s->output_section) = NULL;
}
/* Conversely, if the member section is not being output
but the SHT_GROUP section is, then adjust its size. */
else if (s->output_section == discarded
&& isec->output_section != discarded)
removed += 4;
s = elf_next_in_group (s);
if (s == first)
break;
}
if (removed != 0)
{
if (discarded != NULL)
{
/* If we've been called for ld -r, then we need to
adjust the input section size. This function may
be called multiple times, so save the original
size. */
if (isec->rawsize == 0)
isec->rawsize = isec->size;
isec->size = isec->rawsize - removed;
}
else
{
/* Adjust the output section size when called from
objcopy. */
isec->output_section->size -= removed;
}
}
}
return TRUE;
}
/* Copy private header information. */
bfd_boolean
_bfd_elf_copy_private_header_data (bfd *ibfd, bfd *obfd)
{
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
/* Copy over private BFD data if it has not already been copied.
This must be done here, rather than in the copy_private_bfd_data
entry point, because the latter is called after the section
contents have been set, which means that the program headers have
already been worked out. */
if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL)
{
if (! copy_private_bfd_data (ibfd, obfd))
return FALSE;
}
return _bfd_elf_fixup_group_sections (ibfd, NULL);
}
1999-05-03 09:29:11 +02:00
/* Copy private symbol information. If this symbol is in a section
which we did not map into a BFD section, try to map the section
index correctly. We use special macro definitions for the mapped
section indices; these definitions are interpreted by the
swap_out_syms function. */
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
#define MAP_ONESYMTAB (SHN_HIOS + 1)
#define MAP_DYNSYMTAB (SHN_HIOS + 2)
#define MAP_STRTAB (SHN_HIOS + 3)
#define MAP_SHSTRTAB (SHN_HIOS + 4)
#define MAP_SYM_SHNDX (SHN_HIOS + 5)
1999-05-03 09:29:11 +02:00
bfd_boolean
_bfd_elf_copy_private_symbol_data (bfd *ibfd,
asymbol *isymarg,
bfd *obfd,
asymbol *osymarg)
1999-05-03 09:29:11 +02:00
{
elf_symbol_type *isym, *osym;
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
1999-05-03 09:29:11 +02:00
isym = elf_symbol_from (ibfd, isymarg);
osym = elf_symbol_from (obfd, osymarg);
if (isym != NULL
&& isym->internal_elf_sym.st_shndx != 0
1999-05-03 09:29:11 +02:00
&& osym != NULL
&& bfd_is_abs_section (isym->symbol.section))
{
unsigned int shndx;
shndx = isym->internal_elf_sym.st_shndx;
if (shndx == elf_onesymtab (ibfd))
shndx = MAP_ONESYMTAB;
else if (shndx == elf_dynsymtab (ibfd))
shndx = MAP_DYNSYMTAB;
else if (shndx == elf_tdata (ibfd)->strtab_section)
shndx = MAP_STRTAB;
else if (shndx == elf_tdata (ibfd)->shstrtab_section)
shndx = MAP_SHSTRTAB;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
else if (shndx == elf_tdata (ibfd)->symtab_shndx_section)
shndx = MAP_SYM_SHNDX;
1999-05-03 09:29:11 +02:00
osym->internal_elf_sym.st_shndx = shndx;
}
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Swap out the symbols. */
static bfd_boolean
swap_out_syms (bfd *abfd,
struct bfd_strtab_hash **sttp,
int relocatable_p)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed;
int symcount;
asymbol **syms;
struct bfd_strtab_hash *stt;
Elf_Internal_Shdr *symtab_hdr;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
Elf_Internal_Shdr *symtab_shndx_hdr;
Elf_Internal_Shdr *symstrtab_hdr;
include/ * xtensa-isa-internal.h (xtensa_length_decode_fn): Warning fix. * xtensa-isa.h (xtensa_insnbuf_to_chars): Likewise. (xtensa_insnbuf_from_chars, xtensa_isa_length_from_chars): Likewise. include/coff/ * xcoff.h (struct xcoff_loader_info): Warning fix. bfd/ * bfd-in.h (bfd_elf_bfd_from_remote_memory): Warning fix. * coff-m68k.c (bfd_m68k_coff_create_embedded_relocs): Likewise. * coff-rs6000.c (xcoff_write_armap_big): Warning fixes. Remove useless assignments. (xcoff_write_archive_contents_big): Likewise. (_bfd_xcoff_put_ldsymbol_name): Likewise. * coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise. * coffgen.c (coff_write_symbols): Make "written" a bfd_vma. * cofflink.c (process_embedded_commands): Warning fixes. * cpu-arm.c: Delete unnecessary prototypes. Convert to C90. Warning fixes. * dwarf2.c: Warning fixes. * elf-bfd.h: Likewise. * elf-eh-frame.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-sh-symbian.c: Likewise. * elf32-sh.c: Delete unnecessary prototypes. Warning fixes. * elf64-sh64.c: Likewise. * peicode.h: Likewise. * elf64-mmix.c: Warning fixes. * elfcode.h: Likewise. * elfxx-mips.c: Likewise. * libbfd-in.h: Likewise. * libbfd.c: Likewise. * mach-o.c: Likewise. * merge.c: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * pef.c: Likewise. * srec.c: Likewise. * vms-hdr.c: Likewise. * vms-tir.c: Likewise. * xtensa-isa.c: Likewise. * xtensa-modules.c: Likewise. * xsym.c: Likewise. (pstrcmp): Use correct choice of string lengths. Fix return value. (bfd_sym_module_name): Correct string length. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2005-02-20 15:59:07 +01:00
bfd_byte *outbound_syms;
bfd_byte *outbound_shndx;
int idx;
bfd_size_type amt;
bfd_boolean name_local_sections;
1999-05-03 09:29:11 +02:00
if (!elf_map_symbols (abfd))
return FALSE;
1999-05-03 09:29:11 +02:00
/* Dump out the symtabs. */
stt = _bfd_elf_stringtab_init ();
if (stt == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
bed = get_elf_backend_data (abfd);
symcount = bfd_get_symcount (abfd);
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
symtab_hdr->sh_type = SHT_SYMTAB;
symtab_hdr->sh_entsize = bed->s->sizeof_sym;
symtab_hdr->sh_size = symtab_hdr->sh_entsize * (symcount + 1);
symtab_hdr->sh_info = elf_num_locals (abfd) + 1;
symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align;
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
symstrtab_hdr->sh_type = SHT_STRTAB;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
outbound_syms = (bfd_byte *) bfd_alloc2 (abfd, 1 + symcount,
bed->s->sizeof_sym);
if (outbound_syms == NULL)
2003-03-31 20:13:25 +02:00
{
_bfd_stringtab_free (stt);
return FALSE;
}
symtab_hdr->contents = outbound_syms;
1999-05-03 09:29:11 +02:00
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
outbound_shndx = NULL;
symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
if (symtab_shndx_hdr->sh_name != 0)
{
amt = (bfd_size_type) (1 + symcount) * sizeof (Elf_External_Sym_Shndx);
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
outbound_shndx = (bfd_byte *)
bfd_zalloc2 (abfd, 1 + symcount, sizeof (Elf_External_Sym_Shndx));
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if (outbound_shndx == NULL)
2003-03-31 20:13:25 +02:00
{
_bfd_stringtab_free (stt);
return FALSE;
}
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
symtab_shndx_hdr->contents = outbound_shndx;
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
symtab_shndx_hdr->sh_size = amt;
symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
}
/* Now generate the data (for "contents"). */
{
/* Fill in zeroth symbol and swap it out. */
Elf_Internal_Sym sym;
sym.st_name = 0;
sym.st_value = 0;
sym.st_size = 0;
sym.st_info = 0;
sym.st_other = 0;
sym.st_shndx = SHN_UNDEF;
include/elf/ * internal.h (elf_internal_sym): Add st_target_internal. * arm.h (arm_st_branch_type): New enum. (ARM_SYM_BRANCH_TYPE): New macro. bfd/ * elf-bfd.h (elf_link_hash_entry): Add target_internal. * elf.c (swap_out_syms): Set st_target_internal for each Elf_Internal_Sym. * elfcode.h (elf_swap_symbol_in): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise. * elf32-sh-symbian.c (sh_symbian_relocate_section): Likewise. * elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise. * elflink.c (elf_link_output_extsym): Likewise. (bfd_elf_final_link): Likewise. (elf_link_add_object_symbols): Copy st_target_internal to the hash table if we see a definition. (_bfd_elf_copy_link_hash_symbol_type): Copy target_internal. * elf32-arm.c (elf32_arm_stub_hash_entry): Replace st_type with a branch_type field. (a8_erratum_fix, a8_erratum_reloc): Likewise. (arm_type_of_stub): Replace actual_st_type with an actual_branch_type parameter. (arm_build_one_stub): Use branch types rather than st_types to determine the type of branch. (cortex_a8_erratum_scan): Likewise. (elf32_arm_size_stubs): Likewise. (bfd_elf32_arm_process_before_allocation): Likewise. (allocate_dynrelocs_for_symbol): Likewise. (elf32_arm_finish_dynamic_sections): Likewise. (elf32_arm_final_link_relocate): Replace sym_flags parameter with a branch_type parameter. (elf32_arm_relocate_section): Update call accordingly. (elf32_arm_adjust_dynamic_symbol): Don't check STT_ARM_TFUNC. (elf32_arm_output_map_sym): Initialize st_target_internal. (elf32_arm_output_stub_sym): Likewise. (elf32_arm_symbol_processing): Delete. (elf32_arm_swap_symbol_in): Convert STT_ARM_TFUNCs into STT_FUNCs. Use st_target_internal to record the branch type. (elf32_arm_swap_symbol_out): Use st_target_internal to test for Thumb functions. (elf32_arm_is_function_type): Delete. (elf_backend_symbol_processing): Likewise. (elf_backend_is_function_type): Likewise. gas/ * config/tc-arm.c (arm_adjust_symtab): Set the branch type for Thumb symbols. ld/ * emultempl/armelf.em (gld${EMULATION_NAME}_finish): Check eh->target_internal. opcodes/ * arm-dis.c (get_sym_code_type): Don't check for STT_ARM_TFUNC. Use branch types instead. (print_insn): Likewise.
2011-03-14 16:55:04 +01:00
sym.st_target_internal = 0;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
bed->s->swap_symbol_out (abfd, &sym, outbound_syms, outbound_shndx);
outbound_syms += bed->s->sizeof_sym;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if (outbound_shndx != NULL)
outbound_shndx += sizeof (Elf_External_Sym_Shndx);
}
1999-05-03 09:29:11 +02:00
name_local_sections
= (bed->elf_backend_name_local_section_symbols
&& bed->elf_backend_name_local_section_symbols (abfd));
syms = bfd_get_outsymbols (abfd);
for (idx = 0; idx < symcount; idx++)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Sym sym;
bfd_vma value = syms[idx]->value;
elf_symbol_type *type_ptr;
flagword flags = syms[idx]->flags;
int type;
1999-05-03 09:29:11 +02:00
if (!name_local_sections
&& (flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM)
{
/* Local section symbols have no name. */
sym.st_name = 0;
}
else
{
sym.st_name = (unsigned long) _bfd_stringtab_add (stt,
syms[idx]->name,
TRUE, FALSE);
if (sym.st_name == (unsigned long) -1)
2003-03-31 20:13:25 +02:00
{
_bfd_stringtab_free (stt);
return FALSE;
}
}
1999-05-03 09:29:11 +02:00
type_ptr = elf_symbol_from (abfd, syms[idx]);
1999-05-03 09:29:11 +02:00
if ((flags & BSF_SECTION_SYM) == 0
&& bfd_is_com_section (syms[idx]->section))
{
/* ELF common symbols put the alignment into the `value' field,
and the size into the `size' field. This is backwards from
how BFD handles it, so reverse it here. */
sym.st_size = value;
if (type_ptr == NULL
|| type_ptr->internal_elf_sym.st_value == 0)
sym.st_value = value >= 16 ? 16 : (1 << bfd_log2 (value));
else
sym.st_value = type_ptr->internal_elf_sym.st_value;
sym.st_shndx = _bfd_elf_section_from_bfd_section
(abfd, syms[idx]->section);
}
else
{
asection *sec = syms[idx]->section;
unsigned int shndx;
1999-05-03 09:29:11 +02:00
if (sec->output_section)
{
value += sec->output_offset;
sec = sec->output_section;
}
/* Don't add in the section vma for relocatable output. */
if (! relocatable_p)
value += sec->vma;
sym.st_value = value;
sym.st_size = type_ptr ? type_ptr->internal_elf_sym.st_size : 0;
if (bfd_is_abs_section (sec)
&& type_ptr != NULL
&& type_ptr->internal_elf_sym.st_shndx != 0)
{
/* This symbol is in a real ELF section which we did
not create as a BFD section. Undo the mapping done
by copy_private_symbol_data. */
shndx = type_ptr->internal_elf_sym.st_shndx;
switch (shndx)
{
case MAP_ONESYMTAB:
shndx = elf_onesymtab (abfd);
break;
case MAP_DYNSYMTAB:
shndx = elf_dynsymtab (abfd);
break;
case MAP_STRTAB:
shndx = elf_tdata (abfd)->strtab_section;
break;
case MAP_SHSTRTAB:
shndx = elf_tdata (abfd)->shstrtab_section;
break;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
case MAP_SYM_SHNDX:
shndx = elf_tdata (abfd)->symtab_shndx_section;
break;
default:
break;
}
}
else
{
shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
1999-05-03 09:29:11 +02:00
if (shndx == SHN_BAD)
{
asection *sec2;
/* Writing this would be a hell of a lot easier if
we had some decent documentation on bfd, and
knew what to expect of the library, and what to
demand of applications. For example, it
appears that `objcopy' might not set the
section of a symbol to be a section that is
actually in the output file. */
sec2 = bfd_get_section_by_name (abfd, sec->name);
if (sec2 == NULL)
{
_bfd_error_handler (_("\
Unable to find equivalent output section for symbol '%s' from section '%s'"),
syms[idx]->name ? syms[idx]->name : "<Local sym>",
sec->name);
bfd_set_error (bfd_error_invalid_operation);
2003-03-31 20:13:25 +02:00
_bfd_stringtab_free (stt);
return FALSE;
}
shndx = _bfd_elf_section_from_bfd_section (abfd, sec2);
BFD_ASSERT (shndx != SHN_BAD);
}
}
1999-05-03 09:29:11 +02:00
sym.st_shndx = shndx;
}
1999-05-03 09:29:11 +02:00
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
if ((flags & BSF_THREAD_LOCAL) != 0)
type = STT_TLS;
include/elf 2009-04-30 Nick Clifton <nickc@redhat.com> * common.h (STT_GNU_IFUNC): Define. elfcpp 2009-04-30 Nick Clifton <nickc@redhat.com> * (enum STT): Add STT_GNU_IFUNC. gas 2009-04-30 Nick Clifton <nickc@redhat.com> * config/obj-elf.c (obj_elf_type): Add support for a gnu_indirect_function type. * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups against indirect function symbols. * doc/as.texinfo (.type): Document the support for the gnu_indirect_function symbol type. * NEWS: Mention the new feature. gas/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * gas/elf/elf.exp: Extend type test to include an ifunc symbol. Provide an alternative test for targets which do not support ifunc symbols. (type.s): Add entry for an ifunc symbol. (type.e): Add ifunc entry to expected symbol dump. (section2.e-armelf): Add entry for ifunc symbol. (type-noifunc.s): New file. (type-noifunc.e): New file. bfd/ 2009-04-30 Nick Clifton <nickc@redhat.com> * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs section pointer. (struct elf_obj_data): Add has_ifunc_symbols boolean. * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags into a STT_GNU_IFUNC symbol type. (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function type. (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if the binary contains ifunc symbols. * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC symbol type into a BSF_GNU_INDIRECT_FUNCTION flag. * elf32-i386.c (is_indirect_function): New function. (elf_i386_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf_i386_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): New function. Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. (elf_backend_add_symbol_hook): Define. (elf_i386_post_process_headers): Rename to elf_i388_fbsd_post_process_headers. * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro. (is_indirect_function): New function. (elf64_x86_64_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf64_x86_64_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT if we have ifunc symbols to handle. (get_ifunc_reloc_section_name): New function. Computes the name for an ifunc section. (_bfd_elf_make_ifunc_reloc_section): New function. Creates a section to hold ifunc relocs. * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define. (bfd_print_symbol_vandf): Handle ifunc symbols. (bfd_decode_symclass): Likewise. * bfd-in2.h: Regenerate. binutils 2009-04-30 Nick Clifton <nickc@redhat.com> * readelf.c (dump_relocations): Display a relocation against an ifunc symbol as if it were a function invocation. (get_symbol_type): Handle STT_GNU_IFUNC. ld 2009-04-30 Nick Clifton <nickc@redhat.com> * NEWS: Mention support for IFUNC symbols. ld/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * ld-ifunc: New directory. * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests. * ld-ifunc/prog.c: New file. * ld-ifunc/lib.c: New file.
2009-04-30 17:47:13 +02:00
else if ((flags & BSF_GNU_INDIRECT_FUNCTION) != 0)
type = STT_GNU_IFUNC;
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
else if ((flags & BSF_FUNCTION) != 0)
type = STT_FUNC;
else if ((flags & BSF_OBJECT) != 0)
type = STT_OBJECT;
else if ((flags & BSF_RELC) != 0)
type = STT_RELC;
else if ((flags & BSF_SRELC) != 0)
type = STT_SRELC;
else
type = STT_NOTYPE;
1999-05-03 09:29:11 +02:00
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL for symbols from SHF_TLS section. (_bfd_elf_print_private_bfd_data): Add PT_TLS. (elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections. (map_sections_to_segments): Build PT_TLS segment if necessary. (assign_file_positions_for_segments): Likewise. (get_program_header_size): Account for PT_TLS segment. (swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from SEC_THREAD_LOCAL sections to STT_TLS. * reloc.c: Add 386 and IA-64 TLS relocs. * section.c (SEC_THREAD_LOCAL): Define. (SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS): Remove. * elflink.h (elf_link_add_object_symbols): Support .tcommon. (size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS unconditionally. (struct elf_final_link_info): Add first_tls_sec. (elf_bfd_final_link): Set first_tls_sec. Compute elf_hash_table (info)->tls_segment. (elf_link_output_extsym): Handle STT_TLS symbols. (elf_link_input_bfd): Likewise. * syms.c (BSF_THREAD_LOCAL): Define. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff, elf_i386_mkobject, elf_i386_object_p): New functions. (elf_howto_table): Add TLS relocs. (elf_i386_reloc_type_lookup): Support TLS relocs. (elf_i386_info_to_howto_rel): Likewise. (struct elf_i386_link_hash_entry): Add tls_type. (struct elf_i386_obj_tdata): New. (elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type): New macros. (struct elf_i386_link_hash_table): Add tls_ldm_got. (link_hash_newfunc): Clear tls_type. (elf_i386_check_relocs): Support TLS relocs. (elf_i386_gc_sweep_hook): Likewise. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (bfd_elf32_mkobject, elf_backend_object_p): Define. * elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset, dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done, want_tprel, want_dtpmod, want_dtprel. (elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions. (ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to R_IA64_LTOFF_TPREL22. (elf_code_to_howto_index): Add TLS relocs. (elfNN_ia64_check_relocs): Support TLS relocs. (allocate_global_data_got): Account for TLS .got data. (allocate_dynrel_entries): Account for TLS dynamic relocations. (elfNN_ia64_install_value): Supprt TLS relocs. (set_got_entry): Support TLS relocs. (elfNN_ia64_relocate_section): Likewise. * config/obj-elf.c (elf_common): Renamed from obj_elf_common. (obj_elf_common): Call elf_common. (obj_elf_tls_common): New function. (elf_pseudo_tab): Support .tls_common. (special_sections): Add .tdata and .tbss. (obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS sections. (obj_elf_parse_section_letters): Support T in section flags (SHF_TLS). (obj_elf_parse_section_letters): Include T in error message. * config/tc-ppc.c (ppc_section_letter): Likewise. * config/tc-alpha.c (alpha_elf_section_letter): Likewise. (tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as SEC_MERGE. * config/tc-sparc.c (md_apply_fix3): Likewise. * config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs. Define them if not BFD_ASSEMBLER. (lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF and @NTPOFF. (md_apply_fix3): Add TLS relocs. * config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE, FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE, FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE. (pseudo_func): Support @dtpmod(), @dtprel() and @tprel(). (ia64_elf_section_letter): Include T in error message. (md_begin): Support TLS operators. (md_operand): Likewise. (ia64_gen_real_reloc_type): Support TLS relocs. * testsuite/gas/i386/tlspic.s: New file. * testsuite/gas/i386/tlsd.s: New file. * testsuite/gas/i386/tlsnopic.s: New file. * testsuite/gas/i386/tlsd.d: New file. * testsuite/gas/i386/tlsnopic.d: New file. * testsuite/gas/i386/tlspic.d: New file. * testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests. * testsuite/gas/ia64/tls.s: New file. * testsuite/gas/ia64/tls.d: New file. * testsuite/gas/ia64/ia64.exp: Add tls test. * write.c (adjust_reloc_syms): Don't change symbols in SEC_THREAD_LOCAL sections to STT_SECTION + addend. * elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define. * elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22. * elf/i386.h: Add TLS relocs. * scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss. * ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for output section if necessary. Handle .tbss. (lang_size_sections): Clear _raw_size for .tbss section (it allocates space in PT_TLS segment only). * ldwrite.c (build_link_order): Build link order for .tbss too. * readelf.c (get_segment_type): Add PT_TLS. (get_elf_section_flags): Add SHF_TLS. (get_dynamic_flags): Optimize. Add DF_STATIC_TLS. (process_dynamic_segment): Use puts instead of printf. (get_symbol_type): Support STT_TLS. * objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS. Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
if (syms[idx]->section->flags & SEC_THREAD_LOCAL)
type = STT_TLS;
/* Processor-specific types. */
if (type_ptr != NULL
&& bed->elf_backend_get_symbol_type)
type = ((*bed->elf_backend_get_symbol_type)
(&type_ptr->internal_elf_sym, type));
1999-05-03 09:29:11 +02:00
if (flags & BSF_SECTION_SYM)
{
if (flags & BSF_GLOBAL)
sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
else
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
}
else if (bfd_is_com_section (syms[idx]->section))
{
#ifdef USE_STT_COMMON
if (type == STT_OBJECT)
sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_COMMON);
else
#endif
sym.st_info = ELF_ST_INFO (STB_GLOBAL, type);
}
else if (bfd_is_und_section (syms[idx]->section))
sym.st_info = ELF_ST_INFO (((flags & BSF_WEAK)
? STB_WEAK
: STB_GLOBAL),
type);
else if (flags & BSF_FILE)
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
else
{
int bind = STB_LOCAL;
1999-05-03 09:29:11 +02:00
if (flags & BSF_LOCAL)
bind = STB_LOCAL;
* config/obj-elf.c (obj_elf_type): Add code to support a type of gnu_unique_object. * doc/as.texinfo: Document new feature of .type directive. * NEWS: Mention support for gnu_unique_object symbol type. * common.h (STB_GNU_UNIQUE): Define. * NEWS: Mention the linker's support for symbols with a binding of STB_GNU_UNIQUE. * gas/elf/type.s: Add unique global symbol definition. * gas/elf/type.e: Add expected readelf output for global unique symbol. * elfcpp.h (enum STB): Add STB_GNU_UNIQUE. * readelf.c (get_symbol_binding): For Linux targeted files return UNIQUE for symbols with the STB_GNU_UNIQUE binding. * doc/binutils.texi: Document the meaning of the 'u' symbol binding in the output of nm and objdump --syms. * elf-bfd.h (struct elf_link_hash_entry): Add unique_global field. * elf.c (swap_out_syms): Set binding to STB_GNU_UNIQUE for symbols with the BSF_GNU_UNIQUE flag bit set. * elfcode.h (elf_slurp_symbol_table): Set the BSF_GNU_UNIQUE flag for symbols with STB_GNU_UNIQUE binding. * elflink.c (_bfd_elf_merge_symbol): Set unique_global for symbols with the STB_GNU_UNIQUE binding. (elf_link_add_object_symbols): Set the BSF_GNU_UNIQUE flag for symbols with STB_GNU_UNIQUE binding. Set STB_GNU_UNIQUE for symbols with the unique_global field set. (elf_link_output_extsym): Set unique_global field for symbols with the STB_GNU_UNIQUE binding. * syms.c (struct bfd_symbol): Define BSF_GNU_UNIQUE flag bit. (bfd_print_symbol_vandf): Print a 'u' character for BSF_GNU_UNIQUE symbols. (bfd_decode_symclass): Return a 'u' character for BSF_GNU_UNIQUE symbols. * bfd-in2.h: Regenerate.
2009-07-23 15:00:30 +02:00
else if (flags & BSF_GNU_UNIQUE)
bind = STB_GNU_UNIQUE;
else if (flags & BSF_WEAK)
bind = STB_WEAK;
else if (flags & BSF_GLOBAL)
bind = STB_GLOBAL;
1999-05-03 09:29:11 +02:00
sym.st_info = ELF_ST_INFO (bind, type);
}
1999-05-03 09:29:11 +02:00
if (type_ptr != NULL)
include/elf/ * internal.h (elf_internal_sym): Add st_target_internal. * arm.h (arm_st_branch_type): New enum. (ARM_SYM_BRANCH_TYPE): New macro. bfd/ * elf-bfd.h (elf_link_hash_entry): Add target_internal. * elf.c (swap_out_syms): Set st_target_internal for each Elf_Internal_Sym. * elfcode.h (elf_swap_symbol_in): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise. * elf32-sh-symbian.c (sh_symbian_relocate_section): Likewise. * elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise. * elflink.c (elf_link_output_extsym): Likewise. (bfd_elf_final_link): Likewise. (elf_link_add_object_symbols): Copy st_target_internal to the hash table if we see a definition. (_bfd_elf_copy_link_hash_symbol_type): Copy target_internal. * elf32-arm.c (elf32_arm_stub_hash_entry): Replace st_type with a branch_type field. (a8_erratum_fix, a8_erratum_reloc): Likewise. (arm_type_of_stub): Replace actual_st_type with an actual_branch_type parameter. (arm_build_one_stub): Use branch types rather than st_types to determine the type of branch. (cortex_a8_erratum_scan): Likewise. (elf32_arm_size_stubs): Likewise. (bfd_elf32_arm_process_before_allocation): Likewise. (allocate_dynrelocs_for_symbol): Likewise. (elf32_arm_finish_dynamic_sections): Likewise. (elf32_arm_final_link_relocate): Replace sym_flags parameter with a branch_type parameter. (elf32_arm_relocate_section): Update call accordingly. (elf32_arm_adjust_dynamic_symbol): Don't check STT_ARM_TFUNC. (elf32_arm_output_map_sym): Initialize st_target_internal. (elf32_arm_output_stub_sym): Likewise. (elf32_arm_symbol_processing): Delete. (elf32_arm_swap_symbol_in): Convert STT_ARM_TFUNCs into STT_FUNCs. Use st_target_internal to record the branch type. (elf32_arm_swap_symbol_out): Use st_target_internal to test for Thumb functions. (elf32_arm_is_function_type): Delete. (elf_backend_symbol_processing): Likewise. (elf_backend_is_function_type): Likewise. gas/ * config/tc-arm.c (arm_adjust_symtab): Set the branch type for Thumb symbols. ld/ * emultempl/armelf.em (gld${EMULATION_NAME}_finish): Check eh->target_internal. opcodes/ * arm-dis.c (get_sym_code_type): Don't check for STT_ARM_TFUNC. Use branch types instead. (print_insn): Likewise.
2011-03-14 16:55:04 +01:00
{
sym.st_other = type_ptr->internal_elf_sym.st_other;
sym.st_target_internal
= type_ptr->internal_elf_sym.st_target_internal;
}
else
include/elf/ * internal.h (elf_internal_sym): Add st_target_internal. * arm.h (arm_st_branch_type): New enum. (ARM_SYM_BRANCH_TYPE): New macro. bfd/ * elf-bfd.h (elf_link_hash_entry): Add target_internal. * elf.c (swap_out_syms): Set st_target_internal for each Elf_Internal_Sym. * elfcode.h (elf_swap_symbol_in): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise. * elf32-sh-symbian.c (sh_symbian_relocate_section): Likewise. * elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise. * elflink.c (elf_link_output_extsym): Likewise. (bfd_elf_final_link): Likewise. (elf_link_add_object_symbols): Copy st_target_internal to the hash table if we see a definition. (_bfd_elf_copy_link_hash_symbol_type): Copy target_internal. * elf32-arm.c (elf32_arm_stub_hash_entry): Replace st_type with a branch_type field. (a8_erratum_fix, a8_erratum_reloc): Likewise. (arm_type_of_stub): Replace actual_st_type with an actual_branch_type parameter. (arm_build_one_stub): Use branch types rather than st_types to determine the type of branch. (cortex_a8_erratum_scan): Likewise. (elf32_arm_size_stubs): Likewise. (bfd_elf32_arm_process_before_allocation): Likewise. (allocate_dynrelocs_for_symbol): Likewise. (elf32_arm_finish_dynamic_sections): Likewise. (elf32_arm_final_link_relocate): Replace sym_flags parameter with a branch_type parameter. (elf32_arm_relocate_section): Update call accordingly. (elf32_arm_adjust_dynamic_symbol): Don't check STT_ARM_TFUNC. (elf32_arm_output_map_sym): Initialize st_target_internal. (elf32_arm_output_stub_sym): Likewise. (elf32_arm_symbol_processing): Delete. (elf32_arm_swap_symbol_in): Convert STT_ARM_TFUNCs into STT_FUNCs. Use st_target_internal to record the branch type. (elf32_arm_swap_symbol_out): Use st_target_internal to test for Thumb functions. (elf32_arm_is_function_type): Delete. (elf_backend_symbol_processing): Likewise. (elf_backend_is_function_type): Likewise. gas/ * config/tc-arm.c (arm_adjust_symtab): Set the branch type for Thumb symbols. ld/ * emultempl/armelf.em (gld${EMULATION_NAME}_finish): Check eh->target_internal. opcodes/ * arm-dis.c (get_sym_code_type): Don't check for STT_ARM_TFUNC. Use branch types instead. (print_insn): Likewise.
2011-03-14 16:55:04 +01:00
{
sym.st_other = 0;
sym.st_target_internal = 0;
}
1999-05-03 09:29:11 +02:00
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
bed->s->swap_symbol_out (abfd, &sym, outbound_syms, outbound_shndx);
outbound_syms += bed->s->sizeof_sym;
Support for more than 64k ELF sections. include/elf/ChangeLog * external.h (Elf_External_Sym_Shndx): Declare. * internal.h (struct elf_internal_sym <st_shndx>): Make it an unsigned int. * common.h (SHN_BAD): Define. bfd/ChangeLog * configure.in: Bump bfd version. * configure: Regenerate. * elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param. (bfd_elf32_swap_symbol_in): Likewise. (bfd_elf32_swap_symbol_out): Likewise. (bfd_elf64_swap_symbol_in): Likewise. (bfd_elf64_swap_symbol_out): Likewise. (elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR. (elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and symtab_shndx_section. (elf_numsections): Define. (elf_symtab_shndx): Define. * elf.c (setup_group): Use elf_numsections rather than header e_shnum. (bfd_elf_find_section): Likewise. (bfd_section_from_elf_index): Likewise. (bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX. (bfd_section_from_r_symndx): Read symbol shndx extension, and translate st_shndx for > SHN_HIRESERVE. (assign_section_numbers): Skip reserved sections. Assign symtab_shndx_section and elf_numsections. Exclude reserved sections from e_shnum. Set up symtab_shndx_hdr. (_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr. (map_sections_to_segments): Don't map eh_frame_hdr unless required. (assign_file_positions_except_relocs): Use elf_numsections rather than header e_shnum. Skip reserved sections and symtab_shndx_section. (prep_headers): Set name for symtab_shndx_hdr. (_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections. (_bfd_elf_write_object_contents): Likewise. Skip reserved sections. (_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section first. Use elf_section_data if available. Use elf_numsections. Start scan at index 1. (copy_private_bfd_data ): Comment fixes. (MAP_ONESYMTAB): Define above SHN_HIOS. (MAP_DYNSYMTAB): Likewise. (MAP_STRTAB): Likewise. (MAP_SHSTRTAB): Likewise. (MAP_SYM_SHNDX): New define. (_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section. (swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too. * elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx extension. (elf_swap_symbol_out): Likewise. (elf_object_p): Set elf_numsections, and use instead of e_shnum. Initialialise reserved elf_elfsections to point at shdr[0]. Remove redundant bfd_release calls. (elf_slurp_symbol_table): Read symbol shndx extension, and use with elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too. * elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_record_local_dynamic_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Also translate st_shndx for elf sections > SHN_HIRESERVE. (NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out call. (struct elf_final_link_info): Add locsym_shndx and symshndxbuf. (elf_bfd_final_link): Allocate the above, and tidy code allocating other buffers. Use elf_numsections instead of e_shnum. Adjust elf_swap_symbol_out calls. (elf_link_output_sym): Swap out symbol shndx extension too. (elf_link_flush_output_syms): And flush them to disk. (elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out calls. (elf_gc_mark): Read symbol shndx extension, and use with elf_swap_symbol_in. (elf_link_input_bfd): Likewise, Translate st_shndx for elf sections > SHN_HIRESERVE too. Use SHN_BAD. (elf_reloc_symbol_deleted_p): Use symbol shndx extensions with elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too. (elf_bfd_discard_info): Read symbol shndx extension. Don't attempt to continue after a bfd error. * elf-m10200.c (mn10200_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Translate SHN_UNDEF, SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd sections too. Remove dead code. (mn10200_elf_relax_delete_bytes): Use symbol shndx extension when swapping in symbols. Tidy code adjusting global syms. Don't swap in global syms. (mn10200_elf_symbol_address_p): Likewise. Remove extsyms param. (mn10200_elf_get_relocated_section_contents): Read symbol shndx extension, and use with swap_symbol_in. Rename "size" -> "amt" to maximize code in common with other files. Translate st_shndx for > SHN_HIRESERVE too. Remove dead code. * elf-m10300.c (mn10300_elf_relax_section): Only read local syms. Stash them immediately to symtab_hdr->contents rather than later in multiple places. Clean up afterwards. Read symbol shndx extension, and use with swap_symbol_in. Remove dead code. (mn10300_elf_relax_delete_bytes): As for elf-m10200.c. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx extension, and use with swap_symbol_in. * elf64-hppa.c (elf64_hppa_check_relocs): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to bfd_elf32_swap_symbol_out. * elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate elf sections > SHN_HIRESERVE too. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-mips.c (_bfd_mips_elf_final_write_processing): Use elf_numsections rather than header e_shnum. * elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. Only read local symbols. * elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to hold section index. Use elf_numsections rather than e_shnum. Rename "index" -> "indx" to avoid shadowing warning. (v850_elf_add_symbol_hook): Likewise. * elf64-alpha.c (elf64_alpha_relax_section): Only read local syms. Read symbol shndx extension, and use with swap_symbol_in. * elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise. Translate SHN_COMMON and elf sections > SHN_HIRESERVE too. * elfxx-ia64.c (elfNN_ia64_relax_section): Likewise. (elfNN_ia64_aix_add_symbol_hook): Use elf_numsections. * elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks before calling bfd_section_from_elf_index on local syms. * elf32-arm.h (elf32_arm_gc_mark_hook): Likewise. * elf32-avr.c (elf32_avr_gc_mark_hook): Likewise. * elf32-cris.c (cris_elf_gc_mark_hook): Likewise. * elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise. * elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise. * elf32-i386.c (elf_i386_gc_mark_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise. * elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise. * elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise. * elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise. * elf32-s390.c (elf_s390_gc_mark_hook): Likewise. * elf32-sh.c (sh_elf_gc_mark_hook): Likewise. * elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise. * elf32-v850.c (v850_elf_gc_mark_hook): Likewise. * elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise. * elf64-mips.c (mips_elf64_gc_mark_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise. * elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise. * elf64-s390.c (elf_s390_gc_mark_hook): Likewise. * elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise. binutils/ChangeLog * readelf.c (symtab_shndx_hdr): New global. (SECTION_HEADER_INDEX): Define. (SECTION_HEADER_NUM): Define. (SECTION_HEADER): Define. (GET_ELF_SYMBOLS): Pass two params rather than three. (get_32bit_elf_symbols): Take file and section args. Read and use SHT_SYMTAB_SHNDX. (get_64bit_elf_symbols): Likewise. (dump_relocations): Use SECTION_HEADER to index "section_headers". (process_section_headers): Likewise. Use SECTION_HEADER_NUM too. Remember symtab_shdx_hdr. (process_program_headers): Scan from index 1 for segment map. (slurp_ia64_unwind_table): Use SECTION_HEADER to index "section_headers". (process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS. (process_unwind): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (display_debug_info): Likewise. (process_dynamic_segment): Fake up a symtab section for changed GET_ELF_SYMBOLS. (get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE. (process_program_headers): Kill signed/unsigned warning. (load_debug_str): Likewise. (display_debug_info): Likewise.
2001-12-17 01:52:35 +01:00
if (outbound_shndx != NULL)
outbound_shndx += sizeof (Elf_External_Sym_Shndx);
}
1999-05-03 09:29:11 +02:00
*sttp = stt;
symstrtab_hdr->sh_size = _bfd_stringtab_size (stt);
symstrtab_hdr->sh_type = SHT_STRTAB;
1999-05-03 09:29:11 +02:00
symstrtab_hdr->sh_flags = 0;
symstrtab_hdr->sh_addr = 0;
symstrtab_hdr->sh_entsize = 0;
symstrtab_hdr->sh_link = 0;
symstrtab_hdr->sh_info = 0;
symstrtab_hdr->sh_addralign = 1;
1999-05-03 09:29:11 +02:00
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Return the number of bytes required to hold the symtab vector.
Note that we base it on the count plus 1, since we will null terminate
the vector allocated based on this size. However, the ELF symbol table
always has a dummy entry as symbol #0, so it ends up even. */
long
_bfd_elf_get_symtab_upper_bound (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
long symcount;
long symtab_size;
Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr;
symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
symtab_size = (symcount + 1) * (sizeof (asymbol *));
if (symcount > 0)
symtab_size -= sizeof (asymbol *);
1999-05-03 09:29:11 +02:00
return symtab_size;
}
long
_bfd_elf_get_dynamic_symtab_upper_bound (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
long symcount;
long symtab_size;
Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->dynsymtab_hdr;
if (elf_dynsymtab (abfd) == 0)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
symtab_size = (symcount + 1) * (sizeof (asymbol *));
if (symcount > 0)
symtab_size -= sizeof (asymbol *);
1999-05-03 09:29:11 +02:00
return symtab_size;
}
long
_bfd_elf_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
sec_ptr asect)
1999-05-03 09:29:11 +02:00
{
return (asect->reloc_count + 1) * sizeof (arelent *);
}
/* Canonicalize the relocs. */
long
_bfd_elf_canonicalize_reloc (bfd *abfd,
sec_ptr section,
arelent **relptr,
asymbol **symbols)
1999-05-03 09:29:11 +02:00
{
arelent *tblptr;
unsigned int i;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
if (! bed->s->slurp_reloc_table (abfd, section, symbols, FALSE))
1999-05-03 09:29:11 +02:00
return -1;
tblptr = section->relocation;
for (i = 0; i < section->reloc_count; i++)
*relptr++ = tblptr++;
*relptr = NULL;
return section->reloc_count;
}
long
Index: doc/ChangeLog 2003-10-15 Andrew Cagney <cagney@redhat.com> * bfdint.texi (BFD target vector symbols): Rename _get_symtab to _canonicalize_symtab. 2003-10-15 Andrew Cagney <cagney@redhat.com> * targets.c (BFD_JUMP_TABLE_SYMBOLS): Replace NAME##_get_symtab with NAME##_canonicalize_symtab. * libcoff-in.h (coff_canonicalize_symtab): Update. * xsym.h (bfd_sym_canonicalize_symtab): Update. * elf-bfd.h (_bfd_elf_canonicalize_symtab): Update. * coffgen.c (coff_canonicalize_symtab): Update. * libbfd-in.h (_bfd_nosymbols_canonicalize_symtab): Update. * libnlm.h (nlmNAME(canonicalize_symtab)): Update. * ieee.c (ieee_vec): Update comment. * libecoff.h (_bfd_ecoff_canonicalize_symtab): Update. * mmo.c (mmo_canonicalize_symtab): Update. * nlm-target.h (nlm_canonicalize_symtab): Update. * nlmcode.h (nlm_canonicalize_symtab): Update. * i386msdos.c (msdos_canonicalize_symtab): Update. * hp300hpux.c (MY (canonicalize_symtab)): Update. * oasys.c (oasys_canonicalize_symtab): Update. * som.c (som_canonicalize_symtab): Update. * pef.c (bfd_pef_canonicalize_symtab): Update. * nlmcode.h (nlm_canonicalize_symtab): Update. * xsym.c (bfd_sym_canonicalize_symtab): Update. * vms.c (vms_canonicalize_symtab): Update. * versados.c (versados_canonicalize_symtab): Update. * mach-o.c (bfd_mach_o_canonicalize_symtab): Update. * ieee.c (ieee_canonicalize_symtab): Update. * pdp11.c (NAME(aout,canonicalize_symtab)): Update. * reloc.c: Update comment. * libaout.h (NAME(aout,canonicalize_symtab)): Update. * coff64-rs6000.c (aix5coff64_vec): Update. * coff64-rs6000.c (bfd_xcoff_aix5_backend_data): Update. * coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Update. * aoutx.h (NAME(aout,canonicalize_symtab)): Update. * elfxx-target.h (bfd_elfNN_canonicalize_symtab): Update. * hp300hpux.c (MY_canonicalize_symtab): Update. * ecoff.c (_bfd_ecoff_canonicalize_symtab): Update. * aout-tic30.c (MY_canonicalize_symtab): Update. * aout-target.h (MY_canonicalize_symtab): Update. * ppcboot.c (ppcboot_canonicalize_symtab): Update. * elf.c (_bfd_elf_canonicalize_symtab): Update. * elfcode.h (elf_canonicalize_symtab): Update. * ihex.c (ihex_canonicalize_symtab): Update. * tekhex.c (tekhex_canonicalize_symtab): Update. * binary.c (binary_canonicalize_symtab): Update. * srec.c (srec_canonicalize_symtab): Update.
2003-10-16 06:11:10 +02:00
_bfd_elf_canonicalize_symtab (bfd *abfd, asymbol **allocation)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
long symcount = bed->s->slurp_symbol_table (abfd, allocation, FALSE);
1999-05-03 09:29:11 +02:00
if (symcount >= 0)
bfd_get_symcount (abfd) = symcount;
return symcount;
}
long
_bfd_elf_canonicalize_dynamic_symtab (bfd *abfd,
asymbol **allocation)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
long symcount = bed->s->slurp_symbol_table (abfd, allocation, TRUE);
if (symcount >= 0)
bfd_get_dynamic_symcount (abfd) = symcount;
return symcount;
1999-05-03 09:29:11 +02:00
}
/* Return the size required for the dynamic reloc entries. Any loadable
section that was actually installed in the BFD, and has type SHT_REL
or SHT_RELA, and uses the dynamic symbol table, is considered to be a
dynamic reloc section. */
1999-05-03 09:29:11 +02:00
long
_bfd_elf_get_dynamic_reloc_upper_bound (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
long ret;
asection *s;
if (elf_dynsymtab (abfd) == 0)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
ret = sizeof (arelent *);
for (s = abfd->sections; s != NULL; s = s->next)
if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
1999-05-03 09:29:11 +02:00
&& (elf_section_data (s)->this_hdr.sh_type == SHT_REL
|| elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
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 06:46:28 +02:00
ret += ((s->size / elf_section_data (s)->this_hdr.sh_entsize)
1999-05-03 09:29:11 +02:00
* sizeof (arelent *));
return ret;
}
/* Canonicalize the dynamic relocation entries. Note that we return the
dynamic relocations as a single block, although they are actually
associated with particular sections; the interface, which was
designed for SunOS style shared libraries, expects that there is only
one set of dynamic relocs. Any loadable section that was actually
installed in the BFD, and has type SHT_REL or SHT_RELA, and uses the
dynamic symbol table, is considered to be a dynamic reloc section. */
1999-05-03 09:29:11 +02:00
long
_bfd_elf_canonicalize_dynamic_reloc (bfd *abfd,
arelent **storage,
asymbol **syms)
1999-05-03 09:29:11 +02:00
{
bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
1999-05-03 09:29:11 +02:00
asection *s;
long ret;
if (elf_dynsymtab (abfd) == 0)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
ret = 0;
for (s = abfd->sections; s != NULL; s = s->next)
{
if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
1999-05-03 09:29:11 +02:00
&& (elf_section_data (s)->this_hdr.sh_type == SHT_REL
|| elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
{
arelent *p;
long count, i;
if (! (*slurp_relocs) (abfd, s, syms, TRUE))
1999-05-03 09:29:11 +02:00
return -1;
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 06:46:28 +02:00
count = s->size / elf_section_data (s)->this_hdr.sh_entsize;
1999-05-03 09:29:11 +02:00
p = s->relocation;
for (i = 0; i < count; i++)
*storage++ = p++;
ret += count;
}
}
*storage = NULL;
return ret;
}
/* Read in the version information. */
bfd_boolean
_bfd_elf_slurp_version_tables (bfd *abfd, bfd_boolean default_imported_symver)
1999-05-03 09:29:11 +02:00
{
bfd_byte *contents = NULL;
unsigned int freeidx = 0;
if (elf_dynverref (abfd) != 0)
{
Elf_Internal_Shdr *hdr;
Elf_External_Verneed *everneed;
Elf_Internal_Verneed *iverneed;
unsigned int i;
bfd_byte *contents_end;
hdr = &elf_tdata (abfd)->dynverref_hdr;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
elf_tdata (abfd)->verref = (Elf_Internal_Verneed *)
bfd_zalloc2 (abfd, hdr->sh_info, sizeof (Elf_Internal_Verneed));
if (elf_tdata (abfd)->verref == NULL)
goto error_return;
elf_tdata (abfd)->cverrefs = hdr->sh_info;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
if (contents == NULL)
{
error_return_verref:
elf_tdata (abfd)->verref = NULL;
elf_tdata (abfd)->cverrefs = 0;
goto error_return;
}
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
|| bfd_bread (contents, hdr->sh_size, abfd) != hdr->sh_size)
goto error_return_verref;
if (hdr->sh_info && hdr->sh_size < sizeof (Elf_External_Verneed))
goto error_return_verref;
BFD_ASSERT (sizeof (Elf_External_Verneed)
== sizeof (Elf_External_Vernaux));
contents_end = contents + hdr->sh_size - sizeof (Elf_External_Verneed);
everneed = (Elf_External_Verneed *) contents;
iverneed = elf_tdata (abfd)->verref;
for (i = 0; i < hdr->sh_info; i++, iverneed++)
{
Elf_External_Vernaux *evernaux;
Elf_Internal_Vernaux *ivernaux;
unsigned int j;
_bfd_elf_swap_verneed_in (abfd, everneed, iverneed);
iverneed->vn_bfd = abfd;
iverneed->vn_filename =
bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
iverneed->vn_file);
if (iverneed->vn_filename == NULL)
goto error_return_verref;
if (iverneed->vn_cnt == 0)
iverneed->vn_auxptr = NULL;
else
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
iverneed->vn_auxptr = (struct elf_internal_vernaux *)
bfd_alloc2 (abfd, iverneed->vn_cnt,
sizeof (Elf_Internal_Vernaux));
if (iverneed->vn_auxptr == NULL)
goto error_return_verref;
}
if (iverneed->vn_aux
> (size_t) (contents_end - (bfd_byte *) everneed))
goto error_return_verref;
evernaux = ((Elf_External_Vernaux *)
((bfd_byte *) everneed + iverneed->vn_aux));
ivernaux = iverneed->vn_auxptr;
for (j = 0; j < iverneed->vn_cnt; j++, ivernaux++)
{
_bfd_elf_swap_vernaux_in (abfd, evernaux, ivernaux);
ivernaux->vna_nodename =
bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
ivernaux->vna_name);
if (ivernaux->vna_nodename == NULL)
goto error_return_verref;
if (j + 1 < iverneed->vn_cnt)
ivernaux->vna_nextptr = ivernaux + 1;
else
ivernaux->vna_nextptr = NULL;
if (ivernaux->vna_next
> (size_t) (contents_end - (bfd_byte *) evernaux))
goto error_return_verref;
evernaux = ((Elf_External_Vernaux *)
((bfd_byte *) evernaux + ivernaux->vna_next));
if (ivernaux->vna_other > freeidx)
freeidx = ivernaux->vna_other;
}
if (i + 1 < hdr->sh_info)
iverneed->vn_nextref = iverneed + 1;
else
iverneed->vn_nextref = NULL;
if (iverneed->vn_next
> (size_t) (contents_end - (bfd_byte *) everneed))
goto error_return_verref;
everneed = ((Elf_External_Verneed *)
((bfd_byte *) everneed + iverneed->vn_next));
}
free (contents);
contents = NULL;
}
1999-05-03 09:29:11 +02:00
if (elf_dynverdef (abfd) != 0)
{
Elf_Internal_Shdr *hdr;
Elf_External_Verdef *everdef;
Elf_Internal_Verdef *iverdef;
Elf_Internal_Verdef *iverdefarr;
Elf_Internal_Verdef iverdefmem;
1999-05-03 09:29:11 +02:00
unsigned int i;
unsigned int maxidx;
bfd_byte *contents_end_def, *contents_end_aux;
1999-05-03 09:29:11 +02:00
hdr = &elf_tdata (abfd)->dynverdef_hdr;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
1999-05-03 09:29:11 +02:00
if (contents == NULL)
goto error_return;
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
|| bfd_bread (contents, hdr->sh_size, abfd) != hdr->sh_size)
1999-05-03 09:29:11 +02:00
goto error_return;
if (hdr->sh_info && hdr->sh_size < sizeof (Elf_External_Verdef))
goto error_return;
BFD_ASSERT (sizeof (Elf_External_Verdef)
>= sizeof (Elf_External_Verdaux));
contents_end_def = contents + hdr->sh_size
- sizeof (Elf_External_Verdef);
contents_end_aux = contents + hdr->sh_size
- sizeof (Elf_External_Verdaux);
/* We know the number of entries in the section but not the maximum
index. Therefore we have to run through all entries and find
the maximum. */
1999-05-03 09:29:11 +02:00
everdef = (Elf_External_Verdef *) contents;
maxidx = 0;
for (i = 0; i < hdr->sh_info; ++i)
{
_bfd_elf_swap_verdef_in (abfd, everdef, &iverdefmem);
if ((iverdefmem.vd_ndx & ((unsigned) VERSYM_VERSION)) > maxidx)
maxidx = iverdefmem.vd_ndx & ((unsigned) VERSYM_VERSION);
if (iverdefmem.vd_next
> (size_t) (contents_end_def - (bfd_byte *) everdef))
goto error_return;
everdef = ((Elf_External_Verdef *)
((bfd_byte *) everdef + iverdefmem.vd_next));
}
if (default_imported_symver)
{
if (freeidx > maxidx)
maxidx = ++freeidx;
else
freeidx = ++maxidx;
}
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *)
bfd_zalloc2 (abfd, maxidx, sizeof (Elf_Internal_Verdef));
if (elf_tdata (abfd)->verdef == NULL)
goto error_return;
elf_tdata (abfd)->cverdefs = maxidx;
everdef = (Elf_External_Verdef *) contents;
iverdefarr = elf_tdata (abfd)->verdef;
for (i = 0; i < hdr->sh_info; i++)
1999-05-03 09:29:11 +02:00
{
Elf_External_Verdaux *everdaux;
Elf_Internal_Verdaux *iverdaux;
unsigned int j;
_bfd_elf_swap_verdef_in (abfd, everdef, &iverdefmem);
if ((iverdefmem.vd_ndx & VERSYM_VERSION) == 0)
{
error_return_verdef:
elf_tdata (abfd)->verdef = NULL;
elf_tdata (abfd)->cverdefs = 0;
goto error_return;
}
iverdef = &iverdefarr[(iverdefmem.vd_ndx & VERSYM_VERSION) - 1];
memcpy (iverdef, &iverdefmem, sizeof (Elf_Internal_Verdef));
1999-05-03 09:29:11 +02:00
iverdef->vd_bfd = abfd;
if (iverdef->vd_cnt == 0)
iverdef->vd_auxptr = NULL;
else
{
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
iverdef->vd_auxptr = (struct elf_internal_verdaux *)
bfd_alloc2 (abfd, iverdef->vd_cnt,
sizeof (Elf_Internal_Verdaux));
if (iverdef->vd_auxptr == NULL)
goto error_return_verdef;
}
if (iverdef->vd_aux
> (size_t) (contents_end_aux - (bfd_byte *) everdef))
goto error_return_verdef;
1999-05-03 09:29:11 +02:00
everdaux = ((Elf_External_Verdaux *)
((bfd_byte *) everdef + iverdef->vd_aux));
iverdaux = iverdef->vd_auxptr;
for (j = 0; j < iverdef->vd_cnt; j++, iverdaux++)
{
_bfd_elf_swap_verdaux_in (abfd, everdaux, iverdaux);
iverdaux->vda_nodename =
bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
iverdaux->vda_name);
if (iverdaux->vda_nodename == NULL)
goto error_return_verdef;
1999-05-03 09:29:11 +02:00
if (j + 1 < iverdef->vd_cnt)
iverdaux->vda_nextptr = iverdaux + 1;
else
iverdaux->vda_nextptr = NULL;
if (iverdaux->vda_next
> (size_t) (contents_end_aux - (bfd_byte *) everdaux))
goto error_return_verdef;
1999-05-03 09:29:11 +02:00
everdaux = ((Elf_External_Verdaux *)
((bfd_byte *) everdaux + iverdaux->vda_next));
}
if (iverdef->vd_cnt)
iverdef->vd_nodename = iverdef->vd_auxptr->vda_nodename;
1999-05-03 09:29:11 +02:00
if ((size_t) (iverdef - iverdefarr) + 1 < maxidx)
1999-05-03 09:29:11 +02:00
iverdef->vd_nextdef = iverdef + 1;
else
iverdef->vd_nextdef = NULL;
everdef = ((Elf_External_Verdef *)
((bfd_byte *) everdef + iverdef->vd_next));
}
free (contents);
contents = NULL;
}
else if (default_imported_symver)
1999-05-03 09:29:11 +02:00
{
if (freeidx < 3)
freeidx = 3;
else
freeidx++;
1999-05-03 09:29:11 +02:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *)
bfd_zalloc2 (abfd, freeidx, sizeof (Elf_Internal_Verdef));
if (elf_tdata (abfd)->verdef == NULL)
1999-05-03 09:29:11 +02:00
goto error_return;
elf_tdata (abfd)->cverdefs = freeidx;
}
1999-05-03 09:29:11 +02:00
/* Create a default version based on the soname. */
if (default_imported_symver)
{
Elf_Internal_Verdef *iverdef;
Elf_Internal_Verdaux *iverdaux;
1999-05-03 09:29:11 +02:00
iverdef = &elf_tdata (abfd)->verdef[freeidx - 1];;
1999-05-03 09:29:11 +02:00
iverdef->vd_version = VER_DEF_CURRENT;
iverdef->vd_flags = 0;
iverdef->vd_ndx = freeidx;
iverdef->vd_cnt = 1;
1999-05-03 09:29:11 +02:00
iverdef->vd_bfd = abfd;
1999-05-03 09:29:11 +02:00
iverdef->vd_nodename = bfd_elf_get_dt_soname (abfd);
if (iverdef->vd_nodename == NULL)
goto error_return_verdef;
iverdef->vd_nextdef = NULL;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
iverdef->vd_auxptr = (struct elf_internal_verdaux *)
bfd_alloc (abfd, sizeof (Elf_Internal_Verdaux));
if (iverdef->vd_auxptr == NULL)
goto error_return_verdef;
1999-05-03 09:29:11 +02:00
iverdaux = iverdef->vd_auxptr;
iverdaux->vda_nodename = iverdef->vd_nodename;
iverdaux->vda_nextptr = NULL;
1999-05-03 09:29:11 +02:00
}
return TRUE;
1999-05-03 09:29:11 +02:00
error_return:
2003-03-31 20:13:25 +02:00
if (contents != NULL)
1999-05-03 09:29:11 +02:00
free (contents);
return FALSE;
1999-05-03 09:29:11 +02:00
}
asymbol *
_bfd_elf_make_empty_symbol (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
elf_symbol_type *newsym;
bfd_size_type amt = sizeof (elf_symbol_type);
1999-05-03 09:29:11 +02:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
newsym = (elf_symbol_type *) bfd_zalloc (abfd, amt);
1999-05-03 09:29:11 +02:00
if (!newsym)
return NULL;
else
{
newsym->symbol.the_bfd = abfd;
return &newsym->symbol;
}
}
void
_bfd_elf_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
asymbol *symbol,
symbol_info *ret)
1999-05-03 09:29:11 +02:00
{
bfd_symbol_info (symbol, ret);
}
/* Return whether a symbol name implies a local symbol. Most targets
use this function for the is_local_label_name entry point, but some
override it. */
bfd_boolean
_bfd_elf_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
const char *name)
1999-05-03 09:29:11 +02:00
{
/* Normal local symbols start with ``.L''. */
if (name[0] == '.' && name[1] == 'L')
return TRUE;
1999-05-03 09:29:11 +02:00
/* At least some SVR4 compilers (e.g., UnixWare 2.1 cc) generate
DWARF debugging symbols starting with ``..''. */
if (name[0] == '.' && name[1] == '.')
return TRUE;
1999-05-03 09:29:11 +02:00
/* gcc will sometimes generate symbols beginning with ``_.L_'' when
emitting DWARF debugging output. I suspect this is actually a
small bug in gcc (it calls ASM_OUTPUT_LABEL when it should call
ASM_GENERATE_INTERNAL_LABEL, and this causes the leading
underscore to be emitted on some ELF targets). For ease of use,
we treat such symbols as local. */
if (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_')
return TRUE;
1999-05-03 09:29:11 +02:00
return FALSE;
1999-05-03 09:29:11 +02:00
}
alent *
_bfd_elf_get_lineno (bfd *abfd ATTRIBUTE_UNUSED,
asymbol *symbol ATTRIBUTE_UNUSED)
1999-05-03 09:29:11 +02:00
{
abort ();
return NULL;
}
bfd_boolean
_bfd_elf_set_arch_mach (bfd *abfd,
enum bfd_architecture arch,
unsigned long machine)
1999-05-03 09:29:11 +02:00
{
/* If this isn't the right architecture for this backend, and this
isn't the generic backend, fail. */
if (arch != get_elf_backend_data (abfd)->arch
&& arch != bfd_arch_unknown
&& get_elf_backend_data (abfd)->arch != bfd_arch_unknown)
return FALSE;
1999-05-03 09:29:11 +02:00
return bfd_default_set_arch_mach (abfd, arch, machine);
}
2001-02-14 20:58:45 +01:00
/* Find the function to a particular section and offset,
for error reporting. */
1999-05-03 09:29:11 +02:00
static bfd_boolean
elf_find_function (bfd *abfd,
asection *section,
asymbol **symbols,
bfd_vma offset,
const char **filename_ptr,
const char **functionname_ptr)
1999-05-03 09:29:11 +02:00
{
const char *filename;
asymbol *func, *file;
1999-05-03 09:29:11 +02:00
bfd_vma low_func;
asymbol **p;
/* ??? Given multiple file symbols, it is impossible to reliably
choose the right file name for global symbols. File symbols are
local symbols, and thus all file symbols must sort before any
global symbols. The ELF spec may be interpreted to say that a
file symbol must sort before other local symbols, but currently
ld -r doesn't do this. So, for ld -r output, it is possible to
make a better choice of file name for local symbols by ignoring
file symbols appearing after a given local symbol. */
enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
if (symbols == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
filename = NULL;
func = NULL;
file = NULL;
1999-05-03 09:29:11 +02:00
low_func = 0;
state = nothing_seen;
1999-05-03 09:29:11 +02:00
for (p = symbols; *p != NULL; p++)
{
asymbol *sym = *p;
asection *code_sec;
bfd_vma code_off;
1999-05-03 09:29:11 +02:00
if ((sym->flags & BSF_FILE) != 0)
1999-05-03 09:29:11 +02:00
{
file = sym;
if (state == symbol_seen)
state = file_after_symbol_seen;
continue;
}
if (bed->maybe_function_sym (sym, &code_sec, &code_off)
&& code_sec == section
&& code_off >= low_func
&& code_off <= offset)
{
func = sym;
low_func = code_off;
filename = NULL;
if (file != NULL
&& ((sym->flags & BSF_LOCAL) != 0
|| state != file_after_symbol_seen))
filename = bfd_asymbol_name (file);
1999-05-03 09:29:11 +02:00
}
if (state == nothing_seen)
state = symbol_seen;
1999-05-03 09:29:11 +02:00
}
if (func == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
2001-02-14 20:58:45 +01:00
if (filename_ptr)
*filename_ptr = filename;
if (functionname_ptr)
*functionname_ptr = bfd_asymbol_name (func);
return TRUE;
2001-02-14 20:58:45 +01:00
}
/* Find the nearest line to a particular section and offset,
for error reporting. */
bfd_boolean
_bfd_elf_find_nearest_line (bfd *abfd,
asection *section,
asymbol **symbols,
bfd_vma offset,
const char **filename_ptr,
const char **functionname_ptr,
unsigned int *line_ptr)
2001-02-14 20:58:45 +01:00
{
bfd_boolean found;
2001-02-14 20:58:45 +01:00
if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
filename_ptr, functionname_ptr,
line_ptr))
2001-02-14 20:58:45 +01:00
{
if (!*functionname_ptr)
elf_find_function (abfd, section, symbols, offset,
*filename_ptr ? NULL : filename_ptr,
functionname_ptr);
return TRUE;
2001-02-14 20:58:45 +01:00
}
2011-09-30 Tristan Gingold <gingold@adacore.com> * dwarf2.c (struct dwarf2_debug): Add field debug_sections. (read_section): Add sec argument. Adjust the code to get section names from it. (read_indirect_string): Adjust call to read_section. (read_abbrevs): Ditto. (decode_line_info): Ditto. (read_debug_ranges): Ditto. (DWARF2_DEBUG_INFO, DWARF2_COMPRESSED_DEBUG_INFO): Remove. (find_debug_info): Add debug_sections parameter. Use it instead the above macros. (place_sections): Get section names from stash. (find_line): Add debug_sections argument. Initialize debug_sections field of stash from it. Adjust calls to find_debug_info. (_bfd_dwarf2_find_nearest_line): Add debug_sections argument. Adjust call to find_line. (_bfd_dwarf2_find_line): Adjust call to find_line. * libcoff-in.h (struct dwarf_debug_section): New declaration. (coff_find_nearest_line_with_names): Likewise. * libcoff.h: Regenerate. * libbfd-in.h (struct dwarf_debug_section): Move declaration. (dwarf_debug_sections): Likewise. (_bfd_dwarf2_find_nearest_line): Add debug_sections argument. * libbfd.h: Regenerate. * elf.c (_bfd_elf_find_nearest_line): Adjust call to _bfd_dwarf2_find_nearest_line. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Ditto. * elf64-alpha.c (elf64_alpha_find_nearest_line): Ditto. * elf32-arm.c (elf32_arm_find_nearest_line): Ditto. * coffgen.c (coff_find_nearest_line_with_names): New function. (coff_find_nearest_line): Calls coff_find_nearest_line_with_names. * coff-rs6000.c (xcoff_debug_sections): New constant. (xcoff_find_nearest_line): New function. (rs6000coff_vec): Use xcoff_find_nearest_line. (pmac_xcoff_vec): Ditto.
2011-09-30 12:39:45 +02:00
if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
section, symbols, offset,
filename_ptr, functionname_ptr,
line_ptr, 0,
&elf_tdata (abfd)->dwarf2_find_line_info))
2001-02-14 20:58:45 +01:00
{
if (!*functionname_ptr)
elf_find_function (abfd, section, symbols, offset,
*filename_ptr ? NULL : filename_ptr,
functionname_ptr);
return TRUE;
2001-02-14 20:58:45 +01:00
}
if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
&found, filename_ptr,
functionname_ptr, line_ptr,
&elf_tdata (abfd)->line_info))
return FALSE;
if (found && (*functionname_ptr || *line_ptr))
return TRUE;
2001-02-14 20:58:45 +01:00
if (symbols == NULL)
return FALSE;
2001-02-14 20:58:45 +01:00
if (! elf_find_function (abfd, section, symbols, offset,
filename_ptr, functionname_ptr))
return FALSE;
2001-02-14 20:58:45 +01:00
1999-05-03 09:29:11 +02:00
*line_ptr = 0;
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Find the line for a symbol. */
bfd_boolean
_bfd_elf_find_line (bfd *abfd, asymbol **symbols, asymbol *symbol,
const char **filename_ptr, unsigned int *line_ptr)
{
return _bfd_dwarf2_find_line (abfd, symbols, symbol,
filename_ptr, line_ptr, 0,
&elf_tdata (abfd)->dwarf2_find_line_info);
}
Approved by nickc@redhat.com 2005-05-23 Fred Fish <fnf@specifixinc.com> * dwarf2.c (struct dwarf2_debug): Add inliner_chain member. (struct funcinfo): Add caller_func, caller_file, caller_line. tag, and nesting_level members. (lookup_address_in_function_table): Change first passed parameter from "struct funcinfo *" to "struct comp_unit *". (lookup_address_in_function_table): Dereference unit to find function table. (lookup_address_in_function_table): Traverse the function list to create a chain of inlined functions back to the first non inlined function. (scan_unit_for_functions): Remember tag and nesting level. Handle DW_AT_call_file and DW_AT_call_line. (comp_unit_find_nearest_line): Adjust lookup_address_in_function_table call to pass unit pointer instead of function table pointer. For inlined functions, save pointer to the inliner chain. (_bfd_dwarf2_find_nearest_line): Initialize inliner_chain to NULL. (_bfd_dwarf2_find_inliner_info): New function that returns information from the inliner chain after a call to bfd_find_nearest_line. * bfd.c (bfd_find_inliner_info): Define using BFD_SEND. * targets.c (BFD_JUMP_TABLE_SYMBOLS): Add entry for NAME##_find_inliner_info. (bfd_target): Add _bfd_find_inliner_info. * bfd-in2.h: Regenerate. * libbfd-in.h (_bfd_nosymbols_find_inliner_info): Define as macro that always returns bfd_false. (_bfd_dwarf2_find_inliner_info): Declare. * libbfd.h: Regenerate. * elf32-arm.c (elf32_arm_find_inliner_info): New function that calls _bfd_dwarf2_find_inliner_info. (bfd_elf32_find_inliner_info): Define to elf32_arm_find_inliner_info. * elfxx-mips.c (_bfd_mips_elf_find_inliner_info): New function that calls _bfd_dwarf2_find_inliner_info. * elfxx-mips.h (_bfd_mips_elf_find_inliner_info): Declare. * elfn32-mips.c (bfd_elf32_find_inliner_info): Define to _bfd_mips_elf_find_inliner_info. * elf64-mips.c (bfd_elf64_find_inliner_info): Ditto. * elf32-mips.c (bfd_elf32_find_inliner_info): Ditto. * elf.c (_bfd_elf_find_inliner_info): New function that calls _bfd_dwarf2_find_inliner_info. * elf-bfd.h (_bfd_elf_find_inliner_info): Declare. * elfxx-target.h (bfd_elfNN_find_inliner_info): Define to _bfd_elf_find_inliner_info. * coffgen.c (coff_find_inliner_info): New function that calls _bfd_dwarf2_find_inliner_info. * libcoff-in.h (coff_find_inliner_info): Declare. * libcoff.h: Regenerate. * coff-rs6000.c (rs6000coff_vec): Add coff_find_inliner_info. (pmac_xcoff_vec) Ditto. * coff64-rs6000.c (rs6000coff64_vec): Ditto. (aix5coff64_vec): Ditto. * aout-target.h (MY_find_inliner_info): Define as _bfd_nosymbols_find_inliner_info. * aout-tic30.c (MY_find_inliner_info): Ditto. * binary.c (binary_find_inliner_info): Ditto. * i386msdos.c (msdos_find_inliner_info): Ditto. * ihex.c (ihex_find_inliner_info): Ditto. * libaout.h (aout_32_find_inliner_info): Ditto. * libecoff.h (_bfd_ecoff_find_inliner_info): Ditto. * mach-o.c (bfd_mach_o_find_inliner_info): Ditto. * mmo.c (mmo_find_inliner_info): Ditto. * nlm-target.h (nlm_find_inliner_info): Ditto. * pef.c (bfd_pef_find_inliner_info): Ditto. * ppcboot.c (ppcboot_find_inliner_info): Ditto. * srec.c (srec_find_inliner_info): Ditto. * tekhex.c (tekhex_find_inliner_info): Ditto. * versados.c (versados_find_inliner_info): Ditto. * xsym.c (bfd_sym_find_inliner_info): Ditto. * ieee.c (ieee_find_inliner_info): New function that always returns FALSE. * oasys.c (oasys_find_inliner_info): Ditto. * vms.c (vms_find_inliner_info): Ditto.
2005-05-23 19:44:55 +02:00
/* After a call to bfd_find_nearest_line, successive calls to
bfd_find_inliner_info can be used to get source information about
each level of function inlining that terminated at the address
passed to bfd_find_nearest_line. Currently this is only supported
for DWARF2 with appropriate DWARF3 extensions. */
bfd_boolean
_bfd_elf_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,
& elf_tdata (abfd)->dwarf2_find_line_info);
return found;
}
1999-05-03 09:29:11 +02:00
int
bfd/ * elf-bfd.h (struct elf_backend_data): Add bfd_link_info pointer parameter. (_bfd_elf_sizeof_headers): Replace bfd_boolean param with bfd_link_info pointer. * targets.c (struct bfd_target <_bfd_sizeof_headers>): Likewise. * bfd.c (bfd_sizeof_headers): Tweak param name. * aout-adobe.c (aout_adobe_sizeof_headers): Adjust. * aoutx.h (NAME (aout, sizeof_headers)): Adjust. * binary.c (binary_sizeof_headers): Adjust. * bout.c (b_out_sizeof_headers): Adjust. * coff-rs6000.c (_bfd_xcoff_sizeof_headers): Adjust. * coff64-rs6000.c (xcoff64_sizeof_headers): Adjust. * coffgen.c (coff_sizeof_headers): Adjust. * ecoff.c (_bfd_ecoff_sizeof_headers): Adjust. (ecoff_compute_section_file_positions): Adjust. (_bfd_ecoff_write_object_contents): Adjust. * elf.c (get_program_header_size, _bfd_elf_sizeof_headers): Adjust. * elf32-arm.c (elf32_arm_additional_program_headers): Adjust. * elf32-i370.c (elf_backend_additional_program_headers): Adjust. * elf32-ppc.c (ppc_elf_additional_program_headers): Adjust. * elf64-hppa.c (elf64_hppa_additional_program_headers): Adjust. * elf64-x86-64.c (elf64_x86_64_additional_program_headers): Adjust. * elfxx-ia64.c (elfNN_ia64_additional_program_headers): Adjust. * elfxx-mips.c (_bfd_mips_elf_additional_program_headers): Adjust. * elfxx-mips.h (_bfd_mips_elf_additional_program_headers): Adjust. * i386msdos.c: Convert to ISO C. (msdos_sizeof_headers): Adjust. * i386os9k.c: Convert to ISO C. (os9k_sizeof_headers): Adjust. * ieee.c (ieee_sizeof_headers): Adjust. * ihex.c (ihex_sizeof_headers): Adjust. * libaout.h (NAME (aout, sizeof_headers)): Adjust. * libbfd-in.h (_bfd_nolink_sizeof_headers): Adjust. * libcoff-in.h (coff_sizeof_headers): Adjust. * libecoff.h (_bfd_ecoff_sizeof_headers): Adjust. * mach-o.c (bfd_mach_o_sizeof_headers): Adjust. * mmo.c (mmo_sizeof_headers): Adjust. * oasys.c (oasys_sizeof_headers): Adjust. * pdp11.c (NAME (aout, sizeof_headers)): Adjust. * pef.c (bfd_pef_sizeof_headers): Adjust. * ppcboot.c (ppcboot_sizeof_headers): Adjust. * som.c (som_sizeof_headers): Adjust. * srec.c (srec_sizeof_headers): Adjust. * tekhex.c (tekhex_sizeof_headers): Adjust. * versados.c (versados_sizeof_headers): Adjust. * vms.c (vms_sizeof_headers): Adjust. * xcoff-target.h (_bfd_xcoff_sizeof_headers): Adjust. * xsym.c (bfd_sym_sizeof_headers): Adjust. * xsym.h (bfd_sym_sizeof_headers): Adjust. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * libcoff.h: Regenerate. ld/ * ldexp.c (fold_name): Adjust bfd_sizeof_headers call.
2006-06-19 15:17:44 +02:00
_bfd_elf_sizeof_headers (bfd *abfd, struct bfd_link_info *info)
1999-05-03 09:29:11 +02:00
{
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
int ret = bed->s->sizeof_ehdr;
1999-05-03 09:29:11 +02:00
bfd/ * elf-bfd.h (struct elf_backend_data): Add bfd_link_info pointer parameter. (_bfd_elf_sizeof_headers): Replace bfd_boolean param with bfd_link_info pointer. * targets.c (struct bfd_target <_bfd_sizeof_headers>): Likewise. * bfd.c (bfd_sizeof_headers): Tweak param name. * aout-adobe.c (aout_adobe_sizeof_headers): Adjust. * aoutx.h (NAME (aout, sizeof_headers)): Adjust. * binary.c (binary_sizeof_headers): Adjust. * bout.c (b_out_sizeof_headers): Adjust. * coff-rs6000.c (_bfd_xcoff_sizeof_headers): Adjust. * coff64-rs6000.c (xcoff64_sizeof_headers): Adjust. * coffgen.c (coff_sizeof_headers): Adjust. * ecoff.c (_bfd_ecoff_sizeof_headers): Adjust. (ecoff_compute_section_file_positions): Adjust. (_bfd_ecoff_write_object_contents): Adjust. * elf.c (get_program_header_size, _bfd_elf_sizeof_headers): Adjust. * elf32-arm.c (elf32_arm_additional_program_headers): Adjust. * elf32-i370.c (elf_backend_additional_program_headers): Adjust. * elf32-ppc.c (ppc_elf_additional_program_headers): Adjust. * elf64-hppa.c (elf64_hppa_additional_program_headers): Adjust. * elf64-x86-64.c (elf64_x86_64_additional_program_headers): Adjust. * elfxx-ia64.c (elfNN_ia64_additional_program_headers): Adjust. * elfxx-mips.c (_bfd_mips_elf_additional_program_headers): Adjust. * elfxx-mips.h (_bfd_mips_elf_additional_program_headers): Adjust. * i386msdos.c: Convert to ISO C. (msdos_sizeof_headers): Adjust. * i386os9k.c: Convert to ISO C. (os9k_sizeof_headers): Adjust. * ieee.c (ieee_sizeof_headers): Adjust. * ihex.c (ihex_sizeof_headers): Adjust. * libaout.h (NAME (aout, sizeof_headers)): Adjust. * libbfd-in.h (_bfd_nolink_sizeof_headers): Adjust. * libcoff-in.h (coff_sizeof_headers): Adjust. * libecoff.h (_bfd_ecoff_sizeof_headers): Adjust. * mach-o.c (bfd_mach_o_sizeof_headers): Adjust. * mmo.c (mmo_sizeof_headers): Adjust. * oasys.c (oasys_sizeof_headers): Adjust. * pdp11.c (NAME (aout, sizeof_headers)): Adjust. * pef.c (bfd_pef_sizeof_headers): Adjust. * ppcboot.c (ppcboot_sizeof_headers): Adjust. * som.c (som_sizeof_headers): Adjust. * srec.c (srec_sizeof_headers): Adjust. * tekhex.c (tekhex_sizeof_headers): Adjust. * versados.c (versados_sizeof_headers): Adjust. * vms.c (vms_sizeof_headers): Adjust. * xcoff-target.h (_bfd_xcoff_sizeof_headers): Adjust. * xsym.c (bfd_sym_sizeof_headers): Adjust. * xsym.h (bfd_sym_sizeof_headers): Adjust. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * libcoff.h: Regenerate. ld/ * ldexp.c (fold_name): Adjust bfd_sizeof_headers call.
2006-06-19 15:17:44 +02:00
if (!info->relocatable)
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
{
bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (phdr_size == (bfd_size_type) -1)
{
struct elf_segment_map *m;
phdr_size = 0;
for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
phdr_size += bed->s->sizeof_phdr;
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
if (phdr_size == 0)
phdr_size = get_program_header_size (abfd, info);
}
bfd/ * elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
2006-06-20 04:22:16 +02:00
elf_tdata (abfd)->program_header_size = phdr_size;
ret += phdr_size;
}
1999-05-03 09:29:11 +02:00
return ret;
}
bfd_boolean
_bfd_elf_set_section_contents (bfd *abfd,
sec_ptr section,
* aout-adobe.c (aout_adobe_set_section_contents): Constify location. * aoutx.h (NAME(aout,set_section_contents)): Ditto. * bfd-in2.h: Regenerate. * binary.c (binary_set_section_contents): Ditto. * bout.c (b_out_set_section_contents): Ditto. * coff-tic54x.c (tic54x_set_section_contents): Ditto. * coffcode.h (coff_set_section_contents): Ditto. * ecoff.c (_bfd_ecoff_set_section_contents): Ditto. * elf-bfd.h (_bfd_elf_set_section_contents): Ditto. * elf.c (_bfd_elf_set_section_contents): Ditto. * elfxx-mips.c (_bfd_mips_elf_set_section_contents): Ditto. * elfxx-mips.h (_bfd_mips_elf_set_section_contents): Ditto. * i386msdos.c (msdos_set_section_contents): Ditto. * ieee.c (ieee_set_section_contents): Ditto. * ihex.c (ihex_set_section_contents): Ditto. * libaout.h (NAME(aout,set_section_contents)): Ditto. * libbfd-in.h (_bfd_nowrite_set_section_contents): Ditto. (_bfd_generic_set_section_contents): Ditto. * libbfd.h: Regenerate. * libbfd.c (_bfd_generic_set_section_contents): Ditto. * libecoff.h (_bfd_ecoff_set_section_contents): Ditto. * libnlm.h (nlmNAME(set_section_contents)): Ditto. (struct nlm_backend_data <nlm_mangle_relocs>): Ditto. * mmo.c (mmo_set_section_contents): Ditto. * nlm32-alpha.c (nlm_alpha_mangle_relocs): Ditto. * nlm32-i386.c (nlm_i386_mangle_relocs): Ditto. * nlm32-ppc.c (nlm_powerpc_mangle_relocs): Ditto. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Ditto. * nlmcode.h (nlm_set_section_contents): Ditto. * oasys.c (oasys_set_section_contents): Ditto. * pdp11.c (NAME(aout,set_section_contents)): Ditto. * ppcboot.c (ppcboot_set_section_contents): Ditto. * srec.c (srec_set_section_contents): Ditto. * targets.c (BFD_JUMP_TABLE_WRITE <_bfd_set_section_contents>): Ditto. * tekhex.c (tekhex_set_section_contents): Ditto. (move_section_contents): Ditto. * versados.c (versados_set_section_contents): Ditto. * vms-misc.c (_bfd_save_vms_section): Ditto. * vms.c (vms_set_section_contents): Ditto. * vms.h (_bfd_save_vms_section): Ditto.
2003-11-04 11:41:52 +01:00
const void *location,
file_ptr offset,
bfd_size_type count)
1999-05-03 09:29:11 +02:00
{
Elf_Internal_Shdr *hdr;
bfd_signed_vma pos;
1999-05-03 09:29:11 +02:00
if (! abfd->output_has_begun
&& ! _bfd_elf_compute_section_file_positions (abfd, NULL))
return FALSE;
1999-05-03 09:29:11 +02:00
hdr = &elf_section_data (section)->this_hdr;
pos = hdr->sh_offset + offset;
if (bfd_seek (abfd, pos, SEEK_SET) != 0
|| bfd_bwrite (location, count, abfd) != count)
return FALSE;
1999-05-03 09:29:11 +02:00
return TRUE;
1999-05-03 09:29:11 +02:00
}
void
_bfd_elf_no_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
arelent *cache_ptr ATTRIBUTE_UNUSED,
Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
1999-05-03 09:29:11 +02:00
{
abort ();
}
/* Try to convert a non-ELF reloc into an ELF one. */
bfd_boolean
_bfd_elf_validate_reloc (bfd *abfd, arelent *areloc)
1999-05-03 09:29:11 +02:00
{
/* Check whether we really have an ELF howto. */
1999-05-03 09:29:11 +02:00
if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec)
{
bfd_reloc_code_real_type code;
reloc_howto_type *howto;
/* Alien reloc: Try to determine its type to replace it with an
equivalent ELF reloc. */
1999-05-03 09:29:11 +02:00
if (areloc->howto->pc_relative)
{
switch (areloc->howto->bitsize)
{
case 8:
code = BFD_RELOC_8_PCREL;
break;
case 12:
code = BFD_RELOC_12_PCREL;
break;
case 16:
code = BFD_RELOC_16_PCREL;
break;
case 24:
code = BFD_RELOC_24_PCREL;
break;
case 32:
code = BFD_RELOC_32_PCREL;
break;
case 64:
code = BFD_RELOC_64_PCREL;
break;
default:
goto fail;
}
howto = bfd_reloc_type_lookup (abfd, code);
if (areloc->howto->pcrel_offset != howto->pcrel_offset)
{
if (howto->pcrel_offset)
areloc->addend += areloc->address;
else
areloc->addend -= areloc->address; /* addend is unsigned!! */
}
}
else
{
switch (areloc->howto->bitsize)
{
case 8:
code = BFD_RELOC_8;
break;
case 14:
code = BFD_RELOC_14;
break;
case 16:
code = BFD_RELOC_16;
break;
case 26:
code = BFD_RELOC_26;
break;
case 32:
code = BFD_RELOC_32;
break;
case 64:
code = BFD_RELOC_64;
break;
default:
goto fail;
}
howto = bfd_reloc_type_lookup (abfd, code);
}
if (howto)
areloc->howto = howto;
else
goto fail;
}
return TRUE;
1999-05-03 09:29:11 +02:00
fail:
(*_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 05:16:01 +02:00
(_("%B: unsupported relocation type %s"),
abfd, areloc->howto->name);
1999-05-03 09:29:11 +02:00
bfd_set_error (bfd_error_bad_value);
return FALSE;
1999-05-03 09:29:11 +02:00
}
bfd_boolean
_bfd_elf_close_and_cleanup (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
struct elf_obj_tdata *tdata = elf_tdata (abfd);
if (bfd_get_format (abfd) == bfd_object && tdata != NULL)
1999-05-03 09:29:11 +02:00
{
if (elf_shstrtab (abfd) != NULL)
* Makefile.am (BFD32_BACKENDS): Add elf-strtab.lo. (BFD32_BACKENDS_CFILES): Add elf-strtab.c. (elf-strtab.lo): Add rule. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-strtab.lo. * configure: Rebuilt. * elf-bfd.h (elf_strtab_hash): Forward declare. (struct elf_link_hash_table): Change dynstr type to struct elf_strtab_hash *. (struct elf_obj_tdata): Change strtab_ptr type to struct elf_strtab_hash *. (_bfd_elf_strtab_init, _bfd_elf_strtab_free, _bfd_elf_strtab_add, _bfd_elf_strtab_addref, _bfd_elf_strtab_delref, _bfd_elf_strtab_clear_all_refs, _bfd_elf_strtab_size, _bfd_elf_strtab_offset, _bfd_elf_strtab_emit, _bfd_elf_strtab_finalize): New prototypes. * elf-strtab.c: New file. * elflink.h (elf_link_add_object_symbols): Use _bfd_elf_strtab_add and _bfd_elf_strtab_size instead of _bfd_stringtab calls. Call _bfd_elf_strtab_delref if DT_NEEDED entry is not needed or when forcing dynamic symbol to local. (elf_link_create_dynamic_sections): Call _bfd_elf_strtab_init instead of elf_stringtab_init. (elf_link_record_local_dynamic_symbol): Likewise, change dynstr type. Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. (size_dynamic_sections): Use _bfd_elf_strtab functions instead of _bfd_stringtab calls. For DT_RUNPATH and Verdaux vda_name fields, call _bfd_elf_strtab_addref. Call elf_finalize_dynstr. (elf_adjust_dynstr_offsets, elf_finalize_dynstr): New functions. (elf_fix_symbol_flags): Call _bfd_elf_strtab_delref when forcing dynamic symbol to local. (elf_link_assign_sym_version): Likewise. (elf_bfd_final_link): Call _bfd_elf_strtab_emit instead of _bfd_stringtab_emit. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Change dynstr type. Call _bfd_elf_strtab functions instead of _bfd_stringtab functions. * elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_init_reloc_shdr): Likewise. (elf_fake_sections): Likewise. (assign_section_numbers): Call _bfd_elf_strtab_clear_all_refs on shstrtab hash table, call _bfd_elf_strtab_addref on each section name in the output. Call _bfd_elf_strtab_finalize and use _bfd_elf_strtab_offset to finalize sh_name section header fields. (_bfd_elf_compute_section_file_positions): Use _bfd_elf_strtab_size instead of _bfd_stringtab_size. (prep_headers): Change shstrtab type. Use _bfd_elf_strtab calls instead of _bfd_stringtab calls.
2001-11-07 17:50:38 +01:00
_bfd_elf_strtab_free (elf_shstrtab (abfd));
_bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info);
1999-05-03 09:29:11 +02:00
}
return _bfd_generic_close_and_cleanup (abfd);
}
/* For Rel targets, we encode meaningful data for BFD_RELOC_VTABLE_ENTRY
in the relocation's offset. Thus we cannot allow any sort of sanity
range-checking to interfere. There is nothing else to do in processing
this reloc. */
bfd_reloc_status_type
_bfd_elf_rel_vtable_reloc_fn
(bfd *abfd ATTRIBUTE_UNUSED, arelent *re ATTRIBUTE_UNUSED,
struct bfd_symbol *symbol ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED, asection *is ATTRIBUTE_UNUSED,
bfd *obfd ATTRIBUTE_UNUSED, char **errmsg ATTRIBUTE_UNUSED)
1999-05-03 09:29:11 +02:00
{
return bfd_reloc_ok;
}
/* Elf core file support. Much of this only works on native
toolchains, since we rely on knowing the
machine-dependent procfs structure in order to pick
out details about the corefile. */
1999-05-03 09:29:11 +02:00
#ifdef HAVE_SYS_PROCFS_H
/* Needed for new procfs interface on sparc-solaris. */
# define _STRUCTURED_PROC 1
1999-05-03 09:29:11 +02:00
# include <sys/procfs.h>
#endif
2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 bfd/ * bfd-in2.h: Regenerate. * corefile.c (bfd_core_file_pid): New. * targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid. (struct bfd_target) <_core_file_pid>: New. * libbfd-in.h (_bfd_nocore_core_file_pid): Declare. * libbfd.c (_bfd_nocore_core_file_pid): New. * elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid): Declare. * elfcode.h (elf_core_file_pid): New define. * elfcore.h (elf_core_file_pid): New function. * elf.c (elfcore_make_pid): Rewrite. (elfcore_grok_prstatus): Only set core_pid if not set yet. (elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to getting the lwpid from prstat.pr_pid. * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf64_x86_64_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf_i386_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * plugin.c (bfd_plugin_core_file_pid): New function. * aout-target.h (MY_core_file_pid): Define. * aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines. * coff-rs6000.c (coff_core_file_pid): New define. (rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE. * coff64-rs6000.c (coff_core_file_pid): New define. (rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE. (xcoff64_core_file_pid): New define. (aix5coff64_vec): Use BFD_JUMP_TABLE_CORE. * mach-o-target.c (bfd_mach_o_core_file_pid): New define. * aix386-core.c (aix386_core_file_pid): New define. * hppabsd-core.c (hppabsd_core_core_file_pid): New define. * hpux-core.c (hpux_core_core_file_pid): New define. * irix-core.c (irix_core_core_file_pid): New define. * lynx-core.c (lynx_core_file_pid): New define. * osf-core.c (osf_core_core_file_pid): New define. * ptrace-core.c (ptrace_unix_core_file_pid): New define. * sco5-core.c (sco5_core_file_pid): New define. * xcoff-target.h (coff_core_file_pid): New define. * netbsd-core.c (netbsd_core_core_file_pid): New define. gdb/ 2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 gdb/ * corelow.c (add_to_thread_list): Don't use gdbarch_core_reg_section_encodes_pid. Use bfd_core_file_pid. (get_core_register_section): Don't use gdbarch_core_reg_section_encodes_pid. * gdbarch.sh (core_reg_section_encodes_pid): Delete. * gdbarch.h, gdbarch.c: Regenerate. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set gdbarch_core_reg_section_encodes_pid. * i386-sol2-tdep.c (i386_sol2_init_abi): Ditto. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
2010-08-18 14:24:13 +02:00
/* Return a PID that identifies a "thread" for threaded cores, or the
PID of the main process for non-threaded cores. */
1999-05-03 09:29:11 +02:00
static int
elfcore_make_pid (bfd *abfd)
1999-05-03 09:29:11 +02:00
{
2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 bfd/ * bfd-in2.h: Regenerate. * corefile.c (bfd_core_file_pid): New. * targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid. (struct bfd_target) <_core_file_pid>: New. * libbfd-in.h (_bfd_nocore_core_file_pid): Declare. * libbfd.c (_bfd_nocore_core_file_pid): New. * elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid): Declare. * elfcode.h (elf_core_file_pid): New define. * elfcore.h (elf_core_file_pid): New function. * elf.c (elfcore_make_pid): Rewrite. (elfcore_grok_prstatus): Only set core_pid if not set yet. (elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to getting the lwpid from prstat.pr_pid. * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf64_x86_64_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf_i386_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * plugin.c (bfd_plugin_core_file_pid): New function. * aout-target.h (MY_core_file_pid): Define. * aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines. * coff-rs6000.c (coff_core_file_pid): New define. (rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE. * coff64-rs6000.c (coff_core_file_pid): New define. (rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE. (xcoff64_core_file_pid): New define. (aix5coff64_vec): Use BFD_JUMP_TABLE_CORE. * mach-o-target.c (bfd_mach_o_core_file_pid): New define. * aix386-core.c (aix386_core_file_pid): New define. * hppabsd-core.c (hppabsd_core_core_file_pid): New define. * hpux-core.c (hpux_core_core_file_pid): New define. * irix-core.c (irix_core_core_file_pid): New define. * lynx-core.c (lynx_core_file_pid): New define. * osf-core.c (osf_core_core_file_pid): New define. * ptrace-core.c (ptrace_unix_core_file_pid): New define. * sco5-core.c (sco5_core_file_pid): New define. * xcoff-target.h (coff_core_file_pid): New define. * netbsd-core.c (netbsd_core_core_file_pid): New define. gdb/ 2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 gdb/ * corelow.c (add_to_thread_list): Don't use gdbarch_core_reg_section_encodes_pid. Use bfd_core_file_pid. (get_core_register_section): Don't use gdbarch_core_reg_section_encodes_pid. * gdbarch.sh (core_reg_section_encodes_pid): Delete. * gdbarch.h, gdbarch.c: Regenerate. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set gdbarch_core_reg_section_encodes_pid. * i386-sol2-tdep.c (i386_sol2_init_abi): Ditto. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
2010-08-18 14:24:13 +02:00
int pid;
pid = elf_tdata (abfd)->core_lwpid;
if (pid == 0)
pid = elf_tdata (abfd)->core_pid;
return pid;
1999-05-03 09:29:11 +02:00
}
/* If there isn't a section called NAME, make one, using
data from SECT. Note, this function will generate a
reference to NAME, so you shouldn't deallocate or
overwrite it. */
1999-05-03 09:29:11 +02:00
static bfd_boolean
elfcore_maybe_make_sect (bfd *abfd, char *name, asection *sect)
1999-05-03 09:29:11 +02:00
{
asection *sect2;
1999-05-03 09:29:11 +02:00
if (bfd_get_section_by_name (abfd, name) != NULL)
return TRUE;
1999-05-03 09:29:11 +02:00
sect2 = bfd_make_section_with_flags (abfd, name, sect->flags);
1999-05-03 09:29:11 +02:00
if (sect2 == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
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 06:46:28 +02:00
sect2->size = sect->size;
1999-05-03 09:29:11 +02:00
sect2->filepos = sect->filepos;
sect2->alignment_power = sect->alignment_power;
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Create a pseudosection containing SIZE bytes at FILEPOS. This
actually creates up to two pseudosections:
- For the single-threaded case, a section named NAME, unless
such a section already exists.
- For the multi-threaded case, a section named "NAME/PID", where
PID is elfcore_make_pid (abfd).
Both pseudosections have identical contents. */
bfd_boolean
_bfd_elfcore_make_pseudosection (bfd *abfd,
char *name,
size_t size,
ufile_ptr filepos)
{
char buf[100];
char *threaded_name;
2002-06-25 11:40:45 +02:00
size_t len;
asection *sect;
/* Build the section name. */
sprintf (buf, "%s/%d", name, elfcore_make_pid (abfd));
2002-06-25 11:40:45 +02:00
len = strlen (buf) + 1;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
threaded_name = (char *) bfd_alloc (abfd, len);
if (threaded_name == NULL)
return FALSE;
2002-06-25 11:40:45 +02:00
memcpy (threaded_name, buf, len);
sect = bfd_make_section_anyway_with_flags (abfd, threaded_name,
SEC_HAS_CONTENTS);
if (sect == NULL)
return FALSE;
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 06:46:28 +02:00
sect->size = size;
sect->filepos = filepos;
sect->alignment_power = 2;
return elfcore_maybe_make_sect (abfd, name, sect);
}
1999-05-03 09:29:11 +02:00
/* prstatus_t exists on:
solaris 2.5+
1999-05-03 09:29:11 +02:00
linux 2.[01] + glibc
unixware 4.2
*/
#if defined (HAVE_PRSTATUS_T)
static bfd_boolean
elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
1999-05-03 09:29:11 +02:00
{
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 06:46:28 +02:00
size_t size;
int offset;
1999-05-03 09:29:11 +02:00
if (note->descsz == sizeof (prstatus_t))
{
prstatus_t prstat;
1999-05-03 09:29:11 +02:00
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 06:46:28 +02:00
size = sizeof (prstat.pr_reg);
offset = offsetof (prstatus_t, pr_reg);
memcpy (&prstat, note->descdata, sizeof (prstat));
1999-05-03 09:29:11 +02:00
/* Do not overwrite the core signal if it
has already been set by another thread. */
if (elf_tdata (abfd)->core_signal == 0)
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 bfd/ * bfd-in2.h: Regenerate. * corefile.c (bfd_core_file_pid): New. * targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid. (struct bfd_target) <_core_file_pid>: New. * libbfd-in.h (_bfd_nocore_core_file_pid): Declare. * libbfd.c (_bfd_nocore_core_file_pid): New. * elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid): Declare. * elfcode.h (elf_core_file_pid): New define. * elfcore.h (elf_core_file_pid): New function. * elf.c (elfcore_make_pid): Rewrite. (elfcore_grok_prstatus): Only set core_pid if not set yet. (elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to getting the lwpid from prstat.pr_pid. * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf64_x86_64_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf_i386_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * plugin.c (bfd_plugin_core_file_pid): New function. * aout-target.h (MY_core_file_pid): Define. * aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines. * coff-rs6000.c (coff_core_file_pid): New define. (rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE. * coff64-rs6000.c (coff_core_file_pid): New define. (rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE. (xcoff64_core_file_pid): New define. (aix5coff64_vec): Use BFD_JUMP_TABLE_CORE. * mach-o-target.c (bfd_mach_o_core_file_pid): New define. * aix386-core.c (aix386_core_file_pid): New define. * hppabsd-core.c (hppabsd_core_core_file_pid): New define. * hpux-core.c (hpux_core_core_file_pid): New define. * irix-core.c (irix_core_core_file_pid): New define. * lynx-core.c (lynx_core_file_pid): New define. * osf-core.c (osf_core_core_file_pid): New define. * ptrace-core.c (ptrace_unix_core_file_pid): New define. * sco5-core.c (sco5_core_file_pid): New define. * xcoff-target.h (coff_core_file_pid): New define. * netbsd-core.c (netbsd_core_core_file_pid): New define. gdb/ 2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 gdb/ * corelow.c (add_to_thread_list): Don't use gdbarch_core_reg_section_encodes_pid. Use bfd_core_file_pid. (get_core_register_section): Don't use gdbarch_core_reg_section_encodes_pid. * gdbarch.sh (core_reg_section_encodes_pid): Delete. * gdbarch.h, gdbarch.c: Regenerate. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set gdbarch_core_reg_section_encodes_pid. * i386-sol2-tdep.c (i386_sol2_init_abi): Ditto. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
2010-08-18 14:24:13 +02:00
if (elf_tdata (abfd)->core_pid == 0)
elf_tdata (abfd)->core_pid = prstat.pr_pid;
1999-05-03 09:29:11 +02:00
/* pr_who exists on:
solaris 2.5+
unixware 4.2
pr_who doesn't exist on:
linux 2.[01]
*/
1999-05-03 09:29:11 +02:00
#if defined (HAVE_PRSTATUS_T_PR_WHO)
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 bfd/ * bfd-in2.h: Regenerate. * corefile.c (bfd_core_file_pid): New. * targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid. (struct bfd_target) <_core_file_pid>: New. * libbfd-in.h (_bfd_nocore_core_file_pid): Declare. * libbfd.c (_bfd_nocore_core_file_pid): New. * elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid): Declare. * elfcode.h (elf_core_file_pid): New define. * elfcore.h (elf_core_file_pid): New function. * elf.c (elfcore_make_pid): Rewrite. (elfcore_grok_prstatus): Only set core_pid if not set yet. (elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to getting the lwpid from prstat.pr_pid. * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf64_x86_64_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf_i386_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * plugin.c (bfd_plugin_core_file_pid): New function. * aout-target.h (MY_core_file_pid): Define. * aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines. * coff-rs6000.c (coff_core_file_pid): New define. (rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE. * coff64-rs6000.c (coff_core_file_pid): New define. (rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE. (xcoff64_core_file_pid): New define. (aix5coff64_vec): Use BFD_JUMP_TABLE_CORE. * mach-o-target.c (bfd_mach_o_core_file_pid): New define. * aix386-core.c (aix386_core_file_pid): New define. * hppabsd-core.c (hppabsd_core_core_file_pid): New define. * hpux-core.c (hpux_core_core_file_pid): New define. * irix-core.c (irix_core_core_file_pid): New define. * lynx-core.c (lynx_core_file_pid): New define. * osf-core.c (osf_core_core_file_pid): New define. * ptrace-core.c (ptrace_unix_core_file_pid): New define. * sco5-core.c (sco5_core_file_pid): New define. * xcoff-target.h (coff_core_file_pid): New define. * netbsd-core.c (netbsd_core_core_file_pid): New define. gdb/ 2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 gdb/ * corelow.c (add_to_thread_list): Don't use gdbarch_core_reg_section_encodes_pid. Use bfd_core_file_pid. (get_core_register_section): Don't use gdbarch_core_reg_section_encodes_pid. * gdbarch.sh (core_reg_section_encodes_pid): Delete. * gdbarch.h, gdbarch.c: Regenerate. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set gdbarch_core_reg_section_encodes_pid. * i386-sol2-tdep.c (i386_sol2_init_abi): Ditto. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
2010-08-18 14:24:13 +02:00
#else
elf_tdata (abfd)->core_lwpid = prstat.pr_pid;
1999-05-03 09:29:11 +02:00
#endif
}
#if defined (HAVE_PRSTATUS32_T)
else if (note->descsz == sizeof (prstatus32_t))
{
/* 64-bit host, 32-bit corefile */
prstatus32_t prstat;
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 06:46:28 +02:00
size = sizeof (prstat.pr_reg);
offset = offsetof (prstatus32_t, pr_reg);
memcpy (&prstat, note->descdata, sizeof (prstat));
/* Do not overwrite the core signal if it
has already been set by another thread. */
if (elf_tdata (abfd)->core_signal == 0)
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 bfd/ * bfd-in2.h: Regenerate. * corefile.c (bfd_core_file_pid): New. * targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid. (struct bfd_target) <_core_file_pid>: New. * libbfd-in.h (_bfd_nocore_core_file_pid): Declare. * libbfd.c (_bfd_nocore_core_file_pid): New. * elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid): Declare. * elfcode.h (elf_core_file_pid): New define. * elfcore.h (elf_core_file_pid): New function. * elf.c (elfcore_make_pid): Rewrite. (elfcore_grok_prstatus): Only set core_pid if not set yet. (elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to getting the lwpid from prstat.pr_pid. * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf64_x86_64_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf_i386_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * plugin.c (bfd_plugin_core_file_pid): New function. * aout-target.h (MY_core_file_pid): Define. * aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines. * coff-rs6000.c (coff_core_file_pid): New define. (rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE. * coff64-rs6000.c (coff_core_file_pid): New define. (rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE. (xcoff64_core_file_pid): New define. (aix5coff64_vec): Use BFD_JUMP_TABLE_CORE. * mach-o-target.c (bfd_mach_o_core_file_pid): New define. * aix386-core.c (aix386_core_file_pid): New define. * hppabsd-core.c (hppabsd_core_core_file_pid): New define. * hpux-core.c (hpux_core_core_file_pid): New define. * irix-core.c (irix_core_core_file_pid): New define. * lynx-core.c (lynx_core_file_pid): New define. * osf-core.c (osf_core_core_file_pid): New define. * ptrace-core.c (ptrace_unix_core_file_pid): New define. * sco5-core.c (sco5_core_file_pid): New define. * xcoff-target.h (coff_core_file_pid): New define. * netbsd-core.c (netbsd_core_core_file_pid): New define. gdb/ 2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 gdb/ * corelow.c (add_to_thread_list): Don't use gdbarch_core_reg_section_encodes_pid. Use bfd_core_file_pid. (get_core_register_section): Don't use gdbarch_core_reg_section_encodes_pid. * gdbarch.sh (core_reg_section_encodes_pid): Delete. * gdbarch.h, gdbarch.c: Regenerate. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set gdbarch_core_reg_section_encodes_pid. * i386-sol2-tdep.c (i386_sol2_init_abi): Ditto. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
2010-08-18 14:24:13 +02:00
if (elf_tdata (abfd)->core_pid == 0)
elf_tdata (abfd)->core_pid = prstat.pr_pid;
/* pr_who exists on:
solaris 2.5+
unixware 4.2
pr_who doesn't exist on:
linux 2.[01]
*/
#if defined (HAVE_PRSTATUS32_T_PR_WHO)
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 bfd/ * bfd-in2.h: Regenerate. * corefile.c (bfd_core_file_pid): New. * targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid. (struct bfd_target) <_core_file_pid>: New. * libbfd-in.h (_bfd_nocore_core_file_pid): Declare. * libbfd.c (_bfd_nocore_core_file_pid): New. * elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid): Declare. * elfcode.h (elf_core_file_pid): New define. * elfcore.h (elf_core_file_pid): New function. * elf.c (elfcore_make_pid): Rewrite. (elfcore_grok_prstatus): Only set core_pid if not set yet. (elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to getting the lwpid from prstat.pr_pid. * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf64_x86_64_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. (elf_i386_grok_psinfo): Extract the the main process's PID, and store it in elf_tdata's core_pid field. * elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to elf_tdata's core_lwpid instead of to core_pid. * plugin.c (bfd_plugin_core_file_pid): New function. * aout-target.h (MY_core_file_pid): Define. * aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines. * coff-rs6000.c (coff_core_file_pid): New define. (rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE. * coff64-rs6000.c (coff_core_file_pid): New define. (rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE. (xcoff64_core_file_pid): New define. (aix5coff64_vec): Use BFD_JUMP_TABLE_CORE. * mach-o-target.c (bfd_mach_o_core_file_pid): New define. * aix386-core.c (aix386_core_file_pid): New define. * hppabsd-core.c (hppabsd_core_core_file_pid): New define. * hpux-core.c (hpux_core_core_file_pid): New define. * irix-core.c (irix_core_core_file_pid): New define. * lynx-core.c (lynx_core_file_pid): New define. * osf-core.c (osf_core_core_file_pid): New define. * ptrace-core.c (ptrace_unix_core_file_pid): New define. * sco5-core.c (sco5_core_file_pid): New define. * xcoff-target.h (coff_core_file_pid): New define. * netbsd-core.c (netbsd_core_core_file_pid): New define. gdb/ 2010-08-18 Pedro Alves <pedro@codesourcery.com> PR corefile/8210 gdb/ * corelow.c (add_to_thread_list): Don't use gdbarch_core_reg_section_encodes_pid. Use bfd_core_file_pid. (get_core_register_section): Don't use gdbarch_core_reg_section_encodes_pid. * gdbarch.sh (core_reg_section_encodes_pid): Delete. * gdbarch.h, gdbarch.c: Regenerate. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set gdbarch_core_reg_section_encodes_pid. * i386-sol2-tdep.c (i386_sol2_init_abi): Ditto. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
2010-08-18 14:24:13 +02:00
#else
elf_tdata (abfd)->core_lwpid = prstat.pr_pid;
#endif
}
#endif /* HAVE_PRSTATUS32_T */
else
{
/* Fail - we don't know how to handle any other
note size (ie. data object type). */
return TRUE;
}
1999-05-03 09:29:11 +02:00
/* Make a ".reg/999" section and a ".reg" section. */
return _bfd_elfcore_make_pseudosection (abfd, ".reg",
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 06:46:28 +02:00
size, note->descpos + offset);
1999-05-03 09:29:11 +02:00
}
#endif /* defined (HAVE_PRSTATUS_T) */
/* Create a pseudosection containing the exact contents of NOTE. */
static bfd_boolean
elfcore_make_note_pseudosection (bfd *abfd,
char *name,
Elf_Internal_Note *note)
1999-05-03 09:29:11 +02:00
{
return _bfd_elfcore_make_pseudosection (abfd, name,
note->descsz, note->descpos);
1999-05-03 09:29:11 +02:00
}
/* There isn't a consistent prfpregset_t across platforms,
but it doesn't matter, because we don't have to pick this
data structure apart. */
static bfd_boolean
elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
}
/* Linux dumps the Intel SSE regs in a note named "LINUX" with a note
type of NT_PRXFPREG. Just include the whole note's contents
literally. */
static bfd_boolean
elfcore_grok_prxfpreg (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
}
/* Linux dumps the Intel XSAVE extended state in a note named "LINUX"
with a note type of NT_X86_XSTATE. Just include the whole note's
contents literally. */
static bfd_boolean
elfcore_grok_xstatereg (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-xstate", note);
}
static bfd_boolean
elfcore_grok_ppc_vmx (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vmx", note);
}
static bfd_boolean
elfcore_grok_ppc_vsx (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vsx", note);
}
static bfd_boolean
elfcore_grok_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-high-gprs", note);
}
static bfd_boolean
elfcore_grok_s390_timer (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-timer", note);
}
static bfd_boolean
elfcore_grok_s390_todcmp (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-todcmp", note);
}
static bfd_boolean
elfcore_grok_s390_todpreg (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-todpreg", note);
}
static bfd_boolean
elfcore_grok_s390_ctrs (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-ctrs", note);
}
static bfd_boolean
elfcore_grok_s390_prefix (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-prefix", note);
}
static bfd_boolean
elfcore_grok_s390_last_break (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-last-break", note);
}
static bfd_boolean
elfcore_grok_s390_system_call (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-s390-system-call", note);
}
static bfd_boolean
elfcore_grok_arm_vfp (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-arm-vfp", note);
}
1999-05-03 09:29:11 +02:00
#if defined (HAVE_PRPSINFO_T)
typedef prpsinfo_t elfcore_psinfo_t;
#if defined (HAVE_PRPSINFO32_T) /* Sparc64 cross Sparc32 */
typedef prpsinfo32_t elfcore_psinfo32_t;
#endif
1999-05-03 09:29:11 +02:00
#endif
#if defined (HAVE_PSINFO_T)
typedef psinfo_t elfcore_psinfo_t;
#if defined (HAVE_PSINFO32_T) /* Sparc64 cross Sparc32 */
typedef psinfo32_t elfcore_psinfo32_t;
#endif
1999-05-03 09:29:11 +02:00
#endif
/* return a malloc'ed copy of a string at START which is at
most MAX bytes long, possibly without a terminating '\0'.
the copy will always have a terminating '\0'. */
1999-05-03 09:29:11 +02:00
char *
_bfd_elfcore_strndup (bfd *abfd, char *start, size_t max)
1999-05-03 09:29:11 +02:00
{
char *dups;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
char *end = (char *) memchr (start, '\0', max);
size_t len;
1999-05-03 09:29:11 +02:00
if (end == NULL)
len = max;
else
len = end - start;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
dups = (char *) bfd_alloc (abfd, len + 1);
if (dups == NULL)
1999-05-03 09:29:11 +02:00
return NULL;
memcpy (dups, start, len);
dups[len] = '\0';
1999-05-03 09:29:11 +02:00
return dups;
1999-05-03 09:29:11 +02:00
}
#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
static bfd_boolean
elfcore_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
1999-05-03 09:29:11 +02:00
{
if (note->descsz == sizeof (elfcore_psinfo_t))
{
elfcore_psinfo_t psinfo;
1999-05-03 09:29:11 +02:00
memcpy (&psinfo, note->descdata, sizeof (psinfo));
1999-05-03 09:29:11 +02:00
#if defined (HAVE_PSINFO_T_PR_PID) || defined (HAVE_PRPSINFO_T_PR_PID)
elf_tdata (abfd)->core_pid = psinfo.pr_pid;
#endif
elf_tdata (abfd)->core_program
= _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
sizeof (psinfo.pr_fname));
1999-05-03 09:29:11 +02:00
elf_tdata (abfd)->core_command
= _bfd_elfcore_strndup (abfd, psinfo.pr_psargs,
sizeof (psinfo.pr_psargs));
}
#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
else if (note->descsz == sizeof (elfcore_psinfo32_t))
{
/* 64-bit host, 32-bit corefile */
elfcore_psinfo32_t psinfo;
memcpy (&psinfo, note->descdata, sizeof (psinfo));
1999-05-03 09:29:11 +02:00
#if defined (HAVE_PSINFO32_T_PR_PID) || defined (HAVE_PRPSINFO32_T_PR_PID)
elf_tdata (abfd)->core_pid = psinfo.pr_pid;
#endif
elf_tdata (abfd)->core_program
= _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
sizeof (psinfo.pr_fname));
elf_tdata (abfd)->core_command
= _bfd_elfcore_strndup (abfd, psinfo.pr_psargs,
sizeof (psinfo.pr_psargs));
}
#endif
else
{
/* Fail - we don't know how to handle any other
note size (ie. data object type). */
return TRUE;
}
1999-05-03 09:29:11 +02:00
/* Note that for some reason, a spurious space is tacked
onto the end of the args in some (at least one anyway)
implementations, so strip it off if it exists. */
1999-05-03 09:29:11 +02:00
{
char *command = elf_tdata (abfd)->core_command;
1999-05-03 09:29:11 +02:00
int n = strlen (command);
if (0 < n && command[n - 1] == ' ')
command[n - 1] = '\0';
}
return TRUE;
1999-05-03 09:29:11 +02:00
}
#endif /* defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T) */
#if defined (HAVE_PSTATUS_T)
static bfd_boolean
elfcore_grok_pstatus (bfd *abfd, Elf_Internal_Note *note)
1999-05-03 09:29:11 +02:00
{
if (note->descsz == sizeof (pstatus_t)
#if defined (HAVE_PXSTATUS_T)
|| note->descsz == sizeof (pxstatus_t)
#endif
)
{
pstatus_t pstat;
1999-05-03 09:29:11 +02:00
memcpy (&pstat, note->descdata, sizeof (pstat));
1999-05-03 09:29:11 +02:00
elf_tdata (abfd)->core_pid = pstat.pr_pid;
}
#if defined (HAVE_PSTATUS32_T)
else if (note->descsz == sizeof (pstatus32_t))
{
/* 64-bit host, 32-bit corefile */
pstatus32_t pstat;
1999-05-03 09:29:11 +02:00
memcpy (&pstat, note->descdata, sizeof (pstat));
1999-05-03 09:29:11 +02:00
elf_tdata (abfd)->core_pid = pstat.pr_pid;
}
#endif
1999-05-03 09:29:11 +02:00
/* Could grab some more details from the "representative"
lwpstatus_t in pstat.pr_lwp, but we'll catch it all in an
NT_LWPSTATUS note, presumably. */
1999-05-03 09:29:11 +02:00
return TRUE;
1999-05-03 09:29:11 +02:00
}
#endif /* defined (HAVE_PSTATUS_T) */
#if defined (HAVE_LWPSTATUS_T)
static bfd_boolean
elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
1999-05-03 09:29:11 +02:00
{
lwpstatus_t lwpstat;
char buf[100];
char *name;
2002-06-25 11:40:45 +02:00
size_t len;
asection *sect;
1999-05-03 09:29:11 +02:00
if (note->descsz != sizeof (lwpstat)
#if defined (HAVE_LWPXSTATUS_T)
&& note->descsz != sizeof (lwpxstatus_t)
#endif
)
return TRUE;
1999-05-03 09:29:11 +02:00
memcpy (&lwpstat, note->descdata, sizeof (lwpstat));
elf_tdata (abfd)->core_lwpid = lwpstat.pr_lwpid;
/* Do not overwrite the core signal if it has already been set by
another thread. */
if (elf_tdata (abfd)->core_signal == 0)
elf_tdata (abfd)->core_signal = lwpstat.pr_cursig;
1999-05-03 09:29:11 +02:00
/* Make a ".reg/999" section. */
1999-05-03 09:29:11 +02:00
sprintf (buf, ".reg/%d", elfcore_make_pid (abfd));
2002-06-25 11:40:45 +02:00
len = strlen (buf) + 1;
name = bfd_alloc (abfd, len);
1999-05-03 09:29:11 +02:00
if (name == NULL)
return FALSE;
2002-06-25 11:40:45 +02:00
memcpy (name, buf, len);
1999-05-03 09:29:11 +02:00
sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
1999-05-03 09:29:11 +02:00
if (sect == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
#if defined (HAVE_LWPSTATUS_T_PR_CONTEXT)
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 06:46:28 +02:00
sect->size = sizeof (lwpstat.pr_context.uc_mcontext.gregs);
1999-05-03 09:29:11 +02:00
sect->filepos = note->descpos
+ offsetof (lwpstatus_t, pr_context.uc_mcontext.gregs);
#endif
#if defined (HAVE_LWPSTATUS_T_PR_REG)
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 06:46:28 +02:00
sect->size = sizeof (lwpstat.pr_reg);
1999-05-03 09:29:11 +02:00
sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_reg);
#endif
sect->alignment_power = 2;
if (!elfcore_maybe_make_sect (abfd, ".reg", sect))
return FALSE;
1999-05-03 09:29:11 +02:00
/* Make a ".reg2/999" section */
sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd));
2002-06-25 11:40:45 +02:00
len = strlen (buf) + 1;
name = bfd_alloc (abfd, len);
1999-05-03 09:29:11 +02:00
if (name == NULL)
return FALSE;
2002-06-25 11:40:45 +02:00
memcpy (name, buf, len);
1999-05-03 09:29:11 +02:00
sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
1999-05-03 09:29:11 +02:00
if (sect == NULL)
return FALSE;
1999-05-03 09:29:11 +02:00
#if defined (HAVE_LWPSTATUS_T_PR_CONTEXT)
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 06:46:28 +02:00
sect->size = sizeof (lwpstat.pr_context.uc_mcontext.fpregs);
1999-05-03 09:29:11 +02:00
sect->filepos = note->descpos
+ offsetof (lwpstatus_t, pr_context.uc_mcontext.fpregs);
#endif
#if defined (HAVE_LWPSTATUS_T_PR_FPREG)
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 06:46:28 +02:00
sect->size = sizeof (lwpstat.pr_fpreg);
1999-05-03 09:29:11 +02:00
sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_fpreg);
#endif
sect->alignment_power = 2;
return elfcore_maybe_make_sect (abfd, ".reg2", sect);
1999-05-03 09:29:11 +02:00
}
#endif /* defined (HAVE_LWPSTATUS_T) */
static bfd_boolean
elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
{
char buf[30];
char *name;
2002-06-25 11:40:45 +02:00
size_t len;
asection *sect;
int type;
int is_active_thread;
bfd_vma base_addr;
if (note->descsz < 728)
return TRUE;
if (! CONST_STRNEQ (note->namedata, "win32"))
return TRUE;
type = bfd_get_32 (abfd, note->descdata);
switch (type)
{
case 1 /* NOTE_INFO_PROCESS */:
/* FIXME: need to add ->core_command. */
/* process_info.pid */
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 8);
/* process_info.signal */
elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 12);
break;
case 2 /* NOTE_INFO_THREAD */:
/* Make a ".reg/999" section. */
/* thread_info.tid */
sprintf (buf, ".reg/%ld", (long) bfd_get_32 (abfd, note->descdata + 8));
2002-06-25 11:40:45 +02:00
len = strlen (buf) + 1;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, len);
if (name == NULL)
return FALSE;
2002-06-25 11:40:45 +02:00
memcpy (name, buf, len);
sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
if (sect == NULL)
return FALSE;
/* sizeof (thread_info.thread_context) */
sect->size = 716;
/* offsetof (thread_info.thread_context) */
sect->filepos = note->descpos + 12;
sect->alignment_power = 2;
/* thread_info.is_active_thread */
is_active_thread = bfd_get_32 (abfd, note->descdata + 8);
if (is_active_thread)
if (! elfcore_maybe_make_sect (abfd, ".reg", sect))
return FALSE;
break;
case 3 /* NOTE_INFO_MODULE */:
/* Make a ".module/xxxxxxxx" section. */
/* module_info.base_address */
base_addr = bfd_get_32 (abfd, note->descdata + 4);
2008-07-30 06:34:58 +02:00
sprintf (buf, ".module/%08lx", (unsigned long) base_addr);
2002-06-25 11:40:45 +02:00
len = strlen (buf) + 1;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, len);
if (name == NULL)
return FALSE;
2002-06-25 11:40:45 +02:00
memcpy (name, buf, len);
1999-05-03 09:29:11 +02:00
sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
if (sect == NULL)
return FALSE;
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 06:46:28 +02:00
sect->size = note->descsz;
sect->filepos = note->descpos;
sect->alignment_power = 2;
break;
default:
return TRUE;
}
return TRUE;
}
1999-05-03 09:29:11 +02:00
static bfd_boolean
elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
1999-05-03 09:29:11 +02:00
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
1999-05-03 09:29:11 +02:00
switch (note->type)
{
default:
return TRUE;
1999-05-03 09:29:11 +02:00
case NT_PRSTATUS:
if (bed->elf_backend_grok_prstatus)
if ((*bed->elf_backend_grok_prstatus) (abfd, note))
return TRUE;
#if defined (HAVE_PRSTATUS_T)
1999-05-03 09:29:11 +02:00
return elfcore_grok_prstatus (abfd, note);
#else
return TRUE;
1999-05-03 09:29:11 +02:00
#endif
#if defined (HAVE_PSTATUS_T)
case NT_PSTATUS:
return elfcore_grok_pstatus (abfd, note);
#endif
#if defined (HAVE_LWPSTATUS_T)
case NT_LWPSTATUS:
return elfcore_grok_lwpstatus (abfd, note);
#endif
case NT_FPREGSET: /* FIXME: rename to NT_PRFPREG */
return elfcore_grok_prfpreg (abfd, note);
case NT_WIN32PSTATUS:
return elfcore_grok_win32pstatus (abfd, note);
case NT_PRXFPREG: /* Linux SSE extension */
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_prxfpreg (abfd, note);
else
return TRUE;
case NT_X86_XSTATE: /* Linux XSAVE extension */
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_xstatereg (abfd, note);
else
return TRUE;
case NT_PPC_VMX:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_ppc_vmx (abfd, note);
else
return TRUE;
case NT_PPC_VSX:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_ppc_vsx (abfd, note);
else
return TRUE;
case NT_S390_HIGH_GPRS:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_high_gprs (abfd, note);
else
return TRUE;
case NT_S390_TIMER:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_timer (abfd, note);
else
return TRUE;
case NT_S390_TODCMP:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_todcmp (abfd, note);
else
return TRUE;
case NT_S390_TODPREG:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_todpreg (abfd, note);
else
return TRUE;
case NT_S390_CTRS:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_ctrs (abfd, note);
else
return TRUE;
case NT_S390_PREFIX:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_prefix (abfd, note);
else
return TRUE;
case NT_S390_LAST_BREAK:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_last_break (abfd, note);
else
return TRUE;
case NT_S390_SYSTEM_CALL:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_s390_system_call (abfd, note);
else
return TRUE;
case NT_ARM_VFP:
if (note->namesz == 6
&& strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_arm_vfp (abfd, note);
else
return TRUE;
1999-05-03 09:29:11 +02:00
case NT_PRPSINFO:
case NT_PSINFO:
if (bed->elf_backend_grok_psinfo)
if ((*bed->elf_backend_grok_psinfo) (abfd, note))
return TRUE;
#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
1999-05-03 09:29:11 +02:00
return elfcore_grok_psinfo (abfd, note);
#else
return TRUE;
1999-05-03 09:29:11 +02:00
#endif
case NT_AUXV:
{
asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
SEC_HAS_CONTENTS);
if (sect == NULL)
return FALSE;
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 06:46:28 +02:00
sect->size = note->descsz;
sect->filepos = note->descpos;
sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
return TRUE;
}
1999-05-03 09:29:11 +02:00
}
}
static bfd_boolean
elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note)
{
elf_tdata (abfd)->build_id_size = note->descsz;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
elf_tdata (abfd)->build_id = (bfd_byte *) bfd_alloc (abfd, note->descsz);
if (elf_tdata (abfd)->build_id == NULL)
return FALSE;
memcpy (elf_tdata (abfd)->build_id, note->descdata, note->descsz);
return TRUE;
}
static bfd_boolean
elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
{
switch (note->type)
{
default:
return TRUE;
case NT_GNU_BUILD_ID:
return elfobj_grok_gnu_build_id (abfd, note);
}
}
static bfd_boolean
elfobj_grok_stapsdt_note_1 (bfd *abfd, Elf_Internal_Note *note)
{
struct sdt_note *cur =
(struct sdt_note *) bfd_alloc (abfd, sizeof (struct sdt_note)
+ note->descsz);
cur->next = (struct sdt_note *) (elf_tdata (abfd))->sdt_note_head;
cur->size = (bfd_size_type) note->descsz;
memcpy (cur->data, note->descdata, note->descsz);
elf_tdata (abfd)->sdt_note_head = cur;
return TRUE;
}
static bfd_boolean
elfobj_grok_stapsdt_note (bfd *abfd, Elf_Internal_Note *note)
{
switch (note->type)
{
case NT_STAPSDT:
return elfobj_grok_stapsdt_note_1 (abfd, note);
default:
return TRUE;
}
}
static bfd_boolean
elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
{
char *cp;
cp = strchr (note->namedata, '@');
if (cp != NULL)
{
*lwpidp = atoi(cp + 1);
return TRUE;
}
return FALSE;
}
static bfd_boolean
elfcore_grok_netbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
{
/* Signal number at offset 0x08. */
elf_tdata (abfd)->core_signal
= bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
/* Process ID at offset 0x50. */
elf_tdata (abfd)->core_pid
= bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x50);
/* Command name at 0x7c (max 32 bytes, including nul). */
elf_tdata (abfd)->core_command
= _bfd_elfcore_strndup (abfd, note->descdata + 0x7c, 31);
return elfcore_make_note_pseudosection (abfd, ".note.netbsdcore.procinfo",
note);
}
static bfd_boolean
elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
{
int lwp;
if (elfcore_netbsd_get_lwpid (note, &lwp))
elf_tdata (abfd)->core_lwpid = lwp;
if (note->type == NT_NETBSDCORE_PROCINFO)
{
/* NetBSD-specific core "procinfo". Note that we expect to
find this note before any of the others, which is fine,
since the kernel writes this note out first when it
creates a core file. */
return elfcore_grok_netbsd_procinfo (abfd, note);
}
/* As of Jan 2002 there are no other machine-independent notes
defined for NetBSD core files. If the note type is less
than the start of the machine-dependent note types, we don't
understand it. */
if (note->type < NT_NETBSDCORE_FIRSTMACH)
return TRUE;
switch (bfd_get_arch (abfd))
{
/* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0 and
PT_GETFPREGS == mach+2. */
case bfd_arch_alpha:
case bfd_arch_sparc:
switch (note->type)
{
case NT_NETBSDCORE_FIRSTMACH+0:
return elfcore_make_note_pseudosection (abfd, ".reg", note);
case NT_NETBSDCORE_FIRSTMACH+2:
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
default:
return TRUE;
}
/* On all other arch's, PT_GETREGS == mach+1 and
PT_GETFPREGS == mach+3. */
default:
switch (note->type)
{
case NT_NETBSDCORE_FIRSTMACH+1:
return elfcore_make_note_pseudosection (abfd, ".reg", note);
case NT_NETBSDCORE_FIRSTMACH+3:
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
default:
return TRUE;
}
}
/* NOTREACHED */
}
static bfd_boolean
elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
{
/* Signal number at offset 0x08. */
elf_tdata (abfd)->core_signal
= bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
/* Process ID at offset 0x20. */
elf_tdata (abfd)->core_pid
= bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x20);
/* Command name at 0x48 (max 32 bytes, including nul). */
elf_tdata (abfd)->core_command
= _bfd_elfcore_strndup (abfd, note->descdata + 0x48, 31);
return TRUE;
}
static bfd_boolean
elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)
{
if (note->type == NT_OPENBSD_PROCINFO)
return elfcore_grok_openbsd_procinfo (abfd, note);
if (note->type == NT_OPENBSD_REGS)
return elfcore_make_note_pseudosection (abfd, ".reg", note);
if (note->type == NT_OPENBSD_FPREGS)
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
if (note->type == NT_OPENBSD_XFPREGS)
return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
if (note->type == NT_OPENBSD_AUXV)
{
asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
SEC_HAS_CONTENTS);
if (sect == NULL)
return FALSE;
sect->size = note->descsz;
sect->filepos = note->descpos;
sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
return TRUE;
}
if (note->type == NT_OPENBSD_WCOOKIE)
{
asection *sect = bfd_make_section_anyway_with_flags (abfd, ".wcookie",
SEC_HAS_CONTENTS);
if (sect == NULL)
return FALSE;
sect->size = note->descsz;
sect->filepos = note->descpos;
sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
return TRUE;
}
return TRUE;
}
2003-02-24 19:07:22 +01:00
static bfd_boolean
elfcore_grok_nto_status (bfd *abfd, Elf_Internal_Note *note, long *tid)
2003-02-24 19:07:22 +01:00
{
void *ddata = note->descdata;
char buf[100];
char *name;
asection *sect;
short sig;
unsigned flags;
2003-02-24 19:07:22 +01:00
/* nto_procfs_status 'pid' field is at offset 0. */
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, (bfd_byte *) ddata);
/* nto_procfs_status 'tid' field is at offset 4. Pass it back. */
*tid = bfd_get_32 (abfd, (bfd_byte *) ddata + 4);
/* nto_procfs_status 'flags' field is at offset 8. */
flags = bfd_get_32 (abfd, (bfd_byte *) ddata + 8);
2003-02-24 19:07:22 +01:00
/* nto_procfs_status 'what' field is at offset 14. */
if ((sig = bfd_get_16 (abfd, (bfd_byte *) ddata + 14)) > 0)
{
elf_tdata (abfd)->core_signal = sig;
elf_tdata (abfd)->core_lwpid = *tid;
}
2003-02-24 19:07:22 +01:00
/* _DEBUG_FLAG_CURTID (current thread) is 0x80. Some cores
do not come from signals so we make sure we set the current
thread just in case. */
if (flags & 0x00000080)
elf_tdata (abfd)->core_lwpid = *tid;
2003-02-24 19:07:22 +01:00
/* Make a ".qnx_core_status/%d" section. */
sprintf (buf, ".qnx_core_status/%ld", *tid);
2003-02-24 19:07:22 +01:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, strlen (buf) + 1);
2003-02-24 19:07:22 +01:00
if (name == NULL)
return FALSE;
strcpy (name, buf);
sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
2003-02-24 19:07:22 +01:00
if (sect == NULL)
return FALSE;
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 06:46:28 +02:00
sect->size = note->descsz;
2003-02-24 19:07:22 +01:00
sect->filepos = note->descpos;
sect->alignment_power = 2;
return (elfcore_maybe_make_sect (abfd, ".qnx_core_status", sect));
}
static bfd_boolean
elfcore_grok_nto_regs (bfd *abfd,
Elf_Internal_Note *note,
long tid,
char *base)
2003-02-24 19:07:22 +01:00
{
char buf[100];
char *name;
asection *sect;
/* Make a "(base)/%d" section. */
sprintf (buf, "%s/%ld", base, tid);
2003-02-24 19:07:22 +01:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, strlen (buf) + 1);
2003-02-24 19:07:22 +01:00
if (name == NULL)
return FALSE;
strcpy (name, buf);
sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
2003-02-24 19:07:22 +01:00
if (sect == NULL)
return FALSE;
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 06:46:28 +02:00
sect->size = note->descsz;
2003-02-24 19:07:22 +01:00
sect->filepos = note->descpos;
sect->alignment_power = 2;
/* This is the current thread. */
if (elf_tdata (abfd)->core_lwpid == tid)
return elfcore_maybe_make_sect (abfd, base, sect);
return TRUE;
2003-02-24 19:07:22 +01:00
}
#define BFD_QNT_CORE_INFO 7
#define BFD_QNT_CORE_STATUS 8
#define BFD_QNT_CORE_GREG 9
#define BFD_QNT_CORE_FPREG 10
static bfd_boolean
elfcore_grok_nto_note (bfd *abfd, Elf_Internal_Note *note)
2003-02-24 19:07:22 +01:00
{
/* Every GREG section has a STATUS section before it. Store the
tid from the previous call to pass down to the next gregs
2003-02-24 19:07:22 +01:00
function. */
static long tid = 1;
2003-02-24 19:07:22 +01:00
switch (note->type)
{
case BFD_QNT_CORE_INFO:
return elfcore_make_note_pseudosection (abfd, ".qnx_core_info", note);
case BFD_QNT_CORE_STATUS:
return elfcore_grok_nto_status (abfd, note, &tid);
case BFD_QNT_CORE_GREG:
return elfcore_grok_nto_regs (abfd, note, tid, ".reg");
case BFD_QNT_CORE_FPREG:
return elfcore_grok_nto_regs (abfd, note, tid, ".reg2");
default:
return TRUE;
2003-02-24 19:07:22 +01:00
}
}
static bfd_boolean
elfcore_grok_spu_note (bfd *abfd, Elf_Internal_Note *note)
{
char *name;
asection *sect;
size_t len;
/* Use note name as section name. */
len = note->namesz;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
name = (char *) bfd_alloc (abfd, len);
if (name == NULL)
return FALSE;
memcpy (name, note->namedata, len);
name[len - 1] = '\0';
sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
if (sect == NULL)
return FALSE;
sect->size = note->descsz;
sect->filepos = note->descpos;
sect->alignment_power = 1;
return TRUE;
}
/* Function: elfcore_write_note
Inputs:
buffer to hold note, and current size of buffer
name of note
type of note
data for note
size of data for note
Writes note to end of buffer. ELF64 notes are written exactly as
for ELF32, despite the current (as of 2006) ELF gabi specifying
that they ought to have 8-byte namesz and descsz field, and have
8-byte alignment. Other writers, eg. Linux kernel, do the same.
Return:
Pointer to realloc'd buffer, *BUFSIZ updated. */
char *
elfcore_write_note (bfd *abfd,
char *buf,
int *bufsiz,
const char *name,
int type,
const void *input,
int size)
{
Elf_External_Note *xnp;
2002-06-25 11:40:45 +02:00
size_t namesz;
size_t newspace;
char *dest;
2002-06-25 11:40:45 +02:00
namesz = 0;
if (name != NULL)
namesz = strlen (name) + 1;
2002-06-25 11:40:45 +02:00
newspace = 12 + ((namesz + 3) & -4) + ((size + 3) & -4);
2002-06-25 11:40:45 +02:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
buf = (char *) realloc (buf, *bufsiz + newspace);
if (buf == NULL)
return buf;
dest = buf + *bufsiz;
*bufsiz += newspace;
xnp = (Elf_External_Note *) dest;
H_PUT_32 (abfd, namesz, xnp->namesz);
H_PUT_32 (abfd, size, xnp->descsz);
H_PUT_32 (abfd, type, xnp->type);
2002-06-25 11:40:45 +02:00
dest = xnp->name;
if (name != NULL)
{
memcpy (dest, name, namesz);
dest += namesz;
while (namesz & 3)
2002-06-25 11:40:45 +02:00
{
*dest++ = '\0';
++namesz;
2002-06-25 11:40:45 +02:00
}
}
memcpy (dest, input, size);
dest += size;
while (size & 3)
{
*dest++ = '\0';
++size;
}
return buf;
}
char *
elfcore_write_prpsinfo (bfd *abfd,
char *buf,
int *bufsiz,
const char *fname,
const char *psargs)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->elf_backend_write_core_note != NULL)
{
char *ret;
ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
NT_PRPSINFO, fname, psargs);
if (ret != NULL)
return ret;
}
#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
if (bed->s->elfclass == ELFCLASS32)
{
#if defined (HAVE_PSINFO32_T)
psinfo32_t data;
int note_type = NT_PSINFO;
#else
prpsinfo32_t data;
int note_type = NT_PRPSINFO;
#endif
memset (&data, 0, sizeof (data));
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
return elfcore_write_note (abfd, buf, bufsiz,
"CORE", note_type, &data, sizeof (data));
}
else
#endif
{
#if defined (HAVE_PSINFO_T)
psinfo_t data;
int note_type = NT_PSINFO;
#else
prpsinfo_t data;
int note_type = NT_PRPSINFO;
#endif
memset (&data, 0, sizeof (data));
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
return elfcore_write_note (abfd, buf, bufsiz,
"CORE", note_type, &data, sizeof (data));
}
#endif /* PSINFO_T or PRPSINFO_T */
free (buf);
return NULL;
}
char *
elfcore_write_prstatus (bfd *abfd,
char *buf,
int *bufsiz,
long pid,
int cursig,
const void *gregs)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->elf_backend_write_core_note != NULL)
{
char *ret;
ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
NT_PRSTATUS,
pid, cursig, gregs);
if (ret != NULL)
return ret;
}
#if defined (HAVE_PRSTATUS_T)
#if defined (HAVE_PRSTATUS32_T)
if (bed->s->elfclass == ELFCLASS32)
{
prstatus32_t prstat;
memset (&prstat, 0, sizeof (prstat));
prstat.pr_pid = pid;
prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
return elfcore_write_note (abfd, buf, bufsiz, "CORE",
NT_PRSTATUS, &prstat, sizeof (prstat));
}
else
#endif
{
prstatus_t prstat;
memset (&prstat, 0, sizeof (prstat));
prstat.pr_pid = pid;
prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
return elfcore_write_note (abfd, buf, bufsiz, "CORE",
NT_PRSTATUS, &prstat, sizeof (prstat));
}
#endif /* HAVE_PRSTATUS_T */
free (buf);
return NULL;
}
#if defined (HAVE_LWPSTATUS_T)
char *
elfcore_write_lwpstatus (bfd *abfd,
char *buf,
int *bufsiz,
long pid,
int cursig,
const void *gregs)
{
lwpstatus_t lwpstat;
const char *note_name = "CORE";
memset (&lwpstat, 0, sizeof (lwpstat));
lwpstat.pr_lwpid = pid >> 16;
lwpstat.pr_cursig = cursig;
#if defined (HAVE_LWPSTATUS_T_PR_REG)
memcpy (lwpstat.pr_reg, gregs, sizeof (lwpstat.pr_reg));
#elif defined (HAVE_LWPSTATUS_T_PR_CONTEXT)
#if !defined(gregs)
memcpy (lwpstat.pr_context.uc_mcontext.gregs,
gregs, sizeof (lwpstat.pr_context.uc_mcontext.gregs));
#else
memcpy (lwpstat.pr_context.uc_mcontext.__gregs,
gregs, sizeof (lwpstat.pr_context.uc_mcontext.__gregs));
#endif
#endif
return elfcore_write_note (abfd, buf, bufsiz, note_name,
NT_LWPSTATUS, &lwpstat, sizeof (lwpstat));
}
#endif /* HAVE_LWPSTATUS_T */
#if defined (HAVE_PSTATUS_T)
char *
elfcore_write_pstatus (bfd *abfd,
char *buf,
int *bufsiz,
long pid,
int cursig ATTRIBUTE_UNUSED,
const void *gregs ATTRIBUTE_UNUSED)
{
const char *note_name = "CORE";
#if defined (HAVE_PSTATUS32_T)
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->s->elfclass == ELFCLASS32)
{
pstatus32_t pstat;
memset (&pstat, 0, sizeof (pstat));
pstat.pr_pid = pid & 0xffff;
buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
NT_PSTATUS, &pstat, sizeof (pstat));
return buf;
}
else
#endif
{
pstatus_t pstat;
memset (&pstat, 0, sizeof (pstat));
pstat.pr_pid = pid & 0xffff;
buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
NT_PSTATUS, &pstat, sizeof (pstat));
return buf;
}
}
#endif /* HAVE_PSTATUS_T */
char *
elfcore_write_prfpreg (bfd *abfd,
char *buf,
int *bufsiz,
const void *fpregs,
int size)
{
const char *note_name = "CORE";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_FPREGSET, fpregs, size);
}
char *
elfcore_write_prxfpreg (bfd *abfd,
char *buf,
int *bufsiz,
const void *xfpregs,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_PRXFPREG, xfpregs, size);
}
char *
elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz,
const void *xfpregs, int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_X86_XSTATE, xfpregs, size);
}
char *
elfcore_write_ppc_vmx (bfd *abfd,
char *buf,
int *bufsiz,
const void *ppc_vmx,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_PPC_VMX, ppc_vmx, size);
}
char *
elfcore_write_ppc_vsx (bfd *abfd,
char *buf,
int *bufsiz,
const void *ppc_vsx,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_PPC_VSX, ppc_vsx, size);
}
static char *
elfcore_write_s390_high_gprs (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_high_gprs,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_HIGH_GPRS,
s390_high_gprs, size);
}
char *
elfcore_write_s390_timer (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_timer,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_TIMER, s390_timer, size);
}
char *
elfcore_write_s390_todcmp (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_todcmp,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_TODCMP, s390_todcmp, size);
}
char *
elfcore_write_s390_todpreg (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_todpreg,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_TODPREG, s390_todpreg, size);
}
char *
elfcore_write_s390_ctrs (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_ctrs,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_CTRS, s390_ctrs, size);
}
char *
elfcore_write_s390_prefix (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_prefix,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_PREFIX, s390_prefix, size);
}
char *
elfcore_write_s390_last_break (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_last_break,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_LAST_BREAK,
s390_last_break, size);
}
char *
elfcore_write_s390_system_call (bfd *abfd,
char *buf,
int *bufsiz,
const void *s390_system_call,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_S390_SYSTEM_CALL,
s390_system_call, size);
}
char *
elfcore_write_arm_vfp (bfd *abfd,
char *buf,
int *bufsiz,
const void *arm_vfp,
int size)
{
char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_ARM_VFP, arm_vfp, size);
}
char *
elfcore_write_register_note (bfd *abfd,
char *buf,
int *bufsiz,
const char *section,
const void *data,
int size)
{
if (strcmp (section, ".reg2") == 0)
return elfcore_write_prfpreg (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-xfp") == 0)
return elfcore_write_prxfpreg (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-xstate") == 0)
return elfcore_write_xstatereg (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-ppc-vmx") == 0)
return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-ppc-vsx") == 0)
return elfcore_write_ppc_vsx (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-high-gprs") == 0)
return elfcore_write_s390_high_gprs (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-timer") == 0)
return elfcore_write_s390_timer (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-todcmp") == 0)
return elfcore_write_s390_todcmp (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-todpreg") == 0)
return elfcore_write_s390_todpreg (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-ctrs") == 0)
return elfcore_write_s390_ctrs (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-prefix") == 0)
return elfcore_write_s390_prefix (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-last-break") == 0)
return elfcore_write_s390_last_break (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-s390-system-call") == 0)
return elfcore_write_s390_system_call (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-arm-vfp") == 0)
return elfcore_write_arm_vfp (abfd, buf, bufsiz, data, size);
return NULL;
}
static bfd_boolean
elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset)
1999-05-03 09:29:11 +02:00
{
char *p;
1999-05-03 09:29:11 +02:00
p = buf;
while (p < buf + size)
{
/* FIXME: bad alignment assumption. */
Elf_External_Note *xnp = (Elf_External_Note *) p;
1999-05-03 09:29:11 +02:00
Elf_Internal_Note in;
if (offsetof (Elf_External_Note, name) > buf - p + size)
return FALSE;
in.type = H_GET_32 (abfd, xnp->type);
1999-05-03 09:29:11 +02:00
in.namesz = H_GET_32 (abfd, xnp->namesz);
1999-05-03 09:29:11 +02:00
in.namedata = xnp->name;
if (in.namesz > buf - in.namedata + size)
return FALSE;
1999-05-03 09:29:11 +02:00
in.descsz = H_GET_32 (abfd, xnp->descsz);
1999-05-03 09:29:11 +02:00
in.descdata = in.namedata + BFD_ALIGN (in.namesz, 4);
in.descpos = offset + (in.descdata - buf);
if (in.descsz != 0
&& (in.descdata >= buf + size
|| in.descsz > buf - in.descdata + size))
return FALSE;
1999-05-03 09:29:11 +02:00
switch (bfd_get_format (abfd))
{
default:
return TRUE;
case bfd_core:
if (CONST_STRNEQ (in.namedata, "NetBSD-CORE"))
{
if (! elfcore_grok_netbsd_note (abfd, &in))
return FALSE;
}
else if (CONST_STRNEQ (in.namedata, "OpenBSD"))
{
if (! elfcore_grok_openbsd_note (abfd, &in))
return FALSE;
}
else if (CONST_STRNEQ (in.namedata, "QNX"))
{
if (! elfcore_grok_nto_note (abfd, &in))
return FALSE;
}
else if (CONST_STRNEQ (in.namedata, "SPU/"))
{
if (! elfcore_grok_spu_note (abfd, &in))
return FALSE;
}
else
{
if (! elfcore_grok_note (abfd, &in))
return FALSE;
}
break;
case bfd_object:
if (in.namesz == sizeof "GNU" && strcmp (in.namedata, "GNU") == 0)
{
if (! elfobj_grok_gnu_note (abfd, &in))
return FALSE;
}
else if (in.namesz == sizeof "stapsdt"
&& strcmp (in.namedata, "stapsdt") == 0)
{
if (! elfobj_grok_stapsdt_note (abfd, &in))
return FALSE;
}
break;
}
1999-05-03 09:29:11 +02:00
p = in.descdata + BFD_ALIGN (in.descsz, 4);
}
return TRUE;
}
static bfd_boolean
elf_read_notes (bfd *abfd, file_ptr offset, bfd_size_type size)
{
char *buf;
if (size <= 0)
return TRUE;
if (bfd_seek (abfd, offset, SEEK_SET) != 0)
return FALSE;
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
buf = (char *) bfd_malloc (size);
if (buf == NULL)
return FALSE;
if (bfd_bread (buf, size, abfd) != size
|| !elf_parse_notes (abfd, buf, size, offset))
{
free (buf);
return FALSE;
}
1999-05-03 09:29:11 +02:00
free (buf);
return TRUE;
1999-05-03 09:29:11 +02:00
}
/* Providing external access to the ELF program header table. */
/* Return an upper bound on the number of bytes required to store a
copy of ABFD's program header table entries. Return -1 if an error
occurs; bfd_get_error will return an appropriate code. */
long
bfd_get_elf_phdr_upper_bound (bfd *abfd)
{
if (abfd->xvec->flavour != bfd_target_elf_flavour)
{
bfd_set_error (bfd_error_wrong_format);
return -1;
}
return elf_elfheader (abfd)->e_phnum * sizeof (Elf_Internal_Phdr);
}
/* Copy ABFD's program header table entries to *PHDRS. The entries
will be stored as an array of Elf_Internal_Phdr structures, as
defined in include/elf/internal.h. To find out how large the
buffer needs to be, call bfd_get_elf_phdr_upper_bound.
Return the number of program header table entries read, or -1 if an
error occurs; bfd_get_error will return an appropriate code. */
int
bfd_get_elf_phdrs (bfd *abfd, void *phdrs)
{
int num_phdrs;
if (abfd->xvec->flavour != bfd_target_elf_flavour)
{
bfd_set_error (bfd_error_wrong_format);
return -1;
}
num_phdrs = elf_elfheader (abfd)->e_phnum;
memcpy (phdrs, elf_tdata (abfd)->phdr,
num_phdrs * sizeof (Elf_Internal_Phdr));
return num_phdrs;
}
* elf-bfd.h (enum elf_reloc_type_class): New. (struct elf_backend_data): Add elf_backend_reloc_type_class. (_bfd_elf_reloc_type_class): New. * elfxx-target.h (elf_backend_reloc_type_class): Define. (elfNN_bed): Add elf_backend_reloc_type_class. * elf.c (_bfd_elf_reloc_type_class): New. * elf32-i386.c (elf_i386_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (elf_i386_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (elf_i386_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elf32-sparc.c (elf32_sparc_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (elf32_sparc_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (elf32_sparc_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elf64-sparc.c (sparc64_elf_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (sparc64_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (sparc64_elf_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elfxx-ia64.c (struct elfNN_ia64_link_hash_table): Add reltext field. (elfNN_ia64_hash_table_create): Clear ia64_info. (get_reloc_section): Set DF_TEXTREL if the reloc is against read-only section. (elfNN_ia64_size_dynamic_sections): Use ia64_info->reltext flag instead of looking up section names for DT_TEXTREL. (elfNN_ia64_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elflink.h (size_dynamic_sections): Add spare DT_NULL tags. (struct elf_link_sort_rela): New. (elf_link_sort_cmp1, elf_link_sort_cmp2, elf_link_sort_relocs): New. (elf_bfd_final_link): Call elf_link_sort_relocs. Convert one spare DT_NULL into DT_RELCOUNT resp. DT_RELACOUNT if necessary. * bfdlink.h (struct bfd_link_info): Add combreloc and spare_dynamic_tags fields. * emultempl/elf32.em (place_orphan): Place orphan .rel* sections into .rel.dyn resp. .rela.dyn if combreloc. (get_script): If .x linker script is equal to .xn, only put it once into the binary. Add .xc and .xsc scripts. (parse_args): Handle -z combreloc and -z nocombreloc. * scripttempl/elf.sc (.rela.sbss): Fix a typo. For .xc and .xsc scripts put all .rel* or .rela* input sections but .rel*.plt and PLT-like sections into .rel.dyn resp. .rela.dyn. * genscripts.sh (GENERATE_COMBRELOC_SCRIPT): Set if SCRIPT_NAME is elf. Strip trailing whitespace from script. Generate .xc and .xsc scripts if requested. * ldmain.c (main): Initialize link_info.combreloc and link_info.spare_dynamic_tags. * lexsup.c (OPTION_SPARE_DYNAMIC_TAGS): Define. (ld_options): Add --spare-dynamic-tags option. (parse_args): Likewise. * ld.texinfo: Document -z combreloc and -z nocombreloc. * ldint.texinfo: Document .xc and .xsc linker scripts. * NEWS: Add notes about -z combreloc and SHF_MERGE.
2001-08-23 17:14:18 +02:00
enum elf_reloc_type_class
_bfd_elf_reloc_type_class (const Elf_Internal_Rela *rela ATTRIBUTE_UNUSED)
* elf-bfd.h (enum elf_reloc_type_class): New. (struct elf_backend_data): Add elf_backend_reloc_type_class. (_bfd_elf_reloc_type_class): New. * elfxx-target.h (elf_backend_reloc_type_class): Define. (elfNN_bed): Add elf_backend_reloc_type_class. * elf.c (_bfd_elf_reloc_type_class): New. * elf32-i386.c (elf_i386_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (elf_i386_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (elf_i386_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elf32-sparc.c (elf32_sparc_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (elf32_sparc_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (elf32_sparc_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elf64-sparc.c (sparc64_elf_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (sparc64_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (sparc64_elf_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elfxx-ia64.c (struct elfNN_ia64_link_hash_table): Add reltext field. (elfNN_ia64_hash_table_create): Clear ia64_info. (get_reloc_section): Set DF_TEXTREL if the reloc is against read-only section. (elfNN_ia64_size_dynamic_sections): Use ia64_info->reltext flag instead of looking up section names for DT_TEXTREL. (elfNN_ia64_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elflink.h (size_dynamic_sections): Add spare DT_NULL tags. (struct elf_link_sort_rela): New. (elf_link_sort_cmp1, elf_link_sort_cmp2, elf_link_sort_relocs): New. (elf_bfd_final_link): Call elf_link_sort_relocs. Convert one spare DT_NULL into DT_RELCOUNT resp. DT_RELACOUNT if necessary. * bfdlink.h (struct bfd_link_info): Add combreloc and spare_dynamic_tags fields. * emultempl/elf32.em (place_orphan): Place orphan .rel* sections into .rel.dyn resp. .rela.dyn if combreloc. (get_script): If .x linker script is equal to .xn, only put it once into the binary. Add .xc and .xsc scripts. (parse_args): Handle -z combreloc and -z nocombreloc. * scripttempl/elf.sc (.rela.sbss): Fix a typo. For .xc and .xsc scripts put all .rel* or .rela* input sections but .rel*.plt and PLT-like sections into .rel.dyn resp. .rela.dyn. * genscripts.sh (GENERATE_COMBRELOC_SCRIPT): Set if SCRIPT_NAME is elf. Strip trailing whitespace from script. Generate .xc and .xsc scripts if requested. * ldmain.c (main): Initialize link_info.combreloc and link_info.spare_dynamic_tags. * lexsup.c (OPTION_SPARE_DYNAMIC_TAGS): Define. (ld_options): Add --spare-dynamic-tags option. (parse_args): Likewise. * ld.texinfo: Document -z combreloc and -z nocombreloc. * ldint.texinfo: Document .xc and .xsc linker scripts. * NEWS: Add notes about -z combreloc and SHF_MERGE.
2001-08-23 17:14:18 +02:00
{
return reloc_class_normal;
}
* elf.c (_bfd_elf_rela_local_sym): New. * elflink.h (elf_link_input_bfd): Don't consider empty merged sections as removed in relocation tests. * elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype. * elf32-i386.c (elf_i386_relocate_section): Handle relocs against STT_SECTION symbol of SHF_MERGE section. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Call _bfd_elf_rela_local_sym. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. * elf32-fr30.c (fr30_final_link_relocate): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf-hppa.h (elf_hppa_relocate_section): Likewise. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise for !partial_inplace relocs. Handle relocs against STT_SECTION symbol of SHF_MERGE for partial_inplace relocs. * config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test. * write.c (adjust_reloc_syms): Don't handle relocs against SEC_MERGE section symbols specially. (fixup_segment): Likewise.
2001-11-23 13:17:21 +01:00
/* For RELA architectures, return the relocation value for a
* elf.c (_bfd_elf_rela_local_sym): New. * elflink.h (elf_link_input_bfd): Don't consider empty merged sections as removed in relocation tests. * elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype. * elf32-i386.c (elf_i386_relocate_section): Handle relocs against STT_SECTION symbol of SHF_MERGE section. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Call _bfd_elf_rela_local_sym. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. * elf32-fr30.c (fr30_final_link_relocate): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf-hppa.h (elf_hppa_relocate_section): Likewise. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise for !partial_inplace relocs. Handle relocs against STT_SECTION symbol of SHF_MERGE for partial_inplace relocs. * config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test. * write.c (adjust_reloc_syms): Don't handle relocs against SEC_MERGE section symbols specially. (fixup_segment): Likewise.
2001-11-23 13:17:21 +01:00
relocation against a local symbol. */
bfd_vma
_bfd_elf_rela_local_sym (bfd *abfd,
Elf_Internal_Sym *sym,
* elf.c (_bfd_elf_rela_local_sym): Accept asection **, and return updated section in case of merged section. * elf-bfd.h (_bfd_elf_rela_local_sym): Update declaration. * elf-hppa.h (elf_hppa_relocate_section): Adjust call. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-fr30.c (fr30_elf_relocate_section): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-msp430.c (elf32_msp430_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section) Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise. * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sh64.c (sh_elf64_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Don't recalculate symbol section for reloc output. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Don't recalculate everything for R_PPC_RELAX32 reloc. Don't bother checking ppc_elf_install_value return value. * elf64-ppc.c (ppc64_elf_relocate_section <R_PPC64_TOC>): Sanity check sec->id.
2003-11-05 14:17:09 +01:00
asection **psec,
Elf_Internal_Rela *rel)
* elf.c (_bfd_elf_rela_local_sym): New. * elflink.h (elf_link_input_bfd): Don't consider empty merged sections as removed in relocation tests. * elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype. * elf32-i386.c (elf_i386_relocate_section): Handle relocs against STT_SECTION symbol of SHF_MERGE section. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Call _bfd_elf_rela_local_sym. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. * elf32-fr30.c (fr30_final_link_relocate): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf-hppa.h (elf_hppa_relocate_section): Likewise. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise for !partial_inplace relocs. Handle relocs against STT_SECTION symbol of SHF_MERGE for partial_inplace relocs. * config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test. * write.c (adjust_reloc_syms): Don't handle relocs against SEC_MERGE section symbols specially. (fixup_segment): Likewise.
2001-11-23 13:17:21 +01:00
{
* elf.c (_bfd_elf_rela_local_sym): Accept asection **, and return updated section in case of merged section. * elf-bfd.h (_bfd_elf_rela_local_sym): Update declaration. * elf-hppa.h (elf_hppa_relocate_section): Adjust call. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-fr30.c (fr30_elf_relocate_section): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-msp430.c (elf32_msp430_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section) Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise. * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sh64.c (sh_elf64_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Don't recalculate symbol section for reloc output. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Don't recalculate everything for R_PPC_RELAX32 reloc. Don't bother checking ppc_elf_install_value return value. * elf64-ppc.c (ppc64_elf_relocate_section <R_PPC64_TOC>): Sanity check sec->id.
2003-11-05 14:17:09 +01:00
asection *sec = *psec;
* elf.c (_bfd_elf_rela_local_sym): New. * elflink.h (elf_link_input_bfd): Don't consider empty merged sections as removed in relocation tests. * elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype. * elf32-i386.c (elf_i386_relocate_section): Handle relocs against STT_SECTION symbol of SHF_MERGE section. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Call _bfd_elf_rela_local_sym. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. * elf32-fr30.c (fr30_final_link_relocate): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf-hppa.h (elf_hppa_relocate_section): Likewise. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise for !partial_inplace relocs. Handle relocs against STT_SECTION symbol of SHF_MERGE for partial_inplace relocs. * config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test. * write.c (adjust_reloc_syms): Don't handle relocs against SEC_MERGE section symbols specially. (fixup_segment): Likewise.
2001-11-23 13:17:21 +01:00
bfd_vma relocation;
relocation = (sec->output_section->vma
+ sec->output_offset
+ sym->st_value);
if ((sec->flags & SEC_MERGE)
&& ELF_ST_TYPE (sym->st_info) == STT_SECTION
PR ld/13991 bfd/ * bfd/elf-bfd.h (_bfd_elf_link_just_syms): Define as _bfd_generic_link_just_syms. * bfd/elflink.c (_bfd_elf_link_just_syms): Delete. * bfd/linker.c (_bfd_generic_link_just_syms): Set sec_info_type. * bfd/bfd-in.h (discarded_section): Renamed from elf_discarded_section. * bfd/section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS, SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME, SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE. * bfd/elf-eh-frame.c, * bfd/elf-m10200.c, * bfd/elf-m10300.c, * bfd/elf.c, * bfd/elf32-arm.c, * bfd/elf32-avr.c, * bfd/elf32-bfin.c, * bfd/elf32-cr16.c, * bfd/elf32-cr16c.c, * bfd/elf32-cris.c, * bfd/elf32-crx.c, * bfd/elf32-d10v.c, * bfd/elf32-epiphany.c, * bfd/elf32-fr30.c, * bfd/elf32-frv.c, * bfd/elf32-h8300.c, * bfd/elf32-hppa.c, * bfd/elf32-i370.c, * bfd/elf32-i386.c, * bfd/elf32-i860.c, * bfd/elf32-ip2k.c, * bfd/elf32-iq2000.c, * bfd/elf32-lm32.c, * bfd/elf32-m32c.c, * bfd/elf32-m32r.c, * bfd/elf32-m68hc1x.c, * bfd/elf32-m68k.c, * bfd/elf32-mcore.c, * bfd/elf32-mep.c, * bfd/elf32-moxie.c, * bfd/elf32-msp430.c, * bfd/elf32-mt.c, * bfd/elf32-openrisc.c, * bfd/elf32-ppc.c, * bfd/elf32-rl78.c, * bfd/elf32-rx.c, * bfd/elf32-s390.c, * bfd/elf32-score.c, * bfd/elf32-score7.c, * bfd/elf32-sh.c, * bfd/elf32-spu.c, * bfd/elf32-tic6x.c, * bfd/elf32-tilepro.c, * bfd/elf32-v850.c, * bfd/elf32-vax.c, * bfd/elf32-xc16x.c, * bfd/elf32-xstormy16.c, * bfd/elf32-xtensa.c, * bfd/elf64-alpha.c, * bfd/elf64-hppa.c, * bfd/elf64-ia64-vms.c, * bfd/elf64-mmix.c, * bfd/elf64-ppc.c, * bfd/elf64-s390.c, * bfd/elf64-sh64.c, * bfd/elf64-x86-64.c, * bfd/elflink.c, * bfd/elfnn-ia64.c, * bfd/elfxx-mips.c, * bfd/elfxx-sparc.c, * bfd/elfxx-tilegx.c, * bfd/reloc.c: Update all references. * bfd/bfd-in2.h: Regenerate. ld/ * ld/ldlang.c (size_input_section): Use sec_info_type rather than usrdata->flags.just_syms. * ld/ldwrite.c (build_link_order): Likewise. * ld/emultempl/hppaelf.em (build_section_lists): Likewise. * ld/emultempl/ppc64elf.em (build_toc_list): Likewise. * ld/emultempl/armelf.em (build_section_lists): Likewise. (after_allocation): Update for renamed sec_info_type value. * ld/emultempl/tic6xdsbt.em: Likewise.
2012-04-24 07:12:40 +02:00
&& sec->sec_info_type == SEC_INFO_TYPE_MERGE)
* elf.c (_bfd_elf_rela_local_sym): New. * elflink.h (elf_link_input_bfd): Don't consider empty merged sections as removed in relocation tests. * elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype. * elf32-i386.c (elf_i386_relocate_section): Handle relocs against STT_SECTION symbol of SHF_MERGE section. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Call _bfd_elf_rela_local_sym. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. * elf32-fr30.c (fr30_final_link_relocate): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf-hppa.h (elf_hppa_relocate_section): Likewise. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise for !partial_inplace relocs. Handle relocs against STT_SECTION symbol of SHF_MERGE for partial_inplace relocs. * config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test. * write.c (adjust_reloc_syms): Don't handle relocs against SEC_MERGE section symbols specially. (fixup_segment): Likewise.
2001-11-23 13:17:21 +01:00
{
rel->r_addend =
* elf.c (_bfd_elf_rela_local_sym): Accept asection **, and return updated section in case of merged section. * elf-bfd.h (_bfd_elf_rela_local_sym): Update declaration. * elf-hppa.h (elf_hppa_relocate_section): Adjust call. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-fr30.c (fr30_elf_relocate_section): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-msp430.c (elf32_msp430_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section) Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise. * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sh64.c (sh_elf64_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Don't recalculate symbol section for reloc output. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Don't recalculate everything for R_PPC_RELAX32 reloc. Don't bother checking ppc_elf_install_value return value. * elf64-ppc.c (ppc64_elf_relocate_section <R_PPC64_TOC>): Sanity check sec->id.
2003-11-05 14:17:09 +01:00
_bfd_merged_section_offset (abfd, psec,
* elf-bfd.h (enum elf_link_info_type): New. (struct bfd_elf_section_data): Remove stab_info and merge_info fields, add sec_info and sec_info_type. (struct elf_obj_tdata): Add eh_frame_hdr field. (_bfd_elf_discard_section_eh_frame): New prototype. (_bfd_elf_discard_section_eh_frame_hdr): Likewise. (_bfd_elf_eh_frame_section_offset): Likewise. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_write_section_eh_frame_hdr): Likewise. * Makefile.am (BFD32_BACKENDS): Add elf-eh-frame.lo. (BFD32_BACKENDS_CFILES): Add elf-eh-frame.c. (elf-eh-frame.lo): New. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-eh-frame.lo. * configure: Rebuilt. * elf.c (_bfd_elf_print_private_bfd_data): Support PT_GNU_EH_FRAME. (map_sections_to_segments): Create PT_GNU_EH_FRAME if requested. (get_program_header_size): Take into account PT_GNU_EH_FRAME segment. (_bfd_elf_rela_local_sym): Use sec_info_type and sec_info. (_bfd_elf_rel_local_sym): Likewise. (_bfd_elf_section_offset): Likewise. Call _bfd_elf_eh_frame_section_offset too. * elfxx-ia64.c (elfNN_ia64_relocate_section): Use sec_info_type and sec_info. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf-eh-frame.c: New file. * elflink.h (elf_link_add_object_symbols): Don't optimize SHF_MERGE .stab sections. Set sec_info_type, use sec_info instead of merge_info and stab_info. (elf_link_create_dynamic_sections): Create .eh_frame_hdr section if --eh-frame-hdr. (elf_bfd_final_link): Write .eh_frame_hdr section. (elf_link_sec_merge_syms): Use sec_info_type and sec_info. (elf_link_input_bfd): Likewise. Call _bfd_elf_write_section_eh_frame to write .eh_frame sections. (elf_bfd_discard_info): Add output_bfd argument. Call _bfd_elf_discard_section_eh_frame and _bfd_elf_discard_section_eh_frame_hdr. (elf_section_ignore_discarded_relocs): Use sec_info_type, not section names. * bfd-in.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Adjust prototypes. * bfd-in2.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Likewise. * elf/common.h (PT_GNU_EH_FRAME): Define. * bfdlink.h (struct bfd_link_info): Add eh_frame_hdr field. * emultempl/elf32.em (finish): Supply output_bfd to bfd_elf*_discard_info. (OPTION_EH_FRAME_HDR): Define. (longopts): Add --eh-frame-hdr. (parse_args): Handle it. (list_options): Add --eh-frame-hdr to help. * emultempl/hppaelf.em (finish): Supply output_bfd to bfd_elf*_discard_info. * scripttempl/elf.sc (.eh_frame_hdr): Add. * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME.
2001-12-13 12:09:34 +01:00
elf_section_data (sec)->sec_info,
sym->st_value + rel->r_addend);
if (sec != *psec)
{
/* If we have changed the section, and our original section is
marked with SEC_EXCLUDE, it means that the original
SEC_MERGE section has been completely subsumed in some
other SEC_MERGE section. In this case, we need to leave
some info around for --emit-relocs. */
if ((sec->flags & SEC_EXCLUDE) != 0)
sec->kept_section = *psec;
sec = *psec;
}
* elf.c (_bfd_elf_rela_local_sym): Accept asection **, and return updated section in case of merged section. * elf-bfd.h (_bfd_elf_rela_local_sym): Update declaration. * elf-hppa.h (elf_hppa_relocate_section): Adjust call. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-fr30.c (fr30_elf_relocate_section): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-msp430.c (elf32_msp430_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section) Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise. * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sh64.c (sh_elf64_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Don't recalculate symbol section for reloc output. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-vax.c (elf_vax_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Don't recalculate everything for R_PPC_RELAX32 reloc. Don't bother checking ppc_elf_install_value return value. * elf64-ppc.c (ppc64_elf_relocate_section <R_PPC64_TOC>): Sanity check sec->id.
2003-11-05 14:17:09 +01:00
rel->r_addend -= relocation;
rel->r_addend += sec->output_section->vma + sec->output_offset;
* elf.c (_bfd_elf_rela_local_sym): New. * elflink.h (elf_link_input_bfd): Don't consider empty merged sections as removed in relocation tests. * elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype. * elf32-i386.c (elf_i386_relocate_section): Handle relocs against STT_SECTION symbol of SHF_MERGE section. * elf32-arm.h (elf32_arm_relocate_section): Likewise. * elf32-avr.c (elf32_avr_relocate_section): Call _bfd_elf_rela_local_sym. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. * elf32-fr30.c (fr30_final_link_relocate): Likewise. * elf32-h8300.c (elf32_h8_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-i860.c (elf32_i860_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mcore.c (mcore_elf_relocate_section): Likewise. * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. * elf32-v850.c (v850_elf_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-mmix.c (mmix_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elf-hppa.h (elf_hppa_relocate_section): Likewise. * elf-m10200.c (mn10200_elf_relocate_section): Likewise. * elf-m10300.c (mn10300_elf_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise for !partial_inplace relocs. Handle relocs against STT_SECTION symbol of SHF_MERGE for partial_inplace relocs. * config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test. * write.c (adjust_reloc_syms): Don't handle relocs against SEC_MERGE section symbols specially. (fixup_segment): Likewise.
2001-11-23 13:17:21 +01:00
}
return relocation;
}
bfd_vma
_bfd_elf_rel_local_sym (bfd *abfd,
Elf_Internal_Sym *sym,
asection **psec,
bfd_vma addend)
{
asection *sec = *psec;
PR ld/13991 bfd/ * bfd/elf-bfd.h (_bfd_elf_link_just_syms): Define as _bfd_generic_link_just_syms. * bfd/elflink.c (_bfd_elf_link_just_syms): Delete. * bfd/linker.c (_bfd_generic_link_just_syms): Set sec_info_type. * bfd/bfd-in.h (discarded_section): Renamed from elf_discarded_section. * bfd/section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS, SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME, SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE. * bfd/elf-eh-frame.c, * bfd/elf-m10200.c, * bfd/elf-m10300.c, * bfd/elf.c, * bfd/elf32-arm.c, * bfd/elf32-avr.c, * bfd/elf32-bfin.c, * bfd/elf32-cr16.c, * bfd/elf32-cr16c.c, * bfd/elf32-cris.c, * bfd/elf32-crx.c, * bfd/elf32-d10v.c, * bfd/elf32-epiphany.c, * bfd/elf32-fr30.c, * bfd/elf32-frv.c, * bfd/elf32-h8300.c, * bfd/elf32-hppa.c, * bfd/elf32-i370.c, * bfd/elf32-i386.c, * bfd/elf32-i860.c, * bfd/elf32-ip2k.c, * bfd/elf32-iq2000.c, * bfd/elf32-lm32.c, * bfd/elf32-m32c.c, * bfd/elf32-m32r.c, * bfd/elf32-m68hc1x.c, * bfd/elf32-m68k.c, * bfd/elf32-mcore.c, * bfd/elf32-mep.c, * bfd/elf32-moxie.c, * bfd/elf32-msp430.c, * bfd/elf32-mt.c, * bfd/elf32-openrisc.c, * bfd/elf32-ppc.c, * bfd/elf32-rl78.c, * bfd/elf32-rx.c, * bfd/elf32-s390.c, * bfd/elf32-score.c, * bfd/elf32-score7.c, * bfd/elf32-sh.c, * bfd/elf32-spu.c, * bfd/elf32-tic6x.c, * bfd/elf32-tilepro.c, * bfd/elf32-v850.c, * bfd/elf32-vax.c, * bfd/elf32-xc16x.c, * bfd/elf32-xstormy16.c, * bfd/elf32-xtensa.c, * bfd/elf64-alpha.c, * bfd/elf64-hppa.c, * bfd/elf64-ia64-vms.c, * bfd/elf64-mmix.c, * bfd/elf64-ppc.c, * bfd/elf64-s390.c, * bfd/elf64-sh64.c, * bfd/elf64-x86-64.c, * bfd/elflink.c, * bfd/elfnn-ia64.c, * bfd/elfxx-mips.c, * bfd/elfxx-sparc.c, * bfd/elfxx-tilegx.c, * bfd/reloc.c: Update all references. * bfd/bfd-in2.h: Regenerate. ld/ * ld/ldlang.c (size_input_section): Use sec_info_type rather than usrdata->flags.just_syms. * ld/ldwrite.c (build_link_order): Likewise. * ld/emultempl/hppaelf.em (build_section_lists): Likewise. * ld/emultempl/ppc64elf.em (build_toc_list): Likewise. * ld/emultempl/armelf.em (build_section_lists): Likewise. (after_allocation): Update for renamed sec_info_type value. * ld/emultempl/tic6xdsbt.em: Likewise.
2012-04-24 07:12:40 +02:00
if (sec->sec_info_type != SEC_INFO_TYPE_MERGE)
return sym->st_value + addend;
return _bfd_merged_section_offset (abfd, psec,
* elf-bfd.h (enum elf_link_info_type): New. (struct bfd_elf_section_data): Remove stab_info and merge_info fields, add sec_info and sec_info_type. (struct elf_obj_tdata): Add eh_frame_hdr field. (_bfd_elf_discard_section_eh_frame): New prototype. (_bfd_elf_discard_section_eh_frame_hdr): Likewise. (_bfd_elf_eh_frame_section_offset): Likewise. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_write_section_eh_frame_hdr): Likewise. * Makefile.am (BFD32_BACKENDS): Add elf-eh-frame.lo. (BFD32_BACKENDS_CFILES): Add elf-eh-frame.c. (elf-eh-frame.lo): New. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-eh-frame.lo. * configure: Rebuilt. * elf.c (_bfd_elf_print_private_bfd_data): Support PT_GNU_EH_FRAME. (map_sections_to_segments): Create PT_GNU_EH_FRAME if requested. (get_program_header_size): Take into account PT_GNU_EH_FRAME segment. (_bfd_elf_rela_local_sym): Use sec_info_type and sec_info. (_bfd_elf_rel_local_sym): Likewise. (_bfd_elf_section_offset): Likewise. Call _bfd_elf_eh_frame_section_offset too. * elfxx-ia64.c (elfNN_ia64_relocate_section): Use sec_info_type and sec_info. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf-eh-frame.c: New file. * elflink.h (elf_link_add_object_symbols): Don't optimize SHF_MERGE .stab sections. Set sec_info_type, use sec_info instead of merge_info and stab_info. (elf_link_create_dynamic_sections): Create .eh_frame_hdr section if --eh-frame-hdr. (elf_bfd_final_link): Write .eh_frame_hdr section. (elf_link_sec_merge_syms): Use sec_info_type and sec_info. (elf_link_input_bfd): Likewise. Call _bfd_elf_write_section_eh_frame to write .eh_frame sections. (elf_bfd_discard_info): Add output_bfd argument. Call _bfd_elf_discard_section_eh_frame and _bfd_elf_discard_section_eh_frame_hdr. (elf_section_ignore_discarded_relocs): Use sec_info_type, not section names. * bfd-in.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Adjust prototypes. * bfd-in2.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Likewise. * elf/common.h (PT_GNU_EH_FRAME): Define. * bfdlink.h (struct bfd_link_info): Add eh_frame_hdr field. * emultempl/elf32.em (finish): Supply output_bfd to bfd_elf*_discard_info. (OPTION_EH_FRAME_HDR): Define. (longopts): Add --eh-frame-hdr. (parse_args): Handle it. (list_options): Add --eh-frame-hdr to help. * emultempl/hppaelf.em (finish): Supply output_bfd to bfd_elf*_discard_info. * scripttempl/elf.sc (.eh_frame_hdr): Add. * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME.
2001-12-13 12:09:34 +01:00
elf_section_data (sec)->sec_info,
sym->st_value + addend);
}
bfd_vma
_bfd_elf_section_offset (bfd *abfd,
struct bfd_link_info *info,
asection *sec,
bfd_vma offset)
{
bfd * elf-bfd.h (enum elf_link_info_type): Remove. (struct bfd_elf_section_data): Move sec_info_type, use_rela_p fields to struct sec. Remove linkonce_p field. (elf_linkonce_p): Delete. (elf_discarded_section): Update for sec_info_type change. * section.c (struct sec): Add sec_info_type, use_rela_p, has_tls_reloc, flag11, flag12, flag13, flag14, flag15, flag16, flag20, flag24. (ELF_INFO_TYPE_NONE): Define. (ELF_INFO_TYPE_STABS): Define. (ELF_INFO_TYPE_MERGE): Define. (ELF_INFO_TYPE_EH_FRAME): Define. (ELF_INFO_TYPE_JUST_SYMS): Define. (STD_SECTION): Update struct sec initializer. * ecoff.c (bfd_debug_section): Likewise. * elf.c: Likewise. Update occurrences of sec_info_type and use_rela_p. * elflink.h: Likewise. * elf-eh-frame.c: Likewise. * elf64-alpha.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * bfd-in2.h: Regenerate. * elf32-sparc.c (sec_do_relax): Use elf_section_data macro rather than referring to used_by_bfd. * elf64-sparc.c (sec_do_relax): Likewise. * elf64-mmix.c (mmix_elf_section_data): Likewise. * elfxx-mips.c (mips_elf_section_data): Likewise. * ieee.c (ieee_slurp_section_data): Use ieee_per_section macro. (ieee_get_section_contents): Likewise. (ieee_new_section_hook): Formatting. (ieee_canonicalize_reloc): Remove commented out code. * mmo.c (mmo_section_data): Define. Use throughout file. * oasys.c (oasys_get_section_contents): Use oasys_per_section macro. gas * config/obj-elf.c (obj_elf_change_section): Set SEC_LINK_ONCE and SEC_LINK_DUPLICATES_DISCARD directly rather than using elf_linkonce_p.
2003-02-04 13:34:08 +01:00
switch (sec->sec_info_type)
* elf-bfd.h (enum elf_link_info_type): New. (struct bfd_elf_section_data): Remove stab_info and merge_info fields, add sec_info and sec_info_type. (struct elf_obj_tdata): Add eh_frame_hdr field. (_bfd_elf_discard_section_eh_frame): New prototype. (_bfd_elf_discard_section_eh_frame_hdr): Likewise. (_bfd_elf_eh_frame_section_offset): Likewise. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_write_section_eh_frame_hdr): Likewise. * Makefile.am (BFD32_BACKENDS): Add elf-eh-frame.lo. (BFD32_BACKENDS_CFILES): Add elf-eh-frame.c. (elf-eh-frame.lo): New. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-eh-frame.lo. * configure: Rebuilt. * elf.c (_bfd_elf_print_private_bfd_data): Support PT_GNU_EH_FRAME. (map_sections_to_segments): Create PT_GNU_EH_FRAME if requested. (get_program_header_size): Take into account PT_GNU_EH_FRAME segment. (_bfd_elf_rela_local_sym): Use sec_info_type and sec_info. (_bfd_elf_rel_local_sym): Likewise. (_bfd_elf_section_offset): Likewise. Call _bfd_elf_eh_frame_section_offset too. * elfxx-ia64.c (elfNN_ia64_relocate_section): Use sec_info_type and sec_info. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf-eh-frame.c: New file. * elflink.h (elf_link_add_object_symbols): Don't optimize SHF_MERGE .stab sections. Set sec_info_type, use sec_info instead of merge_info and stab_info. (elf_link_create_dynamic_sections): Create .eh_frame_hdr section if --eh-frame-hdr. (elf_bfd_final_link): Write .eh_frame_hdr section. (elf_link_sec_merge_syms): Use sec_info_type and sec_info. (elf_link_input_bfd): Likewise. Call _bfd_elf_write_section_eh_frame to write .eh_frame sections. (elf_bfd_discard_info): Add output_bfd argument. Call _bfd_elf_discard_section_eh_frame and _bfd_elf_discard_section_eh_frame_hdr. (elf_section_ignore_discarded_relocs): Use sec_info_type, not section names. * bfd-in.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Adjust prototypes. * bfd-in2.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Likewise. * elf/common.h (PT_GNU_EH_FRAME): Define. * bfdlink.h (struct bfd_link_info): Add eh_frame_hdr field. * emultempl/elf32.em (finish): Supply output_bfd to bfd_elf*_discard_info. (OPTION_EH_FRAME_HDR): Define. (longopts): Add --eh-frame-hdr. (parse_args): Handle it. (list_options): Add --eh-frame-hdr to help. * emultempl/hppaelf.em (finish): Supply output_bfd to bfd_elf*_discard_info. * scripttempl/elf.sc (.eh_frame_hdr): Add. * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME.
2001-12-13 12:09:34 +01:00
{
PR ld/13991 bfd/ * bfd/elf-bfd.h (_bfd_elf_link_just_syms): Define as _bfd_generic_link_just_syms. * bfd/elflink.c (_bfd_elf_link_just_syms): Delete. * bfd/linker.c (_bfd_generic_link_just_syms): Set sec_info_type. * bfd/bfd-in.h (discarded_section): Renamed from elf_discarded_section. * bfd/section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS, SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME, SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE. * bfd/elf-eh-frame.c, * bfd/elf-m10200.c, * bfd/elf-m10300.c, * bfd/elf.c, * bfd/elf32-arm.c, * bfd/elf32-avr.c, * bfd/elf32-bfin.c, * bfd/elf32-cr16.c, * bfd/elf32-cr16c.c, * bfd/elf32-cris.c, * bfd/elf32-crx.c, * bfd/elf32-d10v.c, * bfd/elf32-epiphany.c, * bfd/elf32-fr30.c, * bfd/elf32-frv.c, * bfd/elf32-h8300.c, * bfd/elf32-hppa.c, * bfd/elf32-i370.c, * bfd/elf32-i386.c, * bfd/elf32-i860.c, * bfd/elf32-ip2k.c, * bfd/elf32-iq2000.c, * bfd/elf32-lm32.c, * bfd/elf32-m32c.c, * bfd/elf32-m32r.c, * bfd/elf32-m68hc1x.c, * bfd/elf32-m68k.c, * bfd/elf32-mcore.c, * bfd/elf32-mep.c, * bfd/elf32-moxie.c, * bfd/elf32-msp430.c, * bfd/elf32-mt.c, * bfd/elf32-openrisc.c, * bfd/elf32-ppc.c, * bfd/elf32-rl78.c, * bfd/elf32-rx.c, * bfd/elf32-s390.c, * bfd/elf32-score.c, * bfd/elf32-score7.c, * bfd/elf32-sh.c, * bfd/elf32-spu.c, * bfd/elf32-tic6x.c, * bfd/elf32-tilepro.c, * bfd/elf32-v850.c, * bfd/elf32-vax.c, * bfd/elf32-xc16x.c, * bfd/elf32-xstormy16.c, * bfd/elf32-xtensa.c, * bfd/elf64-alpha.c, * bfd/elf64-hppa.c, * bfd/elf64-ia64-vms.c, * bfd/elf64-mmix.c, * bfd/elf64-ppc.c, * bfd/elf64-s390.c, * bfd/elf64-sh64.c, * bfd/elf64-x86-64.c, * bfd/elflink.c, * bfd/elfnn-ia64.c, * bfd/elfxx-mips.c, * bfd/elfxx-sparc.c, * bfd/elfxx-tilegx.c, * bfd/reloc.c: Update all references. * bfd/bfd-in2.h: Regenerate. ld/ * ld/ldlang.c (size_input_section): Use sec_info_type rather than usrdata->flags.just_syms. * ld/ldwrite.c (build_link_order): Likewise. * ld/emultempl/hppaelf.em (build_section_lists): Likewise. * ld/emultempl/ppc64elf.em (build_toc_list): Likewise. * ld/emultempl/armelf.em (build_section_lists): Likewise. (after_allocation): Update for renamed sec_info_type value. * ld/emultempl/tic6xdsbt.em: Likewise.
2012-04-24 07:12:40 +02:00
case SEC_INFO_TYPE_STABS:
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 06:46:28 +02:00
return _bfd_stab_section_offset (sec, elf_section_data (sec)->sec_info,
offset);
PR ld/13991 bfd/ * bfd/elf-bfd.h (_bfd_elf_link_just_syms): Define as _bfd_generic_link_just_syms. * bfd/elflink.c (_bfd_elf_link_just_syms): Delete. * bfd/linker.c (_bfd_generic_link_just_syms): Set sec_info_type. * bfd/bfd-in.h (discarded_section): Renamed from elf_discarded_section. * bfd/section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS, SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME, SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE. * bfd/elf-eh-frame.c, * bfd/elf-m10200.c, * bfd/elf-m10300.c, * bfd/elf.c, * bfd/elf32-arm.c, * bfd/elf32-avr.c, * bfd/elf32-bfin.c, * bfd/elf32-cr16.c, * bfd/elf32-cr16c.c, * bfd/elf32-cris.c, * bfd/elf32-crx.c, * bfd/elf32-d10v.c, * bfd/elf32-epiphany.c, * bfd/elf32-fr30.c, * bfd/elf32-frv.c, * bfd/elf32-h8300.c, * bfd/elf32-hppa.c, * bfd/elf32-i370.c, * bfd/elf32-i386.c, * bfd/elf32-i860.c, * bfd/elf32-ip2k.c, * bfd/elf32-iq2000.c, * bfd/elf32-lm32.c, * bfd/elf32-m32c.c, * bfd/elf32-m32r.c, * bfd/elf32-m68hc1x.c, * bfd/elf32-m68k.c, * bfd/elf32-mcore.c, * bfd/elf32-mep.c, * bfd/elf32-moxie.c, * bfd/elf32-msp430.c, * bfd/elf32-mt.c, * bfd/elf32-openrisc.c, * bfd/elf32-ppc.c, * bfd/elf32-rl78.c, * bfd/elf32-rx.c, * bfd/elf32-s390.c, * bfd/elf32-score.c, * bfd/elf32-score7.c, * bfd/elf32-sh.c, * bfd/elf32-spu.c, * bfd/elf32-tic6x.c, * bfd/elf32-tilepro.c, * bfd/elf32-v850.c, * bfd/elf32-vax.c, * bfd/elf32-xc16x.c, * bfd/elf32-xstormy16.c, * bfd/elf32-xtensa.c, * bfd/elf64-alpha.c, * bfd/elf64-hppa.c, * bfd/elf64-ia64-vms.c, * bfd/elf64-mmix.c, * bfd/elf64-ppc.c, * bfd/elf64-s390.c, * bfd/elf64-sh64.c, * bfd/elf64-x86-64.c, * bfd/elflink.c, * bfd/elfnn-ia64.c, * bfd/elfxx-mips.c, * bfd/elfxx-sparc.c, * bfd/elfxx-tilegx.c, * bfd/reloc.c: Update all references. * bfd/bfd-in2.h: Regenerate. ld/ * ld/ldlang.c (size_input_section): Use sec_info_type rather than usrdata->flags.just_syms. * ld/ldwrite.c (build_link_order): Likewise. * ld/emultempl/hppaelf.em (build_section_lists): Likewise. * ld/emultempl/ppc64elf.em (build_toc_list): Likewise. * ld/emultempl/armelf.em (build_section_lists): Likewise. (after_allocation): Update for renamed sec_info_type value. * ld/emultempl/tic6xdsbt.em: Likewise.
2012-04-24 07:12:40 +02:00
case SEC_INFO_TYPE_EH_FRAME:
return _bfd_elf_eh_frame_section_offset (abfd, info, sec, offset);
* elf-bfd.h (enum elf_link_info_type): New. (struct bfd_elf_section_data): Remove stab_info and merge_info fields, add sec_info and sec_info_type. (struct elf_obj_tdata): Add eh_frame_hdr field. (_bfd_elf_discard_section_eh_frame): New prototype. (_bfd_elf_discard_section_eh_frame_hdr): Likewise. (_bfd_elf_eh_frame_section_offset): Likewise. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_write_section_eh_frame_hdr): Likewise. * Makefile.am (BFD32_BACKENDS): Add elf-eh-frame.lo. (BFD32_BACKENDS_CFILES): Add elf-eh-frame.c. (elf-eh-frame.lo): New. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-eh-frame.lo. * configure: Rebuilt. * elf.c (_bfd_elf_print_private_bfd_data): Support PT_GNU_EH_FRAME. (map_sections_to_segments): Create PT_GNU_EH_FRAME if requested. (get_program_header_size): Take into account PT_GNU_EH_FRAME segment. (_bfd_elf_rela_local_sym): Use sec_info_type and sec_info. (_bfd_elf_rel_local_sym): Likewise. (_bfd_elf_section_offset): Likewise. Call _bfd_elf_eh_frame_section_offset too. * elfxx-ia64.c (elfNN_ia64_relocate_section): Use sec_info_type and sec_info. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf-eh-frame.c: New file. * elflink.h (elf_link_add_object_symbols): Don't optimize SHF_MERGE .stab sections. Set sec_info_type, use sec_info instead of merge_info and stab_info. (elf_link_create_dynamic_sections): Create .eh_frame_hdr section if --eh-frame-hdr. (elf_bfd_final_link): Write .eh_frame_hdr section. (elf_link_sec_merge_syms): Use sec_info_type and sec_info. (elf_link_input_bfd): Likewise. Call _bfd_elf_write_section_eh_frame to write .eh_frame sections. (elf_bfd_discard_info): Add output_bfd argument. Call _bfd_elf_discard_section_eh_frame and _bfd_elf_discard_section_eh_frame_hdr. (elf_section_ignore_discarded_relocs): Use sec_info_type, not section names. * bfd-in.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Adjust prototypes. * bfd-in2.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Likewise. * elf/common.h (PT_GNU_EH_FRAME): Define. * bfdlink.h (struct bfd_link_info): Add eh_frame_hdr field. * emultempl/elf32.em (finish): Supply output_bfd to bfd_elf*_discard_info. (OPTION_EH_FRAME_HDR): Define. (longopts): Add --eh-frame-hdr. (parse_args): Handle it. (list_options): Add --eh-frame-hdr to help. * emultempl/hppaelf.em (finish): Supply output_bfd to bfd_elf*_discard_info. * scripttempl/elf.sc (.eh_frame_hdr): Add. * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME.
2001-12-13 12:09:34 +01:00
default:
if ((sec->flags & SEC_ELF_REVERSE_COPY) != 0)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd_size_type address_size = bed->s->arch_size / 8;
offset = sec->size - offset - address_size;
}
* elf-bfd.h (enum elf_link_info_type): New. (struct bfd_elf_section_data): Remove stab_info and merge_info fields, add sec_info and sec_info_type. (struct elf_obj_tdata): Add eh_frame_hdr field. (_bfd_elf_discard_section_eh_frame): New prototype. (_bfd_elf_discard_section_eh_frame_hdr): Likewise. (_bfd_elf_eh_frame_section_offset): Likewise. (_bfd_elf_write_section_eh_frame): Likewise. (_bfd_elf_write_section_eh_frame_hdr): Likewise. * Makefile.am (BFD32_BACKENDS): Add elf-eh-frame.lo. (BFD32_BACKENDS_CFILES): Add elf-eh-frame.c. (elf-eh-frame.lo): New. * Makefile.in: Rebuilt. * configure.in (elf): Add elf-eh-frame.lo. * configure: Rebuilt. * elf.c (_bfd_elf_print_private_bfd_data): Support PT_GNU_EH_FRAME. (map_sections_to_segments): Create PT_GNU_EH_FRAME if requested. (get_program_header_size): Take into account PT_GNU_EH_FRAME segment. (_bfd_elf_rela_local_sym): Use sec_info_type and sec_info. (_bfd_elf_rel_local_sym): Likewise. (_bfd_elf_section_offset): Likewise. Call _bfd_elf_eh_frame_section_offset too. * elfxx-ia64.c (elfNN_ia64_relocate_section): Use sec_info_type and sec_info. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf-eh-frame.c: New file. * elflink.h (elf_link_add_object_symbols): Don't optimize SHF_MERGE .stab sections. Set sec_info_type, use sec_info instead of merge_info and stab_info. (elf_link_create_dynamic_sections): Create .eh_frame_hdr section if --eh-frame-hdr. (elf_bfd_final_link): Write .eh_frame_hdr section. (elf_link_sec_merge_syms): Use sec_info_type and sec_info. (elf_link_input_bfd): Likewise. Call _bfd_elf_write_section_eh_frame to write .eh_frame sections. (elf_bfd_discard_info): Add output_bfd argument. Call _bfd_elf_discard_section_eh_frame and _bfd_elf_discard_section_eh_frame_hdr. (elf_section_ignore_discarded_relocs): Use sec_info_type, not section names. * bfd-in.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Adjust prototypes. * bfd-in2.h (bfd_elf32_discard_info, bfd_elf64_discard_info): Likewise. * elf/common.h (PT_GNU_EH_FRAME): Define. * bfdlink.h (struct bfd_link_info): Add eh_frame_hdr field. * emultempl/elf32.em (finish): Supply output_bfd to bfd_elf*_discard_info. (OPTION_EH_FRAME_HDR): Define. (longopts): Add --eh-frame-hdr. (parse_args): Handle it. (list_options): Add --eh-frame-hdr to help. * emultempl/hppaelf.em (finish): Supply output_bfd to bfd_elf*_discard_info. * scripttempl/elf.sc (.eh_frame_hdr): Add. * readelf.c (get_segment_type): Support PT_GNU_EH_FRAME.
2001-12-13 12:09:34 +01:00
return offset;
}
}
/* Create a new BFD as if by bfd_openr. Rather than opening a file,
reconstruct an ELF file by reading the segments out of remote memory
based on the ELF file header at EHDR_VMA and the ELF program headers it
points to. If not null, *LOADBASEP is filled in with the difference
between the VMAs from which the segments were read, and the VMAs the
file headers (and hence BFD's idea of each section's VMA) put them at.
The function TARGET_READ_MEMORY is called to copy LEN bytes from the
remote memory at target address VMA into the local buffer at MYADDR; it
should return zero on success or an `errno' code on failure. TEMPL must
be a BFD for an ELF target with the word size and byte order found in
the remote memory. */
bfd *
bfd_elf_bfd_from_remote_memory
(bfd *templ,
bfd_vma ehdr_vma,
bfd_vma *loadbasep,
include/ * xtensa-isa-internal.h (xtensa_length_decode_fn): Warning fix. * xtensa-isa.h (xtensa_insnbuf_to_chars): Likewise. (xtensa_insnbuf_from_chars, xtensa_isa_length_from_chars): Likewise. include/coff/ * xcoff.h (struct xcoff_loader_info): Warning fix. bfd/ * bfd-in.h (bfd_elf_bfd_from_remote_memory): Warning fix. * coff-m68k.c (bfd_m68k_coff_create_embedded_relocs): Likewise. * coff-rs6000.c (xcoff_write_armap_big): Warning fixes. Remove useless assignments. (xcoff_write_archive_contents_big): Likewise. (_bfd_xcoff_put_ldsymbol_name): Likewise. * coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise. * coffgen.c (coff_write_symbols): Make "written" a bfd_vma. * cofflink.c (process_embedded_commands): Warning fixes. * cpu-arm.c: Delete unnecessary prototypes. Convert to C90. Warning fixes. * dwarf2.c: Warning fixes. * elf-bfd.h: Likewise. * elf-eh-frame.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-sh-symbian.c: Likewise. * elf32-sh.c: Delete unnecessary prototypes. Warning fixes. * elf64-sh64.c: Likewise. * peicode.h: Likewise. * elf64-mmix.c: Warning fixes. * elfcode.h: Likewise. * elfxx-mips.c: Likewise. * libbfd-in.h: Likewise. * libbfd.c: Likewise. * mach-o.c: Likewise. * merge.c: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * pef.c: Likewise. * srec.c: Likewise. * vms-hdr.c: Likewise. * vms-tir.c: Likewise. * xtensa-isa.c: Likewise. * xtensa-modules.c: Likewise. * xsym.c: Likewise. (pstrcmp): Use correct choice of string lengths. Fix return value. (bfd_sym_module_name): Correct string length. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2005-02-20 15:59:07 +01:00
int (*target_read_memory) (bfd_vma, bfd_byte *, int))
{
return (*get_elf_backend_data (templ)->elf_backend_bfd_from_remote_memory)
(templ, ehdr_vma, loadbasep, target_read_memory);
}
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
long
_bfd_elf_get_synthetic_symtab (bfd *abfd,
long symcount ATTRIBUTE_UNUSED,
asymbol **syms ATTRIBUTE_UNUSED,
long dynsymcount,
asymbol **dynsyms,
asymbol **ret)
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
asection *relplt;
asymbol *s;
const char *relplt_name;
bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
arelent *p;
long count, i, n;
size_t size;
Elf_Internal_Shdr *hdr;
char *names;
asection *plt;
*ret = NULL;
if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0)
return 0;
if (dynsymcount <= 0)
return 0;
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
if (!bed->plt_sym_val)
return 0;
relplt_name = bed->relplt_name;
if (relplt_name == NULL)
relplt_name = bed->rela_plts_and_copies_p ? ".rela.plt" : ".rel.plt";
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
relplt = bfd_get_section_by_name (abfd, relplt_name);
if (relplt == NULL)
return 0;
hdr = &elf_section_data (relplt)->this_hdr;
if (hdr->sh_link != elf_dynsymtab (abfd)
|| (hdr->sh_type != SHT_REL && hdr->sh_type != SHT_RELA))
return 0;
plt = bfd_get_section_by_name (abfd, ".plt");
if (plt == NULL)
return 0;
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
if (! (*slurp_relocs) (abfd, relplt, dynsyms, TRUE))
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
return -1;
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 06:46:28 +02:00
count = relplt->size / hdr->sh_entsize;
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
size = count * sizeof (asymbol);
p = relplt->relocation;
for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)
{
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
if (p->addend != 0)
{
#ifdef BFD64
size += sizeof ("+0x") - 1 + 8 + 8 * (bed->s->elfclass == ELFCLASS64);
#else
size += sizeof ("+0x") - 1 + 8;
#endif
}
}
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
Updated soruces in bfd/* to compile cleanly with -Wc++-compat. * bfd/aoutx.h: Add casts. * bfd/archive.c: Add casts. * bfd/archive64.c: Add casts. * bfd/archures.c: Add casts. * bfd/bfd-in2.h: Regenerated. * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top level. * bfd/bfdio.c: Add casts. * bfd/binary.c: Add casts. * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated parameter to use enum value instead of int. * bfd/coffcode.h: Add casts. * bfd/coffgen.c: Add casts. * bfd/cofflink.c: Add casts. * bfd/compress.c: Add casts. * bfd/dwarf1.c: Add casts. * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member bfd to bfd_ptr. Update code to use new name. * bfd/elf-attrs.c: Add casts. * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to anonymous struct. (union gotplt_union, struct elf_link_virtual_table_entry): Move to top level. * bfd/elf-eh-frame.c: Add casts. * bfd/elf-strtab.c: Add casts. * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change argument name from typename to type_name. * bfd/elf32-i386.c: Add casts. * bfd/elf64-x86-64.c: Add casts. * bfd/elfcode.h: Add casts. * bfd/elfcore.h: Add casts. * bfd/elflink.c: Add casts. * bfd/format.c: Add casts. * bfd/hash.c: Add casts. * bfd/ihex.c: Add casts. * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to top level. * bfd/libbfd.c: Add casts. * bfd/linker.c: Add casts. * bfd/merge.c: Add casts. * bfd/opncls.c: Add casts. * bfd/peXXigen.c: Add casts. * bfd/peicode.h: Add casts. * bfd/reloc.c: Add casts. * bfd/section.c: Add casts. * bfd/simple.c: Add casts. * bfd/srec.c: Add casts. * bfd/stabs.c: Add casts. * bfd/syms.c: Add casts. * bfd/targets.c: Add casts. * bfd/tekhex.c: Add casts. * bfd/verilog.c: Add casts. * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to top level.
2009-09-09 23:38:59 +02:00
s = *ret = (asymbol *) bfd_malloc (size);
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
if (s == NULL)
return -1;
names = (char *) (s + count);
p = relplt->relocation;
n = 0;
for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
{
size_t len;
bfd_vma addr;
addr = bed->plt_sym_val (i, plt, p);
if (addr == (bfd_vma) -1)
continue;
*s = **p->sym_ptr_ptr;
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
we are defining a symbol, ensure one of them is set. */
if ((s->flags & BSF_LOCAL) == 0)
s->flags |= BSF_GLOBAL;
s->flags |= BSF_SYNTHETIC;
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
s->section = plt;
s->value = addr - plt->vma;
s->name = names;
s->udata.p = NULL;
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
len = strlen ((*p->sym_ptr_ptr)->name);
memcpy (names, (*p->sym_ptr_ptr)->name, len);
names += len;
if (p->addend != 0)
{
char buf[30], *a;
memcpy (names, "+0x", sizeof ("+0x") - 1);
names += sizeof ("+0x") - 1;
bfd_sprintf_vma (abfd, buf, p->addend);
for (a = buf; *a == '0'; ++a)
;
len = strlen (a);
memcpy (names, a, len);
names += len;
}
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
memcpy (names, "@plt", sizeof ("@plt"));
names += sizeof ("@plt");
++s, ++n;
bfd/ * bfd.c (bfd_get_synthetic_symtab): Define. * targets.c (BFD_JUMP_TABLE_DYNAMIC): Add NAME##_get_synthetic_symtab. (struct bfd_target): Add _bfd_get_synthetic_symtab. * libbfd-in.h (_bfd_nodynamic_get_synthetic_symtab): Define. * elf-bfd.h (struct elf_backend_data): Add plt_sym_val and relplt_name fields. (_bfd_elf_get_synthetic_symtab): New prototype. * elfcode.h (elf_get_synthetic_symtab): Define. * elf.c (_bfd_elf_get_synthetic_symtab): New function. * elfxx-target.h (bfd_elfNN_get_synthetic_symtab): Define. (elf_backend_plt_sym_val, elf_backend_relplt_name): Define. (elfNN_bed): Add elf_backend_plt_sym_val and elf_backend_relplt_name. * bfd-in2.h: Rebuilt. * libbfd.h: Rebuilt. * elf32-i386.c (elf_i386_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-x86-64.c (elf64_x86_64_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-s390.c (elf_s390_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-sparc (elf32_sparc_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf64-sparc.c (sparc64_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * elf32-ppc.c (ppc_elf_plt_sym_val): New function. (elf_backend_plt_sym_val): Define. * aout-target.h (MY_get_synthetic_symtab): Define. * aout-tic30.c (MY_get_synthetic_symtab): Define. * coff-rs6000.c (rs6000coff_vec): Add _bfd_nodynamic_get_synthetic_symtab. (pmac_xcoff_vec): Likewise. * coff64-rs6000.c (rs6000coff64_vec): Add _bfd_nodynamic_get_synthetic_symtab. (aix5coff64_vec): Likewise. * sunos.c (MY_get_synthetic_symtab): Define. * vms.c (vms_get_synthetic_symtab): Define. binutils/ * objdump.c (synthsyms, synthcount): New variables. (disassemble_data): Use dynsyms for stripped binaries or libraries. Add synthetized symbols. (dump_bfd): For disassemble, initialize dynsyms always and also synthsyms. Free synthsyms and clear {sym,dynsym,synth}count before returning.
2004-04-22 16:45:32 +02:00
}
return n;
}
bfd/ 2005-07-25 Jan Hubicka <jh@suse.cz> H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (_bfd_elf_large_com_section): New. * elf.c (_bfd_elf_large_com_section): New. Defined. * elf64-x86-64.c (elf64_x86_64_add_symbol_hook): New. (elf64_x86_64_elf_section_from_bfd_section): New. (elf64_x86_64_symbol_processing): New. (elf64_x86_64_common_definition): New. (elf64_x86_64_common_section_index): New. (elf64_x86_64_common_section): New. (elf64_x86_64_merge_symbol): New. (elf64_x86_64_additional_program_headers): New. (elf64_x86_64_special_sections): New. (elf_backend_section_from_bfd_section): New. Defined. (elf_backend_add_symbol_hook): Likewise. (elf_backend_common_section_index): Likewise. (elf_backend_common_section): Likewise. (elf_backend_common_definition): Likewise. (elf_backend_merge_symbol): Likewise. (elf_backend_special_sections): Likewise. (elf_backend_additional_program_headers): Likewise. binutils/ 2005-07-25 H.J. Lu <hongjiu.lu@intel.com> * readelf.c (dump_relocations): Handle SHN_X86_64_LCOMMON. (get_symbol_index_type): Likewise. (get_elf_section_flags): Handle SHF_X86_64_LARGE. gas/ 2005-07-25 Jan Hubicka <jh@suse.cz> H.J. Lu <hongjiu.lu@intel.com> * config/obj-elf.c: Include "elf/x86-64.h" if TC_I386 is defined. (elf_com_section_ptr): New. (elf_begin): Set elf_com_section_ptr to bfd_com_section_ptr. (elf_common_parse): Make it global. Use elf_com_section_ptr instead of bfd_com_section_ptr. (obj_elf_change_section): Handle x86-64 large bss sections. * config/obj-elf.h (elf_com_section_ptr): New. (elf_common_parse): New. * config/tc-i386.c (handle_large_common): New. (md_pseudo_table): Add "largecomm". (x86_64_section_letter): New. (x86_64_section_word): New. * config/tc-i386.h (x86_64_section_word): New. (x86_64_section_letter): New. (md_elf_section_letter): New. Defined. (md_elf_section_word): Likewise. include/elf/ 2005-07-25 Jan Hubicka <jh@suse.cz> * x86-64.h (SHN_X86_64_LCOMMON): New. (SHF_X86_64_LARGE): New. ld/ 2005-07-25 Jan Hubicka <jh@suse.cz> H.J. Lu <hongjiu.lu@intel.com> * emulparams/elf_x86_64.sh (LARGE_SECTIONS): New. * scripttempl/elf.sc: Updated for large section support.
2005-07-25 17:41:08 +02:00
/* It is only used by x86-64 so far. */
asection _bfd_elf_large_com_section
= BFD_FAKE_SECTION (_bfd_elf_large_com_section,
bfd/ * libbfd-in.h (_bfd_generic_new_section_hook): Declare. * section.c (bfd_abs_symbol, bfd_com_symbol): Delete. (bfd_und_symbol, bfd_ind_symbol): Delete. (BFD_FAKE_SECTION): Remove SYM_PTR param, set symbol_ptr_ptr to &SEC.symbol. (STD_SECTION): Adjust. (_bfd_generic_new_section_hook): New function, extracted from.. (bfd_section_init): ..here. (bfd_make_section_old_way): Call new_section_hook for abs, com, und and ind sections. * elf.c (_bfd_elf_large_com_section): Adjust. * aoutx.h (new_section_hook): Call _bfd_generic_new_section_hook. * pdp11.c (new_section_hook): Likewise. * coffcode.h (coff_new_section_hook): Likewise. * ecoff.c (_bfd_ecoff_new_section_hook): Likewise. * elf.c (_bfd_elf_new_section_hook): Likewise. * vms.c (vms_new_section_hook): Likwise. * elf32-arm.c (elf32_arm_new_section_hook): Check used_by_bfd isn't already set. * elf32-sh64.c (sh64_elf_new_section_hook): Likewise. * elf32-xtensa.c (elf_xtensa_new_section_hook): Likewise. * elf64-mmix.c (mmix_elf_new_section_hook): Likewise. * elf64-ppc.c (ppc64_elf_new_section_hook): Likewise. * elfxx-mips.c (_bfd_mips_elf_new_section_hook): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_new_section_hook): Likewise. * ieee.c (ieee_new_section_hook): Likewise. Call _bfd_generic_new_section_hook too. * mmo.c (mmo_new_section_hook): Likewise. * oasys.c (oasys_new_section_hook): Likewise. * som.c (som_new_section_hook): Likewise. * coff-w65.c (reloc_processing): Don't use bfd_abs_symbol. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. gas/ * subsegs.c (subseg_get): Don't call obj_sec_set_private_data. * config/obj-elf.h (obj_sec_set_private_data): Delete. * config/tc-hppa.c (tc_gen_reloc): Don't use bfd_abs_symbol. * config/tc-mn10300.c (tc_gen_reloc): Likewise.
2006-05-03 16:26:41 +02:00
SEC_IS_COMMON, NULL, "LARGE_COMMON", 0);
2007-03-13 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3826 * elf-bfd.h (elf_backend_data): Add elf_osabi. (_bfd_elf_set_osabi): New. * elf.c (_bfd_elf_set_osabi): New. * elf32-hppa.c (elf32_hppa_post_process_headers): Removed. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. (ELF_OSABI): Properly defined for each target. * elf32-i370.c (i370_elf_post_process_headers): Removed. (ELF_OSABI): Defined. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elf32-i386.c (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf_i386_post_process_headers): Set EI_OSABI with elf_osabi. * elf32-msp430.c (elf32_msp430_post_process_headers): Removed. (ELF_OSABI): Defined. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elf64-alpha.c (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf64_alpha_fbsd_post_process_headers): Set EI_OSABI with elf_osabi. * elf64-hppa.c (elf64_hppa_post_process_headers): Set EI_OSABI with elf_osabi. (ELF_OSABI): Properly defined for each target. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi for Linux. * elf64-sparc.c (elf64_sparc_fbsd_post_process_headers): Removed. (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elf64-x86-64.c (elf64_x86_64_fbsd_post_process_headers): Removed. (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elfcode.h (elf_object_p): Match the ELFOSABI_NONE ELF target with any ELF target of the compatible machine for which we do not have a specific backend. * elfxx-ia64.c (elfNN_hpux_post_process_headers): Set EI_OSABI with elf_osabi. * elfxx-target.h (ELF_OSABI): Default to ELFOSABI_NONE. (elfNN_bed): Initialize elf_osabi with ELF_OSABI.
2007-03-14 03:56:45 +01:00
void
_bfd_elf_set_osabi (bfd * abfd,
struct bfd_link_info * link_info ATTRIBUTE_UNUSED)
{
Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */
i_ehdrp = elf_elfheader (abfd);
i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
include/elf 2009-04-30 Nick Clifton <nickc@redhat.com> * common.h (STT_GNU_IFUNC): Define. elfcpp 2009-04-30 Nick Clifton <nickc@redhat.com> * (enum STT): Add STT_GNU_IFUNC. gas 2009-04-30 Nick Clifton <nickc@redhat.com> * config/obj-elf.c (obj_elf_type): Add support for a gnu_indirect_function type. * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups against indirect function symbols. * doc/as.texinfo (.type): Document the support for the gnu_indirect_function symbol type. * NEWS: Mention the new feature. gas/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * gas/elf/elf.exp: Extend type test to include an ifunc symbol. Provide an alternative test for targets which do not support ifunc symbols. (type.s): Add entry for an ifunc symbol. (type.e): Add ifunc entry to expected symbol dump. (section2.e-armelf): Add entry for ifunc symbol. (type-noifunc.s): New file. (type-noifunc.e): New file. bfd/ 2009-04-30 Nick Clifton <nickc@redhat.com> * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs section pointer. (struct elf_obj_data): Add has_ifunc_symbols boolean. * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags into a STT_GNU_IFUNC symbol type. (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function type. (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if the binary contains ifunc symbols. * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC symbol type into a BSF_GNU_INDIRECT_FUNCTION flag. * elf32-i386.c (is_indirect_function): New function. (elf_i386_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf_i386_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): New function. Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. (elf_backend_add_symbol_hook): Define. (elf_i386_post_process_headers): Rename to elf_i388_fbsd_post_process_headers. * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro. (is_indirect_function): New function. (elf64_x86_64_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf64_x86_64_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT if we have ifunc symbols to handle. (get_ifunc_reloc_section_name): New function. Computes the name for an ifunc section. (_bfd_elf_make_ifunc_reloc_section): New function. Creates a section to hold ifunc relocs. * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define. (bfd_print_symbol_vandf): Handle ifunc symbols. (bfd_decode_symclass): Likewise. * bfd-in2.h: Regenerate. binutils 2009-04-30 Nick Clifton <nickc@redhat.com> * readelf.c (dump_relocations): Display a relocation against an ifunc symbol as if it were a function invocation. (get_symbol_type): Handle STT_GNU_IFUNC. ld 2009-04-30 Nick Clifton <nickc@redhat.com> * NEWS: Mention support for IFUNC symbols. ld/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * ld-ifunc: New directory. * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests. * ld-ifunc/prog.c: New file. * ld-ifunc/lib.c: New file.
2009-04-30 17:47:13 +02:00
/* To make things simpler for the loader on Linux systems we set the
osabi field to ELFOSABI_GNU if the binary contains symbols of
the STT_GNU_IFUNC type or STB_GNU_UNIQUE binding. */
include/elf 2009-04-30 Nick Clifton <nickc@redhat.com> * common.h (STT_GNU_IFUNC): Define. elfcpp 2009-04-30 Nick Clifton <nickc@redhat.com> * (enum STT): Add STT_GNU_IFUNC. gas 2009-04-30 Nick Clifton <nickc@redhat.com> * config/obj-elf.c (obj_elf_type): Add support for a gnu_indirect_function type. * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups against indirect function symbols. * doc/as.texinfo (.type): Document the support for the gnu_indirect_function symbol type. * NEWS: Mention the new feature. gas/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * gas/elf/elf.exp: Extend type test to include an ifunc symbol. Provide an alternative test for targets which do not support ifunc symbols. (type.s): Add entry for an ifunc symbol. (type.e): Add ifunc entry to expected symbol dump. (section2.e-armelf): Add entry for ifunc symbol. (type-noifunc.s): New file. (type-noifunc.e): New file. bfd/ 2009-04-30 Nick Clifton <nickc@redhat.com> * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs section pointer. (struct elf_obj_data): Add has_ifunc_symbols boolean. * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags into a STT_GNU_IFUNC symbol type. (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function type. (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if the binary contains ifunc symbols. * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC symbol type into a BSF_GNU_INDIRECT_FUNCTION flag. * elf32-i386.c (is_indirect_function): New function. (elf_i386_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf_i386_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): New function. Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. (elf_backend_add_symbol_hook): Define. (elf_i386_post_process_headers): Rename to elf_i388_fbsd_post_process_headers. * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro. (is_indirect_function): New function. (elf64_x86_64_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf64_x86_64_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT if we have ifunc symbols to handle. (get_ifunc_reloc_section_name): New function. Computes the name for an ifunc section. (_bfd_elf_make_ifunc_reloc_section): New function. Creates a section to hold ifunc relocs. * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define. (bfd_print_symbol_vandf): Handle ifunc symbols. (bfd_decode_symclass): Likewise. * bfd-in2.h: Regenerate. binutils 2009-04-30 Nick Clifton <nickc@redhat.com> * readelf.c (dump_relocations): Display a relocation against an ifunc symbol as if it were a function invocation. (get_symbol_type): Handle STT_GNU_IFUNC. ld 2009-04-30 Nick Clifton <nickc@redhat.com> * NEWS: Mention support for IFUNC symbols. ld/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * ld-ifunc: New directory. * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests. * ld-ifunc/prog.c: New file. * ld-ifunc/lib.c: New file.
2009-04-30 17:47:13 +02:00
if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE
&& elf_tdata (abfd)->has_gnu_symbols)
i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_GNU;
2007-03-13 H.J. Lu <hongjiu.lu@intel.com> PR binutils/3826 * elf-bfd.h (elf_backend_data): Add elf_osabi. (_bfd_elf_set_osabi): New. * elf.c (_bfd_elf_set_osabi): New. * elf32-hppa.c (elf32_hppa_post_process_headers): Removed. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. (ELF_OSABI): Properly defined for each target. * elf32-i370.c (i370_elf_post_process_headers): Removed. (ELF_OSABI): Defined. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elf32-i386.c (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf_i386_post_process_headers): Set EI_OSABI with elf_osabi. * elf32-msp430.c (elf32_msp430_post_process_headers): Removed. (ELF_OSABI): Defined. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elf64-alpha.c (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf64_alpha_fbsd_post_process_headers): Set EI_OSABI with elf_osabi. * elf64-hppa.c (elf64_hppa_post_process_headers): Set EI_OSABI with elf_osabi. (ELF_OSABI): Properly defined for each target. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi for Linux. * elf64-sparc.c (elf64_sparc_fbsd_post_process_headers): Removed. (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elf64-x86-64.c (elf64_x86_64_fbsd_post_process_headers): Removed. (ELF_OSABI): Defined to ELFOSABI_FREEBSD for freebsd. (elf_backend_post_process_headers): Defined with _bfd_elf_set_osabi. * elfcode.h (elf_object_p): Match the ELFOSABI_NONE ELF target with any ELF target of the compatible machine for which we do not have a specific backend. * elfxx-ia64.c (elfNN_hpux_post_process_headers): Set EI_OSABI with elf_osabi. * elfxx-target.h (ELF_OSABI): Default to ELFOSABI_NONE. (elfNN_bed): Initialize elf_osabi with ELF_OSABI.
2007-03-14 03:56:45 +01:00
}
/* Return TRUE for ELF symbol types that represent functions.
This is the default version of this function, which is sufficient for
include/elf 2009-04-30 Nick Clifton <nickc@redhat.com> * common.h (STT_GNU_IFUNC): Define. elfcpp 2009-04-30 Nick Clifton <nickc@redhat.com> * (enum STT): Add STT_GNU_IFUNC. gas 2009-04-30 Nick Clifton <nickc@redhat.com> * config/obj-elf.c (obj_elf_type): Add support for a gnu_indirect_function type. * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups against indirect function symbols. * doc/as.texinfo (.type): Document the support for the gnu_indirect_function symbol type. * NEWS: Mention the new feature. gas/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * gas/elf/elf.exp: Extend type test to include an ifunc symbol. Provide an alternative test for targets which do not support ifunc symbols. (type.s): Add entry for an ifunc symbol. (type.e): Add ifunc entry to expected symbol dump. (section2.e-armelf): Add entry for ifunc symbol. (type-noifunc.s): New file. (type-noifunc.e): New file. bfd/ 2009-04-30 Nick Clifton <nickc@redhat.com> * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs section pointer. (struct elf_obj_data): Add has_ifunc_symbols boolean. * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags into a STT_GNU_IFUNC symbol type. (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function type. (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if the binary contains ifunc symbols. * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC symbol type into a BSF_GNU_INDIRECT_FUNCTION flag. * elf32-i386.c (is_indirect_function): New function. (elf_i386_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf_i386_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): New function. Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. (elf_backend_add_symbol_hook): Define. (elf_i386_post_process_headers): Rename to elf_i388_fbsd_post_process_headers. * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro. (is_indirect_function): New function. (elf64_x86_64_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf64_x86_64_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT if we have ifunc symbols to handle. (get_ifunc_reloc_section_name): New function. Computes the name for an ifunc section. (_bfd_elf_make_ifunc_reloc_section): New function. Creates a section to hold ifunc relocs. * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define. (bfd_print_symbol_vandf): Handle ifunc symbols. (bfd_decode_symclass): Likewise. * bfd-in2.h: Regenerate. binutils 2009-04-30 Nick Clifton <nickc@redhat.com> * readelf.c (dump_relocations): Display a relocation against an ifunc symbol as if it were a function invocation. (get_symbol_type): Handle STT_GNU_IFUNC. ld 2009-04-30 Nick Clifton <nickc@redhat.com> * NEWS: Mention support for IFUNC symbols. ld/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * ld-ifunc: New directory. * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests. * ld-ifunc/prog.c: New file. * ld-ifunc/lib.c: New file.
2009-04-30 17:47:13 +02:00
most targets. It returns true if TYPE is STT_FUNC or STT_GNU_IFUNC. */
bfd_boolean
_bfd_elf_is_function_type (unsigned int type)
{
include/elf 2009-04-30 Nick Clifton <nickc@redhat.com> * common.h (STT_GNU_IFUNC): Define. elfcpp 2009-04-30 Nick Clifton <nickc@redhat.com> * (enum STT): Add STT_GNU_IFUNC. gas 2009-04-30 Nick Clifton <nickc@redhat.com> * config/obj-elf.c (obj_elf_type): Add support for a gnu_indirect_function type. * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups against indirect function symbols. * doc/as.texinfo (.type): Document the support for the gnu_indirect_function symbol type. * NEWS: Mention the new feature. gas/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * gas/elf/elf.exp: Extend type test to include an ifunc symbol. Provide an alternative test for targets which do not support ifunc symbols. (type.s): Add entry for an ifunc symbol. (type.e): Add ifunc entry to expected symbol dump. (section2.e-armelf): Add entry for ifunc symbol. (type-noifunc.s): New file. (type-noifunc.e): New file. bfd/ 2009-04-30 Nick Clifton <nickc@redhat.com> * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs section pointer. (struct elf_obj_data): Add has_ifunc_symbols boolean. * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags into a STT_GNU_IFUNC symbol type. (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function type. (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if the binary contains ifunc symbols. * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC symbol type into a BSF_GNU_INDIRECT_FUNCTION flag. * elf32-i386.c (is_indirect_function): New function. (elf_i386_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf_i386_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): New function. Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. (elf_backend_add_symbol_hook): Define. (elf_i386_post_process_headers): Rename to elf_i388_fbsd_post_process_headers. * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro. (is_indirect_function): New function. (elf64_x86_64_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf64_x86_64_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT if we have ifunc symbols to handle. (get_ifunc_reloc_section_name): New function. Computes the name for an ifunc section. (_bfd_elf_make_ifunc_reloc_section): New function. Creates a section to hold ifunc relocs. * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define. (bfd_print_symbol_vandf): Handle ifunc symbols. (bfd_decode_symclass): Likewise. * bfd-in2.h: Regenerate. binutils 2009-04-30 Nick Clifton <nickc@redhat.com> * readelf.c (dump_relocations): Display a relocation against an ifunc symbol as if it were a function invocation. (get_symbol_type): Handle STT_GNU_IFUNC. ld 2009-04-30 Nick Clifton <nickc@redhat.com> * NEWS: Mention support for IFUNC symbols. ld/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * ld-ifunc: New directory. * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests. * ld-ifunc/prog.c: New file. * ld-ifunc/lib.c: New file.
2009-04-30 17:47:13 +02:00
return (type == STT_FUNC
|| type == STT_GNU_IFUNC);
}
/* Return TRUE iff the ELF symbol SYM might be a function. Set *CODE_SEC
and *CODE_OFF to the function's entry point. */
bfd_boolean
_bfd_elf_maybe_function_sym (const asymbol *sym,
asection **code_sec, bfd_vma *code_off)
{
if ((sym->flags & (BSF_SECTION_SYM | BSF_FILE | BSF_OBJECT
| BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC)) != 0)
return FALSE;
*code_sec = sym->section;
*code_off = sym->value;
return TRUE;
}