1999-05-03 07:29:11 +00:00
|
|
|
|
/* ELF linker support.
|
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 12:34:08 +00:00
|
|
|
|
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
2001-03-08 21:04:02 +00:00
|
|
|
|
Free Software Foundation, Inc.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2003-02-17 18:24:40 +00:00
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2003-02-17 18:24:40 +00: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 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2003-02-17 18:24:40 +00: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 07:29:11 +00:00
|
|
|
|
|
2003-02-17 18:24:40 +00: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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* ELF linker code. */
|
|
|
|
|
|
|
|
|
|
/* This struct is used to pass information to routines called via
|
|
|
|
|
elf_link_hash_traverse which must return failure. */
|
|
|
|
|
|
|
|
|
|
struct elf_info_failed
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean failed;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct bfd_link_info *info;
|
2001-06-18 18:57:06 +00:00
|
|
|
|
struct bfd_elf_version_tree *verdefs;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean is_global_data_symbol_definition
|
2001-08-09 14:38:04 +00:00
|
|
|
|
PARAMS ((bfd *, Elf_Internal_Sym *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_is_defined_archive_symbol
|
2001-08-09 14:38:04 +00:00
|
|
|
|
PARAMS ((bfd *, carsym *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_add_object_symbols
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_add_archive_symbols
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_merge_symbol
|
2001-11-30 15:50:56 +00:00
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, const char *,
|
|
|
|
|
Elf_Internal_Sym *, asection **, bfd_vma *,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
struct elf_link_hash_entry **, bfd_boolean *, bfd_boolean *,
|
|
|
|
|
bfd_boolean *, bfd_boolean));
|
|
|
|
|
static bfd_boolean elf_add_default_symbol
|
2001-11-30 15:50:56 +00:00
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
|
|
|
|
|
const char *, Elf_Internal_Sym *, asection **, bfd_vma *,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean *, bfd_boolean, bfd_boolean));
|
|
|
|
|
static bfd_boolean elf_export_symbol
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_finalize_dynstr
|
* 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 16:50:38 +00:00
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_fix_symbol_flags
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, struct elf_info_failed *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_adjust_dynamic_symbol
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_find_version_dependencies
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_assign_sym_version
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_collect_hash_codes
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_read_relocs_from_section
|
1999-06-13 01:13:26 +00:00
|
|
|
|
PARAMS ((bfd *, Elf_Internal_Shdr *, PTR, Elf_Internal_Rela *));
|
2001-08-09 14:38:04 +00:00
|
|
|
|
static size_t compute_bucket_count
|
|
|
|
|
PARAMS ((struct bfd_link_info *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_output_relocs
|
1999-07-01 23:20:08 +00:00
|
|
|
|
PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_size_reloc_section
|
1999-07-01 23:20:08 +00:00
|
|
|
|
PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
|
2001-01-03 22:53:39 +00:00
|
|
|
|
static void elf_link_adjust_relocs
|
|
|
|
|
PARAMS ((bfd *, Elf_Internal_Shdr *, unsigned int,
|
1999-07-18 06:31:29 +00:00
|
|
|
|
struct elf_link_hash_entry **));
|
2001-08-23 15:14:18 +00:00
|
|
|
|
static int elf_link_sort_cmp1
|
|
|
|
|
PARAMS ((const void *, const void *));
|
|
|
|
|
static int elf_link_sort_cmp2
|
|
|
|
|
PARAMS ((const void *, const void *));
|
|
|
|
|
static size_t elf_link_sort_relocs
|
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, asection **));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_section_ignore_discarded_relocs
|
2001-11-15 01:34:12 +00:00
|
|
|
|
PARAMS ((asection *));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Given an ELF BFD, add symbols to the global hash table as
|
|
|
|
|
appropriate. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_bfd_link_add_symbols (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
switch (bfd_get_format (abfd))
|
|
|
|
|
{
|
|
|
|
|
case bfd_object:
|
|
|
|
|
return elf_link_add_object_symbols (abfd, info);
|
|
|
|
|
case bfd_archive:
|
|
|
|
|
return elf_link_add_archive_symbols (abfd, info);
|
|
|
|
|
default:
|
|
|
|
|
bfd_set_error (bfd_error_wrong_format);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
/* Return TRUE iff this is a non-common, definition of a non-function symbol. */
|
|
|
|
|
static bfd_boolean
|
2001-02-07 23:42:15 +00:00
|
|
|
|
is_global_data_symbol_definition (abfd, sym)
|
2000-03-01 20:39:07 +00:00
|
|
|
|
bfd * abfd ATTRIBUTE_UNUSED;
|
1999-12-14 23:35:43 +00:00
|
|
|
|
Elf_Internal_Sym * sym;
|
|
|
|
|
{
|
|
|
|
|
/* Local symbols do not count, but target specific ones might. */
|
|
|
|
|
if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL
|
|
|
|
|
&& ELF_ST_BIND (sym->st_info) < STB_LOOS)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-12-14 23:35:43 +00:00
|
|
|
|
|
2001-02-07 23:42:15 +00:00
|
|
|
|
/* Function symbols do not count. */
|
|
|
|
|
if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-02-07 23:42:15 +00:00
|
|
|
|
|
1999-12-14 23:35:43 +00:00
|
|
|
|
/* If the section is undefined, then so is the symbol. */
|
|
|
|
|
if (sym->st_shndx == SHN_UNDEF)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-12-14 23:35:43 +00:00
|
|
|
|
/* If the symbol is defined in the common section, then
|
|
|
|
|
it is a common definition and so does not count. */
|
|
|
|
|
if (sym->st_shndx == SHN_COMMON)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-12-14 23:35:43 +00:00
|
|
|
|
|
|
|
|
|
/* If the symbol is in a target specific section then we
|
|
|
|
|
must rely upon the backend to tell us what it is. */
|
|
|
|
|
if (sym->st_shndx >= SHN_LORESERVE && sym->st_shndx < SHN_ABS)
|
|
|
|
|
/* FIXME - this function is not coded yet:
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-12-14 23:35:43 +00:00
|
|
|
|
return _bfd_is_global_symbol_definition (abfd, sym);
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-12-14 23:35:43 +00:00
|
|
|
|
Instead for now assume that the definition is not global,
|
|
|
|
|
Even if this is wrong, at least the linker will behave
|
|
|
|
|
in the same way that it used to do. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-12-14 23:35:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-10 20:17:28 +00:00
|
|
|
|
/* Search the symbol table of the archive element of the archive ABFD
|
2001-06-10 05:21:00 +00:00
|
|
|
|
whose archive map contains a mention of SYMDEF, and determine if
|
1999-12-10 20:17:28 +00:00
|
|
|
|
the symbol is defined in this element. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-12-10 20:17:28 +00:00
|
|
|
|
elf_link_is_defined_archive_symbol (abfd, symdef)
|
|
|
|
|
bfd * abfd;
|
|
|
|
|
carsym * symdef;
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Shdr * hdr;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type symcount;
|
|
|
|
|
bfd_size_type extsymcount;
|
|
|
|
|
bfd_size_type extsymoff;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_Internal_Sym *isymbuf;
|
|
|
|
|
Elf_Internal_Sym *isym;
|
|
|
|
|
Elf_Internal_Sym *isymend;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean result;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-12-10 20:17:28 +00:00
|
|
|
|
abfd = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
|
|
|
|
|
if (abfd == (bfd *) NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-12-10 20:17:28 +00:00
|
|
|
|
|
|
|
|
|
if (! bfd_check_format (abfd, bfd_object))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-12-10 20:17:28 +00:00
|
|
|
|
|
1999-12-14 23:35:43 +00:00
|
|
|
|
/* If we have already included the element containing this symbol in the
|
|
|
|
|
link then we do not need to include it again. Just claim that any symbol
|
|
|
|
|
it contains is not a definition, so that our caller will not decide to
|
|
|
|
|
(re)include this element. */
|
|
|
|
|
if (abfd->archive_pass)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-12-10 20:17:28 +00:00
|
|
|
|
/* Select the appropriate symbol table. */
|
|
|
|
|
if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
hdr = &elf_tdata (abfd)->symtab_hdr;
|
1999-12-10 20:17:28 +00:00
|
|
|
|
else
|
2002-07-07 09:10:41 +00:00
|
|
|
|
hdr = &elf_tdata (abfd)->dynsymtab_hdr;
|
1999-12-10 20:17:28 +00:00
|
|
|
|
|
|
|
|
|
symcount = hdr->sh_size / sizeof (Elf_External_Sym);
|
|
|
|
|
|
|
|
|
|
/* The sh_info field of the symtab header tells us where the
|
|
|
|
|
external symbols start. We don't care about the local symbols. */
|
|
|
|
|
if (elf_bad_symtab (abfd))
|
|
|
|
|
{
|
|
|
|
|
extsymcount = symcount;
|
|
|
|
|
extsymoff = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
extsymcount = symcount - hdr->sh_info;
|
|
|
|
|
extsymoff = hdr->sh_info;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (extsymcount == 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-12-10 20:17:28 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
/* Read in the symbol table. */
|
|
|
|
|
isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
if (isymbuf == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-12-10 20:17:28 +00:00
|
|
|
|
|
|
|
|
|
/* Scan the symbol table looking for SYMDEF. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
result = FALSE;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
for (isym = isymbuf, isymend = isymbuf + extsymcount; isym < isymend; isym++)
|
1999-12-10 20:17:28 +00:00
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
const char *name;
|
1999-12-10 20:17:28 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
|
|
|
|
|
isym->st_name);
|
1999-12-10 20:17:28 +00:00
|
|
|
|
if (name == (const char *) NULL)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (strcmp (name, symdef->name) == 0)
|
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
result = is_global_data_symbol_definition (abfd, isym);
|
1999-12-10 20:17:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
free (isymbuf);
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-12-10 20:17:28 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Add symbols from an ELF archive file to the linker hash table. We
|
|
|
|
|
don't use _bfd_generic_link_add_archive_symbols because of a
|
|
|
|
|
problem which arises on UnixWare. The UnixWare libc.so is an
|
|
|
|
|
archive which includes an entry libc.so.1 which defines a bunch of
|
|
|
|
|
symbols. The libc.so archive also includes a number of other
|
|
|
|
|
object files, which also define symbols, some of which are the same
|
|
|
|
|
as those defined in libc.so.1. Correct linking requires that we
|
|
|
|
|
consider each object file in turn, and include it if it defines any
|
|
|
|
|
symbols we need. _bfd_generic_link_add_archive_symbols does not do
|
|
|
|
|
this; it looks through the list of undefined symbols, and includes
|
|
|
|
|
any object file which defines them. When this algorithm is used on
|
|
|
|
|
UnixWare, it winds up pulling in libc.so.1 early and defining a
|
|
|
|
|
bunch of symbols. This means that some of the other objects in the
|
|
|
|
|
archive are not included in the link, which is incorrect since they
|
|
|
|
|
precede libc.so.1 in the archive.
|
|
|
|
|
|
|
|
|
|
Fortunately, ELF archive handling is simpler than that done by
|
|
|
|
|
_bfd_generic_link_add_archive_symbols, which has to allow for a.out
|
|
|
|
|
oddities. In ELF, if we find a symbol in the archive map, and the
|
|
|
|
|
symbol is currently undefined, we know that we must pull in that
|
|
|
|
|
object file.
|
|
|
|
|
|
|
|
|
|
Unfortunately, we do have to make multiple passes over the symbol
|
|
|
|
|
table until nothing further is resolved. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_add_archive_symbols (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
symindex c;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean *defined = NULL;
|
|
|
|
|
bfd_boolean *included = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
carsym *symdefs;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean loop;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type amt;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (! bfd_has_map (abfd))
|
|
|
|
|
{
|
|
|
|
|
/* An empty archive is a special case. */
|
|
|
|
|
if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_set_error (bfd_error_no_armap);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Keep track of all symbols we know to be already defined, and all
|
|
|
|
|
files we know to be already included. This is to speed up the
|
|
|
|
|
second and subsequent passes. */
|
|
|
|
|
c = bfd_ardata (abfd)->symdef_count;
|
|
|
|
|
if (c == 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = c;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
amt *= sizeof (bfd_boolean);
|
|
|
|
|
defined = (bfd_boolean *) bfd_zmalloc (amt);
|
|
|
|
|
included = (bfd_boolean *) bfd_zmalloc (amt);
|
|
|
|
|
if (defined == (bfd_boolean *) NULL || included == (bfd_boolean *) NULL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
symdefs = bfd_ardata (abfd)->symdefs;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
file_ptr last;
|
|
|
|
|
symindex i;
|
|
|
|
|
carsym *symdef;
|
|
|
|
|
carsym *symdefend;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
loop = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
last = -1;
|
|
|
|
|
|
|
|
|
|
symdef = symdefs;
|
|
|
|
|
symdefend = symdef + c;
|
|
|
|
|
for (i = 0; symdef < symdefend; symdef++, i++)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
bfd *element;
|
|
|
|
|
struct bfd_link_hash_entry *undefs_tail;
|
|
|
|
|
symindex mark;
|
|
|
|
|
|
|
|
|
|
if (defined[i] || included[i])
|
|
|
|
|
continue;
|
|
|
|
|
if (symdef->file_offset == last)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
included[i] = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h = elf_link_hash_lookup (elf_hash_table (info), symdef->name,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE, FALSE, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (h == NULL)
|
|
|
|
|
{
|
|
|
|
|
char *p, *copy;
|
2002-06-23 12:44:31 +00:00
|
|
|
|
size_t len, first;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If this is a default version (the name contains @@),
|
2002-06-23 12:44:31 +00:00
|
|
|
|
look up the symbol again with only one `@' as well
|
|
|
|
|
as without the version. The effect is that references
|
|
|
|
|
to the symbol with and without the version will be
|
|
|
|
|
matched by the default symbol in the archive. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
p = strchr (symdef->name, ELF_VER_CHR);
|
|
|
|
|
if (p == NULL || p[1] != ELF_VER_CHR)
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-06-23 12:44:31 +00:00
|
|
|
|
/* First check with only one `@'. */
|
|
|
|
|
len = strlen (symdef->name);
|
|
|
|
|
copy = bfd_alloc (abfd, (bfd_size_type) len);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (copy == NULL)
|
|
|
|
|
goto error_return;
|
2002-06-23 12:44:31 +00:00
|
|
|
|
first = p - symdef->name + 1;
|
|
|
|
|
memcpy (copy, symdef->name, first);
|
|
|
|
|
memcpy (copy + first, symdef->name + first + 1, len - first);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
h = elf_link_hash_lookup (elf_hash_table (info), copy,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE, FALSE, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-06-23 12:44:31 +00:00
|
|
|
|
if (h == NULL)
|
2002-07-16 12:31:35 +00:00
|
|
|
|
{
|
2002-06-23 12:44:31 +00:00
|
|
|
|
/* We also need to check references to the symbol
|
|
|
|
|
without the version. */
|
|
|
|
|
|
|
|
|
|
copy[first - 1] = '\0';
|
|
|
|
|
h = elf_link_hash_lookup (elf_hash_table (info),
|
2002-11-30 08:39:46 +00:00
|
|
|
|
copy, FALSE, FALSE, FALSE);
|
2002-06-23 12:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_release (abfd, copy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (h == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
1999-12-10 20:17:28 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_common)
|
|
|
|
|
{
|
|
|
|
|
/* We currently have a common symbol. The archive map contains
|
|
|
|
|
a reference to this symbol, so we may want to include it. We
|
|
|
|
|
only want to include it however, if this archive element
|
|
|
|
|
contains a definition of the symbol, not just another common
|
|
|
|
|
declaration of it.
|
|
|
|
|
|
|
|
|
|
Unfortunately some archivers (including GNU ar) will put
|
|
|
|
|
declarations of common symbols into their archive maps, as
|
|
|
|
|
well as real definitions, so we cannot just go by the archive
|
|
|
|
|
map alone. Instead we must read in the element's symbol
|
|
|
|
|
table and check that to see what kind of symbol definition
|
|
|
|
|
this is. */
|
|
|
|
|
if (! elf_link_is_defined_archive_symbol (abfd, symdef))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (h->root.type != bfd_link_hash_undefined)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (h->root.type != bfd_link_hash_undefweak)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
defined[i] = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We need to include this archive member. */
|
|
|
|
|
element = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
|
|
|
|
|
if (element == (bfd *) NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
if (! bfd_check_format (element, bfd_object))
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* Doublecheck that we have not included this object
|
|
|
|
|
already--it should be impossible, but there may be
|
|
|
|
|
something wrong with the archive. */
|
|
|
|
|
if (element->archive_pass != 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
element->archive_pass = 1;
|
|
|
|
|
|
|
|
|
|
undefs_tail = info->hash->undefs_tail;
|
|
|
|
|
|
|
|
|
|
if (! (*info->callbacks->add_archive_element) (info, element,
|
|
|
|
|
symdef->name))
|
|
|
|
|
goto error_return;
|
|
|
|
|
if (! elf_link_add_object_symbols (element, info))
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* If there are any new undefined symbols, we need to make
|
|
|
|
|
another pass through the archive in order to see whether
|
|
|
|
|
they can be defined. FIXME: This isn't perfect, because
|
|
|
|
|
common symbols wind up on undefs_tail and because an
|
|
|
|
|
undefined symbol which is defined later on in this pass
|
|
|
|
|
does not require another pass. This isn't a bug, but it
|
|
|
|
|
does make the code less efficient than it could be. */
|
|
|
|
|
if (undefs_tail != info->hash->undefs_tail)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
loop = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Look backward to mark all symbols from this object file
|
|
|
|
|
which we have already seen in this pass. */
|
|
|
|
|
mark = i;
|
|
|
|
|
do
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
included[mark] = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (mark == 0)
|
|
|
|
|
break;
|
|
|
|
|
--mark;
|
|
|
|
|
}
|
|
|
|
|
while (symdefs[mark].file_offset == symdef->file_offset);
|
|
|
|
|
|
|
|
|
|
/* We mark subsequent symbols from this object file as we go
|
|
|
|
|
on through the loop. */
|
|
|
|
|
last = symdef->file_offset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (loop);
|
|
|
|
|
|
|
|
|
|
free (defined);
|
|
|
|
|
free (included);
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
error_return:
|
2002-11-30 08:39:46 +00:00
|
|
|
|
if (defined != (bfd_boolean *) NULL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
free (defined);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
if (included != (bfd_boolean *) NULL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
free (included);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function is called when we want to define a new symbol. It
|
|
|
|
|
handles the various cases which arise when we find a definition in
|
|
|
|
|
a dynamic object, or when there is already a definition in a
|
|
|
|
|
dynamic object. The new symbol is described by NAME, SYM, PSEC,
|
|
|
|
|
and PVALUE. We set SYM_HASH to the hash table entry. We set
|
|
|
|
|
OVERRIDE if the old symbol is overriding a new definition. We set
|
|
|
|
|
TYPE_CHANGE_OK if it is OK for the type to change. We set
|
|
|
|
|
SIZE_CHANGE_OK if it is OK for the size to change. By OK to
|
|
|
|
|
change, we mean that we shouldn't warn if the type or size does
|
2000-07-28 00:49:07 +00:00
|
|
|
|
change. DT_NEEDED indicates if it comes from a DT_NEEDED entry of
|
|
|
|
|
a shared object. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash,
|
2000-07-28 00:49:07 +00:00
|
|
|
|
override, type_change_ok, size_change_ok, dt_needed)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
const char *name;
|
|
|
|
|
Elf_Internal_Sym *sym;
|
|
|
|
|
asection **psec;
|
|
|
|
|
bfd_vma *pvalue;
|
|
|
|
|
struct elf_link_hash_entry **sym_hash;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean *override;
|
|
|
|
|
bfd_boolean *type_change_ok;
|
|
|
|
|
bfd_boolean *size_change_ok;
|
|
|
|
|
bfd_boolean dt_needed;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
asection *sec;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
int bind;
|
|
|
|
|
bfd *oldbfd;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*override = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
sec = *psec;
|
|
|
|
|
bind = ELF_ST_BIND (sym->st_info);
|
|
|
|
|
|
|
|
|
|
if (! bfd_is_und_section (sec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
h = elf_link_hash_lookup (elf_hash_table (info), name, TRUE, FALSE, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
|
|
|
|
h = ((struct elf_link_hash_entry *)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_wrapped_link_hash_lookup (abfd, info, name, TRUE, FALSE, FALSE));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*sym_hash = h;
|
|
|
|
|
|
|
|
|
|
/* This code is for coping with dynamic objects, and is only useful
|
|
|
|
|
if we are doing an ELF link. */
|
|
|
|
|
if (info->hash->creator != abfd->xvec)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* For merging, we only care about real symbols. */
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
/* If we just created the symbol, mark it as being an ELF symbol.
|
|
|
|
|
Other than that, there is nothing to do--there is no merge issue
|
|
|
|
|
with a newly defined symbol--so we just return. */
|
|
|
|
|
|
|
|
|
|
if (h->root.type == bfd_link_hash_new)
|
|
|
|
|
{
|
|
|
|
|
h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* OLDBFD is a BFD associated with the existing symbol. */
|
|
|
|
|
|
|
|
|
|
switch (h->root.type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
oldbfd = NULL;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_undefined:
|
|
|
|
|
case bfd_link_hash_undefweak:
|
|
|
|
|
oldbfd = h->root.u.undef.abfd;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_defined:
|
|
|
|
|
case bfd_link_hash_defweak:
|
|
|
|
|
oldbfd = h->root.u.def.section->owner;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_common:
|
|
|
|
|
oldbfd = h->root.u.c.p->section->owner;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 15:29:06 +00:00
|
|
|
|
/* In cases involving weak versioned symbols, we may wind up trying
|
|
|
|
|
to merge a symbol with itself. Catch that here, to avoid the
|
|
|
|
|
confusion that results if we try to override a symbol with
|
1999-07-19 19:08:33 +00:00
|
|
|
|
itself. The additional tests catch cases like
|
|
|
|
|
_GLOBAL_OFFSET_TABLE_, which are regular symbols defined in a
|
|
|
|
|
dynamic object, which we do want to handle here. */
|
|
|
|
|
if (abfd == oldbfd
|
|
|
|
|
&& ((abfd->flags & DYNAMIC) == 0
|
|
|
|
|
|| (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-07-07 15:29:06 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* NEWDYN and OLDDYN indicate whether the new or old symbol,
|
|
|
|
|
respectively, is from a dynamic object. */
|
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newdyn = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newdyn = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
1999-08-17 07:50:30 +00:00
|
|
|
|
if (oldbfd != NULL)
|
|
|
|
|
olddyn = (oldbfd->flags & DYNAMIC) != 0;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
1999-08-17 07:50:30 +00:00
|
|
|
|
{
|
|
|
|
|
asection *hsec;
|
|
|
|
|
|
|
|
|
|
/* This code handles the special SHN_MIPS_{TEXT,DATA} section
|
2002-03-05 05:18:41 +00:00
|
|
|
|
indices used by MIPS ELF. */
|
1999-08-17 07:50:30 +00:00
|
|
|
|
switch (h->root.type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
hsec = NULL;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_defined:
|
|
|
|
|
case bfd_link_hash_defweak:
|
|
|
|
|
hsec = h->root.u.def.section;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_common:
|
|
|
|
|
hsec = h->root.u.c.p->section;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hsec == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
olddyn = FALSE;
|
1999-08-17 07:50:30 +00:00
|
|
|
|
else
|
|
|
|
|
olddyn = (hsec->symbol->flags & BSF_DYNAMIC) != 0;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* NEWDEF and OLDDEF indicate whether the new or old symbol,
|
|
|
|
|
respectively, appear to be a definition rather than reference. */
|
|
|
|
|
|
|
|
|
|
if (bfd_is_und_section (sec) || bfd_is_com_section (sec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newdef = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newdef = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (h->root.type == bfd_link_hash_undefined
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak
|
|
|
|
|
|| h->root.type == bfd_link_hash_common)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
olddef = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
olddef = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* NEWDYNCOMMON and OLDDYNCOMMON indicate whether the new or old
|
|
|
|
|
symbol, respectively, appears to be a common symbol in a dynamic
|
|
|
|
|
object. If a symbol appears in an uninitialized section, and is
|
|
|
|
|
not weak, and is not a function, then it may be a common symbol
|
|
|
|
|
which was resolved when the dynamic object was created. We want
|
|
|
|
|
to treat such symbols specially, because they raise special
|
|
|
|
|
considerations when setting the symbol size: if the symbol
|
|
|
|
|
appears as a common symbol in a regular object, and the size in
|
|
|
|
|
the regular object is larger, we must make sure that we use the
|
|
|
|
|
larger size. This problematic case can always be avoided in C,
|
|
|
|
|
but it must be handled correctly when using Fortran shared
|
|
|
|
|
libraries.
|
|
|
|
|
|
|
|
|
|
Note that if NEWDYNCOMMON is set, NEWDEF will be set, and
|
|
|
|
|
likewise for OLDDYNCOMMON and OLDDEF.
|
|
|
|
|
|
|
|
|
|
Note that this test is just a heuristic, and that it is quite
|
|
|
|
|
possible to have an uninitialized symbol in a shared object which
|
|
|
|
|
is really a definition, rather than a common symbol. This could
|
|
|
|
|
lead to some minor confusion when the symbol really is a common
|
|
|
|
|
symbol in some regular object. However, I think it will be
|
|
|
|
|
harmless. */
|
|
|
|
|
|
|
|
|
|
if (newdyn
|
|
|
|
|
&& newdef
|
|
|
|
|
&& (sec->flags & SEC_ALLOC) != 0
|
|
|
|
|
&& (sec->flags & SEC_LOAD) == 0
|
|
|
|
|
&& sym->st_size > 0
|
|
|
|
|
&& bind != STB_WEAK
|
|
|
|
|
&& ELF_ST_TYPE (sym->st_info) != STT_FUNC)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newdyncommon = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newdyncommon = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (olddyn
|
|
|
|
|
&& olddef
|
|
|
|
|
&& h->root.type == bfd_link_hash_defined
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|
|
|
|
&& (h->root.u.def.section->flags & SEC_ALLOC) != 0
|
|
|
|
|
&& (h->root.u.def.section->flags & SEC_LOAD) == 0
|
|
|
|
|
&& h->size > 0
|
|
|
|
|
&& h->type != STT_FUNC)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
olddyncommon = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
olddyncommon = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* It's OK to change the type if either the existing symbol or the
|
2000-07-28 00:49:07 +00:00
|
|
|
|
new symbol is weak unless it comes from a DT_NEEDED entry of
|
|
|
|
|
a shared object, in which case, the DT_NEEDED entry may not be
|
2001-01-03 22:53:39 +00:00
|
|
|
|
required at the run time. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2000-07-28 00:49:07 +00:00
|
|
|
|
if ((! dt_needed && h->root.type == bfd_link_hash_defweak)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak
|
|
|
|
|
|| bind == STB_WEAK)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*type_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* It's OK to change the size if either the existing symbol or the
|
|
|
|
|
new symbol is weak, or if the old symbol is undefined. */
|
|
|
|
|
|
|
|
|
|
if (*type_change_ok
|
|
|
|
|
|| h->root.type == bfd_link_hash_undefined)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*size_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If both the old and the new symbols look like common symbols in a
|
|
|
|
|
dynamic object, set the size of the symbol to the larger of the
|
|
|
|
|
two. */
|
|
|
|
|
|
|
|
|
|
if (olddyncommon
|
|
|
|
|
&& newdyncommon
|
|
|
|
|
&& sym->st_size != h->size)
|
|
|
|
|
{
|
|
|
|
|
/* Since we think we have two common symbols, issue a multiple
|
2002-03-05 05:18:41 +00:00
|
|
|
|
common warning if desired. Note that we only warn if the
|
|
|
|
|
size is different. If the size is the same, we simply let
|
|
|
|
|
the old symbol override the new one as normally happens with
|
|
|
|
|
symbols defined in dynamic objects. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (! ((*info->callbacks->multiple_common)
|
|
|
|
|
(info, h->root.root.string, oldbfd, bfd_link_hash_common,
|
|
|
|
|
h->size, abfd, bfd_link_hash_common, sym->st_size)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (sym->st_size > h->size)
|
|
|
|
|
h->size = sym->st_size;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*size_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we are looking at a dynamic object, and we have found a
|
|
|
|
|
definition, we need to see if the symbol was already defined by
|
|
|
|
|
some other object. If so, we want to use the existing
|
|
|
|
|
definition, and we do not want to report a multiple symbol
|
|
|
|
|
definition error; we do this by clobbering *PSEC to be
|
|
|
|
|
bfd_und_section_ptr.
|
|
|
|
|
|
|
|
|
|
We treat a common symbol as a definition if the symbol in the
|
|
|
|
|
shared library is a function, since common symbols always
|
|
|
|
|
represent variables; this can cause confusion in principle, but
|
|
|
|
|
any such confusion would seem to indicate an erroneous program or
|
|
|
|
|
shared library. We also permit a common symbol in a regular
|
1999-07-07 11:39:43 +00:00
|
|
|
|
object to override a weak symbol in a shared object.
|
|
|
|
|
|
|
|
|
|
We prefer a non-weak definition in a shared library to a weak
|
2000-07-28 00:49:07 +00:00
|
|
|
|
definition in the executable unless it comes from a DT_NEEDED
|
|
|
|
|
entry of a shared object, in which case, the DT_NEEDED entry
|
2001-01-03 22:53:39 +00:00
|
|
|
|
may not be required at the run time. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (newdyn
|
|
|
|
|
&& newdef
|
|
|
|
|
&& (olddef
|
|
|
|
|
|| (h->root.type == bfd_link_hash_common
|
|
|
|
|
&& (bind == STB_WEAK
|
1999-07-07 11:39:43 +00:00
|
|
|
|
|| ELF_ST_TYPE (sym->st_info) == STT_FUNC)))
|
2001-01-03 22:53:39 +00:00
|
|
|
|
&& (h->root.type != bfd_link_hash_defweak
|
2000-07-28 00:49:07 +00:00
|
|
|
|
|| dt_needed
|
1999-07-07 11:39:43 +00:00
|
|
|
|
|| bind == STB_WEAK))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*override = TRUE;
|
|
|
|
|
newdef = FALSE;
|
|
|
|
|
newdyncommon = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
*psec = sec = bfd_und_section_ptr;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*size_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If we get here when the old symbol is a common symbol, then
|
2002-03-05 05:18:41 +00:00
|
|
|
|
we are explicitly letting it override a weak symbol or
|
|
|
|
|
function in a dynamic object, and we don't want to warn about
|
|
|
|
|
a type change. If the old symbol is a defined symbol, a type
|
|
|
|
|
change warning may still be appropriate. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (h->root.type == bfd_link_hash_common)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*type_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle the special case of an old common symbol merging with a
|
|
|
|
|
new symbol which looks like a common symbol in a shared object.
|
|
|
|
|
We change *PSEC and *PVALUE to make the new symbol look like a
|
|
|
|
|
common symbol, and let _bfd_generic_link_add_one_symbol will do
|
|
|
|
|
the right thing. */
|
|
|
|
|
|
|
|
|
|
if (newdyncommon
|
|
|
|
|
&& h->root.type == bfd_link_hash_common)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*override = TRUE;
|
|
|
|
|
newdef = FALSE;
|
|
|
|
|
newdyncommon = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*pvalue = sym->st_size;
|
|
|
|
|
*psec = sec = bfd_com_section_ptr;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*size_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the old symbol is from a dynamic object, and the new symbol is
|
|
|
|
|
a definition which is not from a dynamic object, then the new
|
|
|
|
|
symbol overrides the old symbol. Symbols from regular files
|
|
|
|
|
always take precedence over symbols from dynamic objects, even if
|
|
|
|
|
they are defined after the dynamic object in the link.
|
|
|
|
|
|
|
|
|
|
As above, we again permit a common symbol in a regular object to
|
|
|
|
|
override a definition in a shared object if the shared object
|
1999-07-07 11:39:43 +00:00
|
|
|
|
symbol is a function or is weak.
|
|
|
|
|
|
|
|
|
|
As above, we permit a non-weak definition in a shared object to
|
|
|
|
|
override a weak definition in a regular object. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (! newdyn
|
|
|
|
|
&& (newdef
|
|
|
|
|
|| (bfd_is_com_section (sec)
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defweak
|
|
|
|
|
|| h->type == STT_FUNC)))
|
|
|
|
|
&& olddyn
|
|
|
|
|
&& olddef
|
1999-07-07 11:39:43 +00:00
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|
|
|
|
&& (bind != STB_WEAK
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
/* Change the hash table entry to undefined, and let
|
|
|
|
|
_bfd_generic_link_add_one_symbol do the right thing with the
|
|
|
|
|
new definition. */
|
|
|
|
|
|
|
|
|
|
h->root.type = bfd_link_hash_undefined;
|
|
|
|
|
h->root.u.undef.abfd = h->root.u.def.section->owner;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*size_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
olddef = FALSE;
|
|
|
|
|
olddyncommon = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* We again permit a type change when a common symbol may be
|
2002-03-05 05:18:41 +00:00
|
|
|
|
overriding a function. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (bfd_is_com_section (sec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*type_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* This union may have been set to be non-NULL when this symbol
|
|
|
|
|
was seen in a dynamic object. We must force the union to be
|
|
|
|
|
NULL, so that it is correct for a regular symbol. */
|
|
|
|
|
|
|
|
|
|
h->verinfo.vertree = NULL;
|
|
|
|
|
|
|
|
|
|
/* In this special case, if H is the target of an indirection,
|
2002-03-05 05:18:41 +00:00
|
|
|
|
we want the caller to frob with H rather than with the
|
|
|
|
|
indirect symbol. That will permit the caller to redefine the
|
|
|
|
|
target of the indirection, rather than the indirect symbol
|
|
|
|
|
itself. FIXME: This will break the -y option if we store a
|
|
|
|
|
symbol with a different name. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*sym_hash = h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle the special case of a new common symbol merging with an
|
|
|
|
|
old symbol that looks like it might be a common symbol defined in
|
|
|
|
|
a shared object. Note that we have already handled the case in
|
|
|
|
|
which a new common symbol should simply override the definition
|
|
|
|
|
in the shared library. */
|
|
|
|
|
|
|
|
|
|
if (! newdyn
|
|
|
|
|
&& bfd_is_com_section (sec)
|
|
|
|
|
&& olddyncommon)
|
|
|
|
|
{
|
|
|
|
|
/* It would be best if we could set the hash table entry to a
|
|
|
|
|
common symbol, but we don't know what to use for the section
|
|
|
|
|
or the alignment. */
|
|
|
|
|
if (! ((*info->callbacks->multiple_common)
|
|
|
|
|
(info, h->root.root.string, oldbfd, bfd_link_hash_common,
|
|
|
|
|
h->size, abfd, bfd_link_hash_common, sym->st_size)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If the predumed common symbol in the dynamic object is
|
2002-03-05 05:18:41 +00:00
|
|
|
|
larger, pretend that the new symbol has its size. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (h->size > *pvalue)
|
|
|
|
|
*pvalue = h->size;
|
|
|
|
|
|
|
|
|
|
/* FIXME: We no longer know the alignment required by the symbol
|
|
|
|
|
in the dynamic object, so we just wind up using the one from
|
|
|
|
|
the regular object. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
olddef = FALSE;
|
|
|
|
|
olddyncommon = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
h->root.type = bfd_link_hash_undefined;
|
|
|
|
|
h->root.u.undef.abfd = h->root.u.def.section->owner;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*size_change_ok = TRUE;
|
|
|
|
|
*type_change_ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
h->verinfo.vertree = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 11:39:43 +00:00
|
|
|
|
/* Handle the special case of a weak definition in a regular object
|
|
|
|
|
followed by a non-weak definition in a shared object. In this
|
2000-07-28 00:49:07 +00:00
|
|
|
|
case, we prefer the definition in the shared object unless it
|
|
|
|
|
comes from a DT_NEEDED entry of a shared object, in which case,
|
2001-01-03 22:53:39 +00:00
|
|
|
|
the DT_NEEDED entry may not be required at the run time. */
|
1999-07-07 11:39:43 +00:00
|
|
|
|
if (olddef
|
2000-07-28 00:49:07 +00:00
|
|
|
|
&& ! dt_needed
|
1999-07-07 11:39:43 +00:00
|
|
|
|
&& h->root.type == bfd_link_hash_defweak
|
|
|
|
|
&& newdef
|
|
|
|
|
&& newdyn
|
|
|
|
|
&& bind != STB_WEAK)
|
1999-07-07 15:29:06 +00:00
|
|
|
|
{
|
|
|
|
|
/* To make this work we have to frob the flags so that the rest
|
2002-03-05 05:18:41 +00:00
|
|
|
|
of the code does not think we are using the regular
|
|
|
|
|
definition. */
|
1999-10-08 15:21:56 +00:00
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
|
|
|
|
|
else if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
|
|
|
|
|
h->elf_link_hash_flags &= ~ (ELF_LINK_HASH_DEF_REGULAR
|
|
|
|
|
| ELF_LINK_HASH_DEF_DYNAMIC);
|
1999-07-07 15:29:06 +00:00
|
|
|
|
|
|
|
|
|
/* If H is the target of an indirection, we want the caller to
|
2002-03-05 05:18:41 +00:00
|
|
|
|
use H rather than the indirect symbol. Otherwise if we are
|
|
|
|
|
defining a new indirect symbol we will wind up attaching it
|
|
|
|
|
to the entry we are overriding. */
|
1999-07-07 15:29:06 +00:00
|
|
|
|
*sym_hash = h;
|
|
|
|
|
}
|
1999-07-07 11:39:43 +00:00
|
|
|
|
|
|
|
|
|
/* Handle the special case of a non-weak definition in a shared
|
|
|
|
|
object followed by a weak definition in a regular object. In
|
|
|
|
|
this case we prefer to definition in the shared object. To make
|
|
|
|
|
this work we have to tell the caller to not treat the new symbol
|
|
|
|
|
as a definition. */
|
|
|
|
|
if (olddef
|
|
|
|
|
&& olddyn
|
|
|
|
|
&& h->root.type != bfd_link_hash_defweak
|
|
|
|
|
&& newdef
|
|
|
|
|
&& ! newdyn
|
|
|
|
|
&& bind == STB_WEAK)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*override = TRUE;
|
1999-07-07 11:39:43 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-30 15:50:56 +00:00
|
|
|
|
/* This function is called to create an indirect symbol from the
|
|
|
|
|
default for the symbol with the default version if needed. The
|
2002-08-12 19:23:33 +00:00
|
|
|
|
symbol is described by H, NAME, SYM, PSEC, VALUE, and OVERRIDE. We
|
2001-11-30 15:50:56 +00:00
|
|
|
|
set DYNSYM if the new indirect symbol is dynamic. DT_NEEDED
|
|
|
|
|
indicates if it comes from a DT_NEEDED entry of a shared object. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
2002-08-12 19:23:33 +00:00
|
|
|
|
elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
|
2001-11-30 15:50:56 +00:00
|
|
|
|
dynsym, override, dt_needed)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
const char *name;
|
|
|
|
|
Elf_Internal_Sym *sym;
|
2002-08-12 19:23:33 +00:00
|
|
|
|
asection **psec;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
bfd_vma *value;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean *dynsym;
|
|
|
|
|
bfd_boolean override;
|
|
|
|
|
bfd_boolean dt_needed;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean type_change_ok;
|
|
|
|
|
bfd_boolean size_change_ok;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
char *shortname;
|
|
|
|
|
struct elf_link_hash_entry *hi;
|
2002-10-11 08:33:11 +00:00
|
|
|
|
struct bfd_link_hash_entry *bh;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean collect;
|
|
|
|
|
bfd_boolean dynamic;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
char *p;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
size_t len, shortlen;
|
2002-08-12 19:23:33 +00:00
|
|
|
|
asection *sec;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
/* If this symbol has a version, and it is the default version, we
|
|
|
|
|
create an indirect symbol from the default name to the fully
|
|
|
|
|
decorated name. This will cause external references which do not
|
|
|
|
|
specify a version to be bound to this version of the symbol. */
|
|
|
|
|
p = strchr (name, ELF_VER_CHR);
|
|
|
|
|
if (p == NULL || p[1] != ELF_VER_CHR)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
if (override)
|
|
|
|
|
{
|
|
|
|
|
/* We are overridden by an old defition. We need to check if we
|
2002-06-25 09:40:45 +00:00
|
|
|
|
need to create the indirect symbol from the default name. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
hi = elf_link_hash_lookup (elf_hash_table (info), name, TRUE,
|
|
|
|
|
FALSE, FALSE);
|
2001-11-30 15:50:56 +00:00
|
|
|
|
BFD_ASSERT (hi != NULL);
|
|
|
|
|
if (hi == h)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
while (hi->root.type == bfd_link_hash_indirect
|
|
|
|
|
|| hi->root.type == bfd_link_hash_warning)
|
|
|
|
|
{
|
|
|
|
|
hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
|
|
|
|
|
if (hi == h)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bed = get_elf_backend_data (abfd);
|
|
|
|
|
collect = bed->collect;
|
|
|
|
|
dynamic = (abfd->flags & DYNAMIC) != 0;
|
|
|
|
|
|
2002-06-25 09:40:45 +00:00
|
|
|
|
shortlen = p - name;
|
|
|
|
|
shortname = bfd_hash_allocate (&info->hash->table, shortlen + 1);
|
2001-11-30 15:50:56 +00:00
|
|
|
|
if (shortname == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (shortname, name, shortlen);
|
|
|
|
|
shortname[shortlen] = '\0';
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
/* We are going to create a new symbol. Merge it with any existing
|
|
|
|
|
symbol with this name. For the purposes of the merge, act as
|
|
|
|
|
though we were defining the symbol we just defined, although we
|
|
|
|
|
actually going to define an indirect symbol. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
type_change_ok = FALSE;
|
|
|
|
|
size_change_ok = FALSE;
|
2002-08-12 19:23:33 +00:00
|
|
|
|
sec = *psec;
|
|
|
|
|
if (! elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
|
2001-11-30 15:50:56 +00:00
|
|
|
|
&hi, &override, &type_change_ok,
|
|
|
|
|
&size_change_ok, dt_needed))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
if (! override)
|
|
|
|
|
{
|
2002-10-11 08:33:11 +00:00
|
|
|
|
bh = &hi->root;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(bfd_vma) 0, name, FALSE, collect, &bh)))
|
|
|
|
|
return FALSE;
|
2002-10-11 08:33:11 +00:00
|
|
|
|
hi = (struct elf_link_hash_entry *) bh;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* In this case the symbol named SHORTNAME is overriding the
|
|
|
|
|
indirect symbol we want to add. We were planning on making
|
|
|
|
|
SHORTNAME an indirect symbol referring to NAME. SHORTNAME
|
|
|
|
|
is the name without a version. NAME is the fully versioned
|
|
|
|
|
name, and it is the default version.
|
|
|
|
|
|
|
|
|
|
Overriding means that we already saw a definition for the
|
|
|
|
|
symbol SHORTNAME in a regular object, and it is overriding
|
|
|
|
|
the symbol defined in the dynamic object.
|
|
|
|
|
|
|
|
|
|
When this happens, we actually want to change NAME, the
|
|
|
|
|
symbol we just added, to refer to SHORTNAME. This will cause
|
|
|
|
|
references to NAME in the shared object to become references
|
|
|
|
|
to SHORTNAME in the regular object. This is what we expect
|
|
|
|
|
when we override a function in a shared object: that the
|
|
|
|
|
references in the shared object will be mapped to the
|
|
|
|
|
definition in the regular object. */
|
|
|
|
|
|
|
|
|
|
while (hi->root.type == bfd_link_hash_indirect
|
|
|
|
|
|| hi->root.type == bfd_link_hash_warning)
|
|
|
|
|
hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
|
|
|
|
|
|
|
|
|
|
h->root.type = bfd_link_hash_indirect;
|
|
|
|
|
h->root.u.i.link = (struct bfd_link_hash_entry *) hi;
|
|
|
|
|
if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)
|
|
|
|
|
{
|
|
|
|
|
h->elf_link_hash_flags &=~ ELF_LINK_HASH_DEF_DYNAMIC;
|
|
|
|
|
hi->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
|
|
|
|
|
if (hi->elf_link_hash_flags
|
|
|
|
|
& (ELF_LINK_HASH_REF_REGULAR
|
|
|
|
|
| ELF_LINK_HASH_DEF_REGULAR))
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, hi))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now set HI to H, so that the following code will set the
|
2002-03-05 05:18:41 +00:00
|
|
|
|
other fields correctly. */
|
2001-11-30 15:50:56 +00:00
|
|
|
|
hi = h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If there is a duplicate definition somewhere, then HI may not
|
|
|
|
|
point to an indirect symbol. We will have reported an error to
|
|
|
|
|
the user in that case. */
|
|
|
|
|
|
|
|
|
|
if (hi->root.type == bfd_link_hash_indirect)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *ht;
|
|
|
|
|
|
|
|
|
|
/* If the symbol became indirect, then we assume that we have
|
|
|
|
|
not seen a definition before. */
|
|
|
|
|
BFD_ASSERT ((hi->elf_link_hash_flags
|
|
|
|
|
& (ELF_LINK_HASH_DEF_DYNAMIC
|
|
|
|
|
| ELF_LINK_HASH_DEF_REGULAR)) == 0);
|
|
|
|
|
|
|
|
|
|
ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
|
2002-08-22 01:27:20 +00:00
|
|
|
|
(*bed->elf_backend_copy_indirect_symbol) (bed, ht, hi);
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
/* See if the new flags lead us to realize that the symbol must
|
|
|
|
|
be dynamic. */
|
|
|
|
|
if (! *dynsym)
|
|
|
|
|
{
|
|
|
|
|
if (! dynamic)
|
|
|
|
|
{
|
|
|
|
|
if (info->shared
|
|
|
|
|
|| ((hi->elf_link_hash_flags
|
|
|
|
|
& ELF_LINK_HASH_REF_DYNAMIC) != 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*dynsym = TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((hi->elf_link_hash_flags
|
|
|
|
|
& ELF_LINK_HASH_REF_REGULAR) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*dynsym = TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We also need to define an indirection from the nondefault version
|
|
|
|
|
of the symbol. */
|
|
|
|
|
|
2002-06-25 09:40:45 +00:00
|
|
|
|
len = strlen (name);
|
|
|
|
|
shortname = bfd_hash_allocate (&info->hash->table, len);
|
2001-11-30 15:50:56 +00:00
|
|
|
|
if (shortname == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (shortname, name, shortlen);
|
|
|
|
|
memcpy (shortname + shortlen, p + 1, len - shortlen);
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
/* Once again, merge with any existing symbol. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
type_change_ok = FALSE;
|
|
|
|
|
size_change_ok = FALSE;
|
2002-08-12 19:23:33 +00:00
|
|
|
|
sec = *psec;
|
|
|
|
|
if (! elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
|
2001-11-30 15:50:56 +00:00
|
|
|
|
&hi, &override, &type_change_ok,
|
|
|
|
|
&size_change_ok, dt_needed))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
if (override)
|
|
|
|
|
{
|
|
|
|
|
/* Here SHORTNAME is a versioned name, so we don't expect to see
|
2002-08-09 04:40:29 +00:00
|
|
|
|
the type of override we do in the case above unless it is
|
|
|
|
|
overridden by a versioned definiton. */
|
|
|
|
|
if (hi->root.type != bfd_link_hash_defined
|
|
|
|
|
&& hi->root.type != bfd_link_hash_defweak)
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: warning: unexpected redefinition of indirect versioned symbol `%s'"),
|
|
|
|
|
bfd_archive_filename (abfd), shortname);
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-10-11 08:33:11 +00:00
|
|
|
|
bh = &hi->root;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, abfd, shortname, BSF_INDIRECT,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_ind_section_ptr, (bfd_vma) 0, name, FALSE, collect, &bh)))
|
|
|
|
|
return FALSE;
|
2002-10-11 08:33:11 +00:00
|
|
|
|
hi = (struct elf_link_hash_entry *) bh;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
/* If there is a duplicate definition somewhere, then HI may not
|
|
|
|
|
point to an indirect symbol. We will have reported an error
|
|
|
|
|
to the user in that case. */
|
|
|
|
|
|
|
|
|
|
if (hi->root.type == bfd_link_hash_indirect)
|
|
|
|
|
{
|
|
|
|
|
/* If the symbol became indirect, then we assume that we have
|
|
|
|
|
not seen a definition before. */
|
|
|
|
|
BFD_ASSERT ((hi->elf_link_hash_flags
|
|
|
|
|
& (ELF_LINK_HASH_DEF_DYNAMIC
|
|
|
|
|
| ELF_LINK_HASH_DEF_REGULAR)) == 0);
|
|
|
|
|
|
2002-08-22 01:27:20 +00:00
|
|
|
|
(*bed->elf_backend_copy_indirect_symbol) (bed, h, hi);
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
|
|
|
|
/* See if the new flags lead us to realize that the symbol
|
|
|
|
|
must be dynamic. */
|
|
|
|
|
if (! *dynsym)
|
|
|
|
|
{
|
|
|
|
|
if (! dynamic)
|
|
|
|
|
{
|
|
|
|
|
if (info->shared
|
|
|
|
|
|| ((hi->elf_link_hash_flags
|
|
|
|
|
& ELF_LINK_HASH_REF_DYNAMIC) != 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*dynsym = TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((hi->elf_link_hash_flags
|
|
|
|
|
& ELF_LINK_HASH_REF_REGULAR) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*dynsym = TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Add symbols from an ELF object file to the linker hash table. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_add_object_symbols (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean (*add_symbol_hook)
|
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
|
|
|
|
|
const char **, flagword *, asection **, bfd_vma *));
|
|
|
|
|
bfd_boolean (*check_relocs)
|
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
|
|
|
|
const Elf_Internal_Rela *));
|
|
|
|
|
bfd_boolean collect;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
Elf_Internal_Shdr *hdr;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type symcount;
|
|
|
|
|
bfd_size_type extsymcount;
|
|
|
|
|
bfd_size_type extsymoff;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct elf_link_hash_entry **sym_hash;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean dynamic;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
Elf_External_Versym *extversym = NULL;
|
|
|
|
|
Elf_External_Versym *ever;
|
|
|
|
|
struct elf_link_hash_entry *weaks;
|
2003-02-13 22:14:11 +00:00
|
|
|
|
struct elf_link_hash_entry **nondeflt_vers = NULL;
|
|
|
|
|
bfd_size_type nondeflt_vers_cnt = 0;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_Internal_Sym *isymbuf = NULL;
|
|
|
|
|
Elf_Internal_Sym *isym;
|
|
|
|
|
Elf_Internal_Sym *isymend;
|
2000-02-18 09:23:06 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean dt_needed;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
struct elf_link_hash_table * hash_table;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type amt;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
|
|
|
|
|
hash_table = elf_hash_table (info);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2000-02-18 09:23:06 +00:00
|
|
|
|
bed = get_elf_backend_data (abfd);
|
|
|
|
|
add_symbol_hook = bed->elf_add_symbol_hook;
|
|
|
|
|
collect = bed->collect;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) == 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dynamic = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dynamic = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* You can't use -r against a dynamic object. Also, there's no
|
|
|
|
|
hope of using a dynamic object which does not exactly match
|
|
|
|
|
the format of the output file. */
|
|
|
|
|
if (info->relocateable || info->hash->creator != abfd->xvec)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* As a GNU extension, any input sections which are named
|
|
|
|
|
.gnu.warning.SYMBOL are treated as warning symbols for the given
|
|
|
|
|
symbol. This differs from .gnu.warning sections, which generate
|
|
|
|
|
warnings when they are included in an output file. */
|
|
|
|
|
if (! info->shared)
|
|
|
|
|
{
|
|
|
|
|
asection *s;
|
|
|
|
|
|
|
|
|
|
for (s = abfd->sections; s != NULL; s = s->next)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
name = bfd_get_section_name (abfd, s);
|
|
|
|
|
if (strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0)
|
|
|
|
|
{
|
|
|
|
|
char *msg;
|
|
|
|
|
bfd_size_type sz;
|
|
|
|
|
|
|
|
|
|
name += sizeof ".gnu.warning." - 1;
|
|
|
|
|
|
|
|
|
|
/* If this is a shared object, then look up the symbol
|
|
|
|
|
in the hash table. If it is there, and it is already
|
|
|
|
|
been defined, then we will not be using the entry
|
|
|
|
|
from this shared object, so we don't need to warn.
|
|
|
|
|
FIXME: If we see the definition in a regular object
|
|
|
|
|
later on, we will warn, but we shouldn't. The only
|
|
|
|
|
fix is to keep track of what warnings we are supposed
|
|
|
|
|
to emit, and then handle them all at the end of the
|
|
|
|
|
link. */
|
|
|
|
|
if (dynamic && abfd->xvec == info->hash->creator)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
h = elf_link_hash_lookup (hash_table, name,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE, FALSE, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME: What about bfd_link_hash_common? */
|
|
|
|
|
if (h != NULL
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
/* We don't want to issue this warning. Clobber
|
2002-03-05 05:18:41 +00:00
|
|
|
|
the section size so that the warning does not
|
|
|
|
|
get copied into the output file. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
s->_raw_size = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sz = bfd_section_size (abfd, s);
|
|
|
|
|
msg = (char *) bfd_alloc (abfd, sz + 1);
|
|
|
|
|
if (msg == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
if (! bfd_get_section_contents (abfd, s, msg, (file_ptr) 0, sz))
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
msg[sz] = '\0';
|
|
|
|
|
|
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, abfd, name, BSF_WARNING, s, (bfd_vma) 0, msg,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE, collect, (struct bfd_link_hash_entry **) NULL)))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
if (! info->relocateable)
|
|
|
|
|
{
|
|
|
|
|
/* Clobber the section size so that the warning does
|
2002-03-05 05:18:41 +00:00
|
|
|
|
not get copied into the output file. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
s->_raw_size = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dt_needed = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (! dynamic)
|
|
|
|
|
{
|
|
|
|
|
/* If we are creating a shared library, create all the dynamic
|
2002-03-05 05:18:41 +00:00
|
|
|
|
sections immediately. We need to attach them to something,
|
|
|
|
|
so we attach them to this BFD, provided it is the right
|
|
|
|
|
format. FIXME: If there are no input BFD's of the same
|
|
|
|
|
format as the output, we can't make a shared library. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (info->shared
|
2001-08-24 16:36:04 +00:00
|
|
|
|
&& is_elf_hash_table (info)
|
|
|
|
|
&& ! hash_table->dynamic_sections_created
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& abfd->xvec == info->hash->creator)
|
|
|
|
|
{
|
|
|
|
|
if (! elf_link_create_dynamic_sections (abfd, info))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-08-24 16:36:04 +00:00
|
|
|
|
else if (! is_elf_hash_table (info))
|
|
|
|
|
goto error_return;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
asection *s;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean add_needed;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
const char *name;
|
|
|
|
|
bfd_size_type oldsize;
|
|
|
|
|
bfd_size_type strindex;
|
2002-10-19 17:13:58 +00:00
|
|
|
|
struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-10-16 00:57:39 +00:00
|
|
|
|
/* ld --just-symbols and dynamic objects don't mix very well.
|
|
|
|
|
Test for --just-symbols by looking at info set up by
|
|
|
|
|
_bfd_elf_link_just_syms. */
|
|
|
|
|
if ((s = abfd->sections) != NULL
|
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 12:34:08 +00:00
|
|
|
|
&& s->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
|
2002-10-16 00:57:39 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Find the name to use in a DT_NEEDED entry that refers to this
|
|
|
|
|
object. If the object has a DT_SONAME entry, we use it.
|
|
|
|
|
Otherwise, if the generic linker stuck something in
|
|
|
|
|
elf_dt_name, we use that. Otherwise, we just use the file
|
|
|
|
|
name. If the generic linker put a null string into
|
|
|
|
|
elf_dt_name, we don't make a DT_NEEDED entry at all, even if
|
|
|
|
|
there is a DT_SONAME entry. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
add_needed = TRUE;
|
2001-05-18 16:06:43 +00:00
|
|
|
|
name = bfd_get_filename (abfd);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (elf_dt_name (abfd) != NULL)
|
|
|
|
|
{
|
|
|
|
|
name = elf_dt_name (abfd);
|
|
|
|
|
if (*name == '\0')
|
2000-07-20 03:16:18 +00:00
|
|
|
|
{
|
|
|
|
|
if (elf_dt_soname (abfd) != NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dt_needed = TRUE;
|
2000-07-20 03:16:18 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
add_needed = FALSE;
|
2000-07-20 03:16:18 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
s = bfd_get_section_by_name (abfd, ".dynamic");
|
|
|
|
|
if (s != NULL)
|
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_External_Dyn *dynbuf = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
Elf_External_Dyn *extdyn;
|
|
|
|
|
Elf_External_Dyn *extdynend;
|
|
|
|
|
int elfsec;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
unsigned long shlink;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
dynbuf = (Elf_External_Dyn *) bfd_malloc (s->_raw_size);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (dynbuf == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf,
|
|
|
|
|
(file_ptr) 0, s->_raw_size))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
|
|
|
|
|
if (elfsec == -1)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
shlink = elf_elfsections (abfd)[elfsec]->sh_link;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
extdyn = dynbuf;
|
|
|
|
|
extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn);
|
|
|
|
|
for (; extdyn < extdynend; extdyn++)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Dyn dyn;
|
|
|
|
|
|
|
|
|
|
elf_swap_dyn_in (abfd, extdyn, &dyn);
|
|
|
|
|
if (dyn.d_tag == DT_SONAME)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
unsigned int tagv = dyn.d_un.d_val;
|
|
|
|
|
name = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (name == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
if (dyn.d_tag == DT_NEEDED)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_link_needed_list *n, **pn;
|
|
|
|
|
char *fnm, *anm;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
unsigned int tagv = dyn.d_un.d_val;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = sizeof (struct bfd_link_needed_list);
|
|
|
|
|
n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
|
|
|
|
|
fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (n == NULL || fnm == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
amt = strlen (fnm) + 1;
|
|
|
|
|
anm = bfd_alloc (abfd, amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (anm == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (anm, fnm, (size_t) amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
n->name = anm;
|
|
|
|
|
n->by = abfd;
|
|
|
|
|
n->next = NULL;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
for (pn = & hash_table->needed;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*pn != NULL;
|
|
|
|
|
pn = &(*pn)->next)
|
|
|
|
|
;
|
|
|
|
|
*pn = n;
|
|
|
|
|
}
|
2000-08-22 19:33:16 +00:00
|
|
|
|
if (dyn.d_tag == DT_RUNPATH)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_link_needed_list *n, **pn;
|
|
|
|
|
char *fnm, *anm;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
unsigned int tagv = dyn.d_un.d_val;
|
2000-08-22 19:33:16 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = sizeof (struct bfd_link_needed_list);
|
|
|
|
|
n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
|
|
|
|
|
fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
|
2000-08-22 19:33:16 +00:00
|
|
|
|
if (n == NULL || fnm == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
amt = strlen (fnm) + 1;
|
|
|
|
|
anm = bfd_alloc (abfd, amt);
|
2000-08-22 19:33:16 +00:00
|
|
|
|
if (anm == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (anm, fnm, (size_t) amt);
|
2000-08-22 19:33:16 +00:00
|
|
|
|
n->name = anm;
|
|
|
|
|
n->by = abfd;
|
|
|
|
|
n->next = NULL;
|
2002-10-19 17:13:58 +00:00
|
|
|
|
for (pn = & runpath;
|
2000-08-22 19:33:16 +00:00
|
|
|
|
*pn != NULL;
|
|
|
|
|
pn = &(*pn)->next)
|
|
|
|
|
;
|
|
|
|
|
*pn = n;
|
|
|
|
|
}
|
2001-01-03 22:53:39 +00:00
|
|
|
|
/* Ignore DT_RPATH if we have seen DT_RUNPATH. */
|
2000-08-22 19:33:16 +00:00
|
|
|
|
if (!runpath && dyn.d_tag == DT_RPATH)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
{
|
2000-08-22 19:33:16 +00:00
|
|
|
|
struct bfd_link_needed_list *n, **pn;
|
|
|
|
|
char *fnm, *anm;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
unsigned int tagv = dyn.d_un.d_val;
|
2000-08-22 19:33:16 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = sizeof (struct bfd_link_needed_list);
|
|
|
|
|
n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
|
|
|
|
|
fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
|
2000-08-22 19:33:16 +00:00
|
|
|
|
if (n == NULL || fnm == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_dyn;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
amt = strlen (fnm) + 1;
|
|
|
|
|
anm = bfd_alloc (abfd, amt);
|
2000-08-22 19:33:16 +00:00
|
|
|
|
if (anm == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
{
|
|
|
|
|
error_free_dyn:
|
|
|
|
|
free (dynbuf);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (anm, fnm, (size_t) amt);
|
2000-08-22 19:33:16 +00:00
|
|
|
|
n->name = anm;
|
|
|
|
|
n->by = abfd;
|
|
|
|
|
n->next = NULL;
|
2002-10-19 17:13:58 +00:00
|
|
|
|
for (pn = & rpath;
|
2000-08-22 19:33:16 +00:00
|
|
|
|
*pn != NULL;
|
|
|
|
|
pn = &(*pn)->next)
|
|
|
|
|
;
|
|
|
|
|
*pn = n;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (dynbuf);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-19 17:13:58 +00:00
|
|
|
|
/* DT_RUNPATH overrides DT_RPATH. Do _NOT_ bfd_release, as that
|
|
|
|
|
frees all more recently bfd_alloc'd blocks as well. */
|
|
|
|
|
if (runpath)
|
|
|
|
|
rpath = runpath;
|
|
|
|
|
|
|
|
|
|
if (rpath)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_link_needed_list **pn;
|
|
|
|
|
for (pn = & hash_table->runpath;
|
|
|
|
|
*pn != NULL;
|
|
|
|
|
pn = &(*pn)->next)
|
|
|
|
|
;
|
|
|
|
|
*pn = rpath;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* We do not want to include any of the sections in a dynamic
|
|
|
|
|
object in the output file. We hack by simply clobbering the
|
|
|
|
|
list of sections in the BFD. This could be handled more
|
|
|
|
|
cleanly by, say, a new section flag; the existing
|
|
|
|
|
SEC_NEVER_LOAD flag is not the one we want, because that one
|
|
|
|
|
still implies that the section takes up space in the output
|
|
|
|
|
file. */
|
2002-01-16 05:37:10 +00:00
|
|
|
|
bfd_section_list_clear (abfd);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If this is the first dynamic object found in the link, create
|
|
|
|
|
the special sections required for dynamic linking. */
|
2001-08-24 16:36:04 +00:00
|
|
|
|
if (! hash_table->dynamic_sections_created)
|
|
|
|
|
if (! elf_link_create_dynamic_sections (abfd, info))
|
|
|
|
|
goto error_return;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (add_needed)
|
|
|
|
|
{
|
|
|
|
|
/* Add a DT_NEEDED entry for this dynamic object. */
|
* 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 16:50:38 +00:00
|
|
|
|
oldsize = _bfd_elf_strtab_size (hash_table->dynstr);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
strindex = _bfd_elf_strtab_add (hash_table->dynstr, name, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (strindex == (bfd_size_type) -1)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
* 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 16:50:38 +00:00
|
|
|
|
if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
asection *sdyn;
|
|
|
|
|
Elf_External_Dyn *dyncon, *dynconend;
|
|
|
|
|
|
|
|
|
|
/* The hash table size did not change, which means that
|
|
|
|
|
the dynamic object name was already entered. If we
|
|
|
|
|
have already included this dynamic object in the
|
|
|
|
|
link, just ignore it. There is no reason to include
|
|
|
|
|
a particular dynamic object more than once. */
|
2001-08-24 16:36:04 +00:00
|
|
|
|
sdyn = bfd_get_section_by_name (hash_table->dynobj, ".dynamic");
|
1999-05-03 07:29:11 +00:00
|
|
|
|
BFD_ASSERT (sdyn != NULL);
|
|
|
|
|
|
|
|
|
|
dyncon = (Elf_External_Dyn *) sdyn->contents;
|
|
|
|
|
dynconend = (Elf_External_Dyn *) (sdyn->contents +
|
|
|
|
|
sdyn->_raw_size);
|
|
|
|
|
for (; dyncon < dynconend; dyncon++)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Dyn dyn;
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
elf_swap_dyn_in (hash_table->dynobj, dyncon, & dyn);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (dyn.d_tag == DT_NEEDED
|
|
|
|
|
&& dyn.d_un.d_val == strindex)
|
|
|
|
|
{
|
* 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 16:50:38 +00:00
|
|
|
|
_bfd_elf_strtab_delref (hash_table->dynstr, strindex);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Save the SONAME, if there is one, because sometimes the
|
2002-03-05 05:18:41 +00:00
|
|
|
|
linker emulation code will need to know it. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (*name == '\0')
|
2001-05-03 06:18:09 +00:00
|
|
|
|
name = basename (bfd_get_filename (abfd));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_dt_name (abfd) = name;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
/* If this is a dynamic object, we always link against the .dynsym
|
|
|
|
|
symbol table, not the .symtab symbol table. The dynamic linker
|
|
|
|
|
will only see the .dynsym symbol table, so there is no reason to
|
|
|
|
|
look at .symtab for a dynamic object. */
|
|
|
|
|
|
|
|
|
|
if (! dynamic || elf_dynsymtab (abfd) == 0)
|
|
|
|
|
hdr = &elf_tdata (abfd)->symtab_hdr;
|
|
|
|
|
else
|
|
|
|
|
hdr = &elf_tdata (abfd)->dynsymtab_hdr;
|
|
|
|
|
|
|
|
|
|
symcount = hdr->sh_size / sizeof (Elf_External_Sym);
|
|
|
|
|
|
|
|
|
|
/* The sh_info field of the symtab header tells us where the
|
|
|
|
|
external symbols start. We don't care about the local symbols at
|
|
|
|
|
this point. */
|
|
|
|
|
if (elf_bad_symtab (abfd))
|
|
|
|
|
{
|
|
|
|
|
extsymcount = symcount;
|
|
|
|
|
extsymoff = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
extsymcount = symcount - hdr->sh_info;
|
|
|
|
|
extsymoff = hdr->sh_info;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
sym_hash = NULL;
|
|
|
|
|
if (extsymcount != 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 00:52:35 +00:00
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
if (isymbuf == 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 00:52:35 +00:00
|
|
|
|
goto error_return;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
|
|
|
|
|
/* We store a pointer to the hash table entry for each external
|
|
|
|
|
symbol. */
|
|
|
|
|
amt = extsymcount * sizeof (struct elf_link_hash_entry *);
|
|
|
|
|
sym_hash = (struct elf_link_hash_entry **) bfd_alloc (abfd, amt);
|
|
|
|
|
if (sym_hash == NULL)
|
|
|
|
|
goto error_free_sym;
|
|
|
|
|
elf_sym_hashes (abfd) = sym_hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dynamic)
|
|
|
|
|
{
|
|
|
|
|
/* Read in any version definitions. */
|
|
|
|
|
if (! _bfd_elf_slurp_version_tables (abfd))
|
|
|
|
|
goto error_free_sym;
|
|
|
|
|
|
|
|
|
|
/* Read in the symbol versions, but don't bother to convert them
|
|
|
|
|
to internal format. */
|
|
|
|
|
if (elf_dynversym (abfd) != 0)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Shdr *versymhdr;
|
|
|
|
|
|
|
|
|
|
versymhdr = &elf_tdata (abfd)->dynversym_hdr;
|
|
|
|
|
extversym = (Elf_External_Versym *) bfd_malloc (versymhdr->sh_size);
|
|
|
|
|
if (extversym == NULL)
|
|
|
|
|
goto error_free_sym;
|
|
|
|
|
amt = versymhdr->sh_size;
|
|
|
|
|
if (bfd_seek (abfd, versymhdr->sh_offset, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bread ((PTR) extversym, amt, abfd) != amt)
|
|
|
|
|
goto error_free_vers;
|
|
|
|
|
}
|
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 00:52:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
weaks = NULL;
|
|
|
|
|
|
|
|
|
|
ever = extversym != NULL ? extversym + extsymoff : NULL;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
for (isym = isymbuf, isymend = isymbuf + extsymcount;
|
|
|
|
|
isym < isymend;
|
|
|
|
|
isym++, sym_hash++, ever = (ever != NULL ? ever + 1 : NULL))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
int bind;
|
|
|
|
|
bfd_vma value;
|
|
|
|
|
asection *sec;
|
|
|
|
|
flagword flags;
|
|
|
|
|
const char *name;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean definition;
|
|
|
|
|
bfd_boolean size_change_ok, type_change_ok;
|
|
|
|
|
bfd_boolean new_weakdef;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
unsigned int old_alignment;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean override;
|
2001-11-30 15:50:56 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
override = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
flags = BSF_NO_FLAGS;
|
|
|
|
|
sec = NULL;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
value = isym->st_value;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*sym_hash = NULL;
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
bind = ELF_ST_BIND (isym->st_info);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (bind == STB_LOCAL)
|
|
|
|
|
{
|
|
|
|
|
/* This should be impossible, since ELF requires that all
|
|
|
|
|
global symbols follow all local symbols, and that sh_info
|
|
|
|
|
point to the first global symbol. Unfortunatealy, Irix 5
|
|
|
|
|
screws this up. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (bind == STB_GLOBAL)
|
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym->st_shndx != SHN_UNDEF
|
|
|
|
|
&& isym->st_shndx != SHN_COMMON)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
flags = BSF_GLOBAL;
|
|
|
|
|
}
|
|
|
|
|
else if (bind == STB_WEAK)
|
|
|
|
|
flags = BSF_WEAK;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Leave it up to the processor backend. */
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym->st_shndx == SHN_UNDEF)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
sec = bfd_und_section_ptr;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
else if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
sec = section_from_elf_index (abfd, isym->st_shndx);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (sec == NULL)
|
|
|
|
|
sec = bfd_abs_section_ptr;
|
|
|
|
|
else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
|
|
|
|
|
value -= sec->vma;
|
|
|
|
|
}
|
2002-07-07 09:10:41 +00:00
|
|
|
|
else if (isym->st_shndx == SHN_ABS)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
sec = bfd_abs_section_ptr;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
else if (isym->st_shndx == SHN_COMMON)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
sec = bfd_com_section_ptr;
|
|
|
|
|
/* What ELF calls the size we call the value. What ELF
|
|
|
|
|
calls the value we call the alignment. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
value = isym->st_size;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Leave it up to the processor backend. */
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
|
|
|
|
|
isym->st_name);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (name == (const char *) NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym->st_shndx == SHN_COMMON
|
|
|
|
|
&& ELF_ST_TYPE (isym->st_info) == STT_TLS)
|
* 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 13:12:53 +00:00
|
|
|
|
{
|
|
|
|
|
asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon");
|
|
|
|
|
|
|
|
|
|
if (tcomm == NULL)
|
|
|
|
|
{
|
|
|
|
|
tcomm = bfd_make_section (abfd, ".tcommon");
|
|
|
|
|
if (tcomm == NULL
|
|
|
|
|
|| !bfd_set_section_flags (abfd, tcomm, (SEC_ALLOC
|
|
|
|
|
| SEC_IS_COMMON
|
|
|
|
|
| SEC_LINKER_CREATED
|
|
|
|
|
| SEC_THREAD_LOCAL)))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
* 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 13:12:53 +00:00
|
|
|
|
}
|
|
|
|
|
sec = tcomm;
|
|
|
|
|
}
|
|
|
|
|
else if (add_symbol_hook)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (! (*add_symbol_hook) (abfd, info, isym, &name, &flags, &sec,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&value))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* The hook function sets the name to NULL if this symbol
|
|
|
|
|
should be skipped for some reason. */
|
|
|
|
|
if (name == (const char *) NULL)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sanity check that all possibilities were handled. */
|
|
|
|
|
if (sec == (asection *) NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bfd_is_und_section (sec)
|
|
|
|
|
|| bfd_is_com_section (sec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
definition = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
definition = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
size_change_ok = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
type_change_ok = get_elf_backend_data (abfd)->type_change_ok;
|
|
|
|
|
old_alignment = 0;
|
|
|
|
|
if (info->hash->creator->flavour == bfd_target_elf_flavour)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Versym iver;
|
|
|
|
|
unsigned int vernum = 0;
|
|
|
|
|
|
|
|
|
|
if (ever != NULL)
|
|
|
|
|
{
|
|
|
|
|
_bfd_elf_swap_versym_in (abfd, ever, &iver);
|
|
|
|
|
vernum = iver.vs_vers & VERSYM_VERSION;
|
|
|
|
|
|
|
|
|
|
/* If this is a hidden symbol, or if it is not version
|
2002-03-05 05:18:41 +00:00
|
|
|
|
1, we append the version name to the symbol name.
|
|
|
|
|
However, we do not modify a non-hidden absolute
|
|
|
|
|
symbol, because it might be the version symbol
|
|
|
|
|
itself. FIXME: What if it isn't? */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if ((iver.vs_vers & VERSYM_HIDDEN) != 0
|
|
|
|
|
|| (vernum > 1 && ! bfd_is_abs_section (sec)))
|
|
|
|
|
{
|
|
|
|
|
const char *verstr;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
size_t namelen, verlen, newlen;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
char *newname, *p;
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym->st_shndx != SHN_UNDEF)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (vernum > elf_tdata (abfd)->dynverdef_hdr.sh_info)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: %s: invalid version %u (max %d)"),
|
2001-09-20 23:30:37 +00:00
|
|
|
|
bfd_archive_filename (abfd), name, vernum,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_tdata (abfd)->dynverdef_hdr.sh_info);
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else if (vernum > 1)
|
|
|
|
|
verstr =
|
|
|
|
|
elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
|
|
|
|
|
else
|
|
|
|
|
verstr = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We cannot simply test for the number of
|
|
|
|
|
entries in the VERNEED section since the
|
|
|
|
|
numbers for the needed versions do not start
|
|
|
|
|
at 0. */
|
|
|
|
|
Elf_Internal_Verneed *t;
|
|
|
|
|
|
|
|
|
|
verstr = NULL;
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
verstr = a->vna_nodename;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (a != NULL)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (verstr == NULL)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: %s: invalid needed version %d"),
|
2001-09-20 23:30:37 +00:00
|
|
|
|
bfd_archive_filename (abfd), name, vernum);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namelen = strlen (name);
|
2002-06-25 09:40:45 +00:00
|
|
|
|
verlen = strlen (verstr);
|
|
|
|
|
newlen = namelen + verlen + 2;
|
|
|
|
|
if ((iver.vs_vers & VERSYM_HIDDEN) == 0
|
2002-07-07 09:10:41 +00:00
|
|
|
|
&& isym->st_shndx != SHN_UNDEF)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
++newlen;
|
|
|
|
|
|
2002-06-25 09:40:45 +00:00
|
|
|
|
newname = (char *) bfd_alloc (abfd, (bfd_size_type) newlen);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (newname == NULL)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (newname, name, namelen);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
p = newname + namelen;
|
|
|
|
|
*p++ = ELF_VER_CHR;
|
2000-02-22 08:06:01 +00:00
|
|
|
|
/* If this is a defined non-hidden version symbol,
|
|
|
|
|
we add another @ to the name. This indicates the
|
|
|
|
|
default version of the symbol. */
|
|
|
|
|
if ((iver.vs_vers & VERSYM_HIDDEN) == 0
|
2002-07-07 09:10:41 +00:00
|
|
|
|
&& isym->st_shndx != SHN_UNDEF)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*p++ = ELF_VER_CHR;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (p, verstr, verlen + 1);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
name = newname;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (! elf_merge_symbol (abfd, info, name, isym, &sec, &value,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
sym_hash, &override, &type_change_ok,
|
2000-07-28 00:49:07 +00:00
|
|
|
|
&size_change_ok, dt_needed))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (override)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
definition = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
h = *sym_hash;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
/* Remember the old alignment if this is a common symbol, so
|
2002-03-05 05:18:41 +00:00
|
|
|
|
that we don't reduce the alignment later on. We can't
|
|
|
|
|
check later, because _bfd_generic_link_add_one_symbol
|
|
|
|
|
will set a default for the alignment which we want to
|
|
|
|
|
override. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_common)
|
|
|
|
|
old_alignment = h->root.u.c.p->alignment_power;
|
|
|
|
|
|
|
|
|
|
if (elf_tdata (abfd)->verdef != NULL
|
|
|
|
|
&& ! override
|
|
|
|
|
&& vernum > 1
|
|
|
|
|
&& definition)
|
|
|
|
|
h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, abfd, name, flags, sec, value, (const char *) NULL,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE, collect, (struct bfd_link_hash_entry **) sym_hash)))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
h = *sym_hash;
|
|
|
|
|
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;
|
|
|
|
|
*sym_hash = h;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
new_weakdef = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (dynamic
|
|
|
|
|
&& definition
|
|
|
|
|
&& (flags & BSF_WEAK) != 0
|
2002-07-07 09:10:41 +00:00
|
|
|
|
&& ELF_ST_TYPE (isym->st_info) != STT_FUNC
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& info->hash->creator->flavour == bfd_target_elf_flavour
|
|
|
|
|
&& h->weakdef == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Keep a list of all weak defined non function symbols from
|
|
|
|
|
a dynamic object, using the weakdef field. Later in this
|
|
|
|
|
function we will set the weakdef field to the correct
|
|
|
|
|
value. We only put non-function symbols from dynamic
|
|
|
|
|
objects on this list, because that happens to be the only
|
|
|
|
|
time we need to know the normal symbol corresponding to a
|
|
|
|
|
weak symbol, and the information is time consuming to
|
|
|
|
|
figure out. If the weakdef field is not already NULL,
|
|
|
|
|
then this symbol was already defined by some previous
|
|
|
|
|
dynamic object, and we will be using that previous
|
|
|
|
|
definition anyhow. */
|
|
|
|
|
|
|
|
|
|
h->weakdef = weaks;
|
|
|
|
|
weaks = h;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
new_weakdef = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set the alignment of a common symbol. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym->st_shndx == SHN_COMMON
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& h->root.type == bfd_link_hash_common)
|
|
|
|
|
{
|
|
|
|
|
unsigned int align;
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
align = bfd_log2 (isym->st_value);
|
2000-08-24 17:41:40 +00:00
|
|
|
|
if (align > old_alignment
|
|
|
|
|
/* Permit an alignment power of zero if an alignment of one
|
|
|
|
|
is specified and no other alignments have been specified. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
|| (isym->st_value == 1 && old_alignment == 0))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
h->root.u.c.p->alignment_power = align;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info->hash->creator->flavour == bfd_target_elf_flavour)
|
|
|
|
|
{
|
|
|
|
|
int old_flags;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean dynsym;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
int new_flag;
|
|
|
|
|
|
|
|
|
|
/* Remember the symbol size and type. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym->st_size != 0
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& (definition || h->size == 0))
|
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (h->size != 0 && h->size != isym->st_size && ! size_change_ok)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("Warning: size of symbol `%s' changed from %lu to %lu in %s"),
|
2002-07-07 09:10:41 +00:00
|
|
|
|
name, (unsigned long) h->size,
|
|
|
|
|
(unsigned long) isym->st_size, bfd_archive_filename (abfd));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
h->size = isym->st_size;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is a common symbol, then we always want H->SIZE
|
2002-03-05 05:18:41 +00:00
|
|
|
|
to be the size of the common symbol. The code just above
|
|
|
|
|
won't fix the size if a common symbol becomes larger. We
|
|
|
|
|
don't warn about a size change here, because that is
|
|
|
|
|
covered by --warn-common. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_common)
|
|
|
|
|
h->size = h->root.u.c.size;
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& (definition || h->type == STT_NOTYPE))
|
|
|
|
|
{
|
|
|
|
|
if (h->type != STT_NOTYPE
|
2002-07-07 09:10:41 +00:00
|
|
|
|
&& h->type != ELF_ST_TYPE (isym->st_info)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& ! type_change_ok)
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("Warning: type of symbol `%s' changed from %d to %d in %s"),
|
2002-07-07 09:10:41 +00:00
|
|
|
|
name, h->type, ELF_ST_TYPE (isym->st_info),
|
2001-09-20 23:30:37 +00:00
|
|
|
|
bfd_archive_filename (abfd));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
h->type = ELF_ST_TYPE (isym->st_info);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-01-03 18:32:21 +00:00
|
|
|
|
/* If st_other has a processor-specific meaning, specific code
|
|
|
|
|
might be needed here. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym->st_other != 0)
|
2000-01-03 18:32:21 +00:00
|
|
|
|
{
|
2002-11-21 18:52:36 +00:00
|
|
|
|
unsigned char hvis, symvis, other;
|
|
|
|
|
|
|
|
|
|
/* Take the balance of OTHER from the definition. */
|
|
|
|
|
other = (definition ? isym->st_other : h->other);
|
|
|
|
|
other &= ~ ELF_ST_VISIBILITY (-1);
|
|
|
|
|
|
2000-01-03 18:32:21 +00:00
|
|
|
|
/* Combine visibilities, using the most constraining one. */
|
2002-11-21 18:52:36 +00:00
|
|
|
|
hvis = ELF_ST_VISIBILITY (h->other);
|
|
|
|
|
symvis = ELF_ST_VISIBILITY (isym->st_other);
|
|
|
|
|
|
|
|
|
|
h->other = other | (hvis > symvis ? hvis : symvis);
|
2000-01-03 18:32:21 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Set a flag in the hash table entry indicating the type of
|
|
|
|
|
reference or definition we just found. Keep a count of
|
|
|
|
|
the number of dynamic symbols we find. A dynamic symbol
|
|
|
|
|
is one which is referenced or defined by both a regular
|
|
|
|
|
object and a shared object. */
|
|
|
|
|
old_flags = h->elf_link_hash_flags;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dynsym = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (! dynamic)
|
|
|
|
|
{
|
|
|
|
|
if (! definition)
|
|
|
|
|
{
|
|
|
|
|
new_flag = ELF_LINK_HASH_REF_REGULAR;
|
|
|
|
|
if (bind != STB_WEAK)
|
|
|
|
|
new_flag |= ELF_LINK_HASH_REF_REGULAR_NONWEAK;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
new_flag = ELF_LINK_HASH_DEF_REGULAR;
|
|
|
|
|
if (info->shared
|
|
|
|
|
|| (old_flags & (ELF_LINK_HASH_DEF_DYNAMIC
|
|
|
|
|
| ELF_LINK_HASH_REF_DYNAMIC)) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dynsym = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! definition)
|
|
|
|
|
new_flag = ELF_LINK_HASH_REF_DYNAMIC;
|
|
|
|
|
else
|
|
|
|
|
new_flag = ELF_LINK_HASH_DEF_DYNAMIC;
|
|
|
|
|
if ((old_flags & (ELF_LINK_HASH_DEF_REGULAR
|
|
|
|
|
| ELF_LINK_HASH_REF_REGULAR)) != 0
|
|
|
|
|
|| (h->weakdef != NULL
|
|
|
|
|
&& ! new_weakdef
|
|
|
|
|
&& h->weakdef->dynindx != -1))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dynsym = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h->elf_link_hash_flags |= new_flag;
|
|
|
|
|
|
2001-11-30 15:50:56 +00:00
|
|
|
|
/* Check to see if we need to add an indirect symbol for
|
|
|
|
|
the default name. */
|
2000-11-13 22:49:54 +00:00
|
|
|
|
if (definition || h->root.type == bfd_link_hash_common)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (! elf_add_default_symbol (abfd, info, h, name, isym,
|
2001-11-30 15:50:56 +00:00
|
|
|
|
&sec, &value, &dynsym,
|
|
|
|
|
override, dt_needed))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2003-02-13 22:14:11 +00:00
|
|
|
|
if (definition && (abfd->flags & DYNAMIC) == 0)
|
|
|
|
|
{
|
|
|
|
|
char *p = strchr (name, ELF_VER_CHR);
|
|
|
|
|
if (p != NULL && p[1] != ELF_VER_CHR)
|
|
|
|
|
{
|
|
|
|
|
/* Queue non-default versions so that .symver x, x@FOO
|
|
|
|
|
aliases can be checked. */
|
|
|
|
|
if (! nondeflt_vers)
|
|
|
|
|
{
|
|
|
|
|
amt = (isymend - isym + 1)
|
|
|
|
|
* sizeof (struct elf_link_hash_entry *);
|
|
|
|
|
nondeflt_vers = bfd_malloc (amt);
|
|
|
|
|
}
|
|
|
|
|
nondeflt_vers [nondeflt_vers_cnt++] = h;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (dynsym && h->dynindx == -1)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, h))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->weakdef != NULL
|
|
|
|
|
&& ! new_weakdef
|
|
|
|
|
&& h->weakdef->dynindx == -1)
|
|
|
|
|
{
|
2001-08-09 14:38:04 +00:00
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, h->weakdef))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-05-30 20:51:36 +00:00
|
|
|
|
else if (dynsym && h->dynindx != -1)
|
2000-05-04 06:38:33 +00:00
|
|
|
|
/* If the symbol already has a dynamic index, but
|
|
|
|
|
visibility says it should not be visible, turn it into
|
|
|
|
|
a local symbol. */
|
|
|
|
|
switch (ELF_ST_VISIBILITY (h->other))
|
|
|
|
|
{
|
|
|
|
|
case STV_INTERNAL:
|
2001-01-03 22:53:39 +00:00
|
|
|
|
case STV_HIDDEN:
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(*bed->elf_backend_hide_symbol) (info, h, TRUE);
|
2000-05-04 06:38:33 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2000-07-20 03:16:18 +00:00
|
|
|
|
|
|
|
|
|
if (dt_needed && definition
|
|
|
|
|
&& (h->elf_link_hash_flags
|
|
|
|
|
& ELF_LINK_HASH_REF_REGULAR) != 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type oldsize;
|
|
|
|
|
bfd_size_type strindex;
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
if (! is_elf_hash_table (info))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
|
2000-07-20 03:16:18 +00:00
|
|
|
|
/* The symbol from a DT_NEEDED object is referenced from
|
2002-03-05 05:18:41 +00:00
|
|
|
|
the regular object to create a dynamic executable. We
|
2001-01-03 22:53:39 +00:00
|
|
|
|
have to make sure there is a DT_NEEDED entry for it. */
|
2000-07-20 03:16:18 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
dt_needed = FALSE;
|
* 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 16:50:38 +00:00
|
|
|
|
oldsize = _bfd_elf_strtab_size (hash_table->dynstr);
|
|
|
|
|
strindex = _bfd_elf_strtab_add (hash_table->dynstr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
elf_dt_soname (abfd), FALSE);
|
2000-07-20 03:16:18 +00:00
|
|
|
|
if (strindex == (bfd_size_type) -1)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
2000-07-20 03:16:18 +00: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 16:50:38 +00:00
|
|
|
|
if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr))
|
2000-07-20 03:16:18 +00:00
|
|
|
|
{
|
|
|
|
|
asection *sdyn;
|
|
|
|
|
Elf_External_Dyn *dyncon, *dynconend;
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
sdyn = bfd_get_section_by_name (hash_table->dynobj,
|
2000-07-20 03:16:18 +00:00
|
|
|
|
".dynamic");
|
|
|
|
|
BFD_ASSERT (sdyn != NULL);
|
|
|
|
|
|
|
|
|
|
dyncon = (Elf_External_Dyn *) sdyn->contents;
|
|
|
|
|
dynconend = (Elf_External_Dyn *) (sdyn->contents +
|
|
|
|
|
sdyn->_raw_size);
|
|
|
|
|
for (; dyncon < dynconend; dyncon++)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Dyn dyn;
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
elf_swap_dyn_in (hash_table->dynobj,
|
2000-07-20 03:16:18 +00:00
|
|
|
|
dyncon, &dyn);
|
|
|
|
|
BFD_ASSERT (dyn.d_tag != DT_NEEDED ||
|
|
|
|
|
dyn.d_un.d_val != strindex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex))
|
2002-07-07 09:10:41 +00:00
|
|
|
|
goto error_free_vers;
|
2000-07-20 03:16:18 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-13 22:14:11 +00:00
|
|
|
|
/* Now that all the symbols from this input file are created, handle
|
|
|
|
|
.symver foo, foo@BAR such that any relocs against foo become foo@BAR. */
|
|
|
|
|
if (nondeflt_vers != NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type cnt, symidx;
|
|
|
|
|
|
|
|
|
|
for (cnt = 0; cnt < nondeflt_vers_cnt; ++cnt)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h = nondeflt_vers[cnt], *hi;
|
|
|
|
|
char *shortname, *p;
|
|
|
|
|
|
|
|
|
|
p = strchr (h->root.root.string, ELF_VER_CHR);
|
|
|
|
|
if (p == NULL
|
|
|
|
|
|| (h->root.type != bfd_link_hash_defined
|
|
|
|
|
&& h->root.type != bfd_link_hash_defweak))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
amt = p - h->root.root.string;
|
|
|
|
|
shortname = bfd_malloc (amt + 1);
|
|
|
|
|
memcpy (shortname, h->root.root.string, amt);
|
|
|
|
|
shortname[amt] = '\0';
|
|
|
|
|
|
|
|
|
|
hi = (struct elf_link_hash_entry *)
|
|
|
|
|
bfd_link_hash_lookup (info->hash, shortname,
|
|
|
|
|
FALSE, FALSE, FALSE);
|
|
|
|
|
if (hi != NULL
|
|
|
|
|
&& hi->root.type == h->root.type
|
|
|
|
|
&& hi->root.u.def.value == h->root.u.def.value
|
|
|
|
|
&& hi->root.u.def.section == h->root.u.def.section)
|
|
|
|
|
{
|
|
|
|
|
(*bed->elf_backend_hide_symbol) (info, hi, TRUE);
|
|
|
|
|
hi->root.type = bfd_link_hash_indirect;
|
|
|
|
|
hi->root.u.i.link = (struct bfd_link_hash_entry *) h;
|
|
|
|
|
(*bed->elf_backend_copy_indirect_symbol) (bed, h, hi);
|
|
|
|
|
sym_hash = elf_sym_hashes (abfd);
|
|
|
|
|
if (sym_hash)
|
|
|
|
|
for (symidx = 0; symidx < extsymcount; ++symidx)
|
|
|
|
|
if (sym_hash[symidx] == hi)
|
|
|
|
|
{
|
|
|
|
|
sym_hash[symidx] = h;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free (shortname);
|
|
|
|
|
}
|
|
|
|
|
free (nondeflt_vers);
|
|
|
|
|
nondeflt_vers = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (extversym != NULL)
|
|
|
|
|
{
|
|
|
|
|
free (extversym);
|
|
|
|
|
extversym = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isymbuf != NULL)
|
|
|
|
|
free (isymbuf);
|
|
|
|
|
isymbuf = NULL;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Now set the weakdefs field correctly for all the weak defined
|
|
|
|
|
symbols we found. The only way to do this is to search all the
|
|
|
|
|
symbols. Since we only need the information for non functions in
|
|
|
|
|
dynamic objects, that's the only time we actually put anything on
|
|
|
|
|
the list WEAKS. We need this information so that if a regular
|
|
|
|
|
object refers to a symbol defined weakly in a dynamic object, the
|
|
|
|
|
real symbol in the dynamic object is also put in the dynamic
|
|
|
|
|
symbols; we also must arrange for both symbols to point to the
|
|
|
|
|
same memory location. We could handle the general case of symbol
|
|
|
|
|
aliasing, but a general symbol alias can only be generated in
|
|
|
|
|
assembler code, handling it correctly would be very time
|
|
|
|
|
consuming, and other ELF linkers don't handle general aliasing
|
|
|
|
|
either. */
|
|
|
|
|
while (weaks != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *hlook;
|
|
|
|
|
asection *slook;
|
|
|
|
|
bfd_vma vlook;
|
|
|
|
|
struct elf_link_hash_entry **hpp;
|
|
|
|
|
struct elf_link_hash_entry **hppend;
|
|
|
|
|
|
|
|
|
|
hlook = weaks;
|
|
|
|
|
weaks = hlook->weakdef;
|
|
|
|
|
hlook->weakdef = NULL;
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (hlook->root.type == bfd_link_hash_defined
|
|
|
|
|
|| hlook->root.type == bfd_link_hash_defweak
|
|
|
|
|
|| hlook->root.type == bfd_link_hash_common
|
|
|
|
|
|| hlook->root.type == bfd_link_hash_indirect);
|
|
|
|
|
slook = hlook->root.u.def.section;
|
|
|
|
|
vlook = hlook->root.u.def.value;
|
|
|
|
|
|
|
|
|
|
hpp = elf_sym_hashes (abfd);
|
|
|
|
|
hppend = hpp + extsymcount;
|
|
|
|
|
for (; hpp < hppend; hpp++)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
h = *hpp;
|
|
|
|
|
if (h != NULL && h != hlook
|
|
|
|
|
&& h->root.type == bfd_link_hash_defined
|
|
|
|
|
&& h->root.u.def.section == slook
|
|
|
|
|
&& h->root.u.def.value == vlook)
|
|
|
|
|
{
|
|
|
|
|
hlook->weakdef = h;
|
|
|
|
|
|
|
|
|
|
/* If the weak definition is in the list of dynamic
|
|
|
|
|
symbols, make sure the real definition is put there
|
|
|
|
|
as well. */
|
|
|
|
|
if (hlook->dynindx != -1
|
|
|
|
|
&& h->dynindx == -1)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, h))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the real definition is in the list of dynamic
|
2002-03-05 05:18:41 +00:00
|
|
|
|
symbols, make sure the weak definition is put there
|
|
|
|
|
as well. If we don't do this, then the dynamic
|
|
|
|
|
loader might not merge the entries for the real
|
|
|
|
|
definition and the weak definition. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->dynindx != -1
|
|
|
|
|
&& hlook->dynindx == -1)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, hlook))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this object is the same format as the output object, and it is
|
|
|
|
|
not a shared library, then let the backend look through the
|
|
|
|
|
relocs.
|
|
|
|
|
|
|
|
|
|
This is required to build global offset table entries and to
|
|
|
|
|
arrange for dynamic relocs. It is not required for the
|
|
|
|
|
particular common case of linking non PIC code, even when linking
|
|
|
|
|
against shared libraries, but unfortunately there is no way of
|
|
|
|
|
knowing whether an object file has been compiled PIC or not.
|
|
|
|
|
Looking through the relocs is not particularly time consuming.
|
|
|
|
|
The problem is that we must either (1) keep the relocs in memory,
|
|
|
|
|
which causes the linker to require additional runtime memory or
|
|
|
|
|
(2) read the relocs twice from the input file, which wastes time.
|
|
|
|
|
This would be a good case for using mmap.
|
|
|
|
|
|
|
|
|
|
I have no idea how to handle linking PIC code into a file of a
|
|
|
|
|
different format. It probably can't be done. */
|
|
|
|
|
check_relocs = get_elf_backend_data (abfd)->check_relocs;
|
|
|
|
|
if (! dynamic
|
|
|
|
|
&& abfd->xvec == info->hash->creator
|
|
|
|
|
&& check_relocs != NULL)
|
|
|
|
|
{
|
|
|
|
|
asection *o;
|
|
|
|
|
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela *internal_relocs;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean ok;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if ((o->flags & SEC_RELOC) == 0
|
|
|
|
|
|| o->reloc_count == 0
|
|
|
|
|
|| ((info->strip == strip_all || info->strip == strip_debugger)
|
|
|
|
|
&& (o->flags & SEC_DEBUGGING) != 0)
|
|
|
|
|
|| bfd_is_abs_section (o->output_section))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
internal_relocs = (NAME(_bfd_elf,link_read_relocs)
|
|
|
|
|
(abfd, o, (PTR) NULL,
|
|
|
|
|
(Elf_Internal_Rela *) NULL,
|
|
|
|
|
info->keep_memory));
|
|
|
|
|
if (internal_relocs == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
ok = (*check_relocs) (abfd, info, o, internal_relocs);
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (elf_section_data (o)->relocs != internal_relocs)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
free (internal_relocs);
|
|
|
|
|
|
|
|
|
|
if (! ok)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-12 07:55:43 +00:00
|
|
|
|
/* If this is a non-traditional link, try to optimize the handling
|
|
|
|
|
of the .stab/.stabstr sections. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (! dynamic
|
|
|
|
|
&& ! info->traditional_format
|
|
|
|
|
&& info->hash->creator->flavour == bfd_target_elf_flavour
|
2001-08-24 16:36:04 +00:00
|
|
|
|
&& is_elf_hash_table (info)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& (info->strip != strip_all && info->strip != strip_debugger))
|
|
|
|
|
{
|
|
|
|
|
asection *stab, *stabstr;
|
|
|
|
|
|
|
|
|
|
stab = bfd_get_section_by_name (abfd, ".stab");
|
2002-05-15 00:18:58 +00:00
|
|
|
|
if (stab != NULL
|
|
|
|
|
&& (stab->flags & SEC_MERGE) == 0
|
|
|
|
|
&& !bfd_is_abs_section (stab->output_section))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
stabstr = bfd_get_section_by_name (abfd, ".stabstr");
|
|
|
|
|
|
|
|
|
|
if (stabstr != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_elf_section_data *secdata;
|
|
|
|
|
|
|
|
|
|
secdata = elf_section_data (stab);
|
|
|
|
|
if (! _bfd_link_section_stabs (abfd,
|
2001-08-24 16:36:04 +00:00
|
|
|
|
& hash_table->stab_info,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
stab, stabstr,
|
2001-12-13 11:09:34 +00:00
|
|
|
|
&secdata->sec_info))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
if (secdata->sec_info)
|
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 12:34:08 +00:00
|
|
|
|
stab->sec_info_type = ELF_INFO_TYPE_STABS;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
if (! info->relocateable && ! dynamic
|
|
|
|
|
&& is_elf_hash_table (info))
|
2001-04-13 00:34:36 +00:00
|
|
|
|
{
|
|
|
|
|
asection *s;
|
|
|
|
|
|
|
|
|
|
for (s = abfd->sections; s != NULL; s = s->next)
|
2002-05-15 00:18:58 +00:00
|
|
|
|
if ((s->flags & SEC_MERGE) != 0
|
|
|
|
|
&& !bfd_is_abs_section (s->output_section))
|
2001-12-13 11:09:34 +00:00
|
|
|
|
{
|
|
|
|
|
struct bfd_elf_section_data *secdata;
|
|
|
|
|
|
|
|
|
|
secdata = elf_section_data (s);
|
|
|
|
|
if (! _bfd_merge_section (abfd,
|
|
|
|
|
& hash_table->merge_info,
|
|
|
|
|
s, &secdata->sec_info))
|
|
|
|
|
goto error_return;
|
|
|
|
|
else if (secdata->sec_info)
|
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 12:34:08 +00:00
|
|
|
|
s->sec_info_type = ELF_INFO_TYPE_MERGE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
}
|
2001-04-13 00:34:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-23 02:04:28 +00:00
|
|
|
|
if (is_elf_hash_table (info))
|
|
|
|
|
{
|
|
|
|
|
/* Add this bfd to the loaded list. */
|
|
|
|
|
struct elf_link_loaded_list *n;
|
|
|
|
|
|
|
|
|
|
n = ((struct elf_link_loaded_list *)
|
|
|
|
|
bfd_alloc (abfd, sizeof (struct elf_link_loaded_list)));
|
|
|
|
|
if (n == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
n->abfd = abfd;
|
|
|
|
|
n->next = hash_table->loaded;
|
|
|
|
|
hash_table->loaded = n;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
error_free_vers:
|
2003-02-13 22:14:11 +00:00
|
|
|
|
if (nondeflt_vers != NULL)
|
|
|
|
|
free (nondeflt_vers);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (extversym != NULL)
|
|
|
|
|
free (extversym);
|
2002-07-07 09:10:41 +00:00
|
|
|
|
error_free_sym:
|
|
|
|
|
if (isymbuf != NULL)
|
|
|
|
|
free (isymbuf);
|
|
|
|
|
error_return:
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create some sections which will be filled in with dynamic linking
|
|
|
|
|
information. ABFD is an input file which requires dynamic sections
|
|
|
|
|
to be created. The dynamic sections take up virtual memory space
|
|
|
|
|
when the final executable is run, so we need to create them before
|
|
|
|
|
addresses are assigned to the output sections. We work out the
|
|
|
|
|
actual contents and size of these sections later. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_create_dynamic_sections (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
flagword flags;
|
|
|
|
|
register asection *s;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
2002-10-11 08:33:11 +00:00
|
|
|
|
struct bfd_link_hash_entry *bh;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
if (! is_elf_hash_table (info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (elf_hash_table (info)->dynamic_sections_created)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure that all dynamic sections use the same input BFD. */
|
|
|
|
|
if (elf_hash_table (info)->dynobj == NULL)
|
|
|
|
|
elf_hash_table (info)->dynobj = abfd;
|
|
|
|
|
else
|
|
|
|
|
abfd = elf_hash_table (info)->dynobj;
|
|
|
|
|
|
|
|
|
|
/* Note that we set the SEC_IN_MEMORY flag for all of these
|
|
|
|
|
sections. */
|
|
|
|
|
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
|
|
|
|
|
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
|
|
|
|
|
|
|
|
|
|
/* A dynamically linked executable has a .interp section, but a
|
|
|
|
|
shared library does not. */
|
|
|
|
|
if (! info->shared)
|
|
|
|
|
{
|
|
|
|
|
s = bfd_make_section (abfd, ".interp");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-13 11:09:34 +00:00
|
|
|
|
if (! info->traditional_format
|
|
|
|
|
&& info->hash->creator->flavour == bfd_target_elf_flavour)
|
|
|
|
|
{
|
|
|
|
|
s = bfd_make_section (abfd, ".eh_frame_hdr");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
|
|
|
|
|| ! bfd_set_section_alignment (abfd, s, 2))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-11-12 07:35:26 +00:00
|
|
|
|
elf_hash_table (info)->eh_info.hdr_sec = s;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Create sections to hold version informations. These are removed
|
|
|
|
|
if they are not needed. */
|
|
|
|
|
s = bfd_make_section (abfd, ".gnu.version_d");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
|
|
|
|
|| ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
s = bfd_make_section (abfd, ".gnu.version");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
|
|
|
|
|| ! bfd_set_section_alignment (abfd, s, 1))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
s = bfd_make_section (abfd, ".gnu.version_r");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
|
|
|
|
|| ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
s = bfd_make_section (abfd, ".dynsym");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
|
|
|
|
|| ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
s = bfd_make_section (abfd, ".dynstr");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Create a strtab to hold the dynamic symbol names. */
|
|
|
|
|
if (elf_hash_table (info)->dynstr == 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 16:50:38 +00:00
|
|
|
|
elf_hash_table (info)->dynstr = _bfd_elf_strtab_init ();
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (elf_hash_table (info)->dynstr == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s = bfd_make_section (abfd, ".dynamic");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags)
|
|
|
|
|
|| ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* The special symbol _DYNAMIC is always set to the start of the
|
|
|
|
|
.dynamic section. This call occurs before we have processed the
|
|
|
|
|
symbols for any dynamic object, so we don't have to worry about
|
|
|
|
|
overriding a dynamic definition. We could set _DYNAMIC in a
|
|
|
|
|
linker script, but we only want to define it if we are, in fact,
|
|
|
|
|
creating a .dynamic section. We don't want to define it if there
|
|
|
|
|
is no .dynamic section, since on some ELF platforms the start up
|
|
|
|
|
code examines it to decide how to initialize the process. */
|
2002-10-11 08:33:11 +00:00
|
|
|
|
bh = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, abfd, "_DYNAMIC", BSF_GLOBAL, s, (bfd_vma) 0,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(const char *) 0, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
|
|
|
|
|
return FALSE;
|
2002-10-11 08:33:11 +00:00
|
|
|
|
h = (struct elf_link_hash_entry *) bh;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
|
|
|
|
h->type = STT_OBJECT;
|
|
|
|
|
|
|
|
|
|
if (info->shared
|
|
|
|
|
&& ! _bfd_elf_link_record_dynamic_symbol (info, h))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
1999-07-07 17:50:56 +00:00
|
|
|
|
bed = get_elf_backend_data (abfd);
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
s = bfd_make_section (abfd, ".hash");
|
|
|
|
|
if (s == NULL
|
|
|
|
|
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
|
|
|
|
|| ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
elf_section_data (s)->this_hdr.sh_entsize = bed->s->sizeof_hash_entry;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Let the backend create the rest of the sections. This lets the
|
|
|
|
|
backend set the right flags. The backend will normally create
|
|
|
|
|
the .got and .plt sections. */
|
|
|
|
|
if (! (*bed->elf_backend_create_dynamic_sections) (abfd, info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
elf_hash_table (info)->dynamic_sections_created = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add an entry to the .dynamic table. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_add_dynamic_entry (info, tag, val)
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
bfd_vma tag;
|
|
|
|
|
bfd_vma val;
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Dyn dyn;
|
|
|
|
|
bfd *dynobj;
|
|
|
|
|
asection *s;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type newsize;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_byte *newcontents;
|
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
if (! is_elf_hash_table (info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
dynobj = elf_hash_table (info)->dynobj;
|
|
|
|
|
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".dynamic");
|
|
|
|
|
BFD_ASSERT (s != NULL);
|
|
|
|
|
|
|
|
|
|
newsize = s->_raw_size + sizeof (Elf_External_Dyn);
|
|
|
|
|
newcontents = (bfd_byte *) bfd_realloc (s->contents, newsize);
|
|
|
|
|
if (newcontents == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
dyn.d_tag = tag;
|
|
|
|
|
dyn.d_un.d_val = val;
|
|
|
|
|
elf_swap_dyn_out (dynobj, &dyn,
|
|
|
|
|
(Elf_External_Dyn *) (newcontents + s->_raw_size));
|
|
|
|
|
|
|
|
|
|
s->_raw_size = newsize;
|
|
|
|
|
s->contents = newcontents;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-13 01:13:26 +00:00
|
|
|
|
/* Read and swap the relocs from the section indicated by SHDR. This
|
|
|
|
|
may be either a REL or a RELA section. The relocations are
|
|
|
|
|
translated into RELA relocations and stored in INTERNAL_RELOCS,
|
|
|
|
|
which should have already been allocated to contain enough space.
|
|
|
|
|
The EXTERNAL_RELOCS are a buffer where the external form of the
|
|
|
|
|
relocations should be stored.
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
Returns FALSE if something goes wrong. */
|
1999-06-13 01:13:26 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-06-13 01:13:26 +00:00
|
|
|
|
elf_link_read_relocs_from_section (abfd, shdr, external_relocs,
|
|
|
|
|
internal_relocs)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
Elf_Internal_Shdr *shdr;
|
|
|
|
|
PTR external_relocs;
|
|
|
|
|
Elf_Internal_Rela *internal_relocs;
|
|
|
|
|
{
|
1999-07-07 17:50:56 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
void (*swap_in) PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
|
|
|
|
|
const bfd_byte *erela;
|
|
|
|
|
const bfd_byte *erelaend;
|
|
|
|
|
Elf_Internal_Rela *irela;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
|
1999-06-13 01:13:26 +00:00
|
|
|
|
/* If there aren't any relocations, that's OK. */
|
|
|
|
|
if (!shdr)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
|
|
|
|
|
/* Position ourselves at the start of the section. */
|
|
|
|
|
if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
|
|
|
|
|
/* Read the relocations. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (bfd_bread (external_relocs, shdr->sh_size, abfd) != shdr->sh_size)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
|
1999-07-07 17:50:56 +00:00
|
|
|
|
bed = get_elf_backend_data (abfd);
|
|
|
|
|
|
1999-06-13 01:13:26 +00:00
|
|
|
|
/* Convert the external relocations to the internal format. */
|
|
|
|
|
if (shdr->sh_entsize == sizeof (Elf_External_Rel))
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
swap_in = bed->s->swap_reloc_in;
|
|
|
|
|
else if (shdr->sh_entsize == sizeof (Elf_External_Rela))
|
|
|
|
|
swap_in = bed->s->swap_reloca_in;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
else
|
2003-02-25 04:39:32 +00:00
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_wrong_format);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-06-13 01:13:26 +00:00
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
erela = external_relocs;
|
|
|
|
|
erelaend = erela + NUM_SHDR_ENTRIES (shdr) * shdr->sh_entsize;
|
|
|
|
|
irela = internal_relocs;
|
|
|
|
|
while (erela < erelaend)
|
|
|
|
|
{
|
|
|
|
|
(*swap_in) (abfd, erela, irela);
|
|
|
|
|
irela += bed->s->int_rels_per_ext_rel;
|
|
|
|
|
erela += shdr->sh_entsize;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-01 23:20:08 +00:00
|
|
|
|
/* Read and swap the relocs for a section O. They may have been
|
|
|
|
|
cached. If the EXTERNAL_RELOCS and INTERNAL_RELOCS arguments are
|
|
|
|
|
not NULL, they are used as buffers to read into. They are known to
|
|
|
|
|
be large enough. If the INTERNAL_RELOCS relocs argument is NULL,
|
|
|
|
|
the return value is allocated using either malloc or bfd_alloc,
|
|
|
|
|
according to the KEEP_MEMORY argument. If O has two relocation
|
|
|
|
|
sections (both REL and RELA relocations), then the REL_HDR
|
|
|
|
|
relocations will appear first in INTERNAL_RELOCS, followed by the
|
|
|
|
|
REL_HDR2 relocations. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
Elf_Internal_Rela *
|
|
|
|
|
NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs,
|
|
|
|
|
keep_memory)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
asection *o;
|
|
|
|
|
PTR external_relocs;
|
|
|
|
|
Elf_Internal_Rela *internal_relocs;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean keep_memory;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Shdr *rel_hdr;
|
|
|
|
|
PTR alloc1 = NULL;
|
|
|
|
|
Elf_Internal_Rela *alloc2 = NULL;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (elf_section_data (o)->relocs != NULL)
|
|
|
|
|
return elf_section_data (o)->relocs;
|
|
|
|
|
|
|
|
|
|
if (o->reloc_count == 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
rel_hdr = &elf_section_data (o)->rel_hdr;
|
|
|
|
|
|
|
|
|
|
if (internal_relocs == NULL)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type size;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
size = o->reloc_count;
|
|
|
|
|
size *= bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (keep_memory)
|
|
|
|
|
internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size);
|
|
|
|
|
else
|
|
|
|
|
internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_malloc (size);
|
|
|
|
|
if (internal_relocs == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (external_relocs == NULL)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type size = rel_hdr->sh_size;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
|
|
|
|
|
if (elf_section_data (o)->rel_hdr2)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
size += elf_section_data (o)->rel_hdr2->sh_size;
|
1999-06-13 01:13:26 +00:00
|
|
|
|
alloc1 = (PTR) bfd_malloc (size);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (alloc1 == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
external_relocs = alloc1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-13 01:13:26 +00:00
|
|
|
|
if (!elf_link_read_relocs_from_section (abfd, rel_hdr,
|
|
|
|
|
external_relocs,
|
|
|
|
|
internal_relocs))
|
|
|
|
|
goto error_return;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
if (!elf_link_read_relocs_from_section
|
|
|
|
|
(abfd,
|
1999-06-13 01:13:26 +00:00
|
|
|
|
elf_section_data (o)->rel_hdr2,
|
1999-06-22 13:57:15 +00:00
|
|
|
|
((bfd_byte *) external_relocs) + rel_hdr->sh_size,
|
2001-05-23 08:23:27 +00:00
|
|
|
|
internal_relocs + (NUM_SHDR_ENTRIES (rel_hdr)
|
1999-07-07 17:50:56 +00:00
|
|
|
|
* bed->s->int_rels_per_ext_rel)))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* Cache the results for next time, if we can. */
|
|
|
|
|
if (keep_memory)
|
|
|
|
|
elf_section_data (o)->relocs = internal_relocs;
|
|
|
|
|
|
|
|
|
|
if (alloc1 != NULL)
|
|
|
|
|
free (alloc1);
|
|
|
|
|
|
|
|
|
|
/* Don't free alloc2, since if it was allocated we are passing it
|
|
|
|
|
back (under the name of internal_relocs). */
|
|
|
|
|
|
|
|
|
|
return internal_relocs;
|
|
|
|
|
|
|
|
|
|
error_return:
|
|
|
|
|
if (alloc1 != NULL)
|
|
|
|
|
free (alloc1);
|
|
|
|
|
if (alloc2 != NULL)
|
|
|
|
|
free (alloc2);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Record an assignment to a symbol made by a linker script. We need
|
|
|
|
|
this in case some dynamic object refers to this symbol. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
NAME(bfd_elf,record_link_assignment) (output_bfd, info, name, provide)
|
1999-07-11 19:49:48 +00:00
|
|
|
|
bfd *output_bfd ATTRIBUTE_UNUSED;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
const char *name;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean provide;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
if (info->hash->creator->flavour != bfd_target_elf_flavour)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
h = elf_link_hash_lookup (elf_hash_table (info), name, TRUE, TRUE, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (h->root.type == bfd_link_hash_new)
|
2001-08-09 14:38:04 +00:00
|
|
|
|
h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If this symbol is being provided by the linker script, and it is
|
|
|
|
|
currently defined by a dynamic object, but not by a regular
|
|
|
|
|
object, then mark it as undefined so that the generic linker will
|
|
|
|
|
force the correct value. */
|
|
|
|
|
if (provide
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
|
|
|
|
h->root.type = bfd_link_hash_undefined;
|
|
|
|
|
|
|
|
|
|
/* If this symbol is not being provided by the linker script, and it is
|
|
|
|
|
currently defined by a dynamic object, but not by a regular object,
|
|
|
|
|
then clear out any version information because the symbol will not be
|
|
|
|
|
associated with the dynamic object any more. */
|
|
|
|
|
if (!provide
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
|
|
|
|
h->verinfo.verdef = NULL;
|
|
|
|
|
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
1999-08-31 14:07:27 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (((h->elf_link_hash_flags & (ELF_LINK_HASH_DEF_DYNAMIC
|
|
|
|
|
| ELF_LINK_HASH_REF_DYNAMIC)) != 0
|
|
|
|
|
|| info->shared)
|
|
|
|
|
&& h->dynindx == -1)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, h))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If this is a weak defined symbol, and we know a corresponding
|
|
|
|
|
real symbol from the same dynamic object, make sure the real
|
|
|
|
|
symbol is also made into a dynamic symbol. */
|
|
|
|
|
if (h->weakdef != NULL
|
|
|
|
|
&& h->weakdef->dynindx == -1)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, h->weakdef))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This structure is used to pass information to
|
|
|
|
|
elf_link_assign_sym_version. */
|
|
|
|
|
|
|
|
|
|
struct elf_assign_sym_version_info
|
|
|
|
|
{
|
|
|
|
|
/* Output BFD. */
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
/* General link information. */
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
/* Version tree. */
|
|
|
|
|
struct bfd_elf_version_tree *verdefs;
|
|
|
|
|
/* Whether we had a failure. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean failed;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* This structure is used to pass information to
|
|
|
|
|
elf_link_find_version_dependencies. */
|
|
|
|
|
|
|
|
|
|
struct elf_find_verdep_info
|
|
|
|
|
{
|
|
|
|
|
/* Output BFD. */
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
/* General link information. */
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
/* The number of dependencies. */
|
|
|
|
|
unsigned int vers;
|
|
|
|
|
/* Whether we had a failure. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean failed;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Array used to determine the number of hash table buckets to use
|
|
|
|
|
based on the number of symbols there are. If there are fewer than
|
|
|
|
|
3 symbols we use 1 bucket, fewer than 17 symbols we use 3 buckets,
|
|
|
|
|
fewer than 37 we use 17 buckets, and so forth. We never use more
|
|
|
|
|
than 32771 buckets. */
|
|
|
|
|
|
|
|
|
|
static const size_t elf_buckets[] =
|
|
|
|
|
{
|
|
|
|
|
1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 1031, 2053, 4099, 8209,
|
|
|
|
|
16411, 32771, 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Compute bucket count for hashing table. We do not use a static set
|
|
|
|
|
of possible tables sizes anymore. Instead we determine for all
|
|
|
|
|
possible reasonable sizes of the table the outcome (i.e., the
|
|
|
|
|
number of collisions etc) and choose the best solution. The
|
|
|
|
|
weighting functions are not too simple to allow the table to grow
|
|
|
|
|
without bounds. Instead one of the weighting factors is the size.
|
|
|
|
|
Therefore the result is always a good payoff between few collisions
|
|
|
|
|
(= short chain lengths) and table size. */
|
|
|
|
|
static size_t
|
|
|
|
|
compute_bucket_count (info)
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
size_t dynsymcount = elf_hash_table (info)->dynsymcount;
|
1999-07-11 19:49:48 +00:00
|
|
|
|
size_t best_size = 0;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
unsigned long int *hashcodes;
|
|
|
|
|
unsigned long int *hashcodesp;
|
|
|
|
|
unsigned long int i;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type amt;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Compute the hash values for all exported symbols. At the same
|
|
|
|
|
time store the values in an array so that we could use them for
|
|
|
|
|
optimizations. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = dynsymcount;
|
|
|
|
|
amt *= sizeof (unsigned long int);
|
|
|
|
|
hashcodes = (unsigned long int *) bfd_malloc (amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (hashcodes == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
hashcodesp = hashcodes;
|
|
|
|
|
|
|
|
|
|
/* Put all hash values in HASHCODES. */
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_collect_hash_codes, &hashcodesp);
|
|
|
|
|
|
2002-07-16 12:31:35 +00:00
|
|
|
|
/* We have a problem here. The following code to optimize the table
|
|
|
|
|
size requires an integer type with more the 32 bits. If
|
|
|
|
|
BFD_HOST_U_64_BIT is set we know about such a type. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#ifdef BFD_HOST_U_64_BIT
|
2002-06-25 06:21:54 +00:00
|
|
|
|
if (info->optimize)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned long int nsyms = hashcodesp - hashcodes;
|
|
|
|
|
size_t minsize;
|
|
|
|
|
size_t maxsize;
|
|
|
|
|
BFD_HOST_U_64_BIT best_chlen = ~((BFD_HOST_U_64_BIT) 0);
|
|
|
|
|
unsigned long int *counts ;
|
|
|
|
|
|
|
|
|
|
/* Possible optimization parameters: if we have NSYMS symbols we say
|
|
|
|
|
that the hashing table must at least have NSYMS/4 and at most
|
|
|
|
|
2*NSYMS buckets. */
|
|
|
|
|
minsize = nsyms / 4;
|
|
|
|
|
if (minsize == 0)
|
|
|
|
|
minsize = 1;
|
|
|
|
|
best_size = maxsize = nsyms * 2;
|
|
|
|
|
|
|
|
|
|
/* Create array where we count the collisions in. We must use bfd_malloc
|
|
|
|
|
since the size could be large. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = maxsize;
|
|
|
|
|
amt *= sizeof (unsigned long int);
|
|
|
|
|
counts = (unsigned long int *) bfd_malloc (amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (counts == NULL)
|
|
|
|
|
{
|
|
|
|
|
free (hashcodes);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute the "optimal" size for the hash table. The criteria is a
|
|
|
|
|
minimal chain length. The minor criteria is (of course) the size
|
|
|
|
|
of the table. */
|
|
|
|
|
for (i = minsize; i < maxsize; ++i)
|
|
|
|
|
{
|
|
|
|
|
/* Walk through the array of hashcodes and count the collisions. */
|
|
|
|
|
BFD_HOST_U_64_BIT max;
|
|
|
|
|
unsigned long int j;
|
|
|
|
|
unsigned long int fact;
|
|
|
|
|
|
|
|
|
|
memset (counts, '\0', i * sizeof (unsigned long int));
|
|
|
|
|
|
|
|
|
|
/* Determine how often each hash bucket is used. */
|
|
|
|
|
for (j = 0; j < nsyms; ++j)
|
|
|
|
|
++counts[hashcodes[j] % i];
|
|
|
|
|
|
|
|
|
|
/* For the weight function we need some information about the
|
|
|
|
|
pagesize on the target. This is information need not be 100%
|
|
|
|
|
accurate. Since this information is not available (so far) we
|
|
|
|
|
define it here to a reasonable default value. If it is crucial
|
|
|
|
|
to have a better value some day simply define this value. */
|
|
|
|
|
# ifndef BFD_TARGET_PAGESIZE
|
|
|
|
|
# define BFD_TARGET_PAGESIZE (4096)
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
/* We in any case need 2 + NSYMS entries for the size values and
|
|
|
|
|
the chains. */
|
|
|
|
|
max = (2 + nsyms) * (ARCH_SIZE / 8);
|
|
|
|
|
|
|
|
|
|
# if 1
|
|
|
|
|
/* Variant 1: optimize for short chains. We add the squares
|
|
|
|
|
of all the chain lengths (which favous many small chain
|
|
|
|
|
over a few long chains). */
|
|
|
|
|
for (j = 0; j < i; ++j)
|
|
|
|
|
max += counts[j] * counts[j];
|
|
|
|
|
|
|
|
|
|
/* This adds penalties for the overall size of the table. */
|
|
|
|
|
fact = i / (BFD_TARGET_PAGESIZE / (ARCH_SIZE / 8)) + 1;
|
|
|
|
|
max *= fact * fact;
|
|
|
|
|
# else
|
|
|
|
|
/* Variant 2: Optimize a lot more for small table. Here we
|
|
|
|
|
also add squares of the size but we also add penalties for
|
|
|
|
|
empty slots (the +1 term). */
|
|
|
|
|
for (j = 0; j < i; ++j)
|
|
|
|
|
max += (1 + counts[j]) * (1 + counts[j]);
|
|
|
|
|
|
|
|
|
|
/* The overall size of the table is considered, but not as
|
|
|
|
|
strong as in variant 1, where it is squared. */
|
|
|
|
|
fact = i / (BFD_TARGET_PAGESIZE / (ARCH_SIZE / 8)) + 1;
|
|
|
|
|
max *= fact;
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
/* Compare with current best results. */
|
|
|
|
|
if (max < best_chlen)
|
|
|
|
|
{
|
|
|
|
|
best_chlen = max;
|
|
|
|
|
best_size = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (counts);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif /* defined (BFD_HOST_U_64_BIT) */
|
|
|
|
|
{
|
|
|
|
|
/* This is the fallback solution if no 64bit type is available or if we
|
|
|
|
|
are not supposed to spend much time on optimizations. We select the
|
|
|
|
|
bucket count using a fixed set of numbers. */
|
|
|
|
|
for (i = 0; elf_buckets[i] != 0; i++)
|
|
|
|
|
{
|
|
|
|
|
best_size = elf_buckets[i];
|
|
|
|
|
if (dynsymcount < elf_buckets[i + 1])
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free the arrays we needed. */
|
|
|
|
|
free (hashcodes);
|
|
|
|
|
|
|
|
|
|
return best_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set up the sizes and contents of the ELF dynamic sections. This is
|
|
|
|
|
called by the ELF linker emulation before_allocation routine. We
|
|
|
|
|
must set the sizes of the sections before the linker sets the
|
|
|
|
|
addresses of the various sections. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
|
2001-06-18 22:05:10 +00:00
|
|
|
|
filter_shlib,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
auxiliary_filters, info, sinterpptr,
|
|
|
|
|
verdefs)
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
const char *soname;
|
|
|
|
|
const char *rpath;
|
|
|
|
|
const char *filter_shlib;
|
|
|
|
|
const char * const *auxiliary_filters;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
asection **sinterpptr;
|
|
|
|
|
struct bfd_elf_version_tree *verdefs;
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type soname_indx;
|
2002-03-04 20:41:55 +00:00
|
|
|
|
bfd *dynobj;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
|
|
|
|
struct elf_assign_sym_version_info asvinfo;
|
|
|
|
|
|
|
|
|
|
*sinterpptr = NULL;
|
|
|
|
|
|
|
|
|
|
soname_indx = (bfd_size_type) -1;
|
|
|
|
|
|
|
|
|
|
if (info->hash->creator->flavour != bfd_target_elf_flavour)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
if (! is_elf_hash_table (info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
|
2001-09-29 06:21:59 +00:00
|
|
|
|
/* Any syms created from now on start with -1 in
|
|
|
|
|
got.refcount/offset and plt.refcount/offset. */
|
2003-02-04 12:49:57 +00:00
|
|
|
|
elf_hash_table (info)->init_refcount = elf_hash_table (info)->init_offset;
|
2001-09-29 06:21:59 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* The backend may have to create some sections regardless of whether
|
|
|
|
|
we're dynamic or not. */
|
|
|
|
|
bed = get_elf_backend_data (output_bfd);
|
|
|
|
|
if (bed->elf_backend_always_size_sections
|
|
|
|
|
&& ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
dynobj = elf_hash_table (info)->dynobj;
|
|
|
|
|
|
|
|
|
|
/* If there were no dynamic objects in the link, there is nothing to
|
|
|
|
|
do here. */
|
|
|
|
|
if (dynobj == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-12-15 08:54:13 +00:00
|
|
|
|
if (! _bfd_elf_maybe_strip_eh_frame_hdr (info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-12-15 08:54:13 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (elf_hash_table (info)->dynamic_sections_created)
|
|
|
|
|
{
|
|
|
|
|
struct elf_info_failed eif;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
2000-10-07 13:40:33 +00:00
|
|
|
|
asection *dynstr;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
struct bfd_elf_version_tree *t;
|
|
|
|
|
struct bfd_elf_version_expr *d;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean all_defined;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
*sinterpptr = bfd_get_section_by_name (dynobj, ".interp");
|
|
|
|
|
BFD_ASSERT (*sinterpptr != NULL || info->shared);
|
|
|
|
|
|
|
|
|
|
if (soname != 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 16:50:38 +00:00
|
|
|
|
soname_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
soname, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (soname_indx == (bfd_size_type) -1
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_SONAME,
|
|
|
|
|
soname_indx))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info->symbolic)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_SYMBOLIC,
|
|
|
|
|
(bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2000-07-20 03:21:59 +00:00
|
|
|
|
info->flags |= DF_SYMBOLIC;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rpath != NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type indx;
|
|
|
|
|
|
* 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 16:50:38 +00:00
|
|
|
|
indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, rpath,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
TRUE);
|
* 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 16:50:38 +00:00
|
|
|
|
if (info->new_dtags)
|
|
|
|
|
_bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, indx);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (indx == (bfd_size_type) -1
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_RPATH, indx)
|
2000-07-20 21:16:58 +00:00
|
|
|
|
|| (info->new_dtags
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
&& ! elf_add_dynamic_entry (info, (bfd_vma) DT_RUNPATH,
|
|
|
|
|
indx)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (filter_shlib != NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type indx;
|
|
|
|
|
|
* 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 16:50:38 +00:00
|
|
|
|
indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
filter_shlib, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (indx == (bfd_size_type) -1
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_FILTER, indx))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auxiliary_filters != NULL)
|
|
|
|
|
{
|
|
|
|
|
const char * const *p;
|
|
|
|
|
|
|
|
|
|
for (p = auxiliary_filters; *p != NULL; p++)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type indx;
|
|
|
|
|
|
* 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 16:50:38 +00:00
|
|
|
|
indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*p, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (indx == (bfd_size_type) -1
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_AUXILIARY,
|
|
|
|
|
indx))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-04 00:31:37 +00:00
|
|
|
|
eif.info = info;
|
2001-06-18 18:57:06 +00:00
|
|
|
|
eif.verdefs = verdefs;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eif.failed = FALSE;
|
2001-04-04 00:31:37 +00:00
|
|
|
|
|
1999-12-29 19:50:13 +00:00
|
|
|
|
/* If we are supposed to export all symbols into the dynamic symbol
|
2002-03-05 05:18:41 +00:00
|
|
|
|
table (this is not the normal case), then do so. */
|
2001-06-18 22:05:10 +00:00
|
|
|
|
if (info->export_dynamic)
|
1999-12-29 19:50:13 +00:00
|
|
|
|
{
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info), elf_export_symbol,
|
2002-03-05 05:18:41 +00:00
|
|
|
|
(PTR) &eif);
|
1999-12-29 19:50:13 +00:00
|
|
|
|
if (eif.failed)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-12-29 19:50:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-08 03:50:18 +00:00
|
|
|
|
/* Make all global versions with definiton. */
|
|
|
|
|
for (t = verdefs; t != NULL; t = t->next)
|
|
|
|
|
for (d = t->globals; d != NULL; d = d->next)
|
|
|
|
|
if (!d->symver && strchr (d->pattern, '*') == NULL)
|
|
|
|
|
{
|
|
|
|
|
const char *verstr, *name;
|
|
|
|
|
size_t namelen, verlen, newlen;
|
|
|
|
|
char *newname, *p;
|
|
|
|
|
struct elf_link_hash_entry *newh;
|
|
|
|
|
|
|
|
|
|
name = d->pattern;
|
|
|
|
|
namelen = strlen (name);
|
|
|
|
|
verstr = t->name;
|
|
|
|
|
verlen = strlen (verstr);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newlen = namelen + verlen + 3;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
|
|
|
|
|
newname = (char *) bfd_malloc ((bfd_size_type) newlen);
|
|
|
|
|
if (newname == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
memcpy (newname, name, namelen);
|
|
|
|
|
|
|
|
|
|
/* Check the hidden versioned definition. */
|
|
|
|
|
p = newname + namelen;
|
|
|
|
|
*p++ = ELF_VER_CHR;
|
|
|
|
|
memcpy (p, verstr, verlen + 1);
|
|
|
|
|
newh = elf_link_hash_lookup (elf_hash_table (info),
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newname, FALSE, FALSE,
|
|
|
|
|
FALSE);
|
2002-08-08 03:50:18 +00:00
|
|
|
|
if (newh == NULL
|
|
|
|
|
|| (newh->root.type != bfd_link_hash_defined
|
|
|
|
|
&& newh->root.type != bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
/* Check the default versioned definition. */
|
|
|
|
|
*p++ = ELF_VER_CHR;
|
|
|
|
|
memcpy (p, verstr, verlen + 1);
|
|
|
|
|
newh = elf_link_hash_lookup (elf_hash_table (info),
|
2002-11-30 08:39:46 +00:00
|
|
|
|
newname, FALSE, FALSE,
|
|
|
|
|
FALSE);
|
2002-08-08 03:50:18 +00:00
|
|
|
|
}
|
|
|
|
|
free (newname);
|
|
|
|
|
|
2002-08-14 03:25:48 +00:00
|
|
|
|
/* Mark this version if there is a definition and it is
|
|
|
|
|
not defined in a shared object. */
|
2002-08-08 03:50:18 +00:00
|
|
|
|
if (newh != NULL
|
2002-08-14 03:25:48 +00:00
|
|
|
|
&& ((newh->elf_link_hash_flags
|
|
|
|
|
& ELF_LINK_HASH_DEF_DYNAMIC) == 0)
|
2002-08-08 03:50:18 +00:00
|
|
|
|
&& (newh->root.type == bfd_link_hash_defined
|
|
|
|
|
|| newh->root.type == bfd_link_hash_defweak))
|
|
|
|
|
d->symver = 1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Attach all the symbols to their version information. */
|
|
|
|
|
asvinfo.output_bfd = output_bfd;
|
|
|
|
|
asvinfo.info = info;
|
|
|
|
|
asvinfo.verdefs = verdefs;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
asvinfo.failed = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_link_assign_sym_version,
|
|
|
|
|
(PTR) &asvinfo);
|
|
|
|
|
if (asvinfo.failed)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-08-08 03:50:18 +00:00
|
|
|
|
if (!info->allow_undefined_version)
|
|
|
|
|
{
|
|
|
|
|
/* Check if all global versions have a definiton. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
all_defined = TRUE;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
for (t = verdefs; t != NULL; t = t->next)
|
|
|
|
|
for (d = t->globals; d != NULL; d = d->next)
|
|
|
|
|
if (!d->symver && !d->script
|
|
|
|
|
&& strchr (d->pattern, '*') == NULL)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: undefined version: %s"),
|
|
|
|
|
d->pattern, t->name);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
all_defined = FALSE;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!all_defined)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Find all symbols which were defined in a dynamic object and make
|
|
|
|
|
the backend pick a reasonable value for them. */
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_adjust_dynamic_symbol,
|
|
|
|
|
(PTR) &eif);
|
|
|
|
|
if (eif.failed)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Add some entries to the .dynamic section. We fill in some of the
|
|
|
|
|
values later, in elf_bfd_final_link, but we must add the entries
|
|
|
|
|
now so that we know the final size of the .dynamic section. */
|
1999-06-23 11:06:57 +00:00
|
|
|
|
|
|
|
|
|
/* If there are initialization and/or finalization functions to
|
|
|
|
|
call then add the corresponding DT_INIT/DT_FINI entries. */
|
|
|
|
|
h = (info->init_function
|
2001-01-03 22:53:39 +00:00
|
|
|
|
? elf_link_hash_lookup (elf_hash_table (info),
|
2002-11-30 08:39:46 +00:00
|
|
|
|
info->init_function, FALSE,
|
|
|
|
|
FALSE, FALSE)
|
1999-06-23 11:06:57 +00:00
|
|
|
|
: NULL);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h != NULL
|
|
|
|
|
&& (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
|
|
|
|
|
| ELF_LINK_HASH_DEF_REGULAR)) != 0)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_INIT, (bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
1999-06-23 11:06:57 +00:00
|
|
|
|
h = (info->fini_function
|
2001-01-03 22:53:39 +00:00
|
|
|
|
? elf_link_hash_lookup (elf_hash_table (info),
|
2002-11-30 08:39:46 +00:00
|
|
|
|
info->fini_function, FALSE,
|
|
|
|
|
FALSE, FALSE)
|
1999-06-23 11:06:57 +00:00
|
|
|
|
: NULL);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h != NULL
|
|
|
|
|
&& (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
|
|
|
|
|
| ELF_LINK_HASH_DEF_REGULAR)) != 0)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FINI, (bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
1999-06-23 11:06:57 +00:00
|
|
|
|
|
2002-03-13 07:26:24 +00:00
|
|
|
|
if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* DT_PREINIT_ARRAY is not allowed in shared library. */
|
|
|
|
|
if (info->shared)
|
|
|
|
|
{
|
|
|
|
|
bfd *sub;
|
|
|
|
|
asection *o;
|
|
|
|
|
|
|
|
|
|
for (sub = info->input_bfds; sub != NULL;
|
|
|
|
|
sub = sub->link_next)
|
|
|
|
|
for (o = sub->sections; o != NULL; o = o->next)
|
|
|
|
|
if (elf_section_data (o)->this_hdr.sh_type
|
|
|
|
|
== SHT_PREINIT_ARRAY)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: .preinit_array section is not allowed in DSO"),
|
2002-07-16 12:31:35 +00:00
|
|
|
|
bfd_archive_filename (sub));
|
2002-03-13 07:26:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-03-13 04:04:49 +00:00
|
|
|
|
|
2002-03-14 19:06:16 +00:00
|
|
|
|
bfd_set_error (bfd_error_nonrepresentable_section);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-03-13 07:26:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAY,
|
|
|
|
|
(bfd_vma) 0)
|
|
|
|
|
|| !elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAYSZ,
|
|
|
|
|
(bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-03-13 07:26:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (bfd_get_section_by_name (output_bfd, ".init_array") != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!elf_add_dynamic_entry (info, (bfd_vma) DT_INIT_ARRAY,
|
|
|
|
|
(bfd_vma) 0)
|
|
|
|
|
|| !elf_add_dynamic_entry (info, (bfd_vma) DT_INIT_ARRAYSZ,
|
|
|
|
|
(bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-03-13 07:26:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (bfd_get_section_by_name (output_bfd, ".fini_array") != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!elf_add_dynamic_entry (info, (bfd_vma) DT_FINI_ARRAY,
|
|
|
|
|
(bfd_vma) 0)
|
|
|
|
|
|| !elf_add_dynamic_entry (info, (bfd_vma) DT_FINI_ARRAYSZ,
|
|
|
|
|
(bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-03-13 07:26:24 +00:00
|
|
|
|
}
|
2002-03-02 01:24:50 +00:00
|
|
|
|
|
2000-10-07 13:40:33 +00:00
|
|
|
|
dynstr = bfd_get_section_by_name (dynobj, ".dynstr");
|
|
|
|
|
/* If .dynstr is excluded from the link, we don't want any of
|
|
|
|
|
these tags. Strictly, we should be checking each section
|
|
|
|
|
individually; This quick check covers for the case where
|
|
|
|
|
someone does a /DISCARD/ : { *(*) }. */
|
|
|
|
|
if (dynstr != NULL && dynstr->output_section != bfd_abs_section_ptr)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type strsize;
|
|
|
|
|
|
* 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 16:50:38 +00:00
|
|
|
|
strsize = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_HASH, (bfd_vma) 0)
|
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_STRTAB, (bfd_vma) 0)
|
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_SYMTAB, (bfd_vma) 0)
|
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_STRSZ, strsize)
|
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_SYMENT,
|
|
|
|
|
(bfd_vma) sizeof (Elf_External_Sym)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2000-10-07 13:40:33 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The backend must work out the sizes of all the other dynamic
|
|
|
|
|
sections. */
|
|
|
|
|
if (bed->elf_backend_size_dynamic_sections
|
|
|
|
|
&& ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (elf_hash_table (info)->dynamic_sections_created)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type dynsymcount;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
asection *s;
|
|
|
|
|
size_t bucketcount = 0;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
size_t hash_entry_size;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
unsigned int dtagcount;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Set up the version definition section. */
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
|
|
|
|
|
BFD_ASSERT (s != NULL);
|
|
|
|
|
|
|
|
|
|
/* We may have created additional version definitions if we are
|
2002-03-05 05:18:41 +00:00
|
|
|
|
just linking a regular application. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
verdefs = asvinfo.verdefs;
|
|
|
|
|
|
2001-12-18 12:15:35 +00:00
|
|
|
|
/* Skip anonymous version tag. */
|
|
|
|
|
if (verdefs != NULL && verdefs->vernum == 0)
|
|
|
|
|
verdefs = verdefs->next;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (verdefs == NULL)
|
2000-02-13 22:45:29 +00:00
|
|
|
|
_bfd_strip_section_from_output (info, s);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unsigned int cdefs;
|
|
|
|
|
bfd_size_type size;
|
|
|
|
|
struct bfd_elf_version_tree *t;
|
|
|
|
|
bfd_byte *p;
|
|
|
|
|
Elf_Internal_Verdef def;
|
|
|
|
|
Elf_Internal_Verdaux defaux;
|
|
|
|
|
|
|
|
|
|
cdefs = 0;
|
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
|
|
/* Make space for the base version. */
|
|
|
|
|
size += sizeof (Elf_External_Verdef);
|
|
|
|
|
size += sizeof (Elf_External_Verdaux);
|
|
|
|
|
++cdefs;
|
|
|
|
|
|
|
|
|
|
for (t = verdefs; t != NULL; t = t->next)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_elf_version_deps *n;
|
|
|
|
|
|
|
|
|
|
size += sizeof (Elf_External_Verdef);
|
|
|
|
|
size += sizeof (Elf_External_Verdaux);
|
|
|
|
|
++cdefs;
|
|
|
|
|
|
|
|
|
|
for (n = t->deps; n != NULL; n = n->next)
|
|
|
|
|
size += sizeof (Elf_External_Verdaux);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s->_raw_size = size;
|
|
|
|
|
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
|
|
|
|
|
if (s->contents == NULL && s->_raw_size != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Fill in the version definition section. */
|
|
|
|
|
|
|
|
|
|
p = s->contents;
|
|
|
|
|
|
|
|
|
|
def.vd_version = VER_DEF_CURRENT;
|
|
|
|
|
def.vd_flags = VER_FLG_BASE;
|
|
|
|
|
def.vd_ndx = 1;
|
|
|
|
|
def.vd_cnt = 1;
|
|
|
|
|
def.vd_aux = sizeof (Elf_External_Verdef);
|
|
|
|
|
def.vd_next = (sizeof (Elf_External_Verdef)
|
|
|
|
|
+ sizeof (Elf_External_Verdaux));
|
|
|
|
|
|
|
|
|
|
if (soname_indx != (bfd_size_type) -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 16:50:38 +00:00
|
|
|
|
_bfd_elf_strtab_addref (elf_hash_table (info)->dynstr,
|
|
|
|
|
soname_indx);
|
1999-07-11 17:13:36 +00:00
|
|
|
|
def.vd_hash = bfd_elf_hash (soname);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
defaux.vda_name = soname_indx;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
bfd_size_type indx;
|
|
|
|
|
|
2001-05-18 01:20:02 +00:00
|
|
|
|
name = basename (output_bfd->filename);
|
1999-07-11 17:13:36 +00:00
|
|
|
|
def.vd_hash = bfd_elf_hash (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 16:50:38 +00:00
|
|
|
|
indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
name, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (indx == (bfd_size_type) -1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
defaux.vda_name = indx;
|
|
|
|
|
}
|
|
|
|
|
defaux.vda_next = 0;
|
|
|
|
|
|
|
|
|
|
_bfd_elf_swap_verdef_out (output_bfd, &def,
|
2001-08-09 14:38:04 +00:00
|
|
|
|
(Elf_External_Verdef *) p);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
p += sizeof (Elf_External_Verdef);
|
|
|
|
|
_bfd_elf_swap_verdaux_out (output_bfd, &defaux,
|
|
|
|
|
(Elf_External_Verdaux *) p);
|
|
|
|
|
p += sizeof (Elf_External_Verdaux);
|
|
|
|
|
|
|
|
|
|
for (t = verdefs; t != NULL; t = t->next)
|
|
|
|
|
{
|
|
|
|
|
unsigned int cdeps;
|
|
|
|
|
struct bfd_elf_version_deps *n;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
2002-10-11 08:33:11 +00:00
|
|
|
|
struct bfd_link_hash_entry *bh;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
cdeps = 0;
|
|
|
|
|
for (n = t->deps; n != NULL; n = n->next)
|
|
|
|
|
++cdeps;
|
|
|
|
|
|
|
|
|
|
/* Add a symbol representing this version. */
|
2002-10-11 08:33:11 +00:00
|
|
|
|
bh = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (! (_bfd_generic_link_add_one_symbol
|
|
|
|
|
(info, dynobj, t->name, BSF_GLOBAL, bfd_abs_section_ptr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(bfd_vma) 0, (const char *) NULL, FALSE,
|
2002-10-11 08:33:11 +00:00
|
|
|
|
get_elf_backend_data (dynobj)->collect, &bh)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-10-11 08:33:11 +00:00
|
|
|
|
h = (struct elf_link_hash_entry *) bh;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
h->elf_link_hash_flags &= ~ ELF_LINK_NON_ELF;
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
|
|
|
|
h->type = STT_OBJECT;
|
|
|
|
|
h->verinfo.vertree = t;
|
|
|
|
|
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (info, h))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
def.vd_version = VER_DEF_CURRENT;
|
|
|
|
|
def.vd_flags = 0;
|
|
|
|
|
if (t->globals == NULL && t->locals == NULL && ! t->used)
|
|
|
|
|
def.vd_flags |= VER_FLG_WEAK;
|
|
|
|
|
def.vd_ndx = t->vernum + 1;
|
|
|
|
|
def.vd_cnt = cdeps + 1;
|
1999-07-11 17:13:36 +00:00
|
|
|
|
def.vd_hash = bfd_elf_hash (t->name);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
def.vd_aux = sizeof (Elf_External_Verdef);
|
|
|
|
|
if (t->next != NULL)
|
|
|
|
|
def.vd_next = (sizeof (Elf_External_Verdef)
|
|
|
|
|
+ (cdeps + 1) * sizeof (Elf_External_Verdaux));
|
|
|
|
|
else
|
|
|
|
|
def.vd_next = 0;
|
|
|
|
|
|
|
|
|
|
_bfd_elf_swap_verdef_out (output_bfd, &def,
|
|
|
|
|
(Elf_External_Verdef *) p);
|
|
|
|
|
p += sizeof (Elf_External_Verdef);
|
|
|
|
|
|
|
|
|
|
defaux.vda_name = h->dynstr_index;
|
* 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 16:50:38 +00:00
|
|
|
|
_bfd_elf_strtab_addref (elf_hash_table (info)->dynstr,
|
|
|
|
|
h->dynstr_index);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (t->deps == NULL)
|
|
|
|
|
defaux.vda_next = 0;
|
|
|
|
|
else
|
|
|
|
|
defaux.vda_next = sizeof (Elf_External_Verdaux);
|
|
|
|
|
t->name_indx = defaux.vda_name;
|
|
|
|
|
|
|
|
|
|
_bfd_elf_swap_verdaux_out (output_bfd, &defaux,
|
|
|
|
|
(Elf_External_Verdaux *) p);
|
|
|
|
|
p += sizeof (Elf_External_Verdaux);
|
|
|
|
|
|
|
|
|
|
for (n = t->deps; n != NULL; n = n->next)
|
|
|
|
|
{
|
|
|
|
|
if (n->version_needed == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* This can happen if there was an error in the
|
|
|
|
|
version script. */
|
|
|
|
|
defaux.vda_name = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
* 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 16:50:38 +00:00
|
|
|
|
{
|
|
|
|
|
defaux.vda_name = n->version_needed->name_indx;
|
|
|
|
|
_bfd_elf_strtab_addref (elf_hash_table (info)->dynstr,
|
|
|
|
|
defaux.vda_name);
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (n->next == NULL)
|
|
|
|
|
defaux.vda_next = 0;
|
|
|
|
|
else
|
|
|
|
|
defaux.vda_next = sizeof (Elf_External_Verdaux);
|
|
|
|
|
|
|
|
|
|
_bfd_elf_swap_verdaux_out (output_bfd, &defaux,
|
|
|
|
|
(Elf_External_Verdaux *) p);
|
|
|
|
|
p += sizeof (Elf_External_Verdaux);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_VERDEF, (bfd_vma) 0)
|
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_VERDEFNUM,
|
|
|
|
|
(bfd_vma) cdefs))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
elf_tdata (output_bfd)->cverdefs = cdefs;
|
|
|
|
|
}
|
|
|
|
|
|
* 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 13:12:53 +00:00
|
|
|
|
if ((info->new_dtags && info->flags) || (info->flags & DF_STATIC_TLS))
|
2000-07-20 03:21:59 +00:00
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FLAGS, info->flags))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2000-07-20 03:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-21 03:58:32 +00:00
|
|
|
|
if (info->flags_1)
|
2000-07-20 03:21:59 +00:00
|
|
|
|
{
|
|
|
|
|
if (! info->shared)
|
|
|
|
|
info->flags_1 &= ~ (DF_1_INITFIRST
|
|
|
|
|
| DF_1_NODELETE
|
|
|
|
|
| DF_1_NOOPEN);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FLAGS_1,
|
|
|
|
|
info->flags_1))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2000-07-20 03:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Work out the size of the version reference section. */
|
|
|
|
|
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".gnu.version_r");
|
|
|
|
|
BFD_ASSERT (s != NULL);
|
|
|
|
|
{
|
|
|
|
|
struct elf_find_verdep_info sinfo;
|
|
|
|
|
|
|
|
|
|
sinfo.output_bfd = output_bfd;
|
|
|
|
|
sinfo.info = info;
|
|
|
|
|
sinfo.vers = elf_tdata (output_bfd)->cverdefs;
|
|
|
|
|
if (sinfo.vers == 0)
|
|
|
|
|
sinfo.vers = 1;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sinfo.failed = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_link_find_version_dependencies,
|
|
|
|
|
(PTR) &sinfo);
|
|
|
|
|
|
|
|
|
|
if (elf_tdata (output_bfd)->verref == NULL)
|
2000-02-13 22:45:29 +00:00
|
|
|
|
_bfd_strip_section_from_output (info, s);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Verneed *t;
|
|
|
|
|
unsigned int size;
|
|
|
|
|
unsigned int crefs;
|
|
|
|
|
bfd_byte *p;
|
|
|
|
|
|
|
|
|
|
/* Build the version definition section. */
|
|
|
|
|
size = 0;
|
|
|
|
|
crefs = 0;
|
|
|
|
|
for (t = elf_tdata (output_bfd)->verref;
|
|
|
|
|
t != NULL;
|
|
|
|
|
t = t->vn_nextref)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Vernaux *a;
|
|
|
|
|
|
|
|
|
|
size += sizeof (Elf_External_Verneed);
|
|
|
|
|
++crefs;
|
|
|
|
|
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
|
|
|
|
|
size += sizeof (Elf_External_Vernaux);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s->_raw_size = size;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (s->contents == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
p = s->contents;
|
|
|
|
|
for (t = elf_tdata (output_bfd)->verref;
|
|
|
|
|
t != NULL;
|
|
|
|
|
t = t->vn_nextref)
|
|
|
|
|
{
|
|
|
|
|
unsigned int caux;
|
|
|
|
|
Elf_Internal_Vernaux *a;
|
|
|
|
|
bfd_size_type indx;
|
|
|
|
|
|
|
|
|
|
caux = 0;
|
|
|
|
|
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
|
|
|
|
|
++caux;
|
|
|
|
|
|
|
|
|
|
t->vn_version = VER_NEED_CURRENT;
|
|
|
|
|
t->vn_cnt = caux;
|
* 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 16:50:38 +00:00
|
|
|
|
indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
|
|
|
|
|
elf_dt_name (t->vn_bfd) != NULL
|
|
|
|
|
? elf_dt_name (t->vn_bfd)
|
|
|
|
|
: basename (t->vn_bfd->filename),
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (indx == (bfd_size_type) -1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
t->vn_file = indx;
|
|
|
|
|
t->vn_aux = sizeof (Elf_External_Verneed);
|
|
|
|
|
if (t->vn_nextref == NULL)
|
|
|
|
|
t->vn_next = 0;
|
|
|
|
|
else
|
|
|
|
|
t->vn_next = (sizeof (Elf_External_Verneed)
|
|
|
|
|
+ caux * sizeof (Elf_External_Vernaux));
|
|
|
|
|
|
|
|
|
|
_bfd_elf_swap_verneed_out (output_bfd, t,
|
|
|
|
|
(Elf_External_Verneed *) p);
|
|
|
|
|
p += sizeof (Elf_External_Verneed);
|
|
|
|
|
|
|
|
|
|
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
|
|
|
|
|
{
|
1999-07-11 17:13:36 +00:00
|
|
|
|
a->vna_hash = bfd_elf_hash (a->vna_nodename);
|
* 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 16:50:38 +00:00
|
|
|
|
indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
a->vna_nodename, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (indx == (bfd_size_type) -1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
a->vna_name = indx;
|
|
|
|
|
if (a->vna_nextptr == NULL)
|
|
|
|
|
a->vna_next = 0;
|
|
|
|
|
else
|
|
|
|
|
a->vna_next = sizeof (Elf_External_Vernaux);
|
|
|
|
|
|
|
|
|
|
_bfd_elf_swap_vernaux_out (output_bfd, a,
|
|
|
|
|
(Elf_External_Vernaux *) p);
|
|
|
|
|
p += sizeof (Elf_External_Vernaux);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_VERNEED,
|
|
|
|
|
(bfd_vma) 0)
|
|
|
|
|
|| ! elf_add_dynamic_entry (info, (bfd_vma) DT_VERNEEDNUM,
|
|
|
|
|
(bfd_vma) crefs))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
elf_tdata (output_bfd)->cverrefs = crefs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-03 22:53:39 +00:00
|
|
|
|
/* Assign dynsym indicies. In a shared library we generate a
|
1999-07-13 18:21:29 +00:00
|
|
|
|
section symbol for each output section, which come first.
|
|
|
|
|
Next come all of the back-end allocated local dynamic syms,
|
|
|
|
|
followed by the rest of the global symbols. */
|
|
|
|
|
|
|
|
|
|
dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Work out the size of the symbol version section. */
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".gnu.version");
|
|
|
|
|
BFD_ASSERT (s != NULL);
|
|
|
|
|
if (dynsymcount == 0
|
|
|
|
|
|| (verdefs == NULL && elf_tdata (output_bfd)->verref == NULL))
|
|
|
|
|
{
|
2000-02-13 22:45:29 +00:00
|
|
|
|
_bfd_strip_section_from_output (info, s);
|
1999-06-13 14:49:51 +00:00
|
|
|
|
/* The DYNSYMCOUNT might have changed if we were going to
|
|
|
|
|
output a dynamic symbol table entry for S. */
|
1999-07-13 18:21:29 +00:00
|
|
|
|
dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
s->_raw_size = dynsymcount * sizeof (Elf_External_Versym);
|
|
|
|
|
s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
|
|
|
|
|
if (s->contents == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_VERSYM, (bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set the size of the .dynsym and .hash sections. We counted
|
|
|
|
|
the number of dynamic symbols in elf_link_add_object_symbols.
|
|
|
|
|
We will build the contents of .dynsym and .hash when we build
|
|
|
|
|
the final symbol table, because until then we do not know the
|
|
|
|
|
correct value to give the symbols. We built the .dynstr
|
|
|
|
|
section as we went along in elf_link_add_object_symbols. */
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".dynsym");
|
|
|
|
|
BFD_ASSERT (s != NULL);
|
|
|
|
|
s->_raw_size = dynsymcount * sizeof (Elf_External_Sym);
|
|
|
|
|
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
|
|
|
|
|
if (s->contents == NULL && s->_raw_size != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2000-10-07 13:40:33 +00:00
|
|
|
|
if (dynsymcount != 0)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Sym isym;
|
|
|
|
|
|
|
|
|
|
/* The first entry in .dynsym is a dummy symbol. */
|
|
|
|
|
isym.st_value = 0;
|
|
|
|
|
isym.st_size = 0;
|
|
|
|
|
isym.st_name = 0;
|
|
|
|
|
isym.st_info = 0;
|
|
|
|
|
isym.st_other = 0;
|
|
|
|
|
isym.st_shndx = 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 00:52:35 +00:00
|
|
|
|
elf_swap_symbol_out (output_bfd, &isym, (PTR) s->contents, (PTR) 0);
|
2000-10-07 13:40:33 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Compute the size of the hashing table. As a side effect this
|
|
|
|
|
computes the hash values for all the names we export. */
|
|
|
|
|
bucketcount = compute_bucket_count (info);
|
|
|
|
|
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".hash");
|
|
|
|
|
BFD_ASSERT (s != NULL);
|
1999-07-07 17:50:56 +00:00
|
|
|
|
hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize;
|
|
|
|
|
s->_raw_size = ((2 + bucketcount + dynsymcount) * hash_entry_size);
|
2002-06-07 14:57:11 +00:00
|
|
|
|
s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (s->contents == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_put (8 * hash_entry_size, output_bfd, (bfd_vma) bucketcount,
|
|
|
|
|
s->contents);
|
|
|
|
|
bfd_put (8 * hash_entry_size, output_bfd, (bfd_vma) dynsymcount,
|
1999-07-07 17:50:56 +00:00
|
|
|
|
s->contents + hash_entry_size);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
elf_hash_table (info)->bucketcount = bucketcount;
|
|
|
|
|
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".dynstr");
|
|
|
|
|
BFD_ASSERT (s != 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 16:50:38 +00:00
|
|
|
|
|
|
|
|
|
elf_finalize_dynstr (output_bfd, info);
|
|
|
|
|
|
|
|
|
|
s->_raw_size = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-23 15:14:18 +00:00
|
|
|
|
for (dtagcount = 0; dtagcount <= info->spare_dynamic_tags; ++dtagcount)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NULL, (bfd_vma) 0))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00: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 16:50:38 +00:00
|
|
|
|
/* This function is used to adjust offsets into .dynstr for
|
|
|
|
|
dynamic symbols. This is called via elf_link_hash_traverse. */
|
2002-03-05 05:18:41 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_adjust_dynstr_offsets
|
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-03-05 05:18:41 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
* 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 16:50:38 +00:00
|
|
|
|
elf_adjust_dynstr_offsets (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
struct elf_strtab_hash *dynstr = (struct elf_strtab_hash *) data;
|
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
* 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 16:50:38 +00:00
|
|
|
|
if (h->dynindx != -1)
|
|
|
|
|
h->dynstr_index = _bfd_elf_strtab_offset (dynstr, h->dynstr_index);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
* 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 16:50:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Assign string offsets in .dynstr, update all structures referencing
|
|
|
|
|
them. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
* 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 16:50:38 +00:00
|
|
|
|
elf_finalize_dynstr (output_bfd, info)
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_local_dynamic_entry *entry;
|
|
|
|
|
struct elf_strtab_hash *dynstr = elf_hash_table (info)->dynstr;
|
|
|
|
|
bfd *dynobj = elf_hash_table (info)->dynobj;
|
|
|
|
|
asection *sdyn;
|
|
|
|
|
bfd_size_type size;
|
|
|
|
|
Elf_External_Dyn *dyncon, *dynconend;
|
|
|
|
|
|
|
|
|
|
_bfd_elf_strtab_finalize (dynstr);
|
|
|
|
|
size = _bfd_elf_strtab_size (dynstr);
|
|
|
|
|
|
|
|
|
|
/* Update all .dynamic entries referencing .dynstr strings. */
|
|
|
|
|
sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
|
|
|
|
|
BFD_ASSERT (sdyn != NULL);
|
|
|
|
|
|
|
|
|
|
dyncon = (Elf_External_Dyn *) sdyn->contents;
|
|
|
|
|
dynconend = (Elf_External_Dyn *) (sdyn->contents +
|
|
|
|
|
sdyn->_raw_size);
|
|
|
|
|
for (; dyncon < dynconend; dyncon++)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Dyn dyn;
|
|
|
|
|
|
|
|
|
|
elf_swap_dyn_in (dynobj, dyncon, & dyn);
|
|
|
|
|
switch (dyn.d_tag)
|
|
|
|
|
{
|
|
|
|
|
case DT_STRSZ:
|
|
|
|
|
dyn.d_un.d_val = size;
|
|
|
|
|
elf_swap_dyn_out (dynobj, & dyn, dyncon);
|
|
|
|
|
break;
|
|
|
|
|
case DT_NEEDED:
|
|
|
|
|
case DT_SONAME:
|
|
|
|
|
case DT_RPATH:
|
|
|
|
|
case DT_RUNPATH:
|
|
|
|
|
case DT_FILTER:
|
|
|
|
|
case DT_AUXILIARY:
|
|
|
|
|
dyn.d_un.d_val = _bfd_elf_strtab_offset (dynstr, dyn.d_un.d_val);
|
|
|
|
|
elf_swap_dyn_out (dynobj, & dyn, dyncon);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now update local dynamic symbols. */
|
|
|
|
|
for (entry = elf_hash_table (info)->dynlocal; entry ; entry = entry->next)
|
|
|
|
|
entry->isym.st_name = _bfd_elf_strtab_offset (dynstr,
|
|
|
|
|
entry->isym.st_name);
|
|
|
|
|
|
|
|
|
|
/* And the rest of dynamic symbols. */
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_adjust_dynstr_offsets, dynstr);
|
|
|
|
|
|
|
|
|
|
/* Adjust version definitions. */
|
|
|
|
|
if (elf_tdata (output_bfd)->cverdefs)
|
|
|
|
|
{
|
|
|
|
|
asection *s;
|
|
|
|
|
bfd_byte *p;
|
|
|
|
|
bfd_size_type i;
|
|
|
|
|
Elf_Internal_Verdef def;
|
|
|
|
|
Elf_Internal_Verdaux defaux;
|
2002-03-05 05:18:41 +00: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 16:50:38 +00:00
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
|
|
|
|
|
p = (bfd_byte *) s->contents;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
_bfd_elf_swap_verdef_in (output_bfd, (Elf_External_Verdef *) p,
|
|
|
|
|
&def);
|
|
|
|
|
p += sizeof (Elf_External_Verdef);
|
|
|
|
|
for (i = 0; i < def.vd_cnt; ++i)
|
|
|
|
|
{
|
|
|
|
|
_bfd_elf_swap_verdaux_in (output_bfd,
|
|
|
|
|
(Elf_External_Verdaux *) p, &defaux);
|
|
|
|
|
defaux.vda_name = _bfd_elf_strtab_offset (dynstr,
|
|
|
|
|
defaux.vda_name);
|
|
|
|
|
_bfd_elf_swap_verdaux_out (output_bfd,
|
|
|
|
|
&defaux, (Elf_External_Verdaux *) p);
|
|
|
|
|
p += sizeof (Elf_External_Verdaux);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (def.vd_next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Adjust version references. */
|
|
|
|
|
if (elf_tdata (output_bfd)->verref)
|
|
|
|
|
{
|
|
|
|
|
asection *s;
|
|
|
|
|
bfd_byte *p;
|
|
|
|
|
bfd_size_type i;
|
|
|
|
|
Elf_Internal_Verneed need;
|
|
|
|
|
Elf_Internal_Vernaux needaux;
|
2002-03-05 05:18:41 +00: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 16:50:38 +00:00
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".gnu.version_r");
|
|
|
|
|
p = (bfd_byte *) s->contents;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
_bfd_elf_swap_verneed_in (output_bfd, (Elf_External_Verneed *) p,
|
|
|
|
|
&need);
|
|
|
|
|
need.vn_file = _bfd_elf_strtab_offset (dynstr, need.vn_file);
|
|
|
|
|
_bfd_elf_swap_verneed_out (output_bfd, &need,
|
|
|
|
|
(Elf_External_Verneed *) p);
|
|
|
|
|
p += sizeof (Elf_External_Verneed);
|
|
|
|
|
for (i = 0; i < need.vn_cnt; ++i)
|
|
|
|
|
{
|
|
|
|
|
_bfd_elf_swap_vernaux_in (output_bfd,
|
|
|
|
|
(Elf_External_Vernaux *) p, &needaux);
|
|
|
|
|
needaux.vna_name = _bfd_elf_strtab_offset (dynstr,
|
|
|
|
|
needaux.vna_name);
|
|
|
|
|
_bfd_elf_swap_vernaux_out (output_bfd,
|
|
|
|
|
&needaux,
|
|
|
|
|
(Elf_External_Vernaux *) p);
|
|
|
|
|
p += sizeof (Elf_External_Vernaux);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (need.vn_next);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
* 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 16:50:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Fix up the flags for a symbol. This handles various cases which
|
|
|
|
|
can only be fixed after all the input files are seen. This is
|
|
|
|
|
currently called by both adjust_dynamic_symbol and
|
|
|
|
|
assign_sym_version, which is unnecessary but perhaps more robust in
|
|
|
|
|
the face of future changes. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_fix_symbol_flags (h, eif)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
struct elf_info_failed *eif;
|
|
|
|
|
{
|
|
|
|
|
/* If this symbol was mentioned in a non-ELF file, try to set
|
|
|
|
|
DEF_REGULAR and REF_REGULAR correctly. This is the only way to
|
|
|
|
|
permit a non-ELF file to correctly refer to a symbol defined in
|
|
|
|
|
an ELF dynamic object. */
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_NON_ELF) != 0)
|
|
|
|
|
{
|
2000-06-05 17:21:32 +00:00
|
|
|
|
while (h->root.type == bfd_link_hash_indirect)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->root.type != bfd_link_hash_defined
|
|
|
|
|
&& h->root.type != bfd_link_hash_defweak)
|
|
|
|
|
h->elf_link_hash_flags |= (ELF_LINK_HASH_REF_REGULAR
|
|
|
|
|
| ELF_LINK_HASH_REF_REGULAR_NONWEAK);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (h->root.u.def.section->owner != NULL
|
|
|
|
|
&& (bfd_get_flavour (h->root.u.def.section->owner)
|
|
|
|
|
== bfd_target_elf_flavour))
|
|
|
|
|
h->elf_link_hash_flags |= (ELF_LINK_HASH_REF_REGULAR
|
|
|
|
|
| ELF_LINK_HASH_REF_REGULAR_NONWEAK);
|
|
|
|
|
else
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (h->dynindx == -1
|
|
|
|
|
&& ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|
|
|
|
|| (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0))
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h))
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eif->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Unfortunately, ELF_LINK_NON_ELF is only correct if the symbol
|
2002-03-05 05:18:41 +00:00
|
|
|
|
was first seen in a non-ELF file. Fortunately, if the symbol
|
|
|
|
|
was first seen in an ELF file, we're probably OK unless the
|
|
|
|
|
symbol was defined in a non-ELF file. Catch that case here.
|
|
|
|
|
FIXME: We're still in trouble if the symbol was first seen in
|
|
|
|
|
a dynamic object, and then later in a non-ELF regular object. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
|
|
|
|
|
&& (h->root.u.def.section->owner != NULL
|
|
|
|
|
? (bfd_get_flavour (h->root.u.def.section->owner)
|
|
|
|
|
!= bfd_target_elf_flavour)
|
|
|
|
|
: (bfd_is_abs_section (h->root.u.def.section)
|
|
|
|
|
&& (h->elf_link_hash_flags
|
|
|
|
|
& ELF_LINK_HASH_DEF_DYNAMIC) == 0)))
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is a final link, and the symbol was defined as a common
|
|
|
|
|
symbol in a regular object file, and there was no definition in
|
|
|
|
|
any dynamic object, then the linker will have allocated space for
|
|
|
|
|
the symbol in a common section but the ELF_LINK_HASH_DEF_REGULAR
|
|
|
|
|
flag will not have been set. */
|
|
|
|
|
if (h->root.type == bfd_link_hash_defined
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) != 0
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
|
|
|
|
|
&& (h->root.u.def.section->owner->flags & DYNAMIC) == 0)
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
|
|
|
|
|
|
|
|
|
/* If -Bsymbolic was used (which means to bind references to global
|
|
|
|
|
symbols to the definition within the shared object), and this
|
|
|
|
|
symbol was defined in a regular object, then it actually doesn't
|
2001-04-09 03:24:32 +00:00
|
|
|
|
need a PLT entry, and we can accomplish that by forcing it local.
|
|
|
|
|
Likewise, if the symbol has hidden or internal visibility.
|
|
|
|
|
FIXME: It might be that we also do not need a PLT for other
|
|
|
|
|
non-hidden visibilities, but we would have to tell that to the
|
|
|
|
|
backend specifically; we can't just clear PLT-related data here. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
|
|
|
|
|
&& eif->info->shared
|
2001-08-24 16:36:04 +00:00
|
|
|
|
&& is_elf_hash_table (eif->info)
|
2001-04-09 03:24:32 +00:00
|
|
|
|
&& (eif->info->symbolic
|
|
|
|
|
|| ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
|
|
|
|
|| ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
|
|
|
|
|
{
|
2001-04-04 00:31:37 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean force_local;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
|
2001-04-04 00:31:37 +00:00
|
|
|
|
bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
|
2002-01-21 10:29:09 +00:00
|
|
|
|
|
|
|
|
|
force_local = (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
|
|
|
|
|| ELF_ST_VISIBILITY (h->other) == STV_HIDDEN);
|
|
|
|
|
(*bed->elf_backend_hide_symbol) (eif->info, h, force_local);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-10 04:22:23 +00:00
|
|
|
|
/* If this is a weak defined symbol in a dynamic object, and we know
|
|
|
|
|
the real definition in the dynamic object, copy interesting flags
|
|
|
|
|
over to the real definition. */
|
|
|
|
|
if (h->weakdef != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *weakdef;
|
|
|
|
|
|
2002-09-19 16:34:14 +00:00
|
|
|
|
weakdef = h->weakdef;
|
|
|
|
|
if (h->root.type == bfd_link_hash_indirect)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-09-10 04:22:23 +00:00
|
|
|
|
BFD_ASSERT (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak);
|
|
|
|
|
BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
|
|
|
|
|
|| weakdef->root.type == bfd_link_hash_defweak);
|
|
|
|
|
BFD_ASSERT (weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC);
|
|
|
|
|
|
|
|
|
|
/* If the real definition is defined by a regular object file,
|
|
|
|
|
don't do anything special. See the longer description in
|
|
|
|
|
elf_adjust_dynamic_symbol, below. */
|
|
|
|
|
if ((weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
|
|
|
|
|
h->weakdef = NULL;
|
|
|
|
|
else
|
2001-10-03 08:33:18 +00:00
|
|
|
|
{
|
|
|
|
|
struct elf_backend_data *bed;
|
|
|
|
|
|
|
|
|
|
bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
|
2002-08-22 01:27:20 +00:00
|
|
|
|
(*bed->elf_backend_copy_indirect_symbol) (bed, weakdef, h);
|
2001-10-03 08:33:18 +00:00
|
|
|
|
}
|
1999-09-10 04:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make the backend pick a good value for a dynamic symbol. This is
|
|
|
|
|
called via elf_link_hash_traverse, and also calls itself
|
|
|
|
|
recursively. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_adjust_dynamic_symbol (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
struct elf_info_failed *eif = (struct elf_info_failed *) data;
|
|
|
|
|
bfd *dynobj;
|
|
|
|
|
struct elf_backend_data *bed;
|
|
|
|
|
|
2003-02-04 12:49:57 +00:00
|
|
|
|
if (! is_elf_hash_table (eif->info))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
{
|
2003-02-04 12:49:57 +00:00
|
|
|
|
h->plt = elf_hash_table (eif->info)->init_offset;
|
|
|
|
|
h->got = elf_hash_table (eif->info)->init_offset;
|
2002-03-28 03:27:46 +00:00
|
|
|
|
|
|
|
|
|
/* When warning symbols are created, they **replace** the "real"
|
|
|
|
|
entry in the hash table, thus we never get to see the real
|
|
|
|
|
symbol in a hash traversal. So look at it now. */
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Ignore indirect symbols. These are added by the versioning code. */
|
|
|
|
|
if (h->root.type == bfd_link_hash_indirect)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Fix the symbol flags. */
|
|
|
|
|
if (! elf_fix_symbol_flags (h, eif))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If this symbol does not require a PLT entry, and it is not
|
|
|
|
|
defined by a dynamic object, or is not referenced by a regular
|
|
|
|
|
object, ignore it. We do have to handle a weak defined symbol,
|
|
|
|
|
even if no regular object refers to it, if we decided to add it
|
|
|
|
|
to the dynamic symbol table. FIXME: Do we normally need to worry
|
|
|
|
|
about symbols which are defined by one dynamic object and
|
|
|
|
|
referenced by another one? */
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0
|
|
|
|
|
&& ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
|
|
|
|
|
|| (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
|
|
|
|
|
|| ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
|
|
|
|
|
&& (h->weakdef == NULL || h->weakdef->dynindx == -1))))
|
|
|
|
|
{
|
2003-02-04 12:49:57 +00:00
|
|
|
|
h->plt = elf_hash_table (eif->info)->init_offset;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we've already adjusted this symbol, don't do it again. This
|
|
|
|
|
can happen via a recursive call. */
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Don't look at this symbol again. Note that we must set this
|
|
|
|
|
after checking the above conditions, because we may look at a
|
|
|
|
|
symbol once, decide not to do anything, and then get called
|
|
|
|
|
recursively later after REF_REGULAR is set below. */
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_DYNAMIC_ADJUSTED;
|
|
|
|
|
|
|
|
|
|
/* If this is a weak definition, and we know a real definition, and
|
|
|
|
|
the real symbol is not itself defined by a regular object file,
|
|
|
|
|
then get a good value for the real definition. We handle the
|
|
|
|
|
real symbol first, for the convenience of the backend routine.
|
|
|
|
|
|
|
|
|
|
Note that there is a confusing case here. If the real definition
|
|
|
|
|
is defined by a regular object file, we don't get the real symbol
|
|
|
|
|
from the dynamic object, but we do get the weak symbol. If the
|
|
|
|
|
processor backend uses a COPY reloc, then if some routine in the
|
|
|
|
|
dynamic object changes the real symbol, we will not see that
|
|
|
|
|
change in the corresponding weak symbol. This is the way other
|
|
|
|
|
ELF linkers work as well, and seems to be a result of the shared
|
|
|
|
|
library model.
|
|
|
|
|
|
|
|
|
|
I will clarify this issue. Most SVR4 shared libraries define the
|
|
|
|
|
variable _timezone and define timezone as a weak synonym. The
|
|
|
|
|
tzset call changes _timezone. If you write
|
|
|
|
|
extern int timezone;
|
|
|
|
|
int _timezone = 5;
|
|
|
|
|
int main () { tzset (); printf ("%d %d\n", timezone, _timezone); }
|
|
|
|
|
you might expect that, since timezone is a synonym for _timezone,
|
|
|
|
|
the same number will print both times. However, if the processor
|
|
|
|
|
backend uses a COPY reloc, then actually timezone will be copied
|
|
|
|
|
into your process image, and, since you define _timezone
|
|
|
|
|
yourself, _timezone will not. Thus timezone and _timezone will
|
|
|
|
|
wind up at different memory locations. The tzset call will set
|
|
|
|
|
_timezone, leaving timezone unchanged. */
|
|
|
|
|
|
|
|
|
|
if (h->weakdef != NULL)
|
|
|
|
|
{
|
1999-09-10 04:22:23 +00:00
|
|
|
|
/* If we get to this point, we know there is an implicit
|
|
|
|
|
reference by a regular object file via the weak symbol H.
|
|
|
|
|
FIXME: Is this really true? What if the traversal finds
|
|
|
|
|
H->WEAKDEF before it finds H? */
|
|
|
|
|
h->weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
1999-09-10 04:22:23 +00:00
|
|
|
|
if (! elf_adjust_dynamic_symbol (h->weakdef, (PTR) eif))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If a symbol has no type and no size and does not require a PLT
|
|
|
|
|
entry, then we are probably about to do the wrong thing here: we
|
|
|
|
|
are probably going to create a COPY reloc for an empty object.
|
|
|
|
|
This case can arise when a shared object is built with assembly
|
|
|
|
|
code, and the assembly code fails to set the symbol type. */
|
|
|
|
|
if (h->size == 0
|
|
|
|
|
&& h->type == STT_NOTYPE
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0)
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("warning: type and size of dynamic symbol `%s' are not defined"),
|
2002-07-16 12:31:35 +00:00
|
|
|
|
h->root.root.string);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
dynobj = elf_hash_table (eif->info)->dynobj;
|
|
|
|
|
bed = get_elf_backend_data (dynobj);
|
|
|
|
|
if (! (*bed->elf_backend_adjust_dynamic_symbol) (eif->info, h))
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eif->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This routine is used to export all defined symbols into the dynamic
|
|
|
|
|
symbol table. It is called via elf_link_hash_traverse. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_export_symbol (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
struct elf_info_failed *eif = (struct elf_info_failed *) data;
|
|
|
|
|
|
|
|
|
|
/* Ignore indirect symbols. These are added by the versioning code. */
|
|
|
|
|
if (h->root.type == bfd_link_hash_indirect)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->dynindx == -1
|
|
|
|
|
&& (h->elf_link_hash_flags
|
|
|
|
|
& (ELF_LINK_HASH_DEF_REGULAR | ELF_LINK_HASH_REF_REGULAR)) != 0)
|
|
|
|
|
{
|
2001-06-18 18:57:06 +00:00
|
|
|
|
struct bfd_elf_version_tree *t;
|
|
|
|
|
struct bfd_elf_version_expr *d;
|
|
|
|
|
|
|
|
|
|
for (t = eif->verdefs; t != NULL; t = t->next)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-06-18 18:57:06 +00:00
|
|
|
|
if (t->globals != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (d = t->globals; d != NULL; d = d->next)
|
|
|
|
|
{
|
|
|
|
|
if ((*d->match) (d, h->root.root.string))
|
|
|
|
|
goto doit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t->locals != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (d = t->locals ; d != NULL; d = d->next)
|
|
|
|
|
{
|
|
|
|
|
if ((*d->match) (d, h->root.root.string))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-06-18 18:57:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
2001-06-18 18:57:06 +00:00
|
|
|
|
|
|
|
|
|
if (!eif->verdefs)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
{
|
2002-07-16 12:31:35 +00:00
|
|
|
|
doit:
|
2001-06-18 18:57:06 +00:00
|
|
|
|
if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h))
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eif->failed = TRUE;
|
|
|
|
|
return FALSE;
|
2001-06-18 18:57:06 +00:00
|
|
|
|
}
|
2002-03-05 05:18:41 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Look through the symbols which are defined in other shared
|
|
|
|
|
libraries and referenced here. Update the list of version
|
|
|
|
|
dependencies. This will be put into the .gnu.version_r section.
|
|
|
|
|
This function is called via elf_link_hash_traverse. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_find_version_dependencies (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
struct elf_find_verdep_info *rinfo = (struct elf_find_verdep_info *) data;
|
|
|
|
|
Elf_Internal_Verneed *t;
|
|
|
|
|
Elf_Internal_Vernaux *a;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type amt;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* We only care about symbols defined in shared objects with version
|
|
|
|
|
information. */
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
|
|
|
|
|
|| (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
|
|
|
|
|
|| h->dynindx == -1
|
|
|
|
|
|| h->verinfo.verdef == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* See if we already know about this version. */
|
|
|
|
|
for (t = elf_tdata (rinfo->output_bfd)->verref; t != NULL; t = t->vn_nextref)
|
|
|
|
|
{
|
|
|
|
|
if (t->vn_bfd != h->verinfo.verdef->vd_bfd)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
|
|
|
|
|
if (a->vna_nodename == h->verinfo.verdef->vd_nodename)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This is a new version. Add it to tree we are building. */
|
|
|
|
|
|
|
|
|
|
if (t == NULL)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = sizeof *t;
|
|
|
|
|
t = (Elf_Internal_Verneed *) bfd_zalloc (rinfo->output_bfd, amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (t == NULL)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
rinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t->vn_bfd = h->verinfo.verdef->vd_bfd;
|
|
|
|
|
t->vn_nextref = elf_tdata (rinfo->output_bfd)->verref;
|
|
|
|
|
elf_tdata (rinfo->output_bfd)->verref = t;
|
|
|
|
|
}
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = sizeof *a;
|
|
|
|
|
a = (Elf_Internal_Vernaux *) bfd_zalloc (rinfo->output_bfd, amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Note that we are copying a string pointer here, and testing it
|
|
|
|
|
above. If bfd_elf_string_from_elf_section is ever changed to
|
|
|
|
|
discard the string data when low in memory, this will have to be
|
|
|
|
|
fixed. */
|
|
|
|
|
a->vna_nodename = h->verinfo.verdef->vd_nodename;
|
|
|
|
|
|
|
|
|
|
a->vna_flags = h->verinfo.verdef->vd_flags;
|
|
|
|
|
a->vna_nextptr = t->vn_auxptr;
|
|
|
|
|
|
|
|
|
|
h->verinfo.verdef->vd_exp_refno = rinfo->vers;
|
|
|
|
|
++rinfo->vers;
|
|
|
|
|
|
|
|
|
|
a->vna_other = h->verinfo.verdef->vd_exp_refno + 1;
|
|
|
|
|
|
|
|
|
|
t->vn_auxptr = a;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Figure out appropriate versions for all the symbols. We may not
|
|
|
|
|
have the version number script until we have read all of the input
|
|
|
|
|
files, so until that point we don't know which symbols should be
|
|
|
|
|
local. This function is called via elf_link_hash_traverse. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_assign_sym_version (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
struct elf_assign_sym_version_info *sinfo;
|
|
|
|
|
struct bfd_link_info *info;
|
2000-02-18 09:23:06 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct elf_info_failed eif;
|
|
|
|
|
char *p;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type amt;
|
|
|
|
|
|
|
|
|
|
sinfo = (struct elf_assign_sym_version_info *) data;
|
|
|
|
|
info = sinfo->info;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Fix the symbol flags. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eif.failed = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
eif.info = info;
|
|
|
|
|
if (! elf_fix_symbol_flags (h, &eif))
|
|
|
|
|
{
|
|
|
|
|
if (eif.failed)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We only need version numbers for symbols defined in regular
|
|
|
|
|
objects. */
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2000-02-18 09:23:06 +00:00
|
|
|
|
bed = get_elf_backend_data (sinfo->output_bfd);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
p = strchr (h->root.root.string, ELF_VER_CHR);
|
|
|
|
|
if (p != NULL && h->verinfo.vertree == NULL)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_elf_version_tree *t;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean hidden;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
hidden = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* There are two consecutive ELF_VER_CHR characters if this is
|
2002-03-05 05:18:41 +00:00
|
|
|
|
not a hidden symbol. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
++p;
|
|
|
|
|
if (*p == ELF_VER_CHR)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
hidden = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
++p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If there is no version string, we can just return out. */
|
|
|
|
|
if (*p == '\0')
|
|
|
|
|
{
|
|
|
|
|
if (hidden)
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HIDDEN;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Look for the version. If we find it, it is no longer weak. */
|
|
|
|
|
for (t = sinfo->verdefs; t != NULL; t = t->next)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (t->name, p) == 0)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
size_t len;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
char *alc;
|
|
|
|
|
struct bfd_elf_version_expr *d;
|
|
|
|
|
|
|
|
|
|
len = p - h->root.root.string;
|
2002-01-21 10:29:09 +00:00
|
|
|
|
alc = bfd_malloc ((bfd_size_type) len);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (alc == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-06-25 09:40:45 +00:00
|
|
|
|
memcpy (alc, h->root.root.string, len - 1);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
alc[len - 1] = '\0';
|
|
|
|
|
if (alc[len - 2] == ELF_VER_CHR)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
alc[len - 2] = '\0';
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
h->verinfo.vertree = t;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
t->used = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
d = NULL;
|
|
|
|
|
|
|
|
|
|
if (t->globals != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (d = t->globals; d != NULL; d = d->next)
|
|
|
|
|
if ((*d->match) (d, alc))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See if there is anything to force this symbol to
|
2002-03-05 05:18:41 +00:00
|
|
|
|
local scope. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (d == NULL && t->locals != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (d = t->locals; d != NULL; d = d->next)
|
|
|
|
|
{
|
|
|
|
|
if ((*d->match) (d, alc))
|
|
|
|
|
{
|
|
|
|
|
if (h->dynindx != -1
|
|
|
|
|
&& info->shared
|
2001-06-18 22:05:10 +00:00
|
|
|
|
&& ! info->export_dynamic)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(*bed->elf_backend_hide_symbol) (info, h, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-21 10:29:09 +00:00
|
|
|
|
free (alc);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we are building an application, we need to create a
|
2002-03-05 05:18:41 +00:00
|
|
|
|
version node for this version. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (t == NULL && ! info->shared)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_elf_version_tree **pp;
|
|
|
|
|
int version_index;
|
|
|
|
|
|
|
|
|
|
/* If we aren't going to export this symbol, we don't need
|
2002-03-05 05:18:41 +00:00
|
|
|
|
to worry about it. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->dynindx == -1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = sizeof *t;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
t = ((struct bfd_elf_version_tree *)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_alloc (sinfo->output_bfd, amt));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (t == NULL)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t->next = NULL;
|
|
|
|
|
t->name = p;
|
|
|
|
|
t->globals = NULL;
|
|
|
|
|
t->locals = NULL;
|
|
|
|
|
t->deps = NULL;
|
|
|
|
|
t->name_indx = (unsigned int) -1;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
t->used = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
version_index = 1;
|
2001-12-18 12:15:35 +00:00
|
|
|
|
/* Don't count anonymous version tag. */
|
|
|
|
|
if (sinfo->verdefs != NULL && sinfo->verdefs->vernum == 0)
|
|
|
|
|
version_index = 0;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (pp = &sinfo->verdefs; *pp != NULL; pp = &(*pp)->next)
|
|
|
|
|
++version_index;
|
|
|
|
|
t->vernum = version_index;
|
|
|
|
|
|
|
|
|
|
*pp = t;
|
|
|
|
|
|
|
|
|
|
h->verinfo.vertree = t;
|
|
|
|
|
}
|
|
|
|
|
else if (t == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* We could not find the version for a symbol when
|
2002-03-05 05:18:41 +00:00
|
|
|
|
generating a shared archive. Return an error. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: undefined versioned symbol name %s"),
|
|
|
|
|
bfd_get_filename (sinfo->output_bfd), h->root.root.string);
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hidden)
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HIDDEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we don't have a version for this symbol, see if we can find
|
|
|
|
|
something. */
|
|
|
|
|
if (h->verinfo.vertree == NULL && sinfo->verdefs != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_elf_version_tree *t;
|
2002-07-16 12:31:35 +00:00
|
|
|
|
struct bfd_elf_version_tree *local_ver;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct bfd_elf_version_expr *d;
|
|
|
|
|
|
|
|
|
|
/* See if can find what version this symbol is in. If the
|
2002-03-05 05:18:41 +00:00
|
|
|
|
symbol is supposed to be local, then don't actually register
|
|
|
|
|
it. */
|
2002-07-16 12:31:35 +00:00
|
|
|
|
local_ver = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (t = sinfo->verdefs; t != NULL; t = t->next)
|
|
|
|
|
{
|
|
|
|
|
if (t->globals != NULL)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean matched;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
matched = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (d = t->globals; d != NULL; d = d->next)
|
|
|
|
|
{
|
|
|
|
|
if ((*d->match) (d, h->root.root.string))
|
|
|
|
|
{
|
2002-08-08 03:50:18 +00:00
|
|
|
|
if (d->symver)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
matched = TRUE;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* There is a version without definition. Make
|
|
|
|
|
the symbol the default definition for this
|
|
|
|
|
version. */
|
|
|
|
|
h->verinfo.vertree = t;
|
|
|
|
|
local_ver = NULL;
|
|
|
|
|
d->script = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d != NULL)
|
|
|
|
|
break;
|
2002-08-08 03:50:18 +00:00
|
|
|
|
else if (matched)
|
|
|
|
|
/* There is no undefined version for this symbol. Hide the
|
|
|
|
|
default one. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(*bed->elf_backend_hide_symbol) (info, h, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t->locals != NULL)
|
|
|
|
|
{
|
|
|
|
|
for (d = t->locals; d != NULL; d = d->next)
|
|
|
|
|
{
|
2002-07-16 12:31:35 +00:00
|
|
|
|
/* If the match is "*", keep looking for a more
|
|
|
|
|
explicit, perhaps even global, match. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (d->pattern[0] == '*' && d->pattern[1] == '\0')
|
2002-07-16 12:31:35 +00:00
|
|
|
|
local_ver = t;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else if ((*d->match) (d, h->root.root.string))
|
|
|
|
|
{
|
2002-07-16 12:31:35 +00:00
|
|
|
|
local_ver = t;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d != NULL)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 12:31:35 +00:00
|
|
|
|
if (local_ver != NULL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-07-16 12:31:35 +00:00
|
|
|
|
h->verinfo.vertree = local_ver;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->dynindx != -1
|
|
|
|
|
&& info->shared
|
2001-06-18 22:05:10 +00:00
|
|
|
|
&& ! info->export_dynamic)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(*bed->elf_backend_hide_symbol) (info, h, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Final phase of ELF linker. */
|
|
|
|
|
|
|
|
|
|
/* A structure we use to avoid passing large numbers of arguments. */
|
|
|
|
|
|
|
|
|
|
struct elf_final_link_info
|
|
|
|
|
{
|
|
|
|
|
/* General link information. */
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
/* Output BFD. */
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
/* Symbol string table. */
|
|
|
|
|
struct bfd_strtab_hash *symstrtab;
|
|
|
|
|
/* .dynsym section. */
|
|
|
|
|
asection *dynsym_sec;
|
|
|
|
|
/* .hash section. */
|
|
|
|
|
asection *hash_sec;
|
|
|
|
|
/* symbol version section (.gnu.version). */
|
|
|
|
|
asection *symver_sec;
|
* 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 13:12:53 +00:00
|
|
|
|
/* first SHF_TLS section (if any). */
|
|
|
|
|
asection *first_tls_sec;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Buffer large enough to hold contents of any section. */
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
/* Buffer large enough to hold external relocs of any section. */
|
|
|
|
|
PTR external_relocs;
|
|
|
|
|
/* Buffer large enough to hold internal relocs of any section. */
|
|
|
|
|
Elf_Internal_Rela *internal_relocs;
|
|
|
|
|
/* Buffer large enough to hold external local symbols of any input
|
|
|
|
|
BFD. */
|
|
|
|
|
Elf_External_Sym *external_syms;
|
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 00:52:35 +00:00
|
|
|
|
/* And a buffer for symbol section indices. */
|
|
|
|
|
Elf_External_Sym_Shndx *locsym_shndx;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Buffer large enough to hold internal local symbols of any input
|
|
|
|
|
BFD. */
|
|
|
|
|
Elf_Internal_Sym *internal_syms;
|
|
|
|
|
/* Array large enough to hold a symbol index for each local symbol
|
|
|
|
|
of any input BFD. */
|
|
|
|
|
long *indices;
|
|
|
|
|
/* Array large enough to hold a section pointer for each local
|
|
|
|
|
symbol of any input BFD. */
|
|
|
|
|
asection **sections;
|
|
|
|
|
/* Buffer to hold swapped out symbols. */
|
|
|
|
|
Elf_External_Sym *symbuf;
|
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 00:52:35 +00:00
|
|
|
|
/* And one for symbol section indices. */
|
|
|
|
|
Elf_External_Sym_Shndx *symshndxbuf;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Number of swapped out symbols in buffer. */
|
|
|
|
|
size_t symbuf_count;
|
|
|
|
|
/* Number of symbols which fit in symbuf. */
|
|
|
|
|
size_t symbuf_size;
|
2002-11-04 13:20:56 +00:00
|
|
|
|
/* And same for symshndxbuf. */
|
|
|
|
|
size_t shndxbuf_size;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_output_sym
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_final_link_info *, const char *,
|
|
|
|
|
Elf_Internal_Sym *, asection *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_flush_output_syms
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_final_link_info *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_output_extsym
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_sec_merge_syms
|
2001-04-13 00:34:36 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_check_versioned_symbol
|
2002-06-23 02:04:28 +00:00
|
|
|
|
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_link_input_bfd
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((struct elf_final_link_info *, bfd *));
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_reloc_link_order
|
1999-05-03 07:29:11 +00:00
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
|
|
|
|
struct bfd_link_order *));
|
|
|
|
|
|
|
|
|
|
/* This struct is used to pass information to elf_link_output_extsym. */
|
|
|
|
|
|
|
|
|
|
struct elf_outext_info
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean failed;
|
|
|
|
|
bfd_boolean localsyms;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct elf_final_link_info *finfo;
|
|
|
|
|
};
|
|
|
|
|
|
1999-07-01 23:20:08 +00:00
|
|
|
|
/* Compute the size of, and allocate space for, REL_HDR which is the
|
|
|
|
|
section header for a section containing relocations for O. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-07-01 23:20:08 +00:00
|
|
|
|
elf_link_size_reloc_section (abfd, rel_hdr, o)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
Elf_Internal_Shdr *rel_hdr;
|
|
|
|
|
asection *o;
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type reloc_count;
|
|
|
|
|
bfd_size_type num_rel_hashes;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
|
1999-08-10 03:36:28 +00:00
|
|
|
|
/* Figure out how many relocations there will be. */
|
|
|
|
|
if (rel_hdr == &elf_section_data (o)->rel_hdr)
|
|
|
|
|
reloc_count = elf_section_data (o)->rel_count;
|
|
|
|
|
else
|
|
|
|
|
reloc_count = elf_section_data (o)->rel_count2;
|
|
|
|
|
|
2001-06-20 20:34:10 +00:00
|
|
|
|
num_rel_hashes = o->reloc_count;
|
|
|
|
|
if (num_rel_hashes < reloc_count)
|
|
|
|
|
num_rel_hashes = reloc_count;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|
1999-08-10 03:36:28 +00:00
|
|
|
|
/* That allows us to calculate the size of the section. */
|
|
|
|
|
rel_hdr->sh_size = rel_hdr->sh_entsize * reloc_count;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
|
|
|
|
|
/* The contents field must last into write_object_contents, so we
|
2000-07-27 22:35:08 +00:00
|
|
|
|
allocate it with bfd_alloc rather than malloc. Also since we
|
|
|
|
|
cannot be sure that the contents will actually be filled in,
|
|
|
|
|
we zero the allocated space. */
|
|
|
|
|
rel_hdr->contents = (PTR) bfd_zalloc (abfd, rel_hdr->sh_size);
|
1999-07-01 23:20:08 +00:00
|
|
|
|
if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-08-10 03:36:28 +00:00
|
|
|
|
/* We only allocate one set of hash entries, so we only do it the
|
|
|
|
|
first time we are called. */
|
2001-06-20 20:34:10 +00:00
|
|
|
|
if (elf_section_data (o)->rel_hashes == NULL
|
|
|
|
|
&& num_rel_hashes)
|
1999-08-10 03:36:28 +00:00
|
|
|
|
{
|
2001-05-28 11:57:54 +00:00
|
|
|
|
struct elf_link_hash_entry **p;
|
|
|
|
|
|
1999-08-10 03:36:28 +00:00
|
|
|
|
p = ((struct elf_link_hash_entry **)
|
2001-06-20 20:34:10 +00:00
|
|
|
|
bfd_zmalloc (num_rel_hashes
|
2001-05-28 11:57:54 +00:00
|
|
|
|
* sizeof (struct elf_link_hash_entry *)));
|
2001-06-20 20:34:10 +00:00
|
|
|
|
if (p == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
|
1999-08-10 03:36:28 +00:00
|
|
|
|
elf_section_data (o)->rel_hashes = p;
|
|
|
|
|
}
|
1999-07-01 23:20:08 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-18 06:31:29 +00:00
|
|
|
|
/* When performing a relocateable link, the input relocations are
|
|
|
|
|
preserved. But, if they reference global symbols, the indices
|
|
|
|
|
referenced must be updated. Update all the relocations in
|
|
|
|
|
REL_HDR (there are COUNT of them), using the data in REL_HASH. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
elf_link_adjust_relocs (abfd, rel_hdr, count, rel_hash)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
Elf_Internal_Shdr *rel_hdr;
|
|
|
|
|
unsigned int count;
|
|
|
|
|
struct elf_link_hash_entry **rel_hash;
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
2000-06-16 23:01:00 +00:00
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
bfd_byte *erela;
|
|
|
|
|
void (*swap_in) PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
|
|
|
|
|
void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
|
2001-05-28 11:57:54 +00:00
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
|
2001-05-28 11:57:54 +00:00
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
swap_in = bed->s->swap_reloc_in;
|
|
|
|
|
swap_out = bed->s->swap_reloc_out;
|
2001-05-28 11:57:54 +00:00
|
|
|
|
}
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
else if (rel_hdr->sh_entsize == sizeof (Elf_External_Rela))
|
2001-05-28 11:57:54 +00:00
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
swap_in = bed->s->swap_reloca_in;
|
|
|
|
|
swap_out = bed->s->swap_reloca_out;
|
2001-05-28 11:57:54 +00:00
|
|
|
|
}
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
else
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
if (bed->s->int_rels_per_ext_rel > MAX_INT_RELS_PER_EXT_REL)
|
|
|
|
|
abort ();
|
1999-07-18 06:31:29 +00:00
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
erela = rel_hdr->contents;
|
|
|
|
|
for (i = 0; i < count; i++, rel_hash++, erela += rel_hdr->sh_entsize)
|
1999-07-18 06:31:29 +00:00
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
Elf_Internal_Rela irela[MAX_INT_RELS_PER_EXT_REL];
|
|
|
|
|
unsigned int j;
|
|
|
|
|
|
1999-07-18 06:31:29 +00:00
|
|
|
|
if (*rel_hash == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT ((*rel_hash)->indx >= 0);
|
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
(*swap_in) (abfd, erela, irela);
|
|
|
|
|
for (j = 0; j < bed->s->int_rels_per_ext_rel; j++)
|
|
|
|
|
irela[j].r_info = ELF_R_INFO ((*rel_hash)->indx,
|
|
|
|
|
ELF_R_TYPE (irela[j].r_info));
|
|
|
|
|
(*swap_out) (abfd, irela, erela);
|
1999-07-18 06:31:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 12:31:35 +00:00
|
|
|
|
struct elf_link_sort_rela
|
|
|
|
|
{
|
2001-08-23 15:14:18 +00:00
|
|
|
|
bfd_vma offset;
|
|
|
|
|
enum elf_reloc_type_class type;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
/* We use this as an array of size int_rels_per_ext_rel. */
|
|
|
|
|
Elf_Internal_Rela rela[1];
|
2001-08-23 15:14:18 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
elf_link_sort_cmp1 (A, B)
|
|
|
|
|
const PTR A;
|
|
|
|
|
const PTR B;
|
|
|
|
|
{
|
2001-09-24 01:38:31 +00:00
|
|
|
|
struct elf_link_sort_rela *a = (struct elf_link_sort_rela *) A;
|
|
|
|
|
struct elf_link_sort_rela *b = (struct elf_link_sort_rela *) B;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
int relativea, relativeb;
|
|
|
|
|
|
|
|
|
|
relativea = a->type == reloc_class_relative;
|
|
|
|
|
relativeb = b->type == reloc_class_relative;
|
|
|
|
|
|
|
|
|
|
if (relativea < relativeb)
|
|
|
|
|
return 1;
|
2001-08-24 11:17:30 +00:00
|
|
|
|
if (relativea > relativeb)
|
|
|
|
|
return -1;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (ELF_R_SYM (a->rela->r_info) < ELF_R_SYM (b->rela->r_info))
|
2001-08-23 15:14:18 +00:00
|
|
|
|
return -1;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (ELF_R_SYM (a->rela->r_info) > ELF_R_SYM (b->rela->r_info))
|
2001-08-23 15:14:18 +00:00
|
|
|
|
return 1;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (a->rela->r_offset < b->rela->r_offset)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
return -1;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (a->rela->r_offset > b->rela->r_offset)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
elf_link_sort_cmp2 (A, B)
|
|
|
|
|
const PTR A;
|
|
|
|
|
const PTR B;
|
|
|
|
|
{
|
2001-09-24 01:38:31 +00:00
|
|
|
|
struct elf_link_sort_rela *a = (struct elf_link_sort_rela *) A;
|
|
|
|
|
struct elf_link_sort_rela *b = (struct elf_link_sort_rela *) B;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
int copya, copyb;
|
|
|
|
|
|
|
|
|
|
if (a->offset < b->offset)
|
|
|
|
|
return -1;
|
|
|
|
|
if (a->offset > b->offset)
|
|
|
|
|
return 1;
|
2001-10-10 19:32:02 +00:00
|
|
|
|
copya = (a->type == reloc_class_copy) * 2 + (a->type == reloc_class_plt);
|
|
|
|
|
copyb = (b->type == reloc_class_copy) * 2 + (b->type == reloc_class_plt);
|
2001-08-23 15:14:18 +00:00
|
|
|
|
if (copya < copyb)
|
|
|
|
|
return -1;
|
|
|
|
|
if (copya > copyb)
|
|
|
|
|
return 1;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (a->rela->r_offset < b->rela->r_offset)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
return -1;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (a->rela->r_offset > b->rela->r_offset)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t
|
|
|
|
|
elf_link_sort_relocs (abfd, info, psec)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
asection **psec;
|
|
|
|
|
{
|
|
|
|
|
bfd *dynobj = elf_hash_table (info)->dynobj;
|
|
|
|
|
asection *reldyn, *o;
|
2001-09-24 01:38:31 +00:00
|
|
|
|
bfd_size_type count, size;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
size_t i, ret, sort_elt, ext_size;
|
|
|
|
|
bfd_byte *sort, *s_non_relative, *p;
|
|
|
|
|
struct elf_link_sort_rela *sq;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
2002-10-22 21:00:10 +00:00
|
|
|
|
int i2e = bed->s->int_rels_per_ext_rel;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
void (*swap_in) PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
|
|
|
|
|
void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
|
2001-08-23 15:14:18 +00:00
|
|
|
|
|
|
|
|
|
reldyn = bfd_get_section_by_name (abfd, ".rela.dyn");
|
|
|
|
|
if (reldyn == NULL || reldyn->_raw_size == 0)
|
|
|
|
|
{
|
|
|
|
|
reldyn = bfd_get_section_by_name (abfd, ".rel.dyn");
|
|
|
|
|
if (reldyn == NULL || reldyn->_raw_size == 0)
|
|
|
|
|
return 0;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
ext_size = sizeof (Elf_External_Rel);
|
|
|
|
|
swap_in = bed->s->swap_reloc_in;
|
|
|
|
|
swap_out = bed->s->swap_reloc_out;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
{
|
|
|
|
|
ext_size = sizeof (Elf_External_Rela);
|
|
|
|
|
swap_in = bed->s->swap_reloca_in;
|
|
|
|
|
swap_out = bed->s->swap_reloca_out;
|
|
|
|
|
}
|
|
|
|
|
count = reldyn->_raw_size / ext_size;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
|
for (o = dynobj->sections; o != NULL; o = o->next)
|
|
|
|
|
if ((o->flags & (SEC_HAS_CONTENTS|SEC_LINKER_CREATED))
|
|
|
|
|
== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
|
|
|
|
|
&& o->output_section == reldyn)
|
|
|
|
|
size += o->_raw_size;
|
|
|
|
|
|
|
|
|
|
if (size != reldyn->_raw_size)
|
|
|
|
|
return 0;
|
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
sort_elt = (sizeof (struct elf_link_sort_rela)
|
|
|
|
|
+ (i2e - 1) * sizeof (Elf_Internal_Rela));
|
|
|
|
|
sort = bfd_zmalloc (sort_elt * count);
|
|
|
|
|
if (sort == NULL)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
{
|
|
|
|
|
(*info->callbacks->warning)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
(info, _("Not enough memory to sort relocations"), 0, abfd, 0,
|
|
|
|
|
(bfd_vma) 0);
|
2001-08-23 15:14:18 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (o = dynobj->sections; o != NULL; o = o->next)
|
|
|
|
|
if ((o->flags & (SEC_HAS_CONTENTS|SEC_LINKER_CREATED))
|
|
|
|
|
== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
|
|
|
|
|
&& o->output_section == reldyn)
|
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
bfd_byte *erel, *erelend;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
erel = o->contents;
|
|
|
|
|
erelend = o->contents + o->_raw_size;
|
|
|
|
|
p = sort + o->output_offset / ext_size * sort_elt;
|
|
|
|
|
while (erel < erelend)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
struct elf_link_sort_rela *s = (struct elf_link_sort_rela *) p;
|
|
|
|
|
(*swap_in) (abfd, erel, s->rela);
|
|
|
|
|
s->type = (*bed->elf_backend_reloc_type_class) (s->rela);
|
|
|
|
|
p += sort_elt;
|
|
|
|
|
erel += ext_size;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
qsort (sort, (size_t) count, sort_elt, elf_link_sort_cmp1);
|
|
|
|
|
|
|
|
|
|
for (i = 0, p = sort; i < count; i++, p += sort_elt)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
struct elf_link_sort_rela *s = (struct elf_link_sort_rela *) p;
|
|
|
|
|
if (s->type != reloc_class_relative)
|
|
|
|
|
break;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
}
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
ret = i;
|
|
|
|
|
s_non_relative = p;
|
|
|
|
|
|
|
|
|
|
sq = (struct elf_link_sort_rela *) s_non_relative;
|
|
|
|
|
for (; i < count; i++, p += sort_elt)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_sort_rela *sp = (struct elf_link_sort_rela *) p;
|
|
|
|
|
if (ELF_R_SYM (sp->rela->r_info) != ELF_R_SYM (sq->rela->r_info))
|
|
|
|
|
sq = sp;
|
|
|
|
|
sp->offset = sq->rela->r_offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qsort (s_non_relative, (size_t) count - ret, sort_elt, elf_link_sort_cmp2);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|
2001-08-23 15:14:18 +00:00
|
|
|
|
for (o = dynobj->sections; o != NULL; o = o->next)
|
|
|
|
|
if ((o->flags & (SEC_HAS_CONTENTS|SEC_LINKER_CREATED))
|
|
|
|
|
== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
|
|
|
|
|
&& o->output_section == reldyn)
|
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
bfd_byte *erel, *erelend;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
erel = o->contents;
|
|
|
|
|
erelend = o->contents + o->_raw_size;
|
|
|
|
|
p = sort + o->output_offset / ext_size * sort_elt;
|
|
|
|
|
while (erel < erelend)
|
2001-08-23 15:14:18 +00:00
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
struct elf_link_sort_rela *s = (struct elf_link_sort_rela *) p;
|
|
|
|
|
(*swap_out) (abfd, s->rela, erel);
|
|
|
|
|
p += sort_elt;
|
|
|
|
|
erel += ext_size;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*psec = reldyn;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Do the final step of an ELF link. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_bfd_final_link (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean dynamic;
|
|
|
|
|
bfd_boolean emit_relocs;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd *dynobj;
|
|
|
|
|
struct elf_final_link_info finfo;
|
|
|
|
|
register asection *o;
|
|
|
|
|
register struct bfd_link_order *p;
|
|
|
|
|
register bfd *sub;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type max_contents_size;
|
|
|
|
|
bfd_size_type max_external_reloc_size;
|
|
|
|
|
bfd_size_type max_internal_reloc_count;
|
|
|
|
|
bfd_size_type max_sym_count;
|
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 00:52:35 +00:00
|
|
|
|
bfd_size_type max_sym_shndx_count;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
file_ptr off;
|
|
|
|
|
Elf_Internal_Sym elfsym;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
Elf_Internal_Shdr *symtab_hdr;
|
2002-11-04 13:20:56 +00:00
|
|
|
|
Elf_Internal_Shdr *symtab_shndx_hdr;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
Elf_Internal_Shdr *symstrtab_hdr;
|
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
|
|
|
|
struct elf_outext_info eoinfo;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean merged;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
size_t relativecount = 0;
|
|
|
|
|
asection *reldyn = 0;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_size_type amt;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-24 16:36:04 +00:00
|
|
|
|
if (! is_elf_hash_table (info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-08-24 16:36:04 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (info->shared)
|
|
|
|
|
abfd->flags |= DYNAMIC;
|
|
|
|
|
|
|
|
|
|
dynamic = elf_hash_table (info)->dynamic_sections_created;
|
|
|
|
|
dynobj = elf_hash_table (info)->dynobj;
|
|
|
|
|
|
2001-06-20 20:34:10 +00:00
|
|
|
|
emit_relocs = (info->relocateable
|
2002-03-05 05:18:41 +00:00
|
|
|
|
|| info->emitrelocations
|
|
|
|
|
|| bed->elf_backend_emit_relocs);
|
2001-06-20 20:34:10 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
finfo.info = info;
|
|
|
|
|
finfo.output_bfd = abfd;
|
|
|
|
|
finfo.symstrtab = elf_stringtab_init ();
|
|
|
|
|
if (finfo.symstrtab == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (! dynamic)
|
|
|
|
|
{
|
|
|
|
|
finfo.dynsym_sec = NULL;
|
|
|
|
|
finfo.hash_sec = NULL;
|
|
|
|
|
finfo.symver_sec = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
finfo.dynsym_sec = bfd_get_section_by_name (dynobj, ".dynsym");
|
|
|
|
|
finfo.hash_sec = bfd_get_section_by_name (dynobj, ".hash");
|
|
|
|
|
BFD_ASSERT (finfo.dynsym_sec != NULL && finfo.hash_sec != NULL);
|
|
|
|
|
finfo.symver_sec = bfd_get_section_by_name (dynobj, ".gnu.version");
|
|
|
|
|
/* Note that it is OK if symver_sec is NULL. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
finfo.contents = NULL;
|
|
|
|
|
finfo.external_relocs = NULL;
|
|
|
|
|
finfo.internal_relocs = NULL;
|
|
|
|
|
finfo.external_syms = 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 00:52:35 +00:00
|
|
|
|
finfo.locsym_shndx = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
finfo.internal_syms = NULL;
|
|
|
|
|
finfo.indices = NULL;
|
|
|
|
|
finfo.sections = NULL;
|
|
|
|
|
finfo.symbuf = 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 00:52:35 +00:00
|
|
|
|
finfo.symshndxbuf = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
finfo.symbuf_count = 0;
|
2002-11-04 13:20:56 +00:00
|
|
|
|
finfo.shndxbuf_size = 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 13:12:53 +00:00
|
|
|
|
finfo.first_tls_sec = NULL;
|
|
|
|
|
for (o = abfd->sections; o != (asection *) NULL; o = o->next)
|
|
|
|
|
if ((o->flags & SEC_THREAD_LOCAL) != 0
|
|
|
|
|
&& (o->flags & SEC_LOAD) != 0)
|
|
|
|
|
{
|
|
|
|
|
finfo.first_tls_sec = o;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Count up the number of relocations we will output for each output
|
|
|
|
|
section, so that we know the sizes of the reloc sections. We
|
|
|
|
|
also figure out some maximum sizes. */
|
|
|
|
|
max_contents_size = 0;
|
|
|
|
|
max_external_reloc_size = 0;
|
|
|
|
|
max_internal_reloc_count = 0;
|
|
|
|
|
max_sym_count = 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 00:52:35 +00:00
|
|
|
|
max_sym_shndx_count = 0;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
merged = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (o = abfd->sections; o != (asection *) NULL; o = o->next)
|
|
|
|
|
{
|
2003-02-25 04:14:38 +00:00
|
|
|
|
struct bfd_elf_section_data *esdo = elf_section_data (o);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
o->reloc_count = 0;
|
|
|
|
|
|
|
|
|
|
for (p = o->link_order_head; p != NULL; p = p->next)
|
|
|
|
|
{
|
2003-02-25 04:14:38 +00:00
|
|
|
|
unsigned int reloc_count = 0;
|
|
|
|
|
struct bfd_elf_section_data *esdi = NULL;
|
|
|
|
|
unsigned int *rel_count1;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (p->type == bfd_section_reloc_link_order
|
|
|
|
|
|| p->type == bfd_symbol_reloc_link_order)
|
2003-02-25 04:14:38 +00:00
|
|
|
|
reloc_count = 1;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else if (p->type == bfd_indirect_link_order)
|
|
|
|
|
{
|
|
|
|
|
asection *sec;
|
|
|
|
|
|
|
|
|
|
sec = p->u.indirect.section;
|
2003-02-25 04:14:38 +00:00
|
|
|
|
esdi = elf_section_data (sec);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Mark all sections which are to be included in the
|
|
|
|
|
link. This will normally be every section. We need
|
|
|
|
|
to do this so that we can identify any sections which
|
|
|
|
|
the linker has decided to not include. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sec->linker_mark = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-04-13 00:34:36 +00:00
|
|
|
|
if (sec->flags & SEC_MERGE)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
merged = TRUE;
|
2001-04-13 00:34:36 +00:00
|
|
|
|
|
2000-05-17 19:38:53 +00:00
|
|
|
|
if (info->relocateable || info->emitrelocations)
|
2003-02-25 04:14:38 +00:00
|
|
|
|
reloc_count = sec->reloc_count;
|
2002-03-05 05:18:41 +00:00
|
|
|
|
else if (bed->elf_backend_count_relocs)
|
2001-06-20 20:34:10 +00:00
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela * relocs;
|
|
|
|
|
|
|
|
|
|
relocs = (NAME(_bfd_elf,link_read_relocs)
|
|
|
|
|
(abfd, sec, (PTR) NULL,
|
|
|
|
|
(Elf_Internal_Rela *) NULL, info->keep_memory));
|
|
|
|
|
|
2003-02-25 04:14:38 +00:00
|
|
|
|
reloc_count = (*bed->elf_backend_count_relocs) (sec, relocs);
|
2001-06-20 20:34:10 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (elf_section_data (o)->relocs != relocs)
|
2001-06-20 20:34:10 +00:00
|
|
|
|
free (relocs);
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (sec->_raw_size > max_contents_size)
|
|
|
|
|
max_contents_size = sec->_raw_size;
|
|
|
|
|
if (sec->_cooked_size > max_contents_size)
|
|
|
|
|
max_contents_size = sec->_cooked_size;
|
|
|
|
|
|
|
|
|
|
/* We are interested in just local symbols, not all
|
|
|
|
|
symbols. */
|
|
|
|
|
if (bfd_get_flavour (sec->owner) == bfd_target_elf_flavour
|
|
|
|
|
&& (sec->owner->flags & DYNAMIC) == 0)
|
|
|
|
|
{
|
|
|
|
|
size_t sym_count;
|
|
|
|
|
|
|
|
|
|
if (elf_bad_symtab (sec->owner))
|
|
|
|
|
sym_count = (elf_tdata (sec->owner)->symtab_hdr.sh_size
|
|
|
|
|
/ sizeof (Elf_External_Sym));
|
|
|
|
|
else
|
|
|
|
|
sym_count = elf_tdata (sec->owner)->symtab_hdr.sh_info;
|
|
|
|
|
|
|
|
|
|
if (sym_count > max_sym_count)
|
|
|
|
|
max_sym_count = sym_count;
|
|
|
|
|
|
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 00:52:35 +00:00
|
|
|
|
if (sym_count > max_sym_shndx_count
|
|
|
|
|
&& elf_symtab_shndx (sec->owner) != 0)
|
|
|
|
|
max_sym_shndx_count = sym_count;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if ((sec->flags & SEC_RELOC) != 0)
|
|
|
|
|
{
|
|
|
|
|
size_t ext_size;
|
|
|
|
|
|
|
|
|
|
ext_size = elf_section_data (sec)->rel_hdr.sh_size;
|
|
|
|
|
if (ext_size > max_external_reloc_size)
|
|
|
|
|
max_external_reloc_size = ext_size;
|
|
|
|
|
if (sec->reloc_count > max_internal_reloc_count)
|
|
|
|
|
max_internal_reloc_count = sec->reloc_count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-02-25 04:14:38 +00:00
|
|
|
|
|
|
|
|
|
if (reloc_count == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
o->reloc_count += reloc_count;
|
|
|
|
|
|
|
|
|
|
/* MIPS may have a mix of REL and RELA relocs on sections.
|
|
|
|
|
To support this curious ABI we keep reloc counts in
|
|
|
|
|
elf_section_data too. We must be careful to add the
|
|
|
|
|
relocations from the input section to the right output
|
|
|
|
|
count. FIXME: Get rid of one count. We have
|
|
|
|
|
o->reloc_count == esdo->rel_count + esdo->rel_count2. */
|
|
|
|
|
rel_count1 = &esdo->rel_count;
|
|
|
|
|
if (esdi != NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_boolean same_size;
|
|
|
|
|
bfd_size_type entsize1;
|
|
|
|
|
|
|
|
|
|
entsize1 = esdi->rel_hdr.sh_entsize;
|
|
|
|
|
BFD_ASSERT (entsize1 == sizeof (Elf_External_Rel)
|
|
|
|
|
|| entsize1 == sizeof (Elf_External_Rela));
|
|
|
|
|
same_size = (!o->use_rela_p
|
|
|
|
|
== (entsize1 == sizeof (Elf_External_Rel)));
|
|
|
|
|
|
|
|
|
|
if (!same_size)
|
|
|
|
|
rel_count1 = &esdo->rel_count2;
|
|
|
|
|
|
|
|
|
|
if (esdi->rel_hdr2 != NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type entsize2 = esdi->rel_hdr2->sh_entsize;
|
|
|
|
|
unsigned int alt_count;
|
|
|
|
|
unsigned int *rel_count2;
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (entsize2 != entsize1
|
|
|
|
|
&& (entsize2 == sizeof (Elf_External_Rel)
|
|
|
|
|
|| entsize2 == sizeof (Elf_External_Rela)));
|
|
|
|
|
|
|
|
|
|
rel_count2 = &esdo->rel_count2;
|
|
|
|
|
if (!same_size)
|
|
|
|
|
rel_count2 = &esdo->rel_count;
|
|
|
|
|
|
|
|
|
|
/* The following is probably too simplistic if the
|
|
|
|
|
backend counts output relocs unusually. */
|
|
|
|
|
BFD_ASSERT (bed->elf_backend_count_relocs == NULL);
|
|
|
|
|
alt_count = NUM_SHDR_ENTRIES (esdi->rel_hdr2);
|
|
|
|
|
*rel_count2 += alt_count;
|
|
|
|
|
reloc_count -= alt_count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*rel_count1 += reloc_count;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (o->reloc_count > 0)
|
|
|
|
|
o->flags |= SEC_RELOC;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Explicitly clear the SEC_RELOC flag. The linker tends to
|
|
|
|
|
set it (this is probably a bug) and if it is set
|
|
|
|
|
assign_section_numbers will create a reloc section. */
|
|
|
|
|
o->flags &=~ SEC_RELOC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the SEC_ALLOC flag is not set, force the section VMA to
|
|
|
|
|
zero. This is done in elf_fake_sections as well, but forcing
|
|
|
|
|
the VMA to 0 here will ensure that relocs against these
|
|
|
|
|
sections are handled correctly. */
|
|
|
|
|
if ((o->flags & SEC_ALLOC) == 0
|
|
|
|
|
&& ! o->user_set_vma)
|
|
|
|
|
o->vma = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-13 00:34:36 +00:00
|
|
|
|
if (! info->relocateable && merged)
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_link_sec_merge_syms, (PTR) abfd);
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Figure out the file positions for everything but the symbol table
|
|
|
|
|
and the relocs. We set symcount to force assign_section_numbers
|
|
|
|
|
to create a symbol table. */
|
|
|
|
|
bfd_get_symcount (abfd) = info->strip == strip_all ? 0 : 1;
|
|
|
|
|
BFD_ASSERT (! abfd->output_has_begun);
|
|
|
|
|
if (! _bfd_elf_compute_section_file_positions (abfd, info))
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
/* That created the reloc sections. Set their sizes, and assign
|
|
|
|
|
them file positions, and allocate some buffers. */
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_RELOC) != 0)
|
|
|
|
|
{
|
1999-07-01 23:20:08 +00:00
|
|
|
|
if (!elf_link_size_reloc_section (abfd,
|
|
|
|
|
&elf_section_data (o)->rel_hdr,
|
|
|
|
|
o))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
|
1999-07-01 23:20:08 +00:00
|
|
|
|
if (elf_section_data (o)->rel_hdr2
|
|
|
|
|
&& !elf_link_size_reloc_section (abfd,
|
|
|
|
|
elf_section_data (o)->rel_hdr2,
|
|
|
|
|
o))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-08-10 03:36:28 +00:00
|
|
|
|
|
|
|
|
|
/* Now, reset REL_COUNT and REL_COUNT2 so that we can use them
|
2001-01-03 22:53:39 +00:00
|
|
|
|
to count upwards while actually outputting the relocations. */
|
1999-08-10 03:36:28 +00:00
|
|
|
|
elf_section_data (o)->rel_count = 0;
|
|
|
|
|
elf_section_data (o)->rel_count2 = 0;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_bfd_elf_assign_file_positions_for_relocs (abfd);
|
|
|
|
|
|
|
|
|
|
/* We have now assigned file positions for all the sections except
|
|
|
|
|
.symtab and .strtab. We start the .symtab section at the current
|
|
|
|
|
file position, and write directly to it. We build the .strtab
|
|
|
|
|
section in memory. */
|
|
|
|
|
bfd_get_symcount (abfd) = 0;
|
|
|
|
|
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
|
|
|
|
/* sh_name is set in prep_headers. */
|
|
|
|
|
symtab_hdr->sh_type = SHT_SYMTAB;
|
2002-11-04 13:20:56 +00:00
|
|
|
|
/* sh_flags, sh_addr and sh_size all start off zero. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
symtab_hdr->sh_entsize = sizeof (Elf_External_Sym);
|
|
|
|
|
/* sh_link is set in assign_section_numbers. */
|
|
|
|
|
/* sh_info is set below. */
|
|
|
|
|
/* sh_offset is set just below. */
|
2001-02-12 00:23:37 +00:00
|
|
|
|
symtab_hdr->sh_addralign = bed->s->file_align;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
off = elf_tdata (abfd)->next_file_pos;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Note that at this point elf_tdata (abfd)->next_file_pos is
|
|
|
|
|
incorrect. We do not yet know the size of the .symtab section.
|
|
|
|
|
We correct next_file_pos below, after we do know the size. */
|
|
|
|
|
|
|
|
|
|
/* Allocate a buffer to hold swapped out symbols. This is to avoid
|
|
|
|
|
continuously seeking to the right position in the file. */
|
|
|
|
|
if (! info->keep_memory || max_sym_count < 20)
|
|
|
|
|
finfo.symbuf_size = 20;
|
|
|
|
|
else
|
|
|
|
|
finfo.symbuf_size = max_sym_count;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = finfo.symbuf_size;
|
|
|
|
|
amt *= sizeof (Elf_External_Sym);
|
|
|
|
|
finfo.symbuf = (Elf_External_Sym *) bfd_malloc (amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (finfo.symbuf == NULL)
|
|
|
|
|
goto error_return;
|
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 00:52:35 +00:00
|
|
|
|
if (elf_numsections (abfd) > SHN_LORESERVE)
|
|
|
|
|
{
|
2002-11-04 13:20:56 +00:00
|
|
|
|
/* Wild guess at number of output symbols. realloc'd as needed. */
|
|
|
|
|
amt = 2 * max_sym_count + elf_numsections (abfd) + 1000;
|
|
|
|
|
finfo.shndxbuf_size = amt;
|
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 00:52:35 +00:00
|
|
|
|
amt *= sizeof (Elf_External_Sym_Shndx);
|
2002-11-04 13:20:56 +00:00
|
|
|
|
finfo.symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt);
|
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 00:52:35 +00:00
|
|
|
|
if (finfo.symshndxbuf == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Start writing out the symbol table. The first symbol is always a
|
|
|
|
|
dummy symbol. */
|
2001-06-20 20:34:10 +00:00
|
|
|
|
if (info->strip != strip_all
|
|
|
|
|
|| emit_relocs)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
elfsym.st_value = 0;
|
|
|
|
|
elfsym.st_size = 0;
|
|
|
|
|
elfsym.st_info = 0;
|
|
|
|
|
elfsym.st_other = 0;
|
|
|
|
|
elfsym.st_shndx = SHN_UNDEF;
|
|
|
|
|
if (! elf_link_output_sym (&finfo, (const char *) NULL,
|
|
|
|
|
&elfsym, bfd_und_section_ptr))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* Some standard ELF linkers do this, but we don't because it causes
|
|
|
|
|
bootstrap comparison failures. */
|
|
|
|
|
/* Output a file symbol for the output file as the second symbol.
|
|
|
|
|
We output this even if we are discarding local symbols, although
|
|
|
|
|
I'm not sure if this is correct. */
|
|
|
|
|
elfsym.st_value = 0;
|
|
|
|
|
elfsym.st_size = 0;
|
|
|
|
|
elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
|
|
|
|
|
elfsym.st_other = 0;
|
|
|
|
|
elfsym.st_shndx = SHN_ABS;
|
|
|
|
|
if (! elf_link_output_sym (&finfo, bfd_get_filename (abfd),
|
|
|
|
|
&elfsym, bfd_abs_section_ptr))
|
|
|
|
|
goto error_return;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Output a symbol for each section. We output these even if we are
|
|
|
|
|
discarding local symbols, since they are used for relocs. These
|
|
|
|
|
symbols have no names. We store the index of each one in the
|
|
|
|
|
index field of the section, so that we can find it again when
|
|
|
|
|
outputting relocs. */
|
2001-06-20 20:34:10 +00:00
|
|
|
|
if (info->strip != strip_all
|
|
|
|
|
|| emit_relocs)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
elfsym.st_size = 0;
|
|
|
|
|
elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
|
|
|
|
|
elfsym.st_other = 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 00:52:35 +00:00
|
|
|
|
for (i = 1; i < elf_numsections (abfd); i++)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
o = section_from_elf_index (abfd, i);
|
|
|
|
|
if (o != NULL)
|
|
|
|
|
o->target_index = bfd_get_symcount (abfd);
|
|
|
|
|
elfsym.st_shndx = i;
|
2000-05-18 17:12:31 +00:00
|
|
|
|
if (info->relocateable || o == NULL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elfsym.st_value = 0;
|
|
|
|
|
else
|
|
|
|
|
elfsym.st_value = o->vma;
|
|
|
|
|
if (! elf_link_output_sym (&finfo, (const char *) NULL,
|
|
|
|
|
&elfsym, o))
|
|
|
|
|
goto error_return;
|
2002-11-04 13:20:56 +00:00
|
|
|
|
if (i == SHN_LORESERVE - 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 00:52:35 +00:00
|
|
|
|
i += SHN_HIRESERVE + 1 - SHN_LORESERVE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate some memory to hold information read in from the input
|
|
|
|
|
files. */
|
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 00:52:35 +00:00
|
|
|
|
if (max_contents_size != 0)
|
|
|
|
|
{
|
|
|
|
|
finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
|
|
|
|
|
if (finfo.contents == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (max_external_reloc_size != 0)
|
|
|
|
|
{
|
|
|
|
|
finfo.external_relocs = (PTR) bfd_malloc (max_external_reloc_size);
|
|
|
|
|
if (finfo.external_relocs == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (max_internal_reloc_count != 0)
|
|
|
|
|
{
|
|
|
|
|
amt = max_internal_reloc_count * bed->s->int_rels_per_ext_rel;
|
|
|
|
|
amt *= sizeof (Elf_Internal_Rela);
|
|
|
|
|
finfo.internal_relocs = (Elf_Internal_Rela *) bfd_malloc (amt);
|
|
|
|
|
if (finfo.internal_relocs == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (max_sym_count != 0)
|
|
|
|
|
{
|
|
|
|
|
amt = max_sym_count * sizeof (Elf_External_Sym);
|
|
|
|
|
finfo.external_syms = (Elf_External_Sym *) bfd_malloc (amt);
|
|
|
|
|
if (finfo.external_syms == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
amt = max_sym_count * sizeof (Elf_Internal_Sym);
|
|
|
|
|
finfo.internal_syms = (Elf_Internal_Sym *) bfd_malloc (amt);
|
|
|
|
|
if (finfo.internal_syms == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
amt = max_sym_count * sizeof (long);
|
|
|
|
|
finfo.indices = (long *) bfd_malloc (amt);
|
|
|
|
|
if (finfo.indices == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
amt = max_sym_count * sizeof (asection *);
|
|
|
|
|
finfo.sections = (asection **) bfd_malloc (amt);
|
|
|
|
|
if (finfo.sections == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (max_sym_shndx_count != 0)
|
|
|
|
|
{
|
|
|
|
|
amt = max_sym_shndx_count * sizeof (Elf_External_Sym_Shndx);
|
|
|
|
|
finfo.locsym_shndx = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
|
|
|
|
|
if (finfo.locsym_shndx == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00: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 13:12:53 +00:00
|
|
|
|
if (finfo.first_tls_sec)
|
|
|
|
|
{
|
|
|
|
|
unsigned int align = 0;
|
|
|
|
|
bfd_vma base = finfo.first_tls_sec->vma, end = 0;
|
|
|
|
|
asection *sec;
|
|
|
|
|
|
|
|
|
|
for (sec = finfo.first_tls_sec;
|
|
|
|
|
sec && (sec->flags & SEC_THREAD_LOCAL);
|
|
|
|
|
sec = sec->next)
|
|
|
|
|
{
|
|
|
|
|
bfd_vma size = sec->_raw_size;
|
|
|
|
|
|
|
|
|
|
if (bfd_get_section_alignment (abfd, sec) > align)
|
|
|
|
|
align = bfd_get_section_alignment (abfd, sec);
|
|
|
|
|
if (sec->_raw_size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0)
|
|
|
|
|
{
|
|
|
|
|
struct bfd_link_order *o;
|
|
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
|
for (o = sec->link_order_head; o != NULL; o = o->next)
|
|
|
|
|
if (size < o->offset + o->size)
|
2002-07-16 12:31:35 +00:00
|
|
|
|
size = o->offset + o->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 13:12:53 +00:00
|
|
|
|
}
|
|
|
|
|
end = sec->vma + size;
|
|
|
|
|
}
|
|
|
|
|
elf_hash_table (info)->tls_segment
|
|
|
|
|
= bfd_zalloc (abfd, sizeof (struct elf_link_tls_segment));
|
|
|
|
|
if (elf_hash_table (info)->tls_segment == NULL)
|
|
|
|
|
goto error_return;
|
|
|
|
|
elf_hash_table (info)->tls_segment->start = base;
|
|
|
|
|
elf_hash_table (info)->tls_segment->size = end - base;
|
|
|
|
|
elf_hash_table (info)->tls_segment->align = align;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Since ELF permits relocations to be against local symbols, we
|
|
|
|
|
must have the local symbols available when we do the relocations.
|
|
|
|
|
Since we would rather only read the local symbols once, and we
|
|
|
|
|
would rather not keep them in memory, we handle all the
|
|
|
|
|
relocations for a single input file at the same time.
|
|
|
|
|
|
|
|
|
|
Unfortunately, there is no way to know the total number of local
|
|
|
|
|
symbols until we have seen all of them, and the local symbol
|
|
|
|
|
indices precede the global symbol indices. This means that when
|
|
|
|
|
we are generating relocateable output, and we see a reloc against
|
|
|
|
|
a global symbol, we can not know the symbol index until we have
|
|
|
|
|
finished examining all the local symbols to see which ones we are
|
|
|
|
|
going to output. To deal with this, we keep the relocations in
|
|
|
|
|
memory, and don't output them until the end of the link. This is
|
|
|
|
|
an unfortunate waste of memory, but I don't see a good way around
|
|
|
|
|
it. Fortunately, it only happens when performing a relocateable
|
|
|
|
|
link, which is not the common case. FIXME: If keep_memory is set
|
|
|
|
|
we could write the relocs out and then read them again; I don't
|
|
|
|
|
know how bad the memory loss will be. */
|
|
|
|
|
|
|
|
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sub->output_has_begun = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
for (p = o->link_order_head; p != NULL; p = p->next)
|
|
|
|
|
{
|
|
|
|
|
if (p->type == bfd_indirect_link_order
|
2002-04-26 12:59:23 +00:00
|
|
|
|
&& (bfd_get_flavour ((sub = p->u.indirect.section->owner))
|
2002-03-13 02:56:08 +00:00
|
|
|
|
== bfd_target_elf_flavour)
|
2002-04-26 12:59:23 +00:00
|
|
|
|
&& elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (! sub->output_has_begun)
|
|
|
|
|
{
|
|
|
|
|
if (! elf_link_input_bfd (&finfo, sub))
|
|
|
|
|
goto error_return;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sub->output_has_begun = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (p->type == bfd_section_reloc_link_order
|
|
|
|
|
|| p->type == bfd_symbol_reloc_link_order)
|
|
|
|
|
{
|
|
|
|
|
if (! elf_reloc_link_order (abfd, info, o, p))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_default_link_order (abfd, info, o, p))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-05 05:18:41 +00:00
|
|
|
|
/* Output any global symbols that got converted to local in a
|
|
|
|
|
version script or due to symbol visibility. We do this in a
|
|
|
|
|
separate step since ELF requires all local symbols to appear
|
|
|
|
|
prior to any global symbols. FIXME: We should only do this if
|
|
|
|
|
some global symbols were, in fact, converted to become local.
|
|
|
|
|
FIXME: Will this work correctly with the Irix 5 linker? */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eoinfo.failed = FALSE;
|
2002-03-05 05:18:41 +00:00
|
|
|
|
eoinfo.finfo = &finfo;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eoinfo.localsyms = TRUE;
|
2002-03-05 05:18:41 +00:00
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info), elf_link_output_extsym,
|
|
|
|
|
(PTR) &eoinfo);
|
|
|
|
|
if (eoinfo.failed)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-03-05 05:18:41 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* That wrote out all the local symbols. Finish up the symbol table
|
2000-03-01 19:40:54 +00:00
|
|
|
|
with the global symbols. Even if we want to strip everything we
|
|
|
|
|
can, we still need to deal with those global symbols that got
|
2001-01-03 22:53:39 +00:00
|
|
|
|
converted to local in a version script. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
1999-07-13 18:21:29 +00:00
|
|
|
|
/* The sh_info field records the index of the first non local symbol. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
symtab_hdr->sh_info = bfd_get_symcount (abfd);
|
1999-07-13 18:21:29 +00:00
|
|
|
|
|
2000-10-07 13:40:33 +00:00
|
|
|
|
if (dynamic
|
|
|
|
|
&& finfo.dynsym_sec->output_section != bfd_abs_section_ptr)
|
1999-07-13 18:21:29 +00:00
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Sym sym;
|
|
|
|
|
Elf_External_Sym *dynsym =
|
2001-08-09 14:38:04 +00:00
|
|
|
|
(Elf_External_Sym *) finfo.dynsym_sec->contents;
|
1999-10-28 04:08:57 +00:00
|
|
|
|
long last_local = 0;
|
1999-07-13 18:21:29 +00:00
|
|
|
|
|
|
|
|
|
/* Write out the section symbols for the output sections. */
|
|
|
|
|
if (info->shared)
|
|
|
|
|
{
|
|
|
|
|
asection *s;
|
|
|
|
|
|
|
|
|
|
sym.st_size = 0;
|
|
|
|
|
sym.st_name = 0;
|
|
|
|
|
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
|
|
|
|
|
sym.st_other = 0;
|
|
|
|
|
|
|
|
|
|
for (s = abfd->sections; s != NULL; s = s->next)
|
|
|
|
|
{
|
|
|
|
|
int indx;
|
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 00:52:35 +00:00
|
|
|
|
Elf_External_Sym *dest;
|
|
|
|
|
|
1999-07-13 18:21:29 +00:00
|
|
|
|
indx = elf_section_data (s)->this_idx;
|
|
|
|
|
BFD_ASSERT (indx > 0);
|
|
|
|
|
sym.st_shndx = indx;
|
|
|
|
|
sym.st_value = s->vma;
|
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 00:52:35 +00:00
|
|
|
|
dest = dynsym + elf_section_data (s)->dynindx;
|
|
|
|
|
elf_swap_symbol_out (abfd, &sym, (PTR) dest, (PTR) 0);
|
1999-07-13 18:21:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
last_local = bfd_count_sections (abfd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write out the local dynsyms. */
|
|
|
|
|
if (elf_hash_table (info)->dynlocal)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_local_dynamic_entry *e;
|
|
|
|
|
for (e = elf_hash_table (info)->dynlocal; e ; e = e->next)
|
|
|
|
|
{
|
1999-07-16 08:10:27 +00:00
|
|
|
|
asection *s;
|
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 00:52:35 +00:00
|
|
|
|
Elf_External_Sym *dest;
|
1999-07-13 18:21:29 +00:00
|
|
|
|
|
1999-08-10 03:36:28 +00:00
|
|
|
|
sym.st_size = e->isym.st_size;
|
|
|
|
|
sym.st_other = e->isym.st_other;
|
|
|
|
|
|
1999-08-02 22:31:18 +00:00
|
|
|
|
/* Copy the internal symbol as is.
|
|
|
|
|
Note that we saved a word of storage and overwrote
|
2002-03-05 05:18:41 +00:00
|
|
|
|
the original st_name with the dynstr_index. */
|
|
|
|
|
sym = e->isym;
|
1999-07-13 18:21:29 +00:00
|
|
|
|
|
2002-02-25 23:31:22 +00:00
|
|
|
|
if (e->isym.st_shndx != SHN_UNDEF
|
2002-07-16 12:31:35 +00:00
|
|
|
|
&& (e->isym.st_shndx < SHN_LORESERVE
|
|
|
|
|
|| e->isym.st_shndx > SHN_HIRESERVE))
|
1999-07-30 21:34:44 +00:00
|
|
|
|
{
|
|
|
|
|
s = bfd_section_from_elf_index (e->input_bfd,
|
|
|
|
|
e->isym.st_shndx);
|
|
|
|
|
|
|
|
|
|
sym.st_shndx =
|
|
|
|
|
elf_section_data (s->output_section)->this_idx;
|
|
|
|
|
sym.st_value = (s->output_section->vma
|
|
|
|
|
+ s->output_offset
|
|
|
|
|
+ e->isym.st_value);
|
|
|
|
|
}
|
1999-07-13 18:21:29 +00:00
|
|
|
|
|
|
|
|
|
if (last_local < e->dynindx)
|
|
|
|
|
last_local = e->dynindx;
|
|
|
|
|
|
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 00:52:35 +00:00
|
|
|
|
dest = dynsym + e->dynindx;
|
|
|
|
|
elf_swap_symbol_out (abfd, &sym, (PTR) dest, (PTR) 0);
|
1999-07-13 18:21:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-28 04:08:57 +00:00
|
|
|
|
elf_section_data (finfo.dynsym_sec->output_section)->this_hdr.sh_info =
|
|
|
|
|
last_local + 1;
|
1999-07-13 18:21:29 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* We get the global symbols from the hash table. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eoinfo.failed = FALSE;
|
|
|
|
|
eoinfo.localsyms = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
eoinfo.finfo = &finfo;
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info), elf_link_output_extsym,
|
|
|
|
|
(PTR) &eoinfo);
|
|
|
|
|
if (eoinfo.failed)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
1999-07-30 21:34:44 +00:00
|
|
|
|
/* If backend needs to output some symbols not present in the hash
|
|
|
|
|
table, do it now. */
|
|
|
|
|
if (bed->elf_backend_output_arch_syms)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
typedef bfd_boolean (*out_sym_func)
|
|
|
|
|
PARAMS ((PTR, const char *, Elf_Internal_Sym *, asection *));
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|
|
|
|
|
if (! ((*bed->elf_backend_output_arch_syms)
|
|
|
|
|
(abfd, info, (PTR) &finfo, (out_sym_func) elf_link_output_sym)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
}
|
1999-07-30 21:34:44 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Flush all symbols to the file. */
|
|
|
|
|
if (! elf_link_flush_output_syms (&finfo))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Now we know the size of the symtab section. */
|
|
|
|
|
off += symtab_hdr->sh_size;
|
|
|
|
|
|
2002-11-04 13:20:56 +00:00
|
|
|
|
symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
|
|
|
|
|
if (symtab_shndx_hdr->sh_name != 0)
|
|
|
|
|
{
|
|
|
|
|
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
|
|
|
|
|
symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
|
|
|
|
|
symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
|
|
|
|
|
amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
|
|
|
|
|
symtab_shndx_hdr->sh_size = amt;
|
|
|
|
|
|
|
|
|
|
off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
off, TRUE);
|
2002-11-04 13:20:56 +00:00
|
|
|
|
|
|
|
|
|
if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
|
|
|
|
|
|| (bfd_bwrite ((PTR) finfo.symshndxbuf, amt, abfd) != amt))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-11-04 13:20:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Finish up and write out the symbol string table (.strtab)
|
|
|
|
|
section. */
|
|
|
|
|
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
|
|
|
|
|
/* sh_name was set in prep_headers. */
|
|
|
|
|
symstrtab_hdr->sh_type = SHT_STRTAB;
|
|
|
|
|
symstrtab_hdr->sh_flags = 0;
|
|
|
|
|
symstrtab_hdr->sh_addr = 0;
|
|
|
|
|
symstrtab_hdr->sh_size = _bfd_stringtab_size (finfo.symstrtab);
|
|
|
|
|
symstrtab_hdr->sh_entsize = 0;
|
|
|
|
|
symstrtab_hdr->sh_link = 0;
|
|
|
|
|
symstrtab_hdr->sh_info = 0;
|
|
|
|
|
/* sh_offset is set just below. */
|
|
|
|
|
symstrtab_hdr->sh_addralign = 1;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_tdata (abfd)->next_file_pos = off;
|
|
|
|
|
|
|
|
|
|
if (bfd_get_symcount (abfd) > 0)
|
|
|
|
|
{
|
|
|
|
|
if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0
|
|
|
|
|
|| ! _bfd_stringtab_emit (abfd, finfo.symstrtab))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Adjust the relocs to have the correct symbol indices. */
|
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_RELOC) == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2001-01-03 22:53:39 +00:00
|
|
|
|
elf_link_adjust_relocs (abfd, &elf_section_data (o)->rel_hdr,
|
1999-07-18 06:31:29 +00:00
|
|
|
|
elf_section_data (o)->rel_count,
|
|
|
|
|
elf_section_data (o)->rel_hashes);
|
|
|
|
|
if (elf_section_data (o)->rel_hdr2 != NULL)
|
|
|
|
|
elf_link_adjust_relocs (abfd, elf_section_data (o)->rel_hdr2,
|
|
|
|
|
elf_section_data (o)->rel_count2,
|
2001-01-03 22:53:39 +00:00
|
|
|
|
(elf_section_data (o)->rel_hashes
|
1999-07-18 06:31:29 +00:00
|
|
|
|
+ elf_section_data (o)->rel_count));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Set the reloc_count field to 0 to prevent write_relocs from
|
|
|
|
|
trying to swap the relocs out itself. */
|
|
|
|
|
o->reloc_count = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-23 15:14:18 +00:00
|
|
|
|
if (dynamic && info->combreloc && dynobj != NULL)
|
|
|
|
|
relativecount = elf_link_sort_relocs (abfd, info, &reldyn);
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* If we are linking against a dynamic object, or generating a
|
|
|
|
|
shared library, finish up the dynamic linking information. */
|
|
|
|
|
if (dynamic)
|
|
|
|
|
{
|
|
|
|
|
Elf_External_Dyn *dyncon, *dynconend;
|
|
|
|
|
|
|
|
|
|
/* Fix up .dynamic entries. */
|
|
|
|
|
o = bfd_get_section_by_name (dynobj, ".dynamic");
|
|
|
|
|
BFD_ASSERT (o != NULL);
|
|
|
|
|
|
|
|
|
|
dyncon = (Elf_External_Dyn *) o->contents;
|
|
|
|
|
dynconend = (Elf_External_Dyn *) (o->contents + o->_raw_size);
|
|
|
|
|
for (; dyncon < dynconend; dyncon++)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Dyn dyn;
|
|
|
|
|
const char *name;
|
|
|
|
|
unsigned int type;
|
|
|
|
|
|
|
|
|
|
elf_swap_dyn_in (dynobj, dyncon, &dyn);
|
|
|
|
|
|
|
|
|
|
switch (dyn.d_tag)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2001-08-23 15:14:18 +00:00
|
|
|
|
case DT_NULL:
|
|
|
|
|
if (relativecount > 0 && dyncon + 1 < dynconend)
|
|
|
|
|
{
|
|
|
|
|
switch (elf_section_data (reldyn)->this_hdr.sh_type)
|
|
|
|
|
{
|
|
|
|
|
case SHT_REL: dyn.d_tag = DT_RELCOUNT; break;
|
|
|
|
|
case SHT_RELA: dyn.d_tag = DT_RELACOUNT; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
if (dyn.d_tag != DT_NULL)
|
|
|
|
|
{
|
|
|
|
|
dyn.d_un.d_val = relativecount;
|
|
|
|
|
elf_swap_dyn_out (dynobj, &dyn, dyncon);
|
|
|
|
|
relativecount = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
case DT_INIT:
|
1999-06-23 11:06:57 +00:00
|
|
|
|
name = info->init_function;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto get_sym;
|
|
|
|
|
case DT_FINI:
|
1999-06-23 11:06:57 +00:00
|
|
|
|
name = info->fini_function;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
get_sym:
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
h = elf_link_hash_lookup (elf_hash_table (info), name,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE, FALSE, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h != NULL
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
dyn.d_un.d_val = h->root.u.def.value;
|
|
|
|
|
o = h->root.u.def.section;
|
|
|
|
|
if (o->output_section != NULL)
|
|
|
|
|
dyn.d_un.d_val += (o->output_section->vma
|
|
|
|
|
+ o->output_offset);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* The symbol is imported from another shared
|
|
|
|
|
library and does not apply to this one. */
|
|
|
|
|
dyn.d_un.d_val = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elf_swap_dyn_out (dynobj, &dyn, dyncon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2002-03-02 01:24:50 +00:00
|
|
|
|
case DT_PREINIT_ARRAYSZ:
|
|
|
|
|
name = ".preinit_array";
|
|
|
|
|
goto get_size;
|
|
|
|
|
case DT_INIT_ARRAYSZ:
|
|
|
|
|
name = ".init_array";
|
|
|
|
|
goto get_size;
|
|
|
|
|
case DT_FINI_ARRAYSZ:
|
|
|
|
|
name = ".fini_array";
|
|
|
|
|
get_size:
|
|
|
|
|
o = bfd_get_section_by_name (abfd, name);
|
2002-06-12 18:14:05 +00:00
|
|
|
|
if (o == NULL)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: could not find output section %s"),
|
|
|
|
|
bfd_get_filename (abfd), name);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
2002-03-04 20:41:55 +00:00
|
|
|
|
if (o->_raw_size == 0)
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("warning: %s section has zero size"), name);
|
2002-03-02 01:24:50 +00:00
|
|
|
|
dyn.d_un.d_val = o->_raw_size;
|
|
|
|
|
elf_swap_dyn_out (dynobj, &dyn, dyncon);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DT_PREINIT_ARRAY:
|
|
|
|
|
name = ".preinit_array";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
case DT_INIT_ARRAY:
|
|
|
|
|
name = ".init_array";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
case DT_FINI_ARRAY:
|
|
|
|
|
name = ".fini_array";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
case DT_HASH:
|
|
|
|
|
name = ".hash";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
case DT_STRTAB:
|
|
|
|
|
name = ".dynstr";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
case DT_SYMTAB:
|
|
|
|
|
name = ".dynsym";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
case DT_VERDEF:
|
|
|
|
|
name = ".gnu.version_d";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
case DT_VERNEED:
|
|
|
|
|
name = ".gnu.version_r";
|
|
|
|
|
goto get_vma;
|
|
|
|
|
case DT_VERSYM:
|
|
|
|
|
name = ".gnu.version";
|
|
|
|
|
get_vma:
|
|
|
|
|
o = bfd_get_section_by_name (abfd, name);
|
2002-06-12 18:14:05 +00:00
|
|
|
|
if (o == NULL)
|
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: could not find output section %s"),
|
|
|
|
|
bfd_get_filename (abfd), name);
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
dyn.d_un.d_ptr = o->vma;
|
|
|
|
|
elf_swap_dyn_out (dynobj, &dyn, dyncon);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DT_REL:
|
|
|
|
|
case DT_RELA:
|
|
|
|
|
case DT_RELSZ:
|
|
|
|
|
case DT_RELASZ:
|
|
|
|
|
if (dyn.d_tag == DT_REL || dyn.d_tag == DT_RELSZ)
|
|
|
|
|
type = SHT_REL;
|
|
|
|
|
else
|
|
|
|
|
type = SHT_RELA;
|
|
|
|
|
dyn.d_un.d_val = 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 00:52:35 +00:00
|
|
|
|
for (i = 1; i < elf_numsections (abfd); i++)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Shdr *hdr;
|
|
|
|
|
|
|
|
|
|
hdr = elf_elfsections (abfd)[i];
|
|
|
|
|
if (hdr->sh_type == type
|
|
|
|
|
&& (hdr->sh_flags & SHF_ALLOC) != 0)
|
|
|
|
|
{
|
|
|
|
|
if (dyn.d_tag == DT_RELSZ || dyn.d_tag == DT_RELASZ)
|
|
|
|
|
dyn.d_un.d_val += hdr->sh_size;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (dyn.d_un.d_val == 0
|
|
|
|
|
|| hdr->sh_addr < dyn.d_un.d_val)
|
|
|
|
|
dyn.d_un.d_val = hdr->sh_addr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elf_swap_dyn_out (dynobj, &dyn, dyncon);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we have created any dynamic sections, then output them. */
|
|
|
|
|
if (dynobj != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (! (*bed->elf_backend_finish_dynamic_sections) (abfd, info))
|
|
|
|
|
goto error_return;
|
|
|
|
|
|
|
|
|
|
for (o = dynobj->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_HAS_CONTENTS) == 0
|
2000-10-07 13:40:33 +00:00
|
|
|
|
|| o->_raw_size == 0
|
|
|
|
|
|| o->output_section == bfd_abs_section_ptr)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
continue;
|
|
|
|
|
if ((o->flags & SEC_LINKER_CREATED) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* At this point, we are only interested in sections
|
2002-03-05 05:18:41 +00:00
|
|
|
|
created by elf_link_create_dynamic_sections. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ((elf_section_data (o->output_section)->this_hdr.sh_type
|
|
|
|
|
!= SHT_STRTAB)
|
|
|
|
|
|| strcmp (bfd_get_section_name (abfd, o), ".dynstr") != 0)
|
|
|
|
|
{
|
|
|
|
|
if (! bfd_set_section_contents (abfd, o->output_section,
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
o->contents,
|
|
|
|
|
(file_ptr) o->output_offset,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
o->_raw_size))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* The contents of the .dynstr section are actually in a
|
2002-03-05 05:18:41 +00:00
|
|
|
|
stringtab. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
off = elf_section_data (o->output_section)->this_hdr.sh_offset;
|
|
|
|
|
if (bfd_seek (abfd, off, SEEK_SET) != 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 16:50:38 +00:00
|
|
|
|
|| ! _bfd_elf_strtab_emit (abfd,
|
|
|
|
|
elf_hash_table (info)->dynstr))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-07 14:57:11 +00:00
|
|
|
|
if (info->relocateable)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean failed = FALSE;
|
2002-06-07 14:57:11 +00:00
|
|
|
|
|
|
|
|
|
bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed);
|
|
|
|
|
if (failed)
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* If we have optimized stabs strings, output them. */
|
|
|
|
|
if (elf_hash_table (info)->stab_info != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (! _bfd_write_stab_strings (abfd, &elf_hash_table (info)->stab_info))
|
|
|
|
|
goto error_return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-12 07:35:26 +00:00
|
|
|
|
if (info->eh_frame_hdr)
|
2001-12-13 11:09:34 +00:00
|
|
|
|
{
|
2002-11-12 07:35:26 +00:00
|
|
|
|
if (! _bfd_elf_write_section_eh_frame_hdr (abfd, info))
|
|
|
|
|
goto error_return;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (finfo.symstrtab != NULL)
|
|
|
|
|
_bfd_stringtab_free (finfo.symstrtab);
|
|
|
|
|
if (finfo.contents != NULL)
|
|
|
|
|
free (finfo.contents);
|
|
|
|
|
if (finfo.external_relocs != NULL)
|
|
|
|
|
free (finfo.external_relocs);
|
|
|
|
|
if (finfo.internal_relocs != NULL)
|
|
|
|
|
free (finfo.internal_relocs);
|
|
|
|
|
if (finfo.external_syms != NULL)
|
|
|
|
|
free (finfo.external_syms);
|
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 00:52:35 +00:00
|
|
|
|
if (finfo.locsym_shndx != NULL)
|
|
|
|
|
free (finfo.locsym_shndx);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (finfo.internal_syms != NULL)
|
|
|
|
|
free (finfo.internal_syms);
|
|
|
|
|
if (finfo.indices != NULL)
|
|
|
|
|
free (finfo.indices);
|
|
|
|
|
if (finfo.sections != NULL)
|
|
|
|
|
free (finfo.sections);
|
|
|
|
|
if (finfo.symbuf != NULL)
|
|
|
|
|
free (finfo.symbuf);
|
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 00:52:35 +00:00
|
|
|
|
if (finfo.symshndxbuf != NULL)
|
2002-11-04 13:20:56 +00:00
|
|
|
|
free (finfo.symshndxbuf);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_RELOC) != 0
|
|
|
|
|
&& elf_section_data (o)->rel_hashes != NULL)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
free (elf_section_data (o)->rel_hashes);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
elf_tdata (abfd)->linker = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
error_return:
|
|
|
|
|
if (finfo.symstrtab != NULL)
|
|
|
|
|
_bfd_stringtab_free (finfo.symstrtab);
|
|
|
|
|
if (finfo.contents != NULL)
|
|
|
|
|
free (finfo.contents);
|
|
|
|
|
if (finfo.external_relocs != NULL)
|
|
|
|
|
free (finfo.external_relocs);
|
|
|
|
|
if (finfo.internal_relocs != NULL)
|
|
|
|
|
free (finfo.internal_relocs);
|
|
|
|
|
if (finfo.external_syms != NULL)
|
|
|
|
|
free (finfo.external_syms);
|
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 00:52:35 +00:00
|
|
|
|
if (finfo.locsym_shndx != NULL)
|
|
|
|
|
free (finfo.locsym_shndx);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (finfo.internal_syms != NULL)
|
|
|
|
|
free (finfo.internal_syms);
|
|
|
|
|
if (finfo.indices != NULL)
|
|
|
|
|
free (finfo.indices);
|
|
|
|
|
if (finfo.sections != NULL)
|
|
|
|
|
free (finfo.sections);
|
|
|
|
|
if (finfo.symbuf != NULL)
|
|
|
|
|
free (finfo.symbuf);
|
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 00:52:35 +00:00
|
|
|
|
if (finfo.symshndxbuf != NULL)
|
2002-11-04 13:20:56 +00:00
|
|
|
|
free (finfo.symshndxbuf);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (o = abfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_RELOC) != 0
|
|
|
|
|
&& elf_section_data (o)->rel_hashes != NULL)
|
|
|
|
|
free (elf_section_data (o)->rel_hashes);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add a symbol to the output symbol table. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_output_sym (finfo, name, elfsym, input_sec)
|
|
|
|
|
struct elf_final_link_info *finfo;
|
|
|
|
|
const char *name;
|
|
|
|
|
Elf_Internal_Sym *elfsym;
|
|
|
|
|
asection *input_sec;
|
|
|
|
|
{
|
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 00:52:35 +00:00
|
|
|
|
Elf_External_Sym *dest;
|
|
|
|
|
Elf_External_Sym_Shndx *destshndx;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean (*output_symbol_hook)
|
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *info, const char *,
|
|
|
|
|
Elf_Internal_Sym *, asection *));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
output_symbol_hook = get_elf_backend_data (finfo->output_bfd)->
|
|
|
|
|
elf_backend_link_output_symbol_hook;
|
|
|
|
|
if (output_symbol_hook != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (! ((*output_symbol_hook)
|
|
|
|
|
(finfo->output_bfd, finfo->info, name, elfsym, input_sec)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name == (const char *) NULL || *name == '\0')
|
|
|
|
|
elfsym->st_name = 0;
|
|
|
|
|
else if (input_sec->flags & SEC_EXCLUDE)
|
|
|
|
|
elfsym->st_name = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
elfsym->st_name = (unsigned long) _bfd_stringtab_add (finfo->symstrtab,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
name, TRUE, FALSE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (elfsym->st_name == (unsigned long) -1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (finfo->symbuf_count >= finfo->symbuf_size)
|
|
|
|
|
{
|
|
|
|
|
if (! elf_link_flush_output_syms (finfo))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00: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 00:52:35 +00:00
|
|
|
|
dest = finfo->symbuf + finfo->symbuf_count;
|
|
|
|
|
destshndx = finfo->symshndxbuf;
|
|
|
|
|
if (destshndx != NULL)
|
2002-11-04 13:20:56 +00:00
|
|
|
|
{
|
|
|
|
|
if (bfd_get_symcount (finfo->output_bfd) >= finfo->shndxbuf_size)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type amt;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-04 13:20:56 +00:00
|
|
|
|
amt = finfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx);
|
|
|
|
|
finfo->symshndxbuf = destshndx = bfd_realloc (destshndx, amt * 2);
|
|
|
|
|
if (destshndx == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-11-04 13:20:56 +00:00
|
|
|
|
memset ((char *) destshndx + amt, 0, amt);
|
|
|
|
|
finfo->shndxbuf_size *= 2;
|
|
|
|
|
}
|
|
|
|
|
destshndx += bfd_get_symcount (finfo->output_bfd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elf_swap_symbol_out (finfo->output_bfd, elfsym, (PTR) dest, (PTR) destshndx);
|
|
|
|
|
finfo->symbuf_count += 1;
|
|
|
|
|
bfd_get_symcount (finfo->output_bfd) += 1;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flush the output symbols to the file. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_flush_output_syms (finfo)
|
|
|
|
|
struct elf_final_link_info *finfo;
|
|
|
|
|
{
|
|
|
|
|
if (finfo->symbuf_count > 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 00:52:35 +00:00
|
|
|
|
Elf_Internal_Shdr *hdr;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
file_ptr pos;
|
|
|
|
|
bfd_size_type amt;
|
1999-05-03 07:29:11 +00: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 00:52:35 +00:00
|
|
|
|
hdr = &elf_tdata (finfo->output_bfd)->symtab_hdr;
|
|
|
|
|
pos = hdr->sh_offset + hdr->sh_size;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = finfo->symbuf_count * sizeof (Elf_External_Sym);
|
|
|
|
|
if (bfd_seek (finfo->output_bfd, pos, SEEK_SET) != 0
|
|
|
|
|
|| bfd_bwrite ((PTR) finfo->symbuf, amt, finfo->output_bfd) != amt)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00: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 00:52:35 +00:00
|
|
|
|
hdr->sh_size += amt;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
finfo->symbuf_count = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-04-13 00:34:36 +00:00
|
|
|
|
/* Adjust all external symbols pointing into SEC_MERGE sections
|
|
|
|
|
to reflect the object merging within the sections. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
2001-04-13 00:34:36 +00:00
|
|
|
|
elf_link_sec_merge_syms (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
asection *sec;
|
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
2001-04-13 00:34:36 +00:00
|
|
|
|
if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& ((sec = h->root.u.def.section)->flags & SEC_MERGE)
|
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 12:34:08 +00:00
|
|
|
|
&& sec->sec_info_type == ELF_INFO_TYPE_MERGE)
|
2001-04-13 00:34:36 +00:00
|
|
|
|
{
|
|
|
|
|
bfd *output_bfd = (bfd *) data;
|
|
|
|
|
|
|
|
|
|
h->root.u.def.value =
|
|
|
|
|
_bfd_merged_section_offset (output_bfd,
|
|
|
|
|
&h->root.u.def.section,
|
2001-12-13 11:09:34 +00:00
|
|
|
|
elf_section_data (sec)->sec_info,
|
2001-04-13 00:34:36 +00:00
|
|
|
|
h->root.u.def.value, (bfd_vma) 0);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-04-13 00:34:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-23 02:04:28 +00:00
|
|
|
|
/* For DSOs loaded in via a DT_NEEDED entry, emulate ld.so in
|
|
|
|
|
allowing an unsatisfied unversioned symbol in the DSO to match a
|
|
|
|
|
versioned symbol that would normally require an explicit version. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
2002-06-23 02:04:28 +00:00
|
|
|
|
elf_link_check_versioned_symbol (info, h)
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
{
|
|
|
|
|
bfd *undef_bfd = h->root.u.undef.abfd;
|
|
|
|
|
struct elf_link_loaded_list *loaded;
|
|
|
|
|
|
|
|
|
|
if ((undef_bfd->flags & DYNAMIC) == 0
|
|
|
|
|
|| info->hash->creator->flavour != bfd_target_elf_flavour
|
|
|
|
|
|| elf_dt_soname (h->root.u.undef.abfd) == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-06-23 02:04:28 +00:00
|
|
|
|
|
|
|
|
|
for (loaded = elf_hash_table (info)->loaded;
|
|
|
|
|
loaded != NULL;
|
|
|
|
|
loaded = loaded->next)
|
|
|
|
|
{
|
|
|
|
|
bfd *input;
|
|
|
|
|
Elf_Internal_Shdr *hdr;
|
|
|
|
|
bfd_size_type symcount;
|
|
|
|
|
bfd_size_type extsymcount;
|
|
|
|
|
bfd_size_type extsymoff;
|
|
|
|
|
Elf_Internal_Shdr *versymhdr;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_Internal_Sym *isym;
|
|
|
|
|
Elf_Internal_Sym *isymend;
|
|
|
|
|
Elf_Internal_Sym *isymbuf;
|
2002-06-23 02:04:28 +00:00
|
|
|
|
Elf_External_Versym *ever;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_External_Versym *extversym;
|
2002-06-23 02:04:28 +00:00
|
|
|
|
|
|
|
|
|
input = loaded->abfd;
|
|
|
|
|
|
|
|
|
|
/* We check each DSO for a possible hidden versioned definition. */
|
|
|
|
|
if (input == undef_bfd
|
|
|
|
|
|| (input->flags & DYNAMIC) == 0
|
|
|
|
|
|| elf_dynversym (input) == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
hdr = &elf_tdata (input)->dynsymtab_hdr;
|
|
|
|
|
|
|
|
|
|
symcount = hdr->sh_size / sizeof (Elf_External_Sym);
|
|
|
|
|
if (elf_bad_symtab (input))
|
|
|
|
|
{
|
|
|
|
|
extsymcount = symcount;
|
|
|
|
|
extsymoff = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
extsymcount = symcount - hdr->sh_info;
|
|
|
|
|
extsymoff = hdr->sh_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (extsymcount == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isymbuf = bfd_elf_get_elf_syms (input, hdr, extsymcount, extsymoff,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
if (isymbuf == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-06-23 02:04:28 +00:00
|
|
|
|
|
|
|
|
|
/* Read in any version definitions. */
|
|
|
|
|
versymhdr = &elf_tdata (input)->dynversym_hdr;
|
|
|
|
|
extversym = (Elf_External_Versym *) bfd_malloc (versymhdr->sh_size);
|
|
|
|
|
if (extversym == NULL)
|
|
|
|
|
goto error_ret;
|
|
|
|
|
|
|
|
|
|
if (bfd_seek (input, versymhdr->sh_offset, SEEK_SET) != 0
|
|
|
|
|
|| (bfd_bread ((PTR) extversym, versymhdr->sh_size, input)
|
|
|
|
|
!= versymhdr->sh_size))
|
|
|
|
|
{
|
|
|
|
|
free (extversym);
|
|
|
|
|
error_ret:
|
2002-07-07 09:10:41 +00:00
|
|
|
|
free (isymbuf);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-06-23 02:04:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ever = extversym + extsymoff;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isymend = isymbuf + extsymcount;
|
|
|
|
|
for (isym = isymbuf; isym < isymend; isym++, ever++)
|
2002-06-23 02:04:28 +00:00
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
Elf_Internal_Versym iver;
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (ELF_ST_BIND (isym->st_info) == STB_LOCAL
|
|
|
|
|
|| isym->st_shndx == SHN_UNDEF)
|
2002-06-23 02:04:28 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
name = bfd_elf_string_from_elf_section (input,
|
|
|
|
|
hdr->sh_link,
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isym->st_name);
|
2002-06-23 02:04:28 +00:00
|
|
|
|
if (strcmp (name, h->root.root.string) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
_bfd_elf_swap_versym_in (input, ever, &iver);
|
|
|
|
|
|
|
|
|
|
if ((iver.vs_vers & VERSYM_HIDDEN) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* If we have a non-hidden versioned sym, then it should
|
|
|
|
|
have provided a definition for the undefined sym. */
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((iver.vs_vers & VERSYM_VERSION) == 2)
|
|
|
|
|
{
|
|
|
|
|
/* This is the oldest (default) sym. We can use it. */
|
|
|
|
|
free (extversym);
|
2002-07-07 09:10:41 +00:00
|
|
|
|
free (isymbuf);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2002-06-23 02:04:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (extversym);
|
2002-07-07 09:10:41 +00:00
|
|
|
|
free (isymbuf);
|
2002-06-23 02:04:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-06-23 02:04:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Add an external symbol to the symbol table. This is called from
|
|
|
|
|
the hash table traversal routine. When generating a shared object,
|
|
|
|
|
we go through the symbol table twice. The first time we output
|
|
|
|
|
anything that might have been forced to local scope in a version
|
|
|
|
|
script. The second time we output the symbols that are still
|
|
|
|
|
global symbols. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_output_extsym (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
struct elf_outext_info *eoinfo = (struct elf_outext_info *) data;
|
|
|
|
|
struct elf_final_link_info *finfo = eoinfo->finfo;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean strip;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
Elf_Internal_Sym sym;
|
|
|
|
|
asection *input_sec;
|
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
{
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
if (h->root.type == bfd_link_hash_new)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2002-03-28 03:27:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Decide whether to output this symbol in this pass. */
|
|
|
|
|
if (eoinfo->localsyms)
|
|
|
|
|
{
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we are not creating a shared library, and this symbol is
|
|
|
|
|
referenced by a shared library but is not defined anywhere, then
|
|
|
|
|
warn that it is undefined. If we do not do this, the runtime
|
|
|
|
|
linker will complain that the symbol is undefined when the
|
|
|
|
|
program is run. We don't have to worry about symbols that are
|
|
|
|
|
referenced by regular files, because we will already have issued
|
|
|
|
|
warnings for them. */
|
|
|
|
|
if (! finfo->info->relocateable
|
2003-02-17 18:24:40 +00:00
|
|
|
|
&& (! finfo->info->shared || ! finfo->info->allow_shlib_undefined)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& h->root.type == bfd_link_hash_undefined
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
|
2002-06-23 02:04:28 +00:00
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
|
|
|
|
|
&& ! elf_link_check_versioned_symbol (finfo->info, h))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (! ((*finfo->info->callbacks->undefined_symbol)
|
|
|
|
|
(finfo->info, h->root.root.string, h->root.u.undef.abfd,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(asection *) NULL, (bfd_vma) 0, TRUE)))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eoinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We don't want to output symbols that have never been mentioned by
|
|
|
|
|
a regular file, or that we have been told to strip. However, if
|
|
|
|
|
h->indx is set to -2, the symbol is used by a reloc and we must
|
|
|
|
|
output it. */
|
|
|
|
|
if (h->indx == -2)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
strip = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else if (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|
|
|
|
|| (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
strip = TRUE;
|
2002-12-23 11:53:59 +00:00
|
|
|
|
else if (finfo->info->strip == strip_all)
|
|
|
|
|
strip = TRUE;
|
|
|
|
|
else if (finfo->info->strip == strip_some
|
|
|
|
|
&& bfd_hash_lookup (finfo->info->keep_hash,
|
|
|
|
|
h->root.root.string, FALSE, FALSE) == NULL)
|
|
|
|
|
strip = TRUE;
|
|
|
|
|
else if (finfo->info->strip_discarded
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& elf_discarded_section (h->root.u.def.section))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
strip = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
strip = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If we're stripping it, and it's not a dynamic symbol, there's
|
2000-02-22 05:51:02 +00:00
|
|
|
|
nothing else to do unless it is a forced local symbol. */
|
|
|
|
|
if (strip
|
|
|
|
|
&& h->dynindx == -1
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
sym.st_value = 0;
|
|
|
|
|
sym.st_size = h->size;
|
|
|
|
|
sym.st_other = h->other;
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
|
|
|
|
|
sym.st_info = ELF_ST_INFO (STB_LOCAL, h->type);
|
|
|
|
|
else if (h->root.type == bfd_link_hash_undefweak
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
|
|
|
|
sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
|
|
|
|
|
else
|
|
|
|
|
sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
|
|
|
|
|
|
|
|
|
|
switch (h->root.type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case bfd_link_hash_new:
|
2002-03-28 03:27:46 +00:00
|
|
|
|
case bfd_link_hash_warning:
|
1999-05-03 07:29:11 +00:00
|
|
|
|
abort ();
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
case bfd_link_hash_undefined:
|
|
|
|
|
case bfd_link_hash_undefweak:
|
|
|
|
|
input_sec = bfd_und_section_ptr;
|
|
|
|
|
sym.st_shndx = SHN_UNDEF;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_defined:
|
|
|
|
|
case bfd_link_hash_defweak:
|
|
|
|
|
{
|
|
|
|
|
input_sec = h->root.u.def.section;
|
|
|
|
|
if (input_sec->output_section != NULL)
|
|
|
|
|
{
|
|
|
|
|
sym.st_shndx =
|
|
|
|
|
_bfd_elf_section_from_bfd_section (finfo->output_bfd,
|
|
|
|
|
input_sec->output_section);
|
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 00:52:35 +00:00
|
|
|
|
if (sym.st_shndx == SHN_BAD)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: could not find output section %s for input section %s"),
|
|
|
|
|
bfd_get_filename (finfo->output_bfd),
|
|
|
|
|
input_sec->output_section->name,
|
|
|
|
|
input_sec->name);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eoinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ELF symbols in relocateable files are section relative,
|
|
|
|
|
but in nonrelocateable files they are virtual
|
|
|
|
|
addresses. */
|
|
|
|
|
sym.st_value = h->root.u.def.value + input_sec->output_offset;
|
|
|
|
|
if (! finfo->info->relocateable)
|
* 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 13:12:53 +00:00
|
|
|
|
{
|
|
|
|
|
sym.st_value += input_sec->output_section->vma;
|
|
|
|
|
if (h->type == STT_TLS)
|
|
|
|
|
{
|
|
|
|
|
/* STT_TLS symbols are relative to PT_TLS segment
|
|
|
|
|
base. */
|
|
|
|
|
BFD_ASSERT (finfo->first_tls_sec != NULL);
|
|
|
|
|
sym.st_value -= finfo->first_tls_sec->vma;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (input_sec->owner == NULL
|
|
|
|
|
|| (input_sec->owner->flags & DYNAMIC) != 0);
|
|
|
|
|
sym.st_shndx = SHN_UNDEF;
|
|
|
|
|
input_sec = bfd_und_section_ptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_common:
|
|
|
|
|
input_sec = h->root.u.c.p->section;
|
|
|
|
|
sym.st_shndx = SHN_COMMON;
|
|
|
|
|
sym.st_value = 1 << h->root.u.c.p->alignment_power;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_link_hash_indirect:
|
|
|
|
|
/* These symbols are created by symbol versioning. They point
|
2002-03-05 05:18:41 +00:00
|
|
|
|
to the decorated version of the name. For example, if the
|
|
|
|
|
symbol foo@@GNU_1.2 is the default, which should be used when
|
|
|
|
|
foo is used with no version, then we add an indirect symbol
|
|
|
|
|
foo which points to foo@@GNU_1.2. We ignore these symbols,
|
|
|
|
|
since the indirected symbol is already in the hash table. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Give the processor backend a chance to tweak the symbol value,
|
|
|
|
|
and also to finish up anything that needs to be done for this
|
2002-03-05 05:18:41 +00:00
|
|
|
|
symbol. FIXME: Not calling elf_backend_finish_dynamic_symbol for
|
|
|
|
|
forced local syms when non-shared is due to a historical quirk. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if ((h->dynindx != -1
|
|
|
|
|
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
&& (finfo->info->shared
|
|
|
|
|
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& elf_hash_table (finfo->info)->dynamic_sections_created)
|
|
|
|
|
{
|
|
|
|
|
struct elf_backend_data *bed;
|
|
|
|
|
|
|
|
|
|
bed = get_elf_backend_data (finfo->output_bfd);
|
|
|
|
|
if (! ((*bed->elf_backend_finish_dynamic_symbol)
|
|
|
|
|
(finfo->output_bfd, finfo->info, h, &sym)))
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eoinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we are marking the symbol as undefined, and there are no
|
|
|
|
|
non-weak references to this symbol from a regular object, then
|
1999-08-09 05:42:31 +00:00
|
|
|
|
mark the symbol as weak undefined; if there are non-weak
|
|
|
|
|
references, mark the symbol as strong. We can't do this earlier,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
because it might not be marked as undefined until the
|
|
|
|
|
finish_dynamic_symbol routine gets through with it. */
|
|
|
|
|
if (sym.st_shndx == SHN_UNDEF
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) != 0
|
2001-08-09 14:38:04 +00:00
|
|
|
|
&& (ELF_ST_BIND (sym.st_info) == STB_GLOBAL
|
|
|
|
|
|| ELF_ST_BIND (sym.st_info) == STB_WEAK))
|
1999-08-09 05:42:31 +00:00
|
|
|
|
{
|
|
|
|
|
int bindtype;
|
|
|
|
|
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK) != 0)
|
|
|
|
|
bindtype = STB_GLOBAL;
|
|
|
|
|
else
|
|
|
|
|
bindtype = STB_WEAK;
|
|
|
|
|
sym.st_info = ELF_ST_INFO (bindtype, ELF_ST_TYPE (sym.st_info));
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-21 18:52:36 +00:00
|
|
|
|
/* If a symbol is not defined locally, we clear the visibility field. */
|
2001-10-31 16:42:48 +00:00
|
|
|
|
if (! finfo->info->relocateable
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
2002-11-21 18:52:36 +00:00
|
|
|
|
sym.st_other &= ~ ELF_ST_VISIBILITY (-1);
|
2000-05-22 07:26:58 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* If this symbol should be put in the .dynsym section, then put it
|
2002-06-23 02:04:28 +00:00
|
|
|
|
there now. We already know the symbol index. We also fill in
|
|
|
|
|
the entry in the .hash section. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->dynindx != -1
|
|
|
|
|
&& elf_hash_table (finfo->info)->dynamic_sections_created)
|
|
|
|
|
{
|
|
|
|
|
size_t bucketcount;
|
|
|
|
|
size_t bucket;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
size_t hash_entry_size;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_byte *bucketpos;
|
|
|
|
|
bfd_vma chain;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
Elf_External_Sym *esym;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
sym.st_name = h->dynstr_index;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
esym = (Elf_External_Sym *) finfo->dynsym_sec->contents + h->dynindx;
|
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 00:52:35 +00:00
|
|
|
|
elf_swap_symbol_out (finfo->output_bfd, &sym, (PTR) esym, (PTR) 0);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
bucketcount = elf_hash_table (finfo->info)->bucketcount;
|
|
|
|
|
bucket = h->elf_hash_value % bucketcount;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
hash_entry_size
|
1999-07-07 17:50:56 +00:00
|
|
|
|
= elf_section_data (finfo->hash_sec)->this_hdr.sh_entsize;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bucketpos = ((bfd_byte *) finfo->hash_sec->contents
|
1999-07-07 17:50:56 +00:00
|
|
|
|
+ (bucket + 2) * hash_entry_size);
|
|
|
|
|
chain = bfd_get (8 * hash_entry_size, finfo->output_bfd, bucketpos);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
bfd_put (8 * hash_entry_size, finfo->output_bfd, (bfd_vma) h->dynindx,
|
|
|
|
|
bucketpos);
|
1999-07-07 17:50:56 +00:00
|
|
|
|
bfd_put (8 * hash_entry_size, finfo->output_bfd, chain,
|
|
|
|
|
((bfd_byte *) finfo->hash_sec->contents
|
|
|
|
|
+ (bucketcount + 2 + h->dynindx) * hash_entry_size));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (finfo->symver_sec != NULL && finfo->symver_sec->contents != NULL)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Versym iversym;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
Elf_External_Versym *eversym;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (h->verinfo.verdef == NULL)
|
|
|
|
|
iversym.vs_vers = 0;
|
|
|
|
|
else
|
|
|
|
|
iversym.vs_vers = h->verinfo.verdef->vd_exp_refno + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (h->verinfo.vertree == NULL)
|
|
|
|
|
iversym.vs_vers = 1;
|
|
|
|
|
else
|
|
|
|
|
iversym.vs_vers = h->verinfo.vertree->vernum + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((h->elf_link_hash_flags & ELF_LINK_HIDDEN) != 0)
|
|
|
|
|
iversym.vs_vers |= VERSYM_HIDDEN;
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
eversym = (Elf_External_Versym *) finfo->symver_sec->contents;
|
|
|
|
|
eversym += h->dynindx;
|
|
|
|
|
_bfd_elf_swap_versym_out (finfo->output_bfd, &iversym, eversym);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we're stripping it, then it was just a dynamic symbol, and
|
|
|
|
|
there's nothing else to do. */
|
2002-08-08 00:20:16 +00:00
|
|
|
|
if (strip || (input_sec->flags & SEC_EXCLUDE) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
h->indx = bfd_get_symcount (finfo->output_bfd);
|
|
|
|
|
|
|
|
|
|
if (! elf_link_output_sym (finfo, h->root.root.string, &sym, input_sec))
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
eoinfo->failed = TRUE;
|
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-01 23:20:08 +00:00
|
|
|
|
/* Copy the relocations indicated by the INTERNAL_RELOCS (which
|
|
|
|
|
originated from the section given by INPUT_REL_HDR) to the
|
|
|
|
|
OUTPUT_BFD. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
2001-01-03 22:53:39 +00:00
|
|
|
|
elf_link_output_relocs (output_bfd, input_section, input_rel_hdr,
|
1999-07-01 23:20:08 +00:00
|
|
|
|
internal_relocs)
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
asection *input_section;
|
|
|
|
|
Elf_Internal_Shdr *input_rel_hdr;
|
|
|
|
|
Elf_Internal_Rela *internal_relocs;
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela *irela;
|
|
|
|
|
Elf_Internal_Rela *irelaend;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
bfd_byte *erel;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
Elf_Internal_Shdr *output_rel_hdr;
|
|
|
|
|
asection *output_section;
|
1999-07-11 19:49:48 +00:00
|
|
|
|
unsigned int *rel_countp = NULL;
|
2000-06-16 23:01:00 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
|
1999-07-01 23:20:08 +00:00
|
|
|
|
|
|
|
|
|
output_section = input_section->output_section;
|
|
|
|
|
output_rel_hdr = NULL;
|
|
|
|
|
|
2001-01-03 22:53:39 +00:00
|
|
|
|
if (elf_section_data (output_section)->rel_hdr.sh_entsize
|
1999-07-01 23:20:08 +00:00
|
|
|
|
== input_rel_hdr->sh_entsize)
|
|
|
|
|
{
|
|
|
|
|
output_rel_hdr = &elf_section_data (output_section)->rel_hdr;
|
|
|
|
|
rel_countp = &elf_section_data (output_section)->rel_count;
|
|
|
|
|
}
|
|
|
|
|
else if (elf_section_data (output_section)->rel_hdr2
|
|
|
|
|
&& (elf_section_data (output_section)->rel_hdr2->sh_entsize
|
|
|
|
|
== input_rel_hdr->sh_entsize))
|
|
|
|
|
{
|
|
|
|
|
output_rel_hdr = elf_section_data (output_section)->rel_hdr2;
|
|
|
|
|
rel_countp = &elf_section_data (output_section)->rel_count2;
|
|
|
|
|
}
|
2002-05-21 16:03:46 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-07-16 12:31:35 +00:00
|
|
|
|
(*_bfd_error_handler)
|
|
|
|
|
(_("%s: relocation size mismatch in %s section %s"),
|
|
|
|
|
bfd_get_filename (output_bfd),
|
|
|
|
|
bfd_archive_filename (input_section->owner),
|
|
|
|
|
input_section->name);
|
2002-05-21 16:03:46 +00:00
|
|
|
|
bfd_set_error (bfd_error_wrong_object_format);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-05-21 16:03:46 +00:00
|
|
|
|
}
|
2000-06-16 23:01:00 +00:00
|
|
|
|
|
|
|
|
|
bed = get_elf_backend_data (output_bfd);
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
|
|
|
|
|
swap_out = bed->s->swap_reloc_out;
|
|
|
|
|
else if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rela))
|
|
|
|
|
swap_out = bed->s->swap_reloca_out;
|
|
|
|
|
else
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
erel = output_rel_hdr->contents;
|
|
|
|
|
erel += *rel_countp * input_rel_hdr->sh_entsize;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
irela = internal_relocs;
|
2002-07-16 12:31:35 +00:00
|
|
|
|
irelaend = irela + (NUM_SHDR_ENTRIES (input_rel_hdr)
|
|
|
|
|
* bed->s->int_rels_per_ext_rel);
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
while (irela < irelaend)
|
1999-07-01 23:20:08 +00:00
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
(*swap_out) (output_bfd, irela, erel);
|
|
|
|
|
irela += bed->s->int_rels_per_ext_rel;
|
|
|
|
|
erel += input_rel_hdr->sh_entsize;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Bump the counter, so that we know where to add the next set of
|
|
|
|
|
relocations. */
|
2001-05-23 08:23:27 +00:00
|
|
|
|
*rel_countp += NUM_SHDR_ENTRIES (input_rel_hdr);
|
2002-05-21 16:03:46 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-07-01 23:20:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Link an input file into the linker output file. This function
|
|
|
|
|
handles all the sections and relocations of the input file at once.
|
|
|
|
|
This is so that we only have to read the local symbols once, and
|
|
|
|
|
don't have to keep them in memory. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_input_bfd (finfo, input_bfd)
|
|
|
|
|
struct elf_final_link_info *finfo;
|
|
|
|
|
bfd *input_bfd;
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean (*relocate_section)
|
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
|
|
|
|
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
Elf_Internal_Shdr *symtab_hdr;
|
|
|
|
|
size_t locsymcount;
|
|
|
|
|
size_t extsymoff;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_Internal_Sym *isymbuf;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
Elf_Internal_Sym *isym;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_Internal_Sym *isymend;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
long *pindex;
|
|
|
|
|
asection **ppsection;
|
|
|
|
|
asection *o;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean emit_relocs;
|
2001-11-06 17:49:38 +00:00
|
|
|
|
struct elf_link_hash_entry **sym_hashes;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
output_bfd = finfo->output_bfd;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
bed = get_elf_backend_data (output_bfd);
|
|
|
|
|
relocate_section = bed->elf_backend_relocate_section;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If this is a dynamic object, we don't want to do anything here:
|
|
|
|
|
we don't want the local symbols, and we don't want the section
|
|
|
|
|
contents. */
|
|
|
|
|
if ((input_bfd->flags & DYNAMIC) != 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-06-20 20:34:10 +00:00
|
|
|
|
emit_relocs = (finfo->info->relocateable
|
2002-03-05 05:18:41 +00:00
|
|
|
|
|| finfo->info->emitrelocations
|
|
|
|
|
|| bed->elf_backend_emit_relocs);
|
2001-06-20 20:34:10 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
|
|
|
|
if (elf_bad_symtab (input_bfd))
|
|
|
|
|
{
|
|
|
|
|
locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
|
|
|
|
|
extsymoff = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
locsymcount = symtab_hdr->sh_info;
|
|
|
|
|
extsymoff = symtab_hdr->sh_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read the local symbols. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
|
|
|
|
|
if (isymbuf == NULL && locsymcount != 0)
|
|
|
|
|
{
|
|
|
|
|
isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, locsymcount, 0,
|
|
|
|
|
finfo->internal_syms,
|
|
|
|
|
finfo->external_syms,
|
|
|
|
|
finfo->locsym_shndx);
|
|
|
|
|
if (isymbuf == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
/* Find local symbol sections and adjust values of symbols in
|
|
|
|
|
SEC_MERGE sections. Write out those local symbols we know are
|
|
|
|
|
going into the output file. */
|
|
|
|
|
isymend = isymbuf + locsymcount;
|
|
|
|
|
for (isym = isymbuf, pindex = finfo->indices, ppsection = finfo->sections;
|
|
|
|
|
isym < isymend;
|
|
|
|
|
isym++, pindex++, ppsection++)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
asection *isec;
|
|
|
|
|
const char *name;
|
|
|
|
|
Elf_Internal_Sym osym;
|
|
|
|
|
|
|
|
|
|
*pindex = -1;
|
|
|
|
|
|
|
|
|
|
if (elf_bad_symtab (input_bfd))
|
|
|
|
|
{
|
|
|
|
|
if (ELF_ST_BIND (isym->st_info) != STB_LOCAL)
|
|
|
|
|
{
|
|
|
|
|
*ppsection = NULL;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isym->st_shndx == SHN_UNDEF)
|
2001-09-29 12:07:01 +00:00
|
|
|
|
isec = bfd_und_section_ptr;
|
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 00:52:35 +00:00
|
|
|
|
else if (isym->st_shndx < SHN_LORESERVE
|
|
|
|
|
|| isym->st_shndx > SHN_HIRESERVE)
|
2001-04-13 00:34:36 +00:00
|
|
|
|
{
|
|
|
|
|
isec = section_from_elf_index (input_bfd, isym->st_shndx);
|
2001-12-13 11:09:34 +00:00
|
|
|
|
if (isec
|
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 12:34:08 +00:00
|
|
|
|
&& isec->sec_info_type == ELF_INFO_TYPE_MERGE
|
2001-04-13 00:34:36 +00:00
|
|
|
|
&& ELF_ST_TYPE (isym->st_info) != STT_SECTION)
|
|
|
|
|
isym->st_value =
|
|
|
|
|
_bfd_merged_section_offset (output_bfd, &isec,
|
2001-12-13 11:09:34 +00:00
|
|
|
|
elf_section_data (isec)->sec_info,
|
2001-04-13 00:34:36 +00:00
|
|
|
|
isym->st_value, (bfd_vma) 0);
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else if (isym->st_shndx == SHN_ABS)
|
2001-09-29 12:07:01 +00:00
|
|
|
|
isec = bfd_abs_section_ptr;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else if (isym->st_shndx == SHN_COMMON)
|
2001-09-29 12:07:01 +00:00
|
|
|
|
isec = bfd_com_section_ptr;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Who knows? */
|
|
|
|
|
isec = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*ppsection = isec;
|
|
|
|
|
|
|
|
|
|
/* Don't output the first, undefined, symbol. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (ppsection == finfo->sections)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2000-10-12 03:44:51 +00:00
|
|
|
|
if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
|
|
|
|
|
{
|
|
|
|
|
/* We never output section symbols. Instead, we use the
|
|
|
|
|
section symbol of the corresponding section in the output
|
|
|
|
|
file. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* If we are stripping all symbols, we don't want to output this
|
|
|
|
|
one. */
|
|
|
|
|
if (finfo->info->strip == strip_all)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* If we are discarding all local symbols, we don't want to
|
|
|
|
|
output this one. If we are generating a relocateable output
|
|
|
|
|
file, then some of the local symbols may be required by
|
|
|
|
|
relocs; we output them below as we discover that they are
|
|
|
|
|
needed. */
|
|
|
|
|
if (finfo->info->discard == discard_all)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* If this symbol is defined in a section which we are
|
2002-03-05 05:18:41 +00:00
|
|
|
|
discarding, we don't need to keep it, but note that
|
|
|
|
|
linker_mark is only reliable for sections that have contents.
|
|
|
|
|
For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
|
|
|
|
|
as well as linker_mark. */
|
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 00:52:35 +00:00
|
|
|
|
if ((isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& isec != NULL
|
|
|
|
|
&& ((! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
|
|
|
|
|
|| (! finfo->info->relocateable
|
|
|
|
|
&& (isec->flags & SEC_EXCLUDE) != 0)))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Get the name of the symbol. */
|
|
|
|
|
name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link,
|
|
|
|
|
isym->st_name);
|
|
|
|
|
if (name == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* See if we are discarding symbols with this name. */
|
|
|
|
|
if ((finfo->info->strip == strip_some
|
2002-11-30 08:39:46 +00:00
|
|
|
|
&& (bfd_hash_lookup (finfo->info->keep_hash, name, FALSE, FALSE)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
== NULL))
|
2001-04-13 00:34:36 +00:00
|
|
|
|
|| (((finfo->info->discard == discard_sec_merge
|
|
|
|
|
&& (isec->flags & SEC_MERGE) && ! finfo->info->relocateable)
|
|
|
|
|
|| finfo->info->discard == discard_l)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
&& bfd_is_local_label_name (input_bfd, name)))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* If we get here, we are going to output this symbol. */
|
|
|
|
|
|
|
|
|
|
osym = *isym;
|
|
|
|
|
|
|
|
|
|
/* Adjust the section index for the output file. */
|
|
|
|
|
osym.st_shndx = _bfd_elf_section_from_bfd_section (output_bfd,
|
|
|
|
|
isec->output_section);
|
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 00:52:35 +00:00
|
|
|
|
if (osym.st_shndx == SHN_BAD)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
*pindex = bfd_get_symcount (output_bfd);
|
|
|
|
|
|
|
|
|
|
/* ELF symbols in relocateable files are section relative, but
|
|
|
|
|
in executable files they are virtual addresses. Note that
|
|
|
|
|
this code assumes that all ELF sections have an associated
|
|
|
|
|
BFD section with a reasonable value for output_offset; below
|
|
|
|
|
we assume that they also have a reasonable value for
|
|
|
|
|
output_section. Any special sections must be set up to meet
|
|
|
|
|
these requirements. */
|
|
|
|
|
osym.st_value += isec->output_offset;
|
|
|
|
|
if (! finfo->info->relocateable)
|
* 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 13:12:53 +00:00
|
|
|
|
{
|
|
|
|
|
osym.st_value += isec->output_section->vma;
|
|
|
|
|
if (ELF_ST_TYPE (osym.st_info) == STT_TLS)
|
|
|
|
|
{
|
|
|
|
|
/* STT_TLS symbols are relative to PT_TLS segment base. */
|
|
|
|
|
BFD_ASSERT (finfo->first_tls_sec != NULL);
|
|
|
|
|
osym.st_value -= finfo->first_tls_sec->vma;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (! elf_link_output_sym (finfo, name, &osym, isec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Relocate the contents of each section. */
|
2001-11-06 17:49:38 +00:00
|
|
|
|
sym_hashes = elf_sym_hashes (input_bfd);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (o = input_bfd->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
bfd_byte *contents;
|
|
|
|
|
|
|
|
|
|
if (! o->linker_mark)
|
|
|
|
|
{
|
|
|
|
|
/* This section was omitted from the link. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((o->flags & SEC_HAS_CONTENTS) == 0
|
|
|
|
|
|| (o->_raw_size == 0 && (o->flags & SEC_RELOC) == 0))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ((o->flags & SEC_LINKER_CREATED) != 0)
|
|
|
|
|
{
|
|
|
|
|
/* Section was created by elf_link_create_dynamic_sections
|
|
|
|
|
or somesuch. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the contents of the section. They have been cached by a
|
2002-03-05 05:18:41 +00:00
|
|
|
|
relaxation routine. Note that o is a section in an input
|
|
|
|
|
file, so the contents field will not have been set by any of
|
|
|
|
|
the routines which work on output files. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (elf_section_data (o)->this_hdr.contents != NULL)
|
|
|
|
|
contents = elf_section_data (o)->this_hdr.contents;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
contents = finfo->contents;
|
|
|
|
|
if (! bfd_get_section_contents (input_bfd, o, contents,
|
|
|
|
|
(file_ptr) 0, o->_raw_size))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((o->flags & SEC_RELOC) != 0)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela *internal_relocs;
|
|
|
|
|
|
|
|
|
|
/* Get the swapped relocs. */
|
|
|
|
|
internal_relocs = (NAME(_bfd_elf,link_read_relocs)
|
|
|
|
|
(input_bfd, o, finfo->external_relocs,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
finfo->internal_relocs, FALSE));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (internal_relocs == NULL
|
|
|
|
|
&& o->reloc_count > 0)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-11-10 00:23:35 +00:00
|
|
|
|
/* Run through the relocs looking for any against symbols
|
|
|
|
|
from discarded sections and section symbols from
|
|
|
|
|
removed link-once sections. Complain about relocs
|
|
|
|
|
against discarded sections. Zero relocs against removed
|
2002-11-12 07:35:26 +00:00
|
|
|
|
link-once sections. */
|
2001-11-15 01:34:12 +00:00
|
|
|
|
if (!finfo->info->relocateable
|
|
|
|
|
&& !elf_section_ignore_discarded_relocs (o))
|
2001-11-10 00:23:35 +00:00
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela *rel, *relend;
|
2001-10-06 07:25:40 +00:00
|
|
|
|
|
2001-11-10 00:23:35 +00:00
|
|
|
|
rel = internal_relocs;
|
|
|
|
|
relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel;
|
|
|
|
|
for ( ; rel < relend; rel++)
|
|
|
|
|
{
|
|
|
|
|
unsigned long r_symndx = ELF_R_SYM (rel->r_info);
|
|
|
|
|
|
|
|
|
|
if (r_symndx >= locsymcount
|
|
|
|
|
|| (elf_bad_symtab (input_bfd)
|
|
|
|
|
&& finfo->sections[r_symndx] == NULL))
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
h = sym_hashes[r_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;
|
|
|
|
|
|
|
|
|
|
/* Complain if the definition comes from a
|
|
|
|
|
discarded section. */
|
|
|
|
|
if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
2001-12-17 22:44:12 +00:00
|
|
|
|
&& elf_discarded_section (h->root.u.def.section))
|
2001-11-10 00:23:35 +00:00
|
|
|
|
{
|
|
|
|
|
if ((o->flags & SEC_DEBUGGING) != 0)
|
|
|
|
|
{
|
2001-11-20 00:54:51 +00:00
|
|
|
|
BFD_ASSERT (r_symndx != 0);
|
2001-11-06 17:49:38 +00:00
|
|
|
|
memset (rel, 0, sizeof (*rel));
|
2001-11-10 00:23:35 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! ((*finfo->info->callbacks->undefined_symbol)
|
|
|
|
|
(finfo->info, h->root.root.string,
|
|
|
|
|
input_bfd, o, rel->r_offset,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
TRUE)))
|
|
|
|
|
return FALSE;
|
2001-11-10 00:23:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2001-11-15 09:31:25 +00:00
|
|
|
|
asection *sec = finfo->sections[r_symndx];
|
2001-10-06 07:25:40 +00:00
|
|
|
|
|
2001-12-17 22:44:12 +00:00
|
|
|
|
if (sec != NULL && elf_discarded_section (sec))
|
2001-11-15 09:31:25 +00:00
|
|
|
|
{
|
2002-03-26 18:13:54 +00:00
|
|
|
|
if ((o->flags & SEC_DEBUGGING) != 0
|
|
|
|
|
|| (sec->flags & SEC_LINK_ONCE) != 0)
|
2001-11-15 09:31:25 +00:00
|
|
|
|
{
|
2001-11-20 00:54:51 +00:00
|
|
|
|
BFD_ASSERT (r_symndx != 0);
|
2001-11-15 09:31:25 +00:00
|
|
|
|
rel->r_info
|
|
|
|
|
= ELF_R_INFO (0, ELF_R_TYPE (rel->r_info));
|
|
|
|
|
rel->r_addend = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean ok;
|
2001-11-15 09:31:25 +00:00
|
|
|
|
const char *msg
|
|
|
|
|
= _("local symbols in discarded section %s");
|
|
|
|
|
bfd_size_type amt
|
|
|
|
|
= strlen (sec->name) + strlen (msg) - 1;
|
|
|
|
|
char *buf = (char *) bfd_malloc (amt);
|
|
|
|
|
|
|
|
|
|
if (buf != NULL)
|
|
|
|
|
sprintf (buf, msg, sec->name);
|
|
|
|
|
else
|
|
|
|
|
buf = (char *) sec->name;
|
|
|
|
|
ok = (*finfo->info->callbacks
|
|
|
|
|
->undefined_symbol) (finfo->info, buf,
|
|
|
|
|
input_bfd, o,
|
|
|
|
|
rel->r_offset,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
TRUE);
|
2001-11-15 09:31:25 +00:00
|
|
|
|
if (buf != sec->name)
|
|
|
|
|
free (buf);
|
|
|
|
|
if (!ok)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-10 00:23:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-10-06 07:25:40 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Relocate the section by invoking a back end routine.
|
|
|
|
|
|
|
|
|
|
The back end routine is responsible for adjusting the
|
|
|
|
|
section contents as necessary, and (if using Rela relocs
|
|
|
|
|
and generating a relocateable output file) adjusting the
|
|
|
|
|
reloc addend as necessary.
|
|
|
|
|
|
|
|
|
|
The back end routine does not have to worry about setting
|
|
|
|
|
the reloc address or the reloc symbol index.
|
|
|
|
|
|
|
|
|
|
The back end routine is given a pointer to the swapped in
|
|
|
|
|
internal symbols, and can access the hash table entries
|
|
|
|
|
for the external symbols via elf_sym_hashes (input_bfd).
|
|
|
|
|
|
|
|
|
|
When generating relocateable output, the back end routine
|
|
|
|
|
must handle STB_LOCAL/STT_SECTION symbols specially. The
|
|
|
|
|
output symbol is going to be a section symbol
|
|
|
|
|
corresponding to the output section, which will require
|
|
|
|
|
the addend to be adjusted. */
|
|
|
|
|
|
|
|
|
|
if (! (*relocate_section) (output_bfd, finfo->info,
|
|
|
|
|
input_bfd, o, contents,
|
|
|
|
|
internal_relocs,
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isymbuf,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
finfo->sections))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-06-20 20:34:10 +00:00
|
|
|
|
if (emit_relocs)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela *irela;
|
|
|
|
|
Elf_Internal_Rela *irelaend;
|
2002-11-26 11:54:02 +00:00
|
|
|
|
bfd_vma last_offset;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct elf_link_hash_entry **rel_hash;
|
2002-07-16 09:00:42 +00:00
|
|
|
|
Elf_Internal_Shdr *input_rel_hdr, *input_rel_hdr2;
|
2001-06-10 05:21:00 +00:00
|
|
|
|
unsigned int next_erel;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean (*reloc_emitter)
|
|
|
|
|
PARAMS ((bfd *, asection *, Elf_Internal_Shdr *,
|
|
|
|
|
Elf_Internal_Rela *));
|
|
|
|
|
bfd_boolean rela_normal;
|
2002-05-07 00:16:53 +00:00
|
|
|
|
|
|
|
|
|
input_rel_hdr = &elf_section_data (o)->rel_hdr;
|
|
|
|
|
rela_normal = (bed->rela_normal
|
|
|
|
|
&& (input_rel_hdr->sh_entsize
|
|
|
|
|
== sizeof (Elf_External_Rela)));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Adjust the reloc addresses and symbol indices. */
|
|
|
|
|
|
|
|
|
|
irela = internal_relocs;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
irelaend = irela + o->reloc_count * bed->s->int_rels_per_ext_rel;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
rel_hash = (elf_section_data (o->output_section)->rel_hashes
|
1999-07-18 06:31:29 +00:00
|
|
|
|
+ elf_section_data (o->output_section)->rel_count
|
|
|
|
|
+ elf_section_data (o->output_section)->rel_count2);
|
2002-11-26 11:54:02 +00:00
|
|
|
|
last_offset = o->output_offset;
|
|
|
|
|
if (!finfo->info->relocateable)
|
|
|
|
|
last_offset += o->output_section->vma;
|
2001-05-28 11:57:54 +00:00
|
|
|
|
for (next_erel = 0; irela < irelaend; irela++, next_erel++)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned long r_symndx;
|
|
|
|
|
asection *sec;
|
2002-07-23 04:38:17 +00:00
|
|
|
|
Elf_Internal_Sym sym;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-05-28 11:57:54 +00:00
|
|
|
|
if (next_erel == bed->s->int_rels_per_ext_rel)
|
|
|
|
|
{
|
|
|
|
|
rel_hash++;
|
|
|
|
|
next_erel = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-12 07:55:43 +00:00
|
|
|
|
irela->r_offset = _bfd_elf_section_offset (output_bfd,
|
|
|
|
|
finfo->info, o,
|
|
|
|
|
irela->r_offset);
|
|
|
|
|
if (irela->r_offset >= (bfd_vma) -2)
|
|
|
|
|
{
|
2002-11-26 11:54:02 +00:00
|
|
|
|
/* This is a reloc for a deleted entry or somesuch.
|
|
|
|
|
Turn it into an R_*_NONE reloc, at the same
|
|
|
|
|
offset as the last reloc. elf_eh_frame.c and
|
|
|
|
|
elf_bfd_discard_info rely on reloc offsets
|
2002-11-30 08:39:46 +00:00
|
|
|
|
being ordered. */
|
2002-11-26 11:54:02 +00:00
|
|
|
|
irela->r_offset = last_offset;
|
|
|
|
|
irela->r_info = 0;
|
|
|
|
|
irela->r_addend = 0;
|
2002-11-12 07:55:43 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
irela->r_offset += o->output_offset;
|
|
|
|
|
|
2000-05-18 17:12:31 +00:00
|
|
|
|
/* Relocs in an executable have to be virtual addresses. */
|
2002-05-06 08:54:44 +00:00
|
|
|
|
if (!finfo->info->relocateable)
|
2000-05-18 17:12:31 +00:00
|
|
|
|
irela->r_offset += o->output_section->vma;
|
|
|
|
|
|
2002-11-26 11:54:02 +00:00
|
|
|
|
last_offset = irela->r_offset;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-26 11:54:02 +00:00
|
|
|
|
r_symndx = ELF_R_SYM (irela->r_info);
|
|
|
|
|
if (r_symndx == STN_UNDEF)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (r_symndx >= locsymcount
|
|
|
|
|
|| (elf_bad_symtab (input_bfd)
|
|
|
|
|
&& finfo->sections[r_symndx] == NULL))
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *rh;
|
2001-05-28 11:57:54 +00:00
|
|
|
|
unsigned long indx;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* This is a reloc against a global symbol. We
|
|
|
|
|
have not yet output all the local symbols, so
|
|
|
|
|
we do not know the symbol index of any global
|
|
|
|
|
symbol. We set the rel_hash entry for this
|
|
|
|
|
reloc to point to the global hash table entry
|
|
|
|
|
for this symbol. The symbol index is then
|
|
|
|
|
set at the end of elf_bfd_final_link. */
|
|
|
|
|
indx = r_symndx - extsymoff;
|
|
|
|
|
rh = elf_sym_hashes (input_bfd)[indx];
|
|
|
|
|
while (rh->root.type == bfd_link_hash_indirect
|
|
|
|
|
|| rh->root.type == bfd_link_hash_warning)
|
|
|
|
|
rh = (struct elf_link_hash_entry *) rh->root.u.i.link;
|
|
|
|
|
|
|
|
|
|
/* Setting the index to -2 tells
|
|
|
|
|
elf_link_output_extsym that this symbol is
|
|
|
|
|
used by a reloc. */
|
|
|
|
|
BFD_ASSERT (rh->indx < 0);
|
|
|
|
|
rh->indx = -2;
|
|
|
|
|
|
|
|
|
|
*rel_hash = rh;
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-03 22:53:39 +00:00
|
|
|
|
/* This is a reloc against a local symbol. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
*rel_hash = NULL;
|
2002-07-23 04:38:17 +00:00
|
|
|
|
sym = isymbuf[r_symndx];
|
1999-05-03 07:29:11 +00:00
|
|
|
|
sec = finfo->sections[r_symndx];
|
2002-07-23 04:38:17 +00:00
|
|
|
|
if (ELF_ST_TYPE (sym.st_info) == STT_SECTION)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
/* I suppose the backend ought to fill in the
|
|
|
|
|
section of any STT_SECTION symbol against a
|
|
|
|
|
processor specific section. If we have
|
|
|
|
|
discarded a section, the output_section will
|
|
|
|
|
be the absolute section. */
|
2002-05-07 00:16:53 +00:00
|
|
|
|
if (bfd_is_abs_section (sec)
|
|
|
|
|
|| (sec != NULL
|
|
|
|
|
&& bfd_is_abs_section (sec->output_section)))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
r_symndx = 0;
|
|
|
|
|
else if (sec == NULL || sec->owner == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
r_symndx = sec->output_section->target_index;
|
|
|
|
|
BFD_ASSERT (r_symndx != 0);
|
|
|
|
|
}
|
2002-05-07 00:16:53 +00:00
|
|
|
|
|
|
|
|
|
/* Adjust the addend according to where the
|
2002-06-23 02:04:28 +00:00
|
|
|
|
section winds up in the output section. */
|
2002-05-07 00:16:53 +00:00
|
|
|
|
if (rela_normal)
|
|
|
|
|
irela->r_addend += sec->output_offset;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (finfo->indices[r_symndx] == -1)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
unsigned long shlink;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
const char *name;
|
|
|
|
|
asection *osec;
|
|
|
|
|
|
|
|
|
|
if (finfo->info->strip == strip_all)
|
|
|
|
|
{
|
|
|
|
|
/* You can't do ld -r -s. */
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This symbol was skipped earlier, but
|
|
|
|
|
since it is needed by a reloc, we
|
|
|
|
|
must output it now. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
shlink = symtab_hdr->sh_link;
|
2001-08-09 14:38:04 +00:00
|
|
|
|
name = (bfd_elf_string_from_elf_section
|
2002-07-23 04:38:17 +00:00
|
|
|
|
(input_bfd, shlink, sym.st_name));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (name == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
osec = sec->output_section;
|
2002-07-23 04:38:17 +00:00
|
|
|
|
sym.st_shndx =
|
1999-05-03 07:29:11 +00:00
|
|
|
|
_bfd_elf_section_from_bfd_section (output_bfd,
|
|
|
|
|
osec);
|
2002-07-23 04:38:17 +00:00
|
|
|
|
if (sym.st_shndx == SHN_BAD)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-23 04:38:17 +00:00
|
|
|
|
sym.st_value += sec->output_offset;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (! finfo->info->relocateable)
|
* 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 13:12:53 +00:00
|
|
|
|
{
|
2002-07-23 04:38:17 +00:00
|
|
|
|
sym.st_value += osec->vma;
|
|
|
|
|
if (ELF_ST_TYPE (sym.st_info) == STT_TLS)
|
* 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 13:12:53 +00:00
|
|
|
|
{
|
|
|
|
|
/* STT_TLS symbols are relative to PT_TLS
|
|
|
|
|
segment base. */
|
|
|
|
|
BFD_ASSERT (finfo->first_tls_sec != NULL);
|
2002-07-23 04:38:17 +00:00
|
|
|
|
sym.st_value -= finfo->first_tls_sec->vma;
|
* 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 13:12:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
finfo->indices[r_symndx]
|
|
|
|
|
= bfd_get_symcount (output_bfd);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-23 04:38:17 +00:00
|
|
|
|
if (! elf_link_output_sym (finfo, name, &sym, sec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r_symndx = finfo->indices[r_symndx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
irela->r_info = ELF_R_INFO (r_symndx,
|
|
|
|
|
ELF_R_TYPE (irela->r_info));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Swap out the relocs. */
|
2002-03-05 05:18:41 +00:00
|
|
|
|
if (bed->elf_backend_emit_relocs
|
|
|
|
|
&& !(finfo->info->relocateable
|
2001-08-09 14:38:04 +00:00
|
|
|
|
|| finfo->info->emitrelocations))
|
2002-03-05 05:18:41 +00:00
|
|
|
|
reloc_emitter = bed->elf_backend_emit_relocs;
|
|
|
|
|
else
|
|
|
|
|
reloc_emitter = elf_link_output_relocs;
|
2001-06-20 20:34:10 +00:00
|
|
|
|
|
2002-07-16 09:00:42 +00:00
|
|
|
|
if (input_rel_hdr->sh_size != 0
|
|
|
|
|
&& ! (*reloc_emitter) (output_bfd, o, input_rel_hdr,
|
|
|
|
|
internal_relocs))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-06-20 20:34:10 +00:00
|
|
|
|
|
2002-07-16 09:00:42 +00:00
|
|
|
|
input_rel_hdr2 = elf_section_data (o)->rel_hdr2;
|
|
|
|
|
if (input_rel_hdr2 && input_rel_hdr2->sh_size != 0)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
{
|
|
|
|
|
internal_relocs += (NUM_SHDR_ENTRIES (input_rel_hdr)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
* bed->s->int_rels_per_ext_rel);
|
2002-07-16 09:00:42 +00:00
|
|
|
|
if (! (*reloc_emitter) (output_bfd, o, input_rel_hdr2,
|
2002-05-21 16:03:46 +00:00
|
|
|
|
internal_relocs))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2002-03-05 05:18:41 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write out the modified section contents. */
|
2001-11-15 01:34:12 +00:00
|
|
|
|
if (bed->elf_backend_write_section
|
2001-11-15 09:31:25 +00:00
|
|
|
|
&& (*bed->elf_backend_write_section) (output_bfd, o, contents))
|
2001-11-15 01:34:12 +00:00
|
|
|
|
{
|
|
|
|
|
/* Section written out. */
|
|
|
|
|
}
|
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 12:34:08 +00:00
|
|
|
|
else switch (o->sec_info_type)
|
2001-04-13 00:34:36 +00:00
|
|
|
|
{
|
2001-12-13 11:09:34 +00:00
|
|
|
|
case ELF_INFO_TYPE_STABS:
|
2001-04-13 00:34:36 +00:00
|
|
|
|
if (! (_bfd_write_section_stabs
|
2001-12-13 11:09:34 +00:00
|
|
|
|
(output_bfd,
|
|
|
|
|
&elf_hash_table (finfo->info)->stab_info,
|
|
|
|
|
o, &elf_section_data (o)->sec_info, contents)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
break;
|
|
|
|
|
case ELF_INFO_TYPE_MERGE:
|
2002-11-12 07:35:26 +00:00
|
|
|
|
if (! _bfd_write_merged_section (output_bfd, o,
|
|
|
|
|
elf_section_data (o)->sec_info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
break;
|
|
|
|
|
case ELF_INFO_TYPE_EH_FRAME:
|
|
|
|
|
{
|
2002-11-12 07:35:26 +00:00
|
|
|
|
if (! _bfd_elf_write_section_eh_frame (output_bfd, finfo->info,
|
|
|
|
|
o, contents))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type sec_size;
|
|
|
|
|
|
|
|
|
|
sec_size = (o->_cooked_size != 0 ? o->_cooked_size : o->_raw_size);
|
|
|
|
|
if (! (o->flags & SEC_EXCLUDE)
|
|
|
|
|
&& ! bfd_set_section_contents (output_bfd, o->output_section,
|
|
|
|
|
contents,
|
|
|
|
|
(file_ptr) o->output_offset,
|
|
|
|
|
sec_size))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Generate a reloc when linking an ELF file. This is a reloc
|
|
|
|
|
requested by the linker, and does come from any input file. This
|
|
|
|
|
is used to build constructor and destructor tables when linking
|
|
|
|
|
with -Ur. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_reloc_link_order (output_bfd, info, output_section, link_order)
|
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
asection *output_section;
|
|
|
|
|
struct bfd_link_order *link_order;
|
|
|
|
|
{
|
|
|
|
|
reloc_howto_type *howto;
|
|
|
|
|
long indx;
|
|
|
|
|
bfd_vma offset;
|
|
|
|
|
bfd_vma addend;
|
|
|
|
|
struct elf_link_hash_entry **rel_hash_ptr;
|
|
|
|
|
Elf_Internal_Shdr *rel_hdr;
|
2000-06-16 23:01:00 +00:00
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
Elf_Internal_Rela irel[MAX_INT_RELS_PER_EXT_REL];
|
|
|
|
|
bfd_byte *erel;
|
|
|
|
|
unsigned int i;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
|
|
|
|
|
if (howto == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addend = link_order->u.reloc.p->addend;
|
|
|
|
|
|
|
|
|
|
/* Figure out the symbol index. */
|
|
|
|
|
rel_hash_ptr = (elf_section_data (output_section)->rel_hashes
|
1999-07-18 06:31:29 +00:00
|
|
|
|
+ elf_section_data (output_section)->rel_count
|
|
|
|
|
+ elf_section_data (output_section)->rel_count2);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (link_order->type == bfd_section_reloc_link_order)
|
|
|
|
|
{
|
|
|
|
|
indx = link_order->u.reloc.p->u.section->target_index;
|
|
|
|
|
BFD_ASSERT (indx != 0);
|
|
|
|
|
*rel_hash_ptr = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
/* Treat a reloc against a defined symbol as though it were
|
2002-03-05 05:18:41 +00:00
|
|
|
|
actually against the section. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
h = ((struct elf_link_hash_entry *)
|
|
|
|
|
bfd_wrapped_link_hash_lookup (output_bfd, info,
|
|
|
|
|
link_order->u.reloc.p->u.name,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
FALSE, FALSE, TRUE));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h != NULL
|
|
|
|
|
&& (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak))
|
|
|
|
|
{
|
|
|
|
|
asection *section;
|
|
|
|
|
|
|
|
|
|
section = h->root.u.def.section;
|
|
|
|
|
indx = section->output_section->target_index;
|
|
|
|
|
*rel_hash_ptr = NULL;
|
|
|
|
|
/* It seems that we ought to add the symbol value to the
|
2002-03-05 05:18:41 +00:00
|
|
|
|
addend here, but in practice it has already been added
|
|
|
|
|
because it was passed to constructor_callback. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
addend += section->output_section->vma + section->output_offset;
|
|
|
|
|
}
|
|
|
|
|
else if (h != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Setting the index to -2 tells elf_link_output_extsym that
|
|
|
|
|
this symbol is used by a reloc. */
|
|
|
|
|
h->indx = -2;
|
|
|
|
|
*rel_hash_ptr = h;
|
|
|
|
|
indx = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (! ((*info->callbacks->unattached_reloc)
|
|
|
|
|
(info, link_order->u.reloc.p->u.name, (bfd *) NULL,
|
|
|
|
|
(asection *) NULL, (bfd_vma) 0)))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
indx = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is an inplace reloc, we must write the addend into the
|
|
|
|
|
object file. */
|
|
|
|
|
if (howto->partial_inplace && addend != 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_size_type size;
|
|
|
|
|
bfd_reloc_status_type rstat;
|
|
|
|
|
bfd_byte *buf;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean ok;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
const char *sym_name;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
size = bfd_get_reloc_size (howto);
|
|
|
|
|
buf = (bfd_byte *) bfd_zmalloc (size);
|
|
|
|
|
if (buf == (bfd_byte *) NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
rstat = _bfd_relocate_contents (howto, output_bfd, (bfd_vma) addend, buf);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
switch (rstat)
|
|
|
|
|
{
|
|
|
|
|
case bfd_reloc_ok:
|
|
|
|
|
break;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
default:
|
|
|
|
|
case bfd_reloc_outofrange:
|
|
|
|
|
abort ();
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
case bfd_reloc_overflow:
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
if (link_order->type == bfd_section_reloc_link_order)
|
|
|
|
|
sym_name = bfd_section_name (output_bfd,
|
|
|
|
|
link_order->u.reloc.p->u.section);
|
|
|
|
|
else
|
|
|
|
|
sym_name = link_order->u.reloc.p->u.name;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (! ((*info->callbacks->reloc_overflow)
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
(info, sym_name, howto->name, addend,
|
|
|
|
|
(bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
free (buf);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
|
|
|
|
|
(file_ptr) link_order->offset, size);
|
|
|
|
|
free (buf);
|
|
|
|
|
if (! ok)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The address of a reloc is relative to the section in a
|
|
|
|
|
relocateable file, and is a virtual address in an executable
|
|
|
|
|
file. */
|
|
|
|
|
offset = link_order->offset;
|
|
|
|
|
if (! info->relocateable)
|
|
|
|
|
offset += output_section->vma;
|
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
|
|
|
|
|
{
|
|
|
|
|
irel[i].r_offset = offset;
|
|
|
|
|
irel[i].r_info = 0;
|
|
|
|
|
irel[i].r_addend = 0;
|
|
|
|
|
}
|
|
|
|
|
irel[0].r_info = ELF_R_INFO (indx, howto->type);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
rel_hdr = &elf_section_data (output_section)->rel_hdr;
|
|
|
|
|
erel = rel_hdr->contents;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (rel_hdr->sh_type == SHT_REL)
|
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
erel += (elf_section_data (output_section)->rel_count
|
|
|
|
|
* sizeof (Elf_External_Rel));
|
|
|
|
|
(*bed->s->swap_reloc_out) (output_bfd, irel, erel);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
irel[0].r_addend = addend;
|
|
|
|
|
erel += (elf_section_data (output_section)->rel_count
|
|
|
|
|
* sizeof (Elf_External_Rela));
|
|
|
|
|
(*bed->s->swap_reloca_out) (output_bfd, irel, erel);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 11:39:43 +00:00
|
|
|
|
++elf_section_data (output_section)->rel_count;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate a pointer to live in a linker created section. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_create_pointer_linker_section (abfd, info, lsect, h, rel)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
elf_linker_section_t *lsect;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
const Elf_Internal_Rela *rel;
|
|
|
|
|
{
|
|
|
|
|
elf_linker_section_pointers_t **ptr_linker_section_ptr = NULL;
|
|
|
|
|
elf_linker_section_pointers_t *linker_section_ptr;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
unsigned long r_symndx = ELF_R_SYM (rel->r_info);
|
|
|
|
|
bfd_size_type amt;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (lsect != NULL);
|
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Is this a global symbol? */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h != NULL)
|
|
|
|
|
{
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Has this symbol already been allocated? If so, our work is done. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (_bfd_elf_find_pointer_linker_section (h->linker_section_pointer,
|
|
|
|
|
rel->r_addend,
|
|
|
|
|
lsect->which))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
ptr_linker_section_ptr = &h->linker_section_pointer;
|
|
|
|
|
/* Make sure this symbol is output as a dynamic symbol. */
|
|
|
|
|
if (h->dynindx == -1)
|
|
|
|
|
{
|
|
|
|
|
if (! elf_link_record_dynamic_symbol (info, h))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lsect->rel_section)
|
|
|
|
|
lsect->rel_section->_raw_size += sizeof (Elf_External_Rela);
|
|
|
|
|
}
|
2001-08-09 14:38:04 +00:00
|
|
|
|
else
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Allocation of a pointer to a local symbol. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_linker_section_pointers_t **ptr = elf_local_ptr_offsets (abfd);
|
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Allocate a table to hold the local symbols if first time. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (!ptr)
|
|
|
|
|
{
|
|
|
|
|
unsigned int num_symbols = elf_tdata (abfd)->symtab_hdr.sh_info;
|
|
|
|
|
register unsigned int i;
|
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = num_symbols;
|
|
|
|
|
amt *= sizeof (elf_linker_section_pointers_t *);
|
|
|
|
|
ptr = (elf_linker_section_pointers_t **) bfd_alloc (abfd, amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (!ptr)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
elf_local_ptr_offsets (abfd) = ptr;
|
|
|
|
|
for (i = 0; i < num_symbols; i++)
|
2001-08-09 14:38:04 +00:00
|
|
|
|
ptr[i] = (elf_linker_section_pointers_t *) 0;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Has this symbol already been allocated? If so, our work is done. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (_bfd_elf_find_pointer_linker_section (ptr[r_symndx],
|
|
|
|
|
rel->r_addend,
|
|
|
|
|
lsect->which))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
ptr_linker_section_ptr = &ptr[r_symndx];
|
|
|
|
|
|
|
|
|
|
if (info->shared)
|
|
|
|
|
{
|
|
|
|
|
/* If we are generating a shared object, we need to
|
|
|
|
|
output a R_<xxx>_RELATIVE reloc so that the
|
|
|
|
|
dynamic linker can adjust this GOT entry. */
|
|
|
|
|
BFD_ASSERT (lsect->rel_section != NULL);
|
|
|
|
|
lsect->rel_section->_raw_size += sizeof (Elf_External_Rela);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Allocate space for a pointer in the linker section, and allocate
|
|
|
|
|
a new pointer record from internal memory. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
BFD_ASSERT (ptr_linker_section_ptr != NULL);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
amt = sizeof (elf_linker_section_pointers_t);
|
|
|
|
|
linker_section_ptr = (elf_linker_section_pointers_t *) bfd_alloc (abfd, amt);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (!linker_section_ptr)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
linker_section_ptr->next = *ptr_linker_section_ptr;
|
|
|
|
|
linker_section_ptr->addend = rel->r_addend;
|
|
|
|
|
linker_section_ptr->which = lsect->which;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
linker_section_ptr->written_address_p = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*ptr_linker_section_ptr = linker_section_ptr;
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
if (lsect->hole_size && lsect->hole_offset < lsect->max_hole_offset)
|
|
|
|
|
{
|
2001-08-09 14:38:04 +00:00
|
|
|
|
linker_section_ptr->offset = (lsect->section->_raw_size
|
|
|
|
|
- lsect->hole_size + (ARCH_SIZE / 8));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
lsect->hole_offset += ARCH_SIZE / 8;
|
|
|
|
|
lsect->sym_offset += ARCH_SIZE / 8;
|
2001-08-09 14:38:04 +00:00
|
|
|
|
if (lsect->sym_hash)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Bump up symbol value if needed. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
lsect->sym_hash->root.u.def.value += ARCH_SIZE / 8;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
fprintf (stderr, "Bump up %s by %ld, current value = %ld\n",
|
|
|
|
|
lsect->sym_hash->root.root.string,
|
2001-08-09 14:38:04 +00:00
|
|
|
|
(long) ARCH_SIZE / 8,
|
|
|
|
|
(long) lsect->sym_hash->root.u.def.value);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
linker_section_ptr->offset = lsect->section->_raw_size;
|
|
|
|
|
|
|
|
|
|
lsect->section->_raw_size += ARCH_SIZE / 8;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-08-09 14:38:04 +00:00
|
|
|
|
fprintf (stderr,
|
|
|
|
|
"Create pointer in linker section %s, offset = %ld, section size = %ld\n",
|
|
|
|
|
lsect->name, (long) linker_section_ptr->offset,
|
|
|
|
|
(long) lsect->section->_raw_size);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ARCH_SIZE==64
|
|
|
|
|
#define bfd_put_ptr(BFD,VAL,ADDR) bfd_put_64 (BFD, VAL, ADDR)
|
|
|
|
|
#endif
|
|
|
|
|
#if ARCH_SIZE==32
|
|
|
|
|
#define bfd_put_ptr(BFD,VAL,ADDR) bfd_put_32 (BFD, VAL, ADDR)
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-05-28 11:57:54 +00:00
|
|
|
|
/* Fill in the address for a pointer generated in a linker section. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
bfd_vma
|
2001-08-09 14:38:04 +00:00
|
|
|
|
elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h,
|
|
|
|
|
relocation, rel, relative_reloc)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd *output_bfd;
|
|
|
|
|
bfd *input_bfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
elf_linker_section_t *lsect;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
bfd_vma relocation;
|
|
|
|
|
const Elf_Internal_Rela *rel;
|
|
|
|
|
int relative_reloc;
|
|
|
|
|
{
|
|
|
|
|
elf_linker_section_pointers_t *linker_section_ptr;
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (lsect != NULL);
|
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
if (h != NULL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Handle global symbol. */
|
|
|
|
|
linker_section_ptr = (_bfd_elf_find_pointer_linker_section
|
|
|
|
|
(h->linker_section_pointer,
|
|
|
|
|
rel->r_addend,
|
|
|
|
|
lsect->which));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (linker_section_ptr != NULL);
|
|
|
|
|
|
|
|
|
|
if (! elf_hash_table (info)->dynamic_sections_created
|
|
|
|
|
|| (info->shared
|
|
|
|
|
&& info->symbolic
|
|
|
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
|
|
|
|
|
{
|
|
|
|
|
/* This is actually a static link, or it is a
|
|
|
|
|
-Bsymbolic link and the symbol is defined
|
|
|
|
|
locally. We must initialize this entry in the
|
|
|
|
|
global section.
|
|
|
|
|
|
|
|
|
|
When doing a dynamic link, we create a .rela.<xxx>
|
|
|
|
|
relocation entry to initialize the value. This
|
|
|
|
|
is done in the finish_dynamic_symbol routine. */
|
|
|
|
|
if (!linker_section_ptr->written_address_p)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
linker_section_ptr->written_address_p = TRUE;
|
2001-08-09 14:38:04 +00:00
|
|
|
|
bfd_put_ptr (output_bfd,
|
|
|
|
|
relocation + linker_section_ptr->addend,
|
|
|
|
|
(lsect->section->contents
|
|
|
|
|
+ linker_section_ptr->offset));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-08-09 14:38:04 +00:00
|
|
|
|
else
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Handle local symbol. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
unsigned long r_symndx = ELF_R_SYM (rel->r_info);
|
|
|
|
|
BFD_ASSERT (elf_local_ptr_offsets (input_bfd) != NULL);
|
|
|
|
|
BFD_ASSERT (elf_local_ptr_offsets (input_bfd)[r_symndx] != NULL);
|
2001-08-09 14:38:04 +00:00
|
|
|
|
linker_section_ptr = (_bfd_elf_find_pointer_linker_section
|
|
|
|
|
(elf_local_ptr_offsets (input_bfd)[r_symndx],
|
|
|
|
|
rel->r_addend,
|
|
|
|
|
lsect->which));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (linker_section_ptr != NULL);
|
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* Write out pointer if it hasn't been rewritten out before. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (!linker_section_ptr->written_address_p)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
linker_section_ptr->written_address_p = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_put_ptr (output_bfd, relocation + linker_section_ptr->addend,
|
|
|
|
|
lsect->section->contents + linker_section_ptr->offset);
|
|
|
|
|
|
|
|
|
|
if (info->shared)
|
|
|
|
|
{
|
|
|
|
|
asection *srel = lsect->rel_section;
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
Elf_Internal_Rela outrel[MAX_INT_RELS_PER_EXT_REL];
|
|
|
|
|
bfd_byte *erel;
|
2001-05-28 11:57:54 +00:00
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
|
|
|
|
|
unsigned int i;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
/* We need to generate a relative reloc for the dynamic
|
|
|
|
|
linker. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (!srel)
|
2001-08-09 14:38:04 +00:00
|
|
|
|
{
|
|
|
|
|
srel = bfd_get_section_by_name (elf_hash_table (info)->dynobj,
|
|
|
|
|
lsect->rel_name);
|
|
|
|
|
lsect->rel_section = srel;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (srel != NULL);
|
|
|
|
|
|
2001-05-28 11:57:54 +00:00
|
|
|
|
for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
{
|
|
|
|
|
outrel[i].r_offset = (lsect->section->output_section->vma
|
|
|
|
|
+ lsect->section->output_offset
|
|
|
|
|
+ linker_section_ptr->offset);
|
|
|
|
|
outrel[i].r_info = 0;
|
|
|
|
|
outrel[i].r_addend = 0;
|
|
|
|
|
}
|
2001-05-28 11:57:54 +00:00
|
|
|
|
outrel[0].r_info = ELF_R_INFO (0, relative_reloc);
|
include/elf/ChangeLog
* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
(Elf_Internal_Rel): Delete.
bfd/ChangeLog
* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
Elf64_Internal_* with Elf_Internal_*. Replace Elf_Internal_Rel
with Elf_Internal_Rela.
* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
* elf-hppa.h (elf_hppa_internal_shdr): Delete. Use Elf_Internal_Shdr
throughout instead.
* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
Remove INLINE keyword.
(elf_swap_reloc_in): Likewise. Also clear r_addend.
(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
as a bfd_byte *.
(elf_write_relocs): Consolidate REL and RELA code.
(elf_slurp_reloc_table_from_section): Simplify REL code.
(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
RELA code.
(elf_link_adjust_relocs): Likewise. Don't malloc space for temp
reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
(elf_link_output_relocs): Likewise.
(elf_reloc_link_order): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(struct elf_link_sort_rela): Remove union.
(elf_link_sort_cmp1): Update to suit.
(elf_link_sort_cmp2): Here too.
(elf_link_sort_relocs): Consolidate REL and RELA code. Fix memory
over-allocation for int_rels_per_ext_rel != 1 case.
* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
* elf32-i386.c: Likewise.
* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
elf64-sparc.c, elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
* elfxx-mips.c (sort_dynamic_relocs): Likewise for
bfd_elf32_swap_reloc_in.
* elf32-arm.h: Update elf32_arm_info_to_howto calls.
* elf32-mips.c: Likewise for mips_info_to_howto_rel.
(mips_elf64_swap_reloc_in): Zero r_addend.
(mips_elf64_be_swap_reloc_in): Likewise.
(mips_elf64_slurp_one_reloc_table): Simplify.
* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
* elf64-hppa.c (hppa64_elf_size_info): Likewise.
* elf64-sparc.c (sparc64_elf_size_info): Likewise.
2002-11-28 11:55:43 +00:00
|
|
|
|
erel = lsect->section->contents;
|
|
|
|
|
erel += (elf_section_data (lsect->section)->rel_count++
|
|
|
|
|
* sizeof (Elf_External_Rela));
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
elf_swap_reloca_out (output_bfd, outrel, erel);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
relocation = (lsect->section->output_offset
|
|
|
|
|
+ linker_section_ptr->offset
|
|
|
|
|
- lsect->hole_offset
|
|
|
|
|
- lsect->sym_offset);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-08-09 14:38:04 +00:00
|
|
|
|
fprintf (stderr,
|
|
|
|
|
"Finish pointer in linker section %s, offset = %ld (0x%lx)\n",
|
|
|
|
|
lsect->name, (long) relocation, (long) relocation);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Subtract out the addend, because it will get added back in by the normal
|
|
|
|
|
processing. */
|
|
|
|
|
return relocation - linker_section_ptr->addend;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Garbage collect unused sections. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_gc_mark
|
2002-07-16 12:31:35 +00:00
|
|
|
|
PARAMS ((struct bfd_link_info *, asection *,
|
|
|
|
|
asection * (*) (asection *, struct bfd_link_info *,
|
|
|
|
|
Elf_Internal_Rela *, struct elf_link_hash_entry *,
|
|
|
|
|
Elf_Internal_Sym *)));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_gc_sweep
|
2002-07-16 12:31:35 +00:00
|
|
|
|
PARAMS ((struct bfd_link_info *,
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *,
|
|
|
|
|
const Elf_Internal_Rela *)));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_gc_sweep_symbol
|
2002-07-16 12:31:35 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_gc_allocate_got_offsets
|
2002-07-16 12:31:35 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_gc_propagate_vtable_entries_used
|
2002-07-16 12:31:35 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean elf_gc_smash_unused_vtentry_relocs
|
2002-07-16 12:31:35 +00:00
|
|
|
|
PARAMS ((struct elf_link_hash_entry *, PTR));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* The mark phase of garbage collection. For a given section, mark
|
2001-10-09 06:05:17 +00:00
|
|
|
|
it and any sections in this section's group, and all the sections
|
|
|
|
|
which define symbols to which it refers. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
typedef asection * (*gc_mark_hook_fn)
|
|
|
|
|
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
|
|
|
|
|
struct elf_link_hash_entry *, Elf_Internal_Sym *));
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_mark (info, sec, gc_mark_hook)
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
asection *sec;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
gc_mark_hook_fn gc_mark_hook;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean ret;
|
2001-10-09 06:05:17 +00:00
|
|
|
|
asection *group_sec;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
sec->gc_mark = 1;
|
|
|
|
|
|
2001-10-09 06:05:17 +00:00
|
|
|
|
/* Mark all the sections in the group. */
|
|
|
|
|
group_sec = elf_section_data (sec)->next_in_group;
|
|
|
|
|
if (group_sec && !group_sec->gc_mark)
|
|
|
|
|
if (!elf_gc_mark (info, group_sec, gc_mark_hook))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-10-09 06:05:17 +00:00
|
|
|
|
/* Look through the section relocs. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
ret = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if ((sec->flags & SEC_RELOC) != 0 && sec->reloc_count > 0)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela *relstart, *rel, *relend;
|
|
|
|
|
Elf_Internal_Shdr *symtab_hdr;
|
|
|
|
|
struct elf_link_hash_entry **sym_hashes;
|
|
|
|
|
size_t nlocsyms;
|
|
|
|
|
size_t extsymoff;
|
|
|
|
|
bfd *input_bfd = sec->owner;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (input_bfd);
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_Internal_Sym *isym = NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
|
|
|
|
sym_hashes = elf_sym_hashes (input_bfd);
|
|
|
|
|
|
|
|
|
|
/* Read the local symbols. */
|
|
|
|
|
if (elf_bad_symtab (input_bfd))
|
|
|
|
|
{
|
|
|
|
|
nlocsyms = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
|
2002-03-05 05:18:41 +00:00
|
|
|
|
extsymoff = 0;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
extsymoff = nlocsyms = symtab_hdr->sh_info;
|
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 00:52:35 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isym = (Elf_Internal_Sym *) symtab_hdr->contents;
|
|
|
|
|
if (isym == NULL && nlocsyms != 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 00:52:35 +00:00
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isym = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, nlocsyms, 0,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
if (isym == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
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 00:52:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Read the relocations. */
|
|
|
|
|
relstart = (NAME(_bfd_elf,link_read_relocs)
|
2002-07-07 09:10:41 +00:00
|
|
|
|
(input_bfd, sec, NULL, (Elf_Internal_Rela *) NULL,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
info->keep_memory));
|
|
|
|
|
if (relstart == NULL)
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
ret = FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
goto out1;
|
|
|
|
|
}
|
1999-07-07 17:50:56 +00:00
|
|
|
|
relend = relstart + sec->reloc_count * bed->s->int_rels_per_ext_rel;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
for (rel = relstart; rel < relend; rel++)
|
|
|
|
|
{
|
|
|
|
|
unsigned long r_symndx;
|
|
|
|
|
asection *rsec;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
r_symndx = ELF_R_SYM (rel->r_info);
|
|
|
|
|
if (r_symndx == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (r_symndx >= nlocsyms
|
|
|
|
|
|| ELF_ST_BIND (isym[r_symndx].st_info) != STB_LOCAL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
h = sym_hashes[r_symndx - extsymoff];
|
2002-07-01 08:06:47 +00:00
|
|
|
|
rsec = (*gc_mark_hook) (sec, info, rel, h, NULL);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
rsec = (*gc_mark_hook) (sec, info, rel, NULL, &isym[r_symndx]);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rsec && !rsec->gc_mark)
|
2002-03-26 11:54:12 +00:00
|
|
|
|
{
|
|
|
|
|
if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour)
|
|
|
|
|
rsec->gc_mark = 1;
|
|
|
|
|
else if (!elf_gc_mark (info, rsec, gc_mark_hook))
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
ret = FALSE;
|
2002-03-26 11:54:12 +00:00
|
|
|
|
goto out2;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out2:
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (elf_section_data (sec)->relocs != relstart)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
free (relstart);
|
|
|
|
|
out1:
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (isym != NULL && symtab_hdr->contents != (unsigned char *) isym)
|
|
|
|
|
{
|
|
|
|
|
if (! info->keep_memory)
|
|
|
|
|
free (isym);
|
|
|
|
|
else
|
|
|
|
|
symtab_hdr->contents = (unsigned char *) isym;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The sweep phase of garbage collection. Remove all garbage sections. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
typedef bfd_boolean (*gc_sweep_hook_fn)
|
|
|
|
|
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
|
|
|
|
const Elf_Internal_Rela *));
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_sweep (info, gc_sweep_hook)
|
|
|
|
|
struct bfd_link_info *info;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
gc_sweep_hook_fn gc_sweep_hook;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
bfd *sub;
|
|
|
|
|
|
|
|
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
|
|
|
|
{
|
|
|
|
|
asection *o;
|
|
|
|
|
|
2000-02-21 12:01:27 +00:00
|
|
|
|
if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
|
|
|
|
|
continue;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (o = sub->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
/* Keep special sections. Keep .debug sections. */
|
|
|
|
|
if ((o->flags & SEC_LINKER_CREATED)
|
|
|
|
|
|| (o->flags & SEC_DEBUGGING))
|
|
|
|
|
o->gc_mark = 1;
|
|
|
|
|
|
|
|
|
|
if (o->gc_mark)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Skip sweeping sections already excluded. */
|
|
|
|
|
if (o->flags & SEC_EXCLUDE)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Since this is early in the link process, it is simple
|
|
|
|
|
to remove a section from the output. */
|
|
|
|
|
o->flags |= SEC_EXCLUDE;
|
|
|
|
|
|
|
|
|
|
/* But we also have to update some of the relocation
|
|
|
|
|
info we collected before. */
|
|
|
|
|
if (gc_sweep_hook
|
|
|
|
|
&& (o->flags & SEC_RELOC) && o->reloc_count > 0)
|
|
|
|
|
{
|
|
|
|
|
Elf_Internal_Rela *internal_relocs;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean r;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
internal_relocs = (NAME(_bfd_elf,link_read_relocs)
|
|
|
|
|
(o->owner, o, NULL, NULL, info->keep_memory));
|
|
|
|
|
if (internal_relocs == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-01-03 22:53:39 +00:00
|
|
|
|
r = (*gc_sweep_hook) (o->owner, info, o, internal_relocs);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (elf_section_data (o)->relocs != internal_relocs)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
free (internal_relocs);
|
|
|
|
|
|
|
|
|
|
if (!r)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove the symbols that were in the swept sections from the dynamic
|
|
|
|
|
symbol table. GCFIXME: Anyone know how to get them out of the
|
|
|
|
|
static symbol table as well? */
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_gc_sweep_symbol,
|
|
|
|
|
(PTR) &i);
|
|
|
|
|
|
|
|
|
|
elf_hash_table (info)->dynsymcount = i;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sweep symbols in swept sections. Called via elf_link_hash_traverse. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_sweep_symbol (h, idxptr)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR idxptr;
|
|
|
|
|
{
|
|
|
|
|
int *idx = (int *) idxptr;
|
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->dynindx != -1
|
|
|
|
|
&& ((h->root.type != bfd_link_hash_defined
|
|
|
|
|
&& h->root.type != bfd_link_hash_defweak)
|
|
|
|
|
|| h->root.u.def.section->gc_mark))
|
|
|
|
|
h->dynindx = (*idx)++;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Propogate collected vtable information. This is called through
|
|
|
|
|
elf_link_hash_traverse. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_propagate_vtable_entries_used (h, okp)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR okp;
|
|
|
|
|
{
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
2001-01-03 22:53:39 +00:00
|
|
|
|
/* Those that are not vtables. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->vtable_parent == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Those vtables that do not have parents, we cannot merge. */
|
|
|
|
|
if (h->vtable_parent == (struct elf_link_hash_entry *) -1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* If we've already been done, exit. */
|
|
|
|
|
if (h->vtable_entries_used && h->vtable_entries_used[-1])
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure the parent's table is up to date. */
|
|
|
|
|
elf_gc_propagate_vtable_entries_used (h->vtable_parent, okp);
|
|
|
|
|
|
|
|
|
|
if (h->vtable_entries_used == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* None of this table's entries were referenced. Re-use the
|
|
|
|
|
parent's table. */
|
|
|
|
|
h->vtable_entries_used = h->vtable_parent->vtable_entries_used;
|
|
|
|
|
h->vtable_entries_size = h->vtable_parent->vtable_entries_size;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
size_t n;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean *cu, *pu;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Or the parent's entries into ours. */
|
|
|
|
|
cu = h->vtable_entries_used;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
cu[-1] = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
pu = h->vtable_parent->vtable_entries_used;
|
|
|
|
|
if (pu != NULL)
|
|
|
|
|
{
|
2002-03-05 05:18:41 +00:00
|
|
|
|
asection *sec = h->root.u.def.section;
|
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (sec->owner);
|
|
|
|
|
int file_align = bed->s->file_align;
|
2001-06-12 17:44:38 +00:00
|
|
|
|
|
|
|
|
|
n = h->vtable_parent->vtable_entries_size / file_align;
|
2001-08-31 16:16:14 +00:00
|
|
|
|
while (n--)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-31 16:16:14 +00:00
|
|
|
|
if (*pu)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
*cu = TRUE;
|
2001-08-31 16:16:14 +00:00
|
|
|
|
pu++;
|
|
|
|
|
cu++;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_smash_unused_vtentry_relocs (h, okp)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR okp;
|
|
|
|
|
{
|
|
|
|
|
asection *sec;
|
|
|
|
|
bfd_vma hstart, hend;
|
|
|
|
|
Elf_Internal_Rela *relstart, *relend, *rel;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
2001-06-12 17:44:38 +00:00
|
|
|
|
int file_align;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Take care of both those symbols that do not describe vtables as
|
|
|
|
|
well as those that are not loaded. */
|
|
|
|
|
if (h->vtable_parent == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak);
|
|
|
|
|
|
|
|
|
|
sec = h->root.u.def.section;
|
|
|
|
|
hstart = h->root.u.def.value;
|
|
|
|
|
hend = hstart + h->size;
|
|
|
|
|
|
|
|
|
|
relstart = (NAME(_bfd_elf,link_read_relocs)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
(sec->owner, sec, NULL, (Elf_Internal_Rela *) NULL, TRUE));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (!relstart)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return *(bfd_boolean *) okp = FALSE;
|
1999-07-07 17:50:56 +00:00
|
|
|
|
bed = get_elf_backend_data (sec->owner);
|
2001-06-12 17:44:38 +00:00
|
|
|
|
file_align = bed->s->file_align;
|
|
|
|
|
|
1999-07-07 17:50:56 +00:00
|
|
|
|
relend = relstart + sec->reloc_count * bed->s->int_rels_per_ext_rel;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
for (rel = relstart; rel < relend; ++rel)
|
|
|
|
|
if (rel->r_offset >= hstart && rel->r_offset < hend)
|
|
|
|
|
{
|
|
|
|
|
/* If the entry is in use, do nothing. */
|
|
|
|
|
if (h->vtable_entries_used
|
|
|
|
|
&& (rel->r_offset - hstart) < h->vtable_entries_size)
|
|
|
|
|
{
|
2001-06-12 17:44:38 +00:00
|
|
|
|
bfd_vma entry = (rel->r_offset - hstart) / file_align;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->vtable_entries_used[entry])
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/* Otherwise, kill it. */
|
|
|
|
|
rel->r_offset = rel->r_info = rel->r_addend = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Do mark and sweep of unused sections. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_sections (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean ok = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd *sub;
|
|
|
|
|
asection * (*gc_mark_hook)
|
2002-07-01 08:06:47 +00:00
|
|
|
|
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
|
2002-03-05 05:18:41 +00:00
|
|
|
|
struct elf_link_hash_entry *h, Elf_Internal_Sym *));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (!get_elf_backend_data (abfd)->can_gc_sections
|
2000-05-17 19:55:14 +00:00
|
|
|
|
|| info->relocateable || info->emitrelocations
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|| elf_hash_table (info)->dynamic_sections_created)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Apply transitive closure to the vtable entry usage info. */
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_gc_propagate_vtable_entries_used,
|
|
|
|
|
(PTR) &ok);
|
|
|
|
|
if (!ok)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Kill the vtable relocations that were not used. */
|
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_gc_smash_unused_vtentry_relocs,
|
|
|
|
|
(PTR) &ok);
|
|
|
|
|
if (!ok)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Grovel through relocs to find out who stays ... */
|
|
|
|
|
|
|
|
|
|
gc_mark_hook = get_elf_backend_data (abfd)->gc_mark_hook;
|
|
|
|
|
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
|
|
|
|
|
{
|
|
|
|
|
asection *o;
|
2000-02-21 12:01:27 +00:00
|
|
|
|
|
|
|
|
|
if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
|
|
|
|
|
continue;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
for (o = sub->sections; o != NULL; o = o->next)
|
|
|
|
|
{
|
|
|
|
|
if (o->flags & SEC_KEEP)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
if (!elf_gc_mark (info, o, gc_mark_hook))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ... and mark SEC_EXCLUDE for those that go. */
|
2001-08-09 14:38:04 +00:00
|
|
|
|
if (!elf_gc_sweep (info, get_elf_backend_data (abfd)->gc_sweep_hook))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Called from check_relocs to record the existance of a VTINHERIT reloc. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_record_vtinherit (abfd, sec, h, offset)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
asection *sec;
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
bfd_vma offset;
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
|
|
|
|
|
struct elf_link_hash_entry **search, *child;
|
|
|
|
|
bfd_size_type extsymcount;
|
|
|
|
|
|
|
|
|
|
/* The sh_info field of the symtab header tells us where the
|
|
|
|
|
external symbols start. We don't care about the local symbols at
|
|
|
|
|
this point. */
|
|
|
|
|
extsymcount = elf_tdata (abfd)->symtab_hdr.sh_size/sizeof (Elf_External_Sym);
|
|
|
|
|
if (!elf_bad_symtab (abfd))
|
|
|
|
|
extsymcount -= elf_tdata (abfd)->symtab_hdr.sh_info;
|
|
|
|
|
|
|
|
|
|
sym_hashes = elf_sym_hashes (abfd);
|
|
|
|
|
sym_hashes_end = sym_hashes + extsymcount;
|
|
|
|
|
|
|
|
|
|
/* Hunt down the child symbol, which is in this section at the same
|
|
|
|
|
offset as the relocation. */
|
|
|
|
|
for (search = sym_hashes; search != sym_hashes_end; ++search)
|
|
|
|
|
{
|
|
|
|
|
if ((child = *search) != NULL
|
|
|
|
|
&& (child->root.type == bfd_link_hash_defined
|
|
|
|
|
|| child->root.type == bfd_link_hash_defweak)
|
|
|
|
|
&& child->root.u.def.section == sec
|
|
|
|
|
&& child->root.u.def.value == offset)
|
|
|
|
|
goto win;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*_bfd_error_handler) ("%s: %s+%lu: No symbol found for INHERIT",
|
2001-09-20 23:30:37 +00:00
|
|
|
|
bfd_archive_filename (abfd), sec->name,
|
2001-08-09 14:38:04 +00:00
|
|
|
|
(unsigned long) offset);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
win:
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (!h)
|
|
|
|
|
{
|
|
|
|
|
/* This *should* only be the absolute section. It could potentially
|
|
|
|
|
be that someone has defined a non-global vtable though, which
|
|
|
|
|
would be bad. It isn't worth paging in the local symbols to be
|
|
|
|
|
sure though; that case should simply be handled by the assembler. */
|
|
|
|
|
|
|
|
|
|
child->vtable_parent = (struct elf_link_hash_entry *) -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
child->vtable_parent = h;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Called from check_relocs to record the existance of a VTENTRY reloc. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_record_vtentry (abfd, sec, h, addend)
|
1999-07-11 19:49:48 +00:00
|
|
|
|
bfd *abfd ATTRIBUTE_UNUSED;
|
|
|
|
|
asection *sec ATTRIBUTE_UNUSED;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
bfd_vma addend;
|
|
|
|
|
{
|
2001-06-12 17:44:38 +00:00
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
|
|
|
|
int file_align = bed->s->file_align;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (addend >= h->vtable_entries_size)
|
|
|
|
|
{
|
|
|
|
|
size_t size, bytes;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean *ptr = h->vtable_entries_used;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* While the symbol is undefined, we have to be prepared to handle
|
|
|
|
|
a zero size. */
|
|
|
|
|
if (h->root.type == bfd_link_hash_undefined)
|
|
|
|
|
size = addend;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
size = h->size;
|
|
|
|
|
if (size < addend)
|
|
|
|
|
{
|
|
|
|
|
/* Oops! We've got a reference past the defined end of
|
|
|
|
|
the table. This is probably a bug -- shall we warn? */
|
|
|
|
|
size = addend;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate one extra entry for use as a "done" flag for the
|
|
|
|
|
consolidation pass. */
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bytes = (size / file_align + 1) * sizeof (bfd_boolean);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
if (ptr)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
ptr = bfd_realloc (ptr - 1, (bfd_size_type) bytes);
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-09-06 08:57:49 +00:00
|
|
|
|
if (ptr != NULL)
|
|
|
|
|
{
|
|
|
|
|
size_t oldbytes;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-09 14:38:04 +00:00
|
|
|
|
oldbytes = ((h->vtable_entries_size / file_align + 1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
* sizeof (bfd_boolean));
|
2001-08-09 14:38:04 +00:00
|
|
|
|
memset (((char *) ptr) + oldbytes, 0, bytes - oldbytes);
|
1999-09-06 08:57:49 +00:00
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
ptr = bfd_zmalloc ((bfd_size_type) bytes);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
1999-09-06 08:57:49 +00:00
|
|
|
|
if (ptr == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* And arrange for that done flag to be at index -1. */
|
1999-09-06 08:57:49 +00:00
|
|
|
|
h->vtable_entries_used = ptr + 1;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
h->vtable_entries_size = size;
|
|
|
|
|
}
|
2001-01-03 22:53:39 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
h->vtable_entries_used[addend / file_align] = TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* And an accompanying bit to work out final got entry offsets once
|
|
|
|
|
we're done. Should be called from final_link. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_common_finalize_got_offsets (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
bfd *i;
|
|
|
|
|
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
|
|
|
|
bfd_vma gotoff;
|
|
|
|
|
|
|
|
|
|
/* The GOT offset is relative to the .got section, but the GOT header is
|
|
|
|
|
put into the .got.plt section, if the backend uses it. */
|
|
|
|
|
if (bed->want_got_plt)
|
|
|
|
|
gotoff = 0;
|
|
|
|
|
else
|
|
|
|
|
gotoff = bed->got_header_size;
|
|
|
|
|
|
|
|
|
|
/* Do the local .got entries first. */
|
|
|
|
|
for (i = info->input_bfds; i; i = i->link_next)
|
|
|
|
|
{
|
2000-02-21 12:01:27 +00:00
|
|
|
|
bfd_signed_vma *local_got;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
bfd_size_type j, locsymcount;
|
|
|
|
|
Elf_Internal_Shdr *symtab_hdr;
|
|
|
|
|
|
2000-02-21 12:01:27 +00:00
|
|
|
|
if (bfd_get_flavour (i) != bfd_target_elf_flavour)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
local_got = elf_local_got_refcounts (i);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (!local_got)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
symtab_hdr = &elf_tdata (i)->symtab_hdr;
|
|
|
|
|
if (elf_bad_symtab (i))
|
|
|
|
|
locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
|
|
|
|
|
else
|
|
|
|
|
locsymcount = symtab_hdr->sh_info;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < locsymcount; ++j)
|
|
|
|
|
{
|
|
|
|
|
if (local_got[j] > 0)
|
|
|
|
|
{
|
|
|
|
|
local_got[j] = gotoff;
|
|
|
|
|
gotoff += ARCH_SIZE / 8;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
local_got[j] = (bfd_vma) -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-27 00:31:17 +00:00
|
|
|
|
/* Then the global .got entries. .plt refcounts are handled by
|
|
|
|
|
adjust_dynamic_symbol */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_link_hash_traverse (elf_hash_table (info),
|
|
|
|
|
elf_gc_allocate_got_offsets,
|
|
|
|
|
(PTR) &gotoff);
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We need a special top-level link routine to convert got reference counts
|
|
|
|
|
to real got offsets. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_allocate_got_offsets (h, offarg)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR offarg;
|
|
|
|
|
{
|
|
|
|
|
bfd_vma *off = (bfd_vma *) offarg;
|
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (h->got.refcount > 0)
|
|
|
|
|
{
|
|
|
|
|
h->got.offset = off[0];
|
|
|
|
|
off[0] += ARCH_SIZE / 8;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
h->got.offset = (bfd_vma) -1;
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Many folk need no more in the way of final link than this, once
|
|
|
|
|
got entry reference counting is enabled. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_gc_common_final_link (abfd, info)
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
if (!elf_gc_common_finalize_got_offsets (abfd, info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Invoke the regular ELF backend linker to do all the work. */
|
|
|
|
|
return elf_bfd_final_link (abfd, info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function will be called though elf_link_hash_traverse to store
|
|
|
|
|
all hash value of the exported symbols in an array. */
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
1999-05-03 07:29:11 +00:00
|
|
|
|
elf_collect_hash_codes (h, data)
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
unsigned long **valuep = (unsigned long **) data;
|
|
|
|
|
const char *name;
|
|
|
|
|
char *p;
|
|
|
|
|
unsigned long ha;
|
|
|
|
|
char *alc = NULL;
|
|
|
|
|
|
2002-03-28 03:27:46 +00:00
|
|
|
|
if (h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Ignore indirect symbols. These are added by the versioning code. */
|
|
|
|
|
if (h->dynindx == -1)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
name = h->root.root.string;
|
|
|
|
|
p = strchr (name, ELF_VER_CHR);
|
|
|
|
|
if (p != NULL)
|
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 09:57:26 +00:00
|
|
|
|
alc = bfd_malloc ((bfd_size_type) (p - name + 1));
|
|
|
|
|
memcpy (alc, name, (size_t) (p - name));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
alc[p - name] = '\0';
|
|
|
|
|
name = alc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute the hash value. */
|
|
|
|
|
ha = bfd_elf_hash (name);
|
|
|
|
|
|
|
|
|
|
/* Store the found hash value in the array given as the argument. */
|
|
|
|
|
*(*valuep)++ = ha;
|
|
|
|
|
|
|
|
|
|
/* And store it in the struct so that we can put it in the hash table
|
|
|
|
|
later. */
|
|
|
|
|
h->elf_hash_value = ha;
|
|
|
|
|
|
|
|
|
|
if (alc != NULL)
|
|
|
|
|
free (alc);
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
2001-11-15 01:34:12 +00:00
|
|
|
|
elf_reloc_symbol_deleted_p (offset, cookie)
|
|
|
|
|
bfd_vma offset;
|
|
|
|
|
PTR cookie;
|
|
|
|
|
{
|
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 00:52:35 +00:00
|
|
|
|
struct elf_reloc_cookie *rcookie = (struct elf_reloc_cookie *) cookie;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
|
|
|
|
if (rcookie->bad_symtab)
|
|
|
|
|
rcookie->rel = rcookie->rels;
|
|
|
|
|
|
|
|
|
|
for (; rcookie->rel < rcookie->relend; rcookie->rel++)
|
|
|
|
|
{
|
2002-11-12 07:55:43 +00:00
|
|
|
|
unsigned long r_symndx;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
|
|
|
|
if (! rcookie->bad_symtab)
|
|
|
|
|
if (rcookie->rel->r_offset > offset)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
if (rcookie->rel->r_offset != offset)
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-11-12 07:55:43 +00:00
|
|
|
|
r_symndx = ELF_R_SYM (rcookie->rel->r_info);
|
|
|
|
|
if (r_symndx == SHN_UNDEF)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2002-11-12 07:55:43 +00:00
|
|
|
|
|
2001-11-15 01:34:12 +00:00
|
|
|
|
if (r_symndx >= rcookie->locsymcount
|
2002-07-07 09:10:41 +00:00
|
|
|
|
|| ELF_ST_BIND (rcookie->locsyms[r_symndx].st_info) != STB_LOCAL)
|
2001-11-15 01:34:12 +00:00
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
|
|
|
|
|
|
h = rcookie->sym_hashes[r_symndx - rcookie->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;
|
|
|
|
|
|
|
|
|
|
if ((h->root.type == bfd_link_hash_defined
|
|
|
|
|
|| h->root.type == bfd_link_hash_defweak)
|
2001-12-17 22:44:12 +00:00
|
|
|
|
&& elf_discarded_section (h->root.u.def.section))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
else
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
}
|
2002-07-07 09:10:41 +00:00
|
|
|
|
else
|
2001-11-15 01:34:12 +00:00
|
|
|
|
{
|
|
|
|
|
/* It's not a relocation against a global symbol,
|
2001-11-16 02:56:08 +00:00
|
|
|
|
but it could be a relocation against a local
|
2001-11-15 01:34:12 +00:00
|
|
|
|
symbol for a discarded section. */
|
|
|
|
|
asection *isec;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
Elf_Internal_Sym *isym;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
|
|
|
|
/* Need to: get the symbol; get the section. */
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isym = &rcookie->locsyms[r_symndx];
|
|
|
|
|
if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
|
2001-11-15 01:34:12 +00:00
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
isec = section_from_elf_index (rcookie->abfd, isym->st_shndx);
|
2001-12-17 22:44:12 +00:00
|
|
|
|
if (isec != NULL && elf_discarded_section (isec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
}
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Discard unneeded references to discarded sections.
|
2002-11-30 08:39:46 +00:00
|
|
|
|
Returns TRUE if any section's size was changed. */
|
2001-11-15 01:34:12 +00:00
|
|
|
|
/* This function assumes that the relocations are in sorted order,
|
2002-12-12 10:26:01 +00:00
|
|
|
|
which is true for all known assemblers. */
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean
|
2001-12-13 11:09:34 +00:00
|
|
|
|
elf_bfd_discard_info (output_bfd, info)
|
|
|
|
|
bfd *output_bfd;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
struct bfd_link_info *info;
|
|
|
|
|
{
|
|
|
|
|
struct elf_reloc_cookie cookie;
|
2002-11-12 07:35:26 +00:00
|
|
|
|
asection *stab, *eh;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
Elf_Internal_Shdr *symtab_hdr;
|
|
|
|
|
struct elf_backend_data *bed;
|
|
|
|
|
bfd *abfd;
|
2002-11-12 06:21:05 +00:00
|
|
|
|
unsigned int count;
|
2002-11-30 08:39:46 +00:00
|
|
|
|
bfd_boolean ret = FALSE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
2002-11-12 07:55:43 +00:00
|
|
|
|
if (info->traditional_format
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|| info->hash->creator->flavour != bfd_target_elf_flavour
|
2001-12-13 11:09:34 +00:00
|
|
|
|
|| ! is_elf_hash_table (info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
|
2001-11-15 01:34:12 +00:00
|
|
|
|
for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
|
|
|
|
|
{
|
2001-11-27 19:03:27 +00:00
|
|
|
|
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
|
|
|
|
|
continue;
|
|
|
|
|
|
2001-11-15 01:34:12 +00:00
|
|
|
|
bed = get_elf_backend_data (abfd);
|
|
|
|
|
|
|
|
|
|
if ((abfd->flags & DYNAMIC) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-11-12 07:35:26 +00:00
|
|
|
|
eh = bfd_get_section_by_name (abfd, ".eh_frame");
|
2003-03-06 15:47:23 +00:00
|
|
|
|
if (info->relocateable
|
|
|
|
|
|| (eh != NULL
|
|
|
|
|
&& (eh->_raw_size == 0
|
|
|
|
|
|| bfd_is_abs_section (eh->output_section))))
|
2002-11-12 07:35:26 +00:00
|
|
|
|
eh = NULL;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
|
2002-11-12 06:21:05 +00:00
|
|
|
|
stab = bfd_get_section_by_name (abfd, ".stab");
|
|
|
|
|
if (stab != NULL
|
|
|
|
|
&& (stab->_raw_size == 0
|
|
|
|
|
|| bfd_is_abs_section (stab->output_section)
|
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 12:34:08 +00:00
|
|
|
|
|| stab->sec_info_type != ELF_INFO_TYPE_STABS))
|
2002-11-12 06:21:05 +00:00
|
|
|
|
stab = NULL;
|
|
|
|
|
|
|
|
|
|
if (stab == NULL
|
|
|
|
|
&& eh == NULL
|
|
|
|
|
&& bed->elf_backend_discard_info == NULL)
|
2001-11-15 01:34:12 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
|
|
|
|
cookie.abfd = abfd;
|
|
|
|
|
cookie.sym_hashes = elf_sym_hashes (abfd);
|
|
|
|
|
cookie.bad_symtab = elf_bad_symtab (abfd);
|
|
|
|
|
if (cookie.bad_symtab)
|
|
|
|
|
{
|
2002-11-12 06:21:05 +00:00
|
|
|
|
cookie.locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
|
2001-11-15 01:34:12 +00:00
|
|
|
|
cookie.extsymoff = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cookie.locsymcount = symtab_hdr->sh_info;
|
|
|
|
|
cookie.extsymoff = symtab_hdr->sh_info;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
cookie.locsyms = (Elf_Internal_Sym *) symtab_hdr->contents;
|
|
|
|
|
if (cookie.locsyms == NULL && cookie.locsymcount != 0)
|
2002-03-05 05:18:41 +00:00
|
|
|
|
{
|
2002-07-07 09:10:41 +00:00
|
|
|
|
cookie.locsyms = bfd_elf_get_elf_syms (abfd, symtab_hdr,
|
|
|
|
|
cookie.locsymcount, 0,
|
|
|
|
|
NULL, NULL, NULL);
|
2002-03-05 05:18:41 +00:00
|
|
|
|
if (cookie.locsyms == NULL)
|
2002-11-30 08:39:46 +00:00
|
|
|
|
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 00:52:35 +00:00
|
|
|
|
}
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
2002-11-12 06:21:05 +00:00
|
|
|
|
if (stab != NULL)
|
2001-11-15 01:34:12 +00:00
|
|
|
|
{
|
2002-11-12 06:21:05 +00:00
|
|
|
|
cookie.rels = NULL;
|
|
|
|
|
count = stab->reloc_count;
|
|
|
|
|
if (count != 0)
|
|
|
|
|
cookie.rels = (NAME(_bfd_elf,link_read_relocs)
|
|
|
|
|
(abfd, stab, (PTR) NULL, (Elf_Internal_Rela *) NULL,
|
|
|
|
|
info->keep_memory));
|
|
|
|
|
if (cookie.rels != NULL)
|
2001-11-15 01:34:12 +00:00
|
|
|
|
{
|
|
|
|
|
cookie.rel = cookie.rels;
|
2002-11-12 06:21:05 +00:00
|
|
|
|
cookie.relend = cookie.rels;
|
|
|
|
|
cookie.relend += count * bed->s->int_rels_per_ext_rel;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
if (_bfd_discard_section_stabs (abfd, stab,
|
|
|
|
|
elf_section_data (stab)->sec_info,
|
2001-11-15 01:34:12 +00:00
|
|
|
|
elf_reloc_symbol_deleted_p,
|
|
|
|
|
&cookie))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
ret = TRUE;
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (elf_section_data (stab)->relocs != cookie.rels)
|
2001-11-15 01:34:12 +00:00
|
|
|
|
free (cookie.rels);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-12 06:21:05 +00:00
|
|
|
|
if (eh != NULL)
|
2001-12-13 11:09:34 +00:00
|
|
|
|
{
|
|
|
|
|
cookie.rels = NULL;
|
2002-11-12 06:21:05 +00:00
|
|
|
|
count = eh->reloc_count;
|
|
|
|
|
if (count != 0)
|
2001-12-13 11:09:34 +00:00
|
|
|
|
cookie.rels = (NAME(_bfd_elf,link_read_relocs)
|
2002-03-13 03:42:39 +00:00
|
|
|
|
(abfd, eh, (PTR) NULL, (Elf_Internal_Rela *) NULL,
|
2001-12-13 11:09:34 +00:00
|
|
|
|
info->keep_memory));
|
2002-11-12 06:21:05 +00:00
|
|
|
|
cookie.rel = cookie.rels;
|
|
|
|
|
cookie.relend = cookie.rels;
|
|
|
|
|
if (cookie.rels != NULL)
|
|
|
|
|
cookie.relend += count * bed->s->int_rels_per_ext_rel;
|
|
|
|
|
|
2002-11-12 07:35:26 +00:00
|
|
|
|
if (_bfd_elf_discard_section_eh_frame (abfd, info, eh,
|
2001-12-13 11:09:34 +00:00
|
|
|
|
elf_reloc_symbol_deleted_p,
|
|
|
|
|
&cookie))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
ret = TRUE;
|
2002-11-12 06:21:05 +00:00
|
|
|
|
|
|
|
|
|
if (cookie.rels != NULL
|
|
|
|
|
&& elf_section_data (eh)->relocs != cookie.rels)
|
2001-12-13 11:09:34 +00:00
|
|
|
|
free (cookie.rels);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-12 06:21:05 +00:00
|
|
|
|
if (bed->elf_backend_discard_info != NULL
|
|
|
|
|
&& (*bed->elf_backend_discard_info) (abfd, &cookie, info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
ret = TRUE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
|
2002-07-07 09:10:41 +00:00
|
|
|
|
if (cookie.locsyms != NULL
|
|
|
|
|
&& symtab_hdr->contents != (unsigned char *) cookie.locsyms)
|
|
|
|
|
{
|
|
|
|
|
if (! info->keep_memory)
|
|
|
|
|
free (cookie.locsyms);
|
|
|
|
|
else
|
|
|
|
|
symtab_hdr->contents = (unsigned char *) cookie.locsyms;
|
|
|
|
|
}
|
2001-11-15 01:34:12 +00:00
|
|
|
|
}
|
2001-12-13 11:09:34 +00:00
|
|
|
|
|
2002-11-12 07:35:26 +00:00
|
|
|
|
if (info->eh_frame_hdr
|
2003-03-06 15:47:23 +00:00
|
|
|
|
&& !info->relocateable
|
2002-11-12 07:35:26 +00:00
|
|
|
|
&& _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
ret = TRUE;
|
2002-11-12 06:21:05 +00:00
|
|
|
|
|
2001-11-15 01:34:12 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
static bfd_boolean
|
2001-11-15 01:34:12 +00:00
|
|
|
|
elf_section_ignore_discarded_relocs (sec)
|
|
|
|
|
asection *sec;
|
|
|
|
|
{
|
2002-03-13 03:42:39 +00:00
|
|
|
|
struct elf_backend_data *bed;
|
|
|
|
|
|
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 12:34:08 +00:00
|
|
|
|
switch (sec->sec_info_type)
|
2001-12-13 11:09:34 +00:00
|
|
|
|
{
|
|
|
|
|
case ELF_INFO_TYPE_STABS:
|
|
|
|
|
case ELF_INFO_TYPE_EH_FRAME:
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-03-13 03:42:39 +00:00
|
|
|
|
|
|
|
|
|
bed = get_elf_backend_data (sec->owner);
|
|
|
|
|
if (bed->elf_backend_ignore_discarded_relocs != NULL
|
|
|
|
|
&& (*bed->elf_backend_ignore_discarded_relocs) (sec))
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return TRUE;
|
2001-12-13 11:09:34 +00:00
|
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
|
return FALSE;
|
2001-11-15 01:34:12 +00:00
|
|
|
|
}
|