Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Typedefs | Enumerations | Functions | Variables
elf-bfd.h File Reference
#include "elf/common.h"
#include "elf/internal.h"
#include "elf/external.h"
#include "bfdlink.h"

Go to the source code of this file.

Classes

struct  elf_symbol_type
struct  elf_link_hash_entry
union  elf_link_hash_entry::gotplt_union
struct  elf_link_local_dynamic_entry
struct  eh_cie_fde
struct  eh_frame_sec_info
struct  eh_frame_array_ent
struct  eh_frame_hdr_info
struct  sym_sec_cache
struct  elf_size_info
struct  bfd_elf_special_section
struct  elf_backend_data
struct  bfd_elf_section_data
struct  elf_info_failed
struct  elf_assign_sym_version_info
struct  elf_find_verdep_info
struct  elf_obj_tdata
union  elf_symbol_type.tc_data
union  elf_link_hash_entry.u
union  elf_link_hash_entry.verinfo
struct  elf_link_hash_entry.vtable
union  bfd_elf_section_data.group
union  elf_obj_tdata.local_got

Defines

#define NUM_SHDR_ENTRIES(shdr)   ((shdr)->sh_size / (shdr)->sh_entsize)
#define NAME(x, y)   x ## NOSIZE ## _ ## y
#define ElfNAME(X)   NAME(Elf,X)
#define elfNAME(X)   NAME(elf,X)
#define SYMBOL_REFERENCES_LOCAL(INFO, H)   _bfd_elf_symbol_refs_local_p (H, INFO, 0)
#define SYMBOL_CALLS_LOCAL(INFO, H)   _bfd_elf_symbol_refs_local_p (H, INFO, 1)
#define ELF_COMMON_DEF_P(H)
#define elf_link_hash_lookup(table, string, create, copy, follow)
#define elf_link_hash_traverse(table, func, info)
#define elf_hash_table(p)   ((struct elf_link_hash_table *) ((p)->hash))
#define is_elf_hash_table(htab)   (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
#define LOCAL_SYM_CACHE_SIZE   32
#define MAX_INT_RELS_PER_EXT_REL   3
#define elf_symbol_from(ABFD, S)
#define elf_section_data(sec)   ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
#define elf_linked_to_section(sec)   (elf_section_data(sec)->linked_to)
#define elf_section_type(sec)   (elf_section_data(sec)->this_hdr.sh_type)
#define elf_section_flags(sec)   (elf_section_data(sec)->this_hdr.sh_flags)
#define elf_group_name(sec)   (elf_section_data(sec)->group.name)
#define elf_group_id(sec)   (elf_section_data(sec)->group.id)
#define elf_next_in_group(sec)   (elf_section_data(sec)->next_in_group)
#define elf_sec_group(sec)   (elf_section_data(sec)->sec_group)
#define xvec_get_elf_backend_data(xvec)   ((struct elf_backend_data *) (xvec)->backend_data)
#define get_elf_backend_data(abfd)   xvec_get_elf_backend_data ((abfd)->xvec)
#define elf_tdata(bfd)   ((bfd) -> tdata.elf_obj_data)
#define elf_elfheader(bfd)   (elf_tdata(bfd) -> elf_header)
#define elf_elfsections(bfd)   (elf_tdata(bfd) -> elf_sect_ptr)
#define elf_numsections(bfd)   (elf_tdata(bfd) -> num_elf_sections)
#define elf_shstrtab(bfd)   (elf_tdata(bfd) -> strtab_ptr)
#define elf_onesymtab(bfd)   (elf_tdata(bfd) -> symtab_section)
#define elf_symtab_shndx(bfd)   (elf_tdata(bfd) -> symtab_shndx_section)
#define elf_dynsymtab(bfd)   (elf_tdata(bfd) -> dynsymtab_section)
#define elf_dynversym(bfd)   (elf_tdata(bfd) -> dynversym_section)
#define elf_dynverdef(bfd)   (elf_tdata(bfd) -> dynverdef_section)
#define elf_dynverref(bfd)   (elf_tdata(bfd) -> dynverref_section)
#define elf_num_locals(bfd)   (elf_tdata(bfd) -> num_locals)
#define elf_num_globals(bfd)   (elf_tdata(bfd) -> num_globals)
#define elf_section_syms(bfd)   (elf_tdata(bfd) -> section_syms)
#define elf_num_section_syms(bfd)   (elf_tdata(bfd) -> num_section_syms)
#define core_prpsinfo(bfd)   (elf_tdata(bfd) -> prpsinfo)
#define core_prstatus(bfd)   (elf_tdata(bfd) -> prstatus)
#define elf_gp(bfd)   (elf_tdata(bfd) -> gp)
#define elf_gp_size(bfd)   (elf_tdata(bfd) -> gp_size)
#define elf_sym_hashes(bfd)   (elf_tdata(bfd) -> sym_hashes)
#define elf_local_got_refcounts(bfd)   (elf_tdata(bfd) -> local_got.refcounts)
#define elf_local_got_offsets(bfd)   (elf_tdata(bfd) -> local_got.offsets)
#define elf_local_got_ents(bfd)   (elf_tdata(bfd) -> local_got.ents)
#define elf_dt_name(bfd)   (elf_tdata(bfd) -> dt_name)
#define elf_dyn_lib_class(bfd)   (elf_tdata(bfd) -> dyn_lib_class)
#define elf_bad_symtab(bfd)   (elf_tdata(bfd) -> bad_symtab)
#define elf_flags_init(bfd)   (elf_tdata(bfd) -> flags_init)
#define _bfd_generic_init_private_section_data   _bfd_elf_init_private_section_data
#define _bfd_generic_find_line   _bfd_elf_find_line
#define _bfd_elf_read_minisymbols   _bfd_generic_read_minisymbols
#define _bfd_elf_minisymbol_to_symbol   _bfd_generic_minisymbol_to_symbol
#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H)
#define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel, r_symndx, symtab_hdr, sym_hashes, h, sec, relocation,unresolved_reloc, warned)
#define SYMBOLIC_BIND(INFO, H)   ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic))

Typedefs

typedef asection *(* elf_gc_mark_hook_fn )(asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *)

Enumerations

enum  elf_reloc_type_class { reloc_class_normal, reloc_class_relative, reloc_class_plt, reloc_class_copy }
enum  irix_compat_t { ict_none, ict_irix5, ict_irix6 }
enum  action_discarded { COMPLAIN = 1, PRETEND = 2 }

Functions

void _bfd_elf_swap_verdef_in (bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *)
void _bfd_elf_swap_verdef_out (bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *)
void _bfd_elf_swap_verdaux_in (bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *)
void _bfd_elf_swap_verdaux_out (bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *)
void _bfd_elf_swap_verneed_in (bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *)
void _bfd_elf_swap_verneed_out (bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *)
void _bfd_elf_swap_vernaux_in (bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *)
void _bfd_elf_swap_vernaux_out (bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *)
void _bfd_elf_swap_versym_in (bfd *, const Elf_External_Versym *, Elf_Internal_Versym *)
void _bfd_elf_swap_versym_out (bfd *, const Elf_Internal_Versym *, Elf_External_Versym *)
int _bfd_elf_section_from_bfd_section (bfd *, asection *)
char * bfd_elf_string_from_elf_section (bfd *, unsigned, unsigned)
char * bfd_elf_get_str_section (bfd *, unsigned)
Elf_Internal_Sym * bfd_elf_get_elf_syms (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *, Elf_External_Sym_Shndx *)
const char * bfd_elf_sym_name (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *)
bfd_boolean _bfd_elf_copy_private_bfd_data (bfd *, bfd *)
bfd_boolean _bfd_elf_print_private_bfd_data (bfd *, void *)
void bfd_elf_print_symbol (bfd *, void *, asymbol *, bfd_print_symbol_type)
void _bfd_elf_sprintf_vma (bfd *, char *, bfd_vma)
void _bfd_elf_fprintf_vma (bfd *, void *, bfd_vma)
unsigned int _bfd_elf_eh_frame_address_size (bfd *, asection *)
bfd_byte _bfd_elf_encode_eh_address (bfd *abfd, struct bfd_link_info *info, asection *osec, bfd_vma offset, asection *loc_sec, bfd_vma loc_offset, bfd_vma *encoded)
bfd_boolean _bfd_elf_can_make_relative (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section)
enum elf_reloc_type_class _bfd_elf_reloc_type_class (const Elf_Internal_Rela *)
bfd_vma _bfd_elf_rela_local_sym (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *)
bfd_vma _bfd_elf_rel_local_sym (bfd *, Elf_Internal_Sym *, asection **, bfd_vma)
bfd_vma _bfd_elf_section_offset (bfd *, struct bfd_link_info *, asection *, bfd_vma)
unsigned long bfd_elf_hash (const char *)
unsigned long bfd_elf_gnu_hash (const char *)
bfd_reloc_status_type bfd_elf_generic_reloc (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **)
bfd_boolean bfd_elf_mkobject (bfd *)
bfd_boolean bfd_elf_mkcorefile (bfd *)
Elf_Internal_Shdrbfd_elf_find_section (bfd *, char *)
bfd_boolean _bfd_elf_make_section_from_shdr (bfd *, Elf_Internal_Shdr *, const char *, int)
bfd_boolean _bfd_elf_make_section_from_phdr (bfd *, Elf_Internal_Phdr *, int, const char *)
struct bfd_hash_entry_bfd_elf_link_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *, const char *)
struct bfd_link_hash_table_bfd_elf_link_hash_table_create (bfd *)
void _bfd_elf_link_hash_copy_indirect (struct bfd_link_info *, struct elf_link_hash_entry *, struct elf_link_hash_entry *)
void _bfd_elf_link_hash_hide_symbol (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean)
bfd_boolean _bfd_elf_link_hash_fixup_symbol (struct bfd_link_info *, struct elf_link_hash_entry *)
bfd_boolean _bfd_elf_link_hash_table_init (struct elf_link_hash_table *, bfd *, struct bfd_hash_entry *(*)(struct bfd_hash_entry *, struct bfd_hash_table *, const char *), unsigned int)
bfd_boolean _bfd_elf_slurp_version_tables (bfd *, bfd_boolean)
bfd_boolean _bfd_elf_merge_sections (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_elf_match_sections_by_type (bfd *, const asection *, bfd *, const asection *)
bfd_boolean bfd_elf_is_group_section (bfd *, const struct bfd_section *)
void _bfd_elf_section_already_linked (bfd *, struct bfd_section *, struct bfd_link_info *)
void bfd_elf_set_group_contents (bfd *, asection *, void *)
asection_bfd_elf_check_kept_section (asection *, struct bfd_link_info *)
void _bfd_elf_link_just_syms (asection *, struct bfd_link_info *)
bfd_boolean _bfd_elf_copy_private_header_data (bfd *, bfd *)
bfd_boolean _bfd_elf_copy_private_symbol_data (bfd *, asymbol *, bfd *, asymbol *)
bfd_boolean _bfd_elf_init_private_section_data (bfd *, asection *, bfd *, asection *, struct bfd_link_info *)
bfd_boolean _bfd_elf_copy_private_section_data (bfd *, asection *, bfd *, asection *)
bfd_boolean _bfd_elf_write_object_contents (bfd *)
bfd_boolean _bfd_elf_write_corefile_contents (bfd *)
bfd_boolean _bfd_elf_set_section_contents (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type)
long _bfd_elf_get_symtab_upper_bound (bfd *)
long _bfd_elf_canonicalize_symtab (bfd *, asymbol **)
long _bfd_elf_get_dynamic_symtab_upper_bound (bfd *)
long _bfd_elf_canonicalize_dynamic_symtab (bfd *, asymbol **)
long _bfd_elf_get_synthetic_symtab (bfd *, long, asymbol **, long, asymbol **, asymbol **)
long _bfd_elf_get_reloc_upper_bound (bfd *, sec_ptr)
long _bfd_elf_canonicalize_reloc (bfd *, sec_ptr, arelent **, asymbol **)
long _bfd_elf_get_dynamic_reloc_upper_bound (bfd *)
long _bfd_elf_canonicalize_dynamic_reloc (bfd *, arelent **, asymbol **)
asymbol_bfd_elf_make_empty_symbol (bfd *)
void _bfd_elf_get_symbol_info (bfd *, asymbol *, symbol_info *)
bfd_boolean _bfd_elf_is_local_label_name (bfd *, const char *)
alent_bfd_elf_get_lineno (bfd *, asymbol *)
bfd_boolean _bfd_elf_set_arch_mach (bfd *, enum bfd_architecture, unsigned long)
bfd_boolean _bfd_elf_find_nearest_line (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, unsigned int *)
bfd_boolean _bfd_elf_find_line (bfd *, asymbol **, asymbol *, const char **, unsigned int *)
bfd_boolean _bfd_elf_find_inliner_info (bfd *, const char **, const char **, unsigned int *)
int _bfd_elf_sizeof_headers (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_elf_new_section_hook (bfd *, asection *)
bfd_boolean _bfd_elf_init_reloc_shdr (bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean)
struct bfd_elf_special_section_bfd_elf_get_special_section (const char *, const struct bfd_elf_special_section *, unsigned int)
struct bfd_elf_special_section_bfd_elf_get_sec_type_attr (bfd *, asection *)
void _bfd_elf_no_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *)
bfd_boolean bfd_section_from_shdr (bfd *, unsigned int shindex)
bfd_boolean bfd_section_from_phdr (bfd *, Elf_Internal_Phdr *, int)
int _bfd_elf_symbol_from_bfd_symbol (bfd *, asymbol **)
asectionbfd_section_from_r_symndx (bfd *, struct sym_sec_cache *, asection *, unsigned long)
asectionbfd_section_from_elf_index (bfd *, unsigned int)
struct bfd_strtab_hash_bfd_elf_stringtab_init (void)
struct elf_strtab_hash_bfd_elf_strtab_init (void)
void _bfd_elf_strtab_free (struct elf_strtab_hash *)
bfd_size_type _bfd_elf_strtab_add (struct elf_strtab_hash *, const char *, bfd_boolean)
void _bfd_elf_strtab_addref (struct elf_strtab_hash *, bfd_size_type)
void _bfd_elf_strtab_delref (struct elf_strtab_hash *, bfd_size_type)
void _bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *)
bfd_size_type _bfd_elf_strtab_size (struct elf_strtab_hash *)
bfd_size_type _bfd_elf_strtab_offset (struct elf_strtab_hash *, bfd_size_type)
bfd_boolean _bfd_elf_strtab_emit (bfd *, struct elf_strtab_hash *)
void _bfd_elf_strtab_finalize (struct elf_strtab_hash *)
bfd_boolean _bfd_elf_discard_section_eh_frame (bfd *, struct bfd_link_info *, asection *, bfd_boolean(*)(bfd_vma, void *), struct elf_reloc_cookie *)
bfd_boolean _bfd_elf_discard_section_eh_frame_hdr (bfd *, struct bfd_link_info *)
bfd_vma _bfd_elf_eh_frame_section_offset (bfd *, struct bfd_link_info *, asection *, bfd_vma)
bfd_boolean _bfd_elf_write_section_eh_frame (bfd *, struct bfd_link_info *, asection *, bfd_byte *)
bfd_boolean _bfd_elf_write_section_eh_frame_hdr (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr (struct bfd_link_info *)
bfd_boolean _bfd_elf_merge_symbol (bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection **, bfd_vma *, unsigned int *, struct elf_link_hash_entry **, bfd_boolean *, bfd_boolean *, bfd_boolean *, bfd_boolean *)
bfd_boolean _bfd_elf_hash_symbol (struct elf_link_hash_entry *)
bfd_boolean _bfd_elf_add_default_symbol (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, const char *, Elf_Internal_Sym *, asection **, bfd_vma *, bfd_boolean *, bfd_boolean)
bfd_boolean _bfd_elf_export_symbol (struct elf_link_hash_entry *, void *)
bfd_boolean _bfd_elf_link_find_version_dependencies (struct elf_link_hash_entry *, void *)
bfd_boolean _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *, void *)
long _bfd_elf_link_lookup_local_dynindx (struct bfd_link_info *, bfd *, long)
bfd_boolean _bfd_elf_compute_section_file_positions (bfd *, struct bfd_link_info *)
void _bfd_elf_assign_file_positions_for_relocs (bfd *)
file_ptr _bfd_elf_assign_file_position_for_section (Elf_Internal_Shdr *, file_ptr, bfd_boolean)
bfd_boolean _bfd_elf_validate_reloc (bfd *, arelent *)
bfd_boolean _bfd_elf_link_create_dynamic_sections (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_elf_link_omit_section_dynsym (bfd *, struct bfd_link_info *, asection *)
bfd_boolean _bfd_elf_create_dynamic_sections (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_elf_create_got_section (bfd *, struct bfd_link_info *)
struct elf_link_hash_entry_bfd_elf_define_linkage_sym (bfd *, struct bfd_link_info *, asection *, const char *)
void _bfd_elf_init_1_index_section (bfd *, struct bfd_link_info *)
void _bfd_elf_init_2_index_sections (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_elfcore_make_pseudosection (bfd *, char *, size_t, ufile_ptr)
char * _bfd_elfcore_strndup (bfd *, char *, size_t)
Elf_Internal_Rela_bfd_elf_link_read_relocs (bfd *, asection *, void *, Elf_Internal_Rela *, bfd_boolean)
bfd_boolean _bfd_elf_link_size_reloc_section (bfd *, Elf_Internal_Shdr *, asection *)
bfd_boolean _bfd_elf_link_output_relocs (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *, struct elf_link_hash_entry **)
bfd_boolean _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *, struct elf_info_failed *)
bfd_boolean _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *, void *)
bfd_boolean _bfd_elf_link_sec_merge_syms (struct elf_link_hash_entry *, void *)
bfd_boolean _bfd_elf_dynamic_symbol_p (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean)
bfd_boolean _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean)
bfd_boolean bfd_elf_match_symbols_in_sections (asection *, asection *, struct bfd_link_info *)
void bfd_elf_perform_complex_relocation (bfd *output_bfd ATTRIBUTE_UNUSED, struct bfd_link_info *info, bfd *input_bfd, asection *input_section, bfd_byte *contents, Elf_Internal_Rela *rel, Elf_Internal_Sym *local_syms, asection **local_sections)
bfd_boolean _bfd_elf_setup_sections (bfd *)
void _bfd_elf_set_osabi (bfd *, struct bfd_link_info *)
const bfd_targetbfd_elf32_object_p (bfd *)
const bfd_targetbfd_elf32_core_file_p (bfd *)
char * bfd_elf32_core_file_failing_command (bfd *)
int bfd_elf32_core_file_failing_signal (bfd *)
bfd_boolean bfd_elf32_core_file_matches_executable_p (bfd *, bfd *)
bfd_boolean bfd_elf32_swap_symbol_in (bfd *, const void *, const void *, Elf_Internal_Sym *)
void bfd_elf32_swap_symbol_out (bfd *, const Elf_Internal_Sym *, void *, void *)
void bfd_elf32_swap_reloc_in (bfd *, const bfd_byte *, Elf_Internal_Rela *)
void bfd_elf32_swap_reloc_out (bfd *, const Elf_Internal_Rela *, bfd_byte *)
void bfd_elf32_swap_reloca_in (bfd *, const bfd_byte *, Elf_Internal_Rela *)
void bfd_elf32_swap_reloca_out (bfd *, const Elf_Internal_Rela *, bfd_byte *)
void bfd_elf32_swap_phdr_in (bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *)
void bfd_elf32_swap_phdr_out (bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *)
void bfd_elf32_swap_dyn_in (bfd *, const void *, Elf_Internal_Dyn *)
void bfd_elf32_swap_dyn_out (bfd *, const Elf_Internal_Dyn *, void *)
long bfd_elf32_slurp_symbol_table (bfd *, asymbol **, bfd_boolean)
bfd_boolean bfd_elf32_write_shdrs_and_ehdr (bfd *)
int bfd_elf32_write_out_phdrs (bfd *, const Elf_Internal_Phdr *, unsigned int)
void bfd_elf32_write_relocs (bfd *, asection *, void *)
bfd_boolean bfd_elf32_slurp_reloc_table (bfd *, asection *, asymbol **, bfd_boolean)
const bfd_targetbfd_elf64_object_p (bfd *)
const bfd_targetbfd_elf64_core_file_p (bfd *)
char * bfd_elf64_core_file_failing_command (bfd *)
int bfd_elf64_core_file_failing_signal (bfd *)
bfd_boolean bfd_elf64_core_file_matches_executable_p (bfd *, bfd *)
bfd_boolean bfd_elf64_swap_symbol_in (bfd *, const void *, const void *, Elf_Internal_Sym *)
void bfd_elf64_swap_symbol_out (bfd *, const Elf_Internal_Sym *, void *, void *)
void bfd_elf64_swap_reloc_in (bfd *, const bfd_byte *, Elf_Internal_Rela *)
void bfd_elf64_swap_reloc_out (bfd *, const Elf_Internal_Rela *, bfd_byte *)
void bfd_elf64_swap_reloca_in (bfd *, const bfd_byte *, Elf_Internal_Rela *)
void bfd_elf64_swap_reloca_out (bfd *, const Elf_Internal_Rela *, bfd_byte *)
void bfd_elf64_swap_phdr_in (bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *)
void bfd_elf64_swap_phdr_out (bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *)
void bfd_elf64_swap_dyn_in (bfd *, const void *, Elf_Internal_Dyn *)
void bfd_elf64_swap_dyn_out (bfd *, const Elf_Internal_Dyn *, void *)
long bfd_elf64_slurp_symbol_table (bfd *, asymbol **, bfd_boolean)
bfd_boolean bfd_elf64_write_shdrs_and_ehdr (bfd *)
int bfd_elf64_write_out_phdrs (bfd *, const Elf_Internal_Phdr *, unsigned int)
void bfd_elf64_write_relocs (bfd *, asection *, void *)
bfd_boolean bfd_elf64_slurp_reloc_table (bfd *, asection *, asymbol **, bfd_boolean)
struct elf_link_hash_entry_bfd_elf_archive_symbol_lookup (bfd *, struct bfd_link_info *, const char *)
bfd_boolean bfd_elf_link_add_symbols (bfd *, struct bfd_link_info *)
bfd_boolean _bfd_elf_add_dynamic_entry (struct bfd_link_info *, bfd_vma, bfd_vma)
bfd_boolean bfd_elf_link_record_dynamic_symbol (struct bfd_link_info *, struct elf_link_hash_entry *)
int bfd_elf_link_record_local_dynamic_symbol (struct bfd_link_info *, bfd *, long)
void bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *, struct elf_link_hash_entry *, Elf_Internal_Sym *)
bfd_boolean _bfd_elf_close_and_cleanup (bfd *)
bfd_boolean _bfd_elf_common_definition (Elf_Internal_Sym *)
unsigned int _bfd_elf_common_section_index (asection *)
asection_bfd_elf_common_section (asection *)
void _bfd_dwarf2_cleanup_debug_info (bfd *)
bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn (bfd *, arelent *, struct bfd_symbol *, void *, asection *, bfd *, char **)
bfd_boolean bfd_elf_final_link (bfd *, struct bfd_link_info *)
bfd_boolean bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
bfd_boolean bfd_elf_gc_sections (bfd *, struct bfd_link_info *)
bfd_boolean bfd_elf_gc_record_vtinherit (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma)
bfd_boolean bfd_elf_gc_record_vtentry (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma)
asection_bfd_elf_gc_mark_hook (asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *)
bfd_boolean _bfd_elf_gc_mark (struct bfd_link_info *, asection *, asection *(*)(asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *))
bfd_boolean bfd_elf_gc_common_finalize_got_offsets (bfd *, struct bfd_link_info *)
bfd_boolean bfd_elf_gc_common_final_link (bfd *, struct bfd_link_info *)
bfd_boolean bfd_elf_reloc_symbol_deleted_p (bfd_vma, void *)
struct elf_segment_map_bfd_elf_make_dynamic_segment (bfd *, asection *)
bfd_boolean _bfd_elf_map_sections_to_segments (bfd *, struct bfd_link_info *)
char * elfcore_write_note (bfd *, char *, int *, const char *, int, const void *, int)
char * elfcore_write_prpsinfo (bfd *, char *, int *, const char *, const char *)
char * elfcore_write_prstatus (bfd *, char *, int *, long, int, const void *)
char * elfcore_write_pstatus (bfd *, char *, int *, long, int, const void *)
char * elfcore_write_prfpreg (bfd *, char *, int *, const void *, int)
char * elfcore_write_prxfpreg (bfd *, char *, int *, const void *, int)
char * elfcore_write_lwpstatus (bfd *, char *, int *, long, int, const void *)
bfd_bfd_elf32_bfd_from_remote_memory (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, int(*target_read_memory)(bfd_vma, bfd_byte *, int))
bfd_bfd_elf64_bfd_from_remote_memory (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, int(*target_read_memory)(bfd_vma, bfd_byte *, int))
bfd_boolean _sh_elf_set_mach_from_flags (bfd *)

Variables

asection _bfd_elf_large_com_section

Class Documentation

struct elf_symbol_type

Definition at line 57 of file elf-bfd.h.

Collaboration diagram for elf_symbol_type:
Class Members
Elf_Internal_Sym internal_elf_sym
asymbol symbol
union elf_symbol_type tc_data
unsigned short version
struct elf_link_hash_entry

Definition at line 85 of file elf-bfd.h.

Collaboration diagram for elf_link_hash_entry:
Class Members
unsigned int def_dynamic: 1
unsigned int def_regular: 1
unsigned int dynamic: 1
unsigned int dynamic_adjusted: 1
unsigned int dynamic_def: 1
unsigned int dynamic_weak: 1
long dynindx
unsigned long dynstr_index
unsigned int forced_local: 1
union gotplt_union got
unsigned int hidden: 1
long indx
unsigned int mark: 1
unsigned int needs_copy: 1
unsigned int needs_plt: 1
unsigned int non_elf: 1
unsigned int non_got_ref: 1
unsigned int other: 8
unsigned int pointer_equality_needed: 1
unsigned int ref_dynamic: 1
unsigned int ref_regular: 1
unsigned int ref_regular_nonweak: 1
bfd_size_type size
unsigned int type: 8
union elf_link_hash_entry u
union elf_link_hash_entry verinfo
struct elf_link_hash_entry vtable
union elf_link_hash_entry::gotplt_union

Definition at line 116 of file elf-bfd.h.

Collaboration diagram for elf_link_hash_entry::gotplt_union:
Class Members
struct got_entry * glist
bfd_vma offset
struct plt_entry * plist
bfd_signed_vma refcount
struct elf_link_local_dynamic_entry

Definition at line 240 of file elf-bfd.h.

Collaboration diagram for elf_link_local_dynamic_entry:
Class Members
long dynindx
bfd * input_bfd
long input_indx
Elf_Internal_Sym isym
struct
elf_link_local_dynamic_entry *
next
struct elf_link_loaded_list

Definition at line 257 of file elf-bfd.h.

Collaboration diagram for elf_link_loaded_list:
Class Members
bfd * abfd
struct elf_link_loaded_list * next
struct eh_cie_fde

Definition at line 264 of file elf-bfd.h.

Collaboration diagram for eh_cie_fde:
Class Members
unsigned int add_augmentation_size: 1
unsigned int add_fde_encoding: 1
unsigned int cie: 1
struct eh_cie_fde * cie_inf
unsigned char fde_encoding
unsigned char lsda_encoding
unsigned char lsda_offset
unsigned int make_lsda_relative: 1
unsigned int make_relative: 1
unsigned int need_lsda_relative: 1
unsigned int new_offset
unsigned int offset
unsigned int per_encoding_relative: 1
unsigned int removed: 1
unsigned int * set_loc
unsigned int size
struct eh_frame_sec_info

Definition at line 285 of file elf-bfd.h.

Class Members
unsigned int count
struct eh_frame_array_ent

Definition at line 291 of file elf-bfd.h.

Class Members
bfd_vma fde
bfd_vma initial_loc
struct eh_frame_hdr_info

Definition at line 299 of file elf-bfd.h.

Collaboration diagram for eh_frame_hdr_info:
Class Members
struct eh_frame_array_ent * array
unsigned int array_count
struct htab * cies
unsigned int fde_count
asection * hdr_sec
bfd_boolean offsets_adjusted
bfd_boolean table
struct elf_link_hash_table

Definition at line 314 of file elf-bfd.h.

Collaboration diagram for elf_link_hash_table:
Class Members
bfd_size_type bucketcount
asection * data_index_section
bfd_boolean dynamic_sections_created
struct
elf_link_local_dynamic_entry *
dynlocal
bfd * dynobj
struct elf_strtab_hash * dynstr
bfd_size_type dynsymcount
struct elf_link_hash_entry * hgot
struct elf_link_hash_entry * hplt
bfd_boolean is_relocatable_executable
struct elf_link_loaded_list * loaded
void * merge_info
struct bfd_link_needed_list * needed
struct bfd_link_needed_list * runpath
asection * text_index_section
asection * tls_sec
bfd_size_type tls_size
struct sym_sec_cache

Definition at line 421 of file elf-bfd.h.

Collaboration diagram for sym_sec_cache:
Class Members
bfd * abfd
unsigned long indx
asection * sec
struct elf_reloc_cookie

Definition at line 499 of file elf-bfd.h.

Collaboration diagram for elf_reloc_cookie:
Class Members
bfd * abfd
bfd_boolean bad_symtab
size_t extsymoff
size_t locsymcount
Elf_Internal_Sym * locsyms
int r_sym_shift
Elf_Internal_Rela * rel
Elf_Internal_Rela * relend
Elf_Internal_Rela * rels
struct elf_link_hash_entry ** sym_hashes
struct bfd_elf_special_section

Definition at line 520 of file elf-bfd.h.

Class Members
int attr
const char * prefix
int prefix_length
int suffix_length
int type
struct bfd_elf_section_data

Definition at line 1135 of file elf-bfd.h.

Collaboration diagram for bfd_elf_section_data:
Class Members
int dynindx
union bfd_elf_section_data group
asection * linked_to
void * local_dynrel
asection * next_in_group
unsigned int rel_count
unsigned int rel_count2
struct elf_link_hash_entry ** rel_hashes
Elf_Internal_Shdr rel_hdr
Elf_Internal_Shdr * rel_hdr2
int rel_idx
int rel_idx2
Elf_Internal_Rela * relocs
asection * sec_group
void * sec_info
asection * sreloc
Elf_Internal_Shdr this_hdr
int this_idx
struct elf_info_failed

Definition at line 1228 of file elf-bfd.h.

Collaboration diagram for elf_info_failed:
Class Members
bfd_boolean failed
struct bfd_link_info * info
struct bfd_elf_version_tree * verdefs
struct elf_assign_sym_version_info

Definition at line 1238 of file elf-bfd.h.

Collaboration diagram for elf_assign_sym_version_info:
Class Members
bfd_boolean failed
struct bfd_link_info * info
bfd * output_bfd
struct bfd_elf_version_tree * verdefs
struct elf_find_verdep_info

Definition at line 1253 of file elf-bfd.h.

Collaboration diagram for elf_find_verdep_info:
Class Members
bfd_boolean failed
struct bfd_link_info * info
bfd * output_bfd
unsigned int vers
struct elf_obj_tdata

Definition at line 1268 of file elf-bfd.h.

Collaboration diagram for elf_obj_tdata:
Class Members
char * core_command
int core_lwpid
int core_pid
char * core_program
int core_signal
unsigned int cverdefs
unsigned int cverrefs
const char * dt_name
struct dwarf1_debug * dwarf1_find_line_info
void * dwarf2_find_line_info
Elf_Internal_Shdr dynstrtab_hdr
Elf_Internal_Shdr dynsymtab_hdr
unsigned int dynsymtab_section
Elf_Internal_Shdr dynverdef_hdr
unsigned int dynverdef_section
Elf_Internal_Shdr dynverref_hdr
unsigned int dynverref_section
Elf_Internal_Shdr dynversym_hdr
unsigned int dynversym_section
asection * eh_frame_hdr
asection * elf_data_section
asymbol * elf_data_symbol
Elf_Internal_Ehdr elf_header
Elf_Internal_Shdr ** elf_sect_ptr
asection * elf_text_section
asymbol * elf_text_symbol
struct mips_elf_find_line * find_line_info
bfd_vma gp
unsigned int gp_size
Elf_Internal_Shdr ** group_sect_ptr
void * line_info
asection ** local_call_stubs
union elf_obj_tdata local_got
asection ** local_stubs
file_ptr next_file_pos
unsigned int num_elf_sections
int num_globals
int num_group
int num_locals
int num_section_syms
Elf_Internal_Phdr * phdr
bfd_size_type program_header_size
bfd_boolean relro
asymbol ** section_syms
struct elf_segment_map * segment_map
Elf_Internal_Shdr shstrtab_hdr
unsigned int shstrtab_section
unsigned int stack_flags
Elf_Internal_Shdr strtab_hdr
struct elf_strtab_hash * strtab_ptr
unsigned int strtab_section
struct elf_link_hash_entry ** sym_hashes
Elf_Internal_Shdr symtab_hdr
unsigned int symtab_section
Elf_Internal_Shdr symtab_shndx_hdr
unsigned int symtab_shndx_section
Elf_Internal_Verdef * verdef
Elf_Internal_Verneed * verref
union elf_symbol_type.tc_data

Definition at line 64 of file elf-bfd.h.

Class Members
void * any
unsigned int hppa_arg_reloc
void * mips_extr
union elf_link_hash_entry.u

Definition at line 178 of file elf-bfd.h.

Class Members
unsigned long elf_hash_value
struct elf_link_hash_entry * weakdef
union elf_link_hash_entry.verinfo

Definition at line 192 of file elf-bfd.h.

Class Members
Elf_Internal_Verdef * verdef
struct bfd_elf_version_tree * vertree
struct elf_link_hash_entry.vtable

Definition at line 204 of file elf-bfd.h.

Class Members
struct elf_link_hash_entry * parent
size_t size
bfd_boolean * used
union bfd_elf_section_data.group

Definition at line 1190 of file elf-bfd.h.

Class Members
struct bfd_symbol * id
const char * name
union elf_obj_tdata.local_got

Definition at line 1312 of file elf-bfd.h.

Class Members
struct got_entry ** ents
bfd_vma * offsets
bfd_signed_vma * refcounts

Define Documentation

Definition at line 1600 of file elf-bfd.h.

Definition at line 1599 of file elf-bfd.h.

Definition at line 1596 of file elf-bfd.h.

Definition at line 1551 of file elf-bfd.h.

#define core_prpsinfo (   bfd)    (elf_tdata(bfd) -> prpsinfo)

Definition at line 1423 of file elf-bfd.h.

#define core_prstatus (   bfd)    (elf_tdata(bfd) -> prstatus)

Definition at line 1424 of file elf-bfd.h.

#define elf_bad_symtab (   bfd)    (elf_tdata(bfd) -> bad_symtab)

Definition at line 1433 of file elf-bfd.h.

#define ELF_COMMON_DEF_P (   H)
Value:
(!(H)->def_regular                                             \
   && !(H)->def_dynamic                                               \
   && (H)->root.type == bfd_link_hash_defined)

Definition at line 233 of file elf-bfd.h.

#define elf_dt_name (   bfd)    (elf_tdata(bfd) -> dt_name)

Definition at line 1431 of file elf-bfd.h.

#define elf_dyn_lib_class (   bfd)    (elf_tdata(bfd) -> dyn_lib_class)

Definition at line 1432 of file elf-bfd.h.

#define elf_dynsymtab (   bfd)    (elf_tdata(bfd) -> dynsymtab_section)

Definition at line 1415 of file elf-bfd.h.

#define elf_dynverdef (   bfd)    (elf_tdata(bfd) -> dynverdef_section)

Definition at line 1417 of file elf-bfd.h.

#define elf_dynverref (   bfd)    (elf_tdata(bfd) -> dynverref_section)

Definition at line 1418 of file elf-bfd.h.

#define elf_dynversym (   bfd)    (elf_tdata(bfd) -> dynversym_section)

Definition at line 1416 of file elf-bfd.h.

#define elf_elfheader (   bfd)    (elf_tdata(bfd) -> elf_header)

Definition at line 1409 of file elf-bfd.h.

#define elf_elfsections (   bfd)    (elf_tdata(bfd) -> elf_sect_ptr)

Definition at line 1410 of file elf-bfd.h.

#define elf_flags_init (   bfd)    (elf_tdata(bfd) -> flags_init)

Definition at line 1434 of file elf-bfd.h.

#define elf_gp (   bfd)    (elf_tdata(bfd) -> gp)

Definition at line 1425 of file elf-bfd.h.

#define elf_gp_size (   bfd)    (elf_tdata(bfd) -> gp_size)

Definition at line 1426 of file elf-bfd.h.

#define elf_group_id (   sec)    (elf_section_data(sec)->group.id)

Definition at line 1215 of file elf-bfd.h.

#define elf_group_name (   sec)    (elf_section_data(sec)->group.name)

Definition at line 1214 of file elf-bfd.h.

#define elf_hash_table (   p)    ((struct elf_link_hash_table *) ((p)->hash))

Definition at line 412 of file elf-bfd.h.

#define elf_link_hash_lookup (   table,
  string,
  create,
  copy,
  follow 
)
Value:
((struct elf_link_hash_entry *)                                \
   bfd_link_hash_lookup (&(table)->root, (string), (create),          \
                      (copy), (follow)))

Definition at line 397 of file elf-bfd.h.

#define elf_link_hash_traverse (   table,
  func,
  info 
)
Value:
(bfd_link_hash_traverse                                        \
   (&(table)->root,                                            \
    (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),  \
    (info)))

Definition at line 404 of file elf-bfd.h.

#define elf_linked_to_section (   sec)    (elf_section_data(sec)->linked_to)

Definition at line 1211 of file elf-bfd.h.

#define elf_local_got_ents (   bfd)    (elf_tdata(bfd) -> local_got.ents)

Definition at line 1430 of file elf-bfd.h.

#define elf_local_got_offsets (   bfd)    (elf_tdata(bfd) -> local_got.offsets)

Definition at line 1429 of file elf-bfd.h.

#define elf_local_got_refcounts (   bfd)    (elf_tdata(bfd) -> local_got.refcounts)

Definition at line 1428 of file elf-bfd.h.

#define elf_next_in_group (   sec)    (elf_section_data(sec)->next_in_group)

Definition at line 1216 of file elf-bfd.h.

#define elf_num_globals (   bfd)    (elf_tdata(bfd) -> num_globals)

Definition at line 1420 of file elf-bfd.h.

#define elf_num_locals (   bfd)    (elf_tdata(bfd) -> num_locals)

Definition at line 1419 of file elf-bfd.h.

#define elf_num_section_syms (   bfd)    (elf_tdata(bfd) -> num_section_syms)

Definition at line 1422 of file elf-bfd.h.

#define elf_numsections (   bfd)    (elf_tdata(bfd) -> num_elf_sections)

Definition at line 1411 of file elf-bfd.h.

#define elf_onesymtab (   bfd)    (elf_tdata(bfd) -> symtab_section)

Definition at line 1413 of file elf-bfd.h.

#define elf_sec_group (   sec)    (elf_section_data(sec)->sec_group)

Definition at line 1217 of file elf-bfd.h.

#define elf_section_data (   sec)    ((struct bfd_elf_section_data*)(sec)->used_by_bfd)

Definition at line 1210 of file elf-bfd.h.

#define elf_section_flags (   sec)    (elf_section_data(sec)->this_hdr.sh_flags)

Definition at line 1213 of file elf-bfd.h.

#define elf_section_syms (   bfd)    (elf_tdata(bfd) -> section_syms)

Definition at line 1421 of file elf-bfd.h.

#define elf_section_type (   sec)    (elf_section_data(sec)->this_hdr.sh_type)

Definition at line 1212 of file elf-bfd.h.

#define elf_shstrtab (   bfd)    (elf_tdata(bfd) -> strtab_ptr)

Definition at line 1412 of file elf-bfd.h.

#define elf_sym_hashes (   bfd)    (elf_tdata(bfd) -> sym_hashes)

Definition at line 1427 of file elf-bfd.h.

#define elf_symbol_from (   ABFD,
  S 
)
Value:
(((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
         && (S)->the_bfd->tdata.elf_obj_data != 0) \
        ? (elf_symbol_type *) (S) \
        : 0)

Definition at line 486 of file elf-bfd.h.

#define elf_symtab_shndx (   bfd)    (elf_tdata(bfd) -> symtab_shndx_section)

Definition at line 1414 of file elf-bfd.h.

#define elf_tdata (   bfd)    ((bfd) -> tdata.elf_obj_data)

Definition at line 1408 of file elf-bfd.h.

#define ElfNAME (   X)    NAME(Elf,X)

Definition at line 49 of file elf-bfd.h.

#define elfNAME (   X)    NAME(elf,X)

Definition at line 50 of file elf-bfd.h.

Definition at line 1222 of file elf-bfd.h.

#define is_elf_hash_table (   htab)    (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)

Definition at line 415 of file elf-bfd.h.

#define LOCAL_SYM_CACHE_SIZE   32

Definition at line 420 of file elf-bfd.h.

#define MAX_INT_RELS_PER_EXT_REL   3

Definition at line 442 of file elf-bfd.h.

#define NAME (   x,
  y 
)    x ## NOSIZE ## _ ## y

Definition at line 46 of file elf-bfd.h.

#define NUM_SHDR_ENTRIES (   shdr)    ((shdr)->sh_size / (shdr)->sh_entsize)

Definition at line 33 of file elf-bfd.h.

#define RELOC_FOR_GLOBAL_SYMBOL (   info,
  input_bfd,
  input_section,
  rel,
  r_symndx,
  symtab_hdr,
  sym_hashes,
  h,
  sec,
  relocation,
  unresolved_reloc,
  warned 
)

Definition at line 1963 of file elf-bfd.h.

#define SYMBOL_CALLS_LOCAL (   INFO,
  H 
)    _bfd_elf_symbol_refs_local_p (H, INFO, 1)

Definition at line 228 of file elf-bfd.h.

#define SYMBOL_REFERENCES_LOCAL (   INFO,
  H 
)    _bfd_elf_symbol_refs_local_p (H, INFO, 0)

Definition at line 224 of file elf-bfd.h.

#define SYMBOLIC_BIND (   INFO,
  H 
)    ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic))

Definition at line 2018 of file elf-bfd.h.

#define WILL_CALL_FINISH_DYNAMIC_SYMBOL (   DYN,
  SHARED,
  H 
)
Value:
((DYN)                                                  \
   && ((SHARED) || !(H)->forced_local)                                \
   && ((H)->dynindx != -1 || (H)->forced_local))

Definition at line 1956 of file elf-bfd.h.

#define xvec_get_elf_backend_data (   xvec)    ((struct elf_backend_data *) (xvec)->backend_data)

Definition at line 1219 of file elf-bfd.h.


Typedef Documentation

Definition at line 542 of file elf-bfd.h.


Enumeration Type Documentation

Enumerator:
COMPLAIN 
PRETEND 

Definition at line 535 of file elf-bfd.h.

  {
    COMPLAIN = 1,
    PRETEND = 2
  };
Enumerator:
reloc_class_normal 
reloc_class_relative 
reloc_class_plt 
reloc_class_copy 

Definition at line 492 of file elf-bfd.h.

Enumerator:
ict_none 
ict_irix5 
ict_irix6 

Definition at line 513 of file elf-bfd.h.


Function Documentation

Definition at line 2788 of file dwarf2.c.

{
  struct comp_unit *each;
  struct dwarf2_debug *stash;

  if (abfd == NULL || elf_tdata (abfd) == NULL)
    return;

  stash = elf_tdata (abfd)->dwarf2_find_line_info;

  if (stash == NULL)
    return;

  for (each = stash->all_comp_units; each; each = each->next_unit)
    {
      struct abbrev_info **abbrevs = each->abbrevs;
      size_t i;

      for (i = 0; i < ABBREV_HASH_SIZE; i++)
       {
         struct abbrev_info *abbrev = abbrevs[i];

         while (abbrev)
           {
             free (abbrev->attrs);
             abbrev = abbrev->next;
           }
       }

      if (each->line_table)
       {
         free (each->line_table->dirs);
         free (each->line_table->files);
       }
    }

  free (stash->dwarf_abbrev_buffer);
  free (stash->dwarf_line_buffer);
  free (stash->dwarf_ranges_buffer);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bfd* _bfd_elf32_bfd_from_remote_memory ( bfd templ,
bfd_vma  ehdr_vma,
bfd_vma loadbasep,
int(*)(bfd_vma, bfd_byte *, int target_read_memory 
)
bfd* _bfd_elf64_bfd_from_remote_memory ( bfd templ,
bfd_vma  ehdr_vma,
bfd_vma loadbasep,
int(*)(bfd_vma, bfd_byte *, int target_read_memory 
)
bfd_boolean _bfd_elf_add_default_symbol ( bfd ,
struct bfd_link_info ,
struct elf_link_hash_entry ,
const char *  ,
Elf_Internal_Sym *  ,
asection **  ,
bfd_vma ,
bfd_boolean ,
bfd_boolean   
)

Definition at line 1432 of file elflink.c.

{
  bfd_boolean type_change_ok;
  bfd_boolean size_change_ok;
  bfd_boolean skip;
  char *shortname;
  struct elf_link_hash_entry *hi;
  struct bfd_link_hash_entry *bh;
  const struct elf_backend_data *bed;
  bfd_boolean collect;
  bfd_boolean dynamic;
  char *p;
  size_t len, shortlen;
  asection *sec;

  /* 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)
    return TRUE;

  if (override)
    {
      /* We are overridden by an old definition. We need to check if we
        need to create the indirect symbol from the default name.  */
      hi = elf_link_hash_lookup (elf_hash_table (info), name, TRUE,
                             FALSE, FALSE);
      BFD_ASSERT (hi != NULL);
      if (hi == h)
       return TRUE;
      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)
           return TRUE;
       }
    }

  bed = get_elf_backend_data (abfd);
  collect = bed->collect;
  dynamic = (abfd->flags & DYNAMIC) != 0;

  shortlen = p - name;
  shortname = bfd_hash_allocate (&info->hash->table, shortlen + 1);
  if (shortname == NULL)
    return FALSE;
  memcpy (shortname, name, shortlen);
  shortname[shortlen] = '\0';

  /* 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.  */
  type_change_ok = FALSE;
  size_change_ok = FALSE;
  sec = *psec;
  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
                           NULL, &hi, &skip, &override,
                           &type_change_ok, &size_change_ok))
    return FALSE;

  if (skip)
    goto nondefault;

  if (! override)
    {
      bh = &hi->root;
      if (! (_bfd_generic_link_add_one_symbol
            (info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr,
             0, name, FALSE, collect, &bh)))
       return FALSE;
      hi = (struct elf_link_hash_entry *) bh;
    }
  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->def_dynamic)
       {
         h->def_dynamic = 0;
         hi->ref_dynamic = 1;
         if (hi->ref_regular
             || hi->def_regular)
           {
             if (! bfd_elf_link_record_dynamic_symbol (info, hi))
              return FALSE;
           }
       }

      /* Now set HI to H, so that the following code will set the
        other fields correctly.  */
      hi = h;
    }

  /* Check if HI is a warning symbol.  */
  if (hi->root.type == bfd_link_hash_warning)
    hi = (struct elf_link_hash_entry *) hi->root.u.i.link;

  /* 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;

      ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
      (*bed->elf_backend_copy_indirect_symbol) (info, ht, hi);

      /* See if the new flags lead us to realize that the symbol must
        be dynamic.  */
      if (! *dynsym)
       {
         if (! dynamic)
           {
             if (info->shared
                || hi->ref_dynamic)
              *dynsym = TRUE;
           }
         else
           {
             if (hi->ref_regular)
              *dynsym = TRUE;
           }
       }
    }

  /* We also need to define an indirection from the nondefault version
     of the symbol.  */

nondefault:
  len = strlen (name);
  shortname = bfd_hash_allocate (&info->hash->table, len);
  if (shortname == NULL)
    return FALSE;
  memcpy (shortname, name, shortlen);
  memcpy (shortname + shortlen, p + 1, len - shortlen);

  /* Once again, merge with any existing symbol.  */
  type_change_ok = FALSE;
  size_change_ok = FALSE;
  sec = *psec;
  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
                           NULL, &hi, &skip, &override,
                           &type_change_ok, &size_change_ok))
    return FALSE;

  if (skip)
    return TRUE;

  if (override)
    {
      /* Here SHORTNAME is a versioned name, so we don't expect to see
        the type of override we do in the case above unless it is
        overridden by a versioned definition.  */
      if (hi->root.type != bfd_link_hash_defined
         && hi->root.type != bfd_link_hash_defweak)
       (*_bfd_error_handler)
         (_("%B: unexpected redefinition of indirect versioned symbol `%s'"),
          abfd, shortname);
    }
  else
    {
      bh = &hi->root;
      if (! (_bfd_generic_link_add_one_symbol
            (info, abfd, shortname, BSF_INDIRECT,
             bfd_ind_section_ptr, 0, name, FALSE, collect, &bh)))
       return FALSE;
      hi = (struct elf_link_hash_entry *) bh;

      /* 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)
       {
         (*bed->elf_backend_copy_indirect_symbol) (info, h, hi);

         /* See if the new flags lead us to realize that the symbol
            must be dynamic.  */
         if (! *dynsym)
           {
             if (! dynamic)
              {
                if (info->shared
                    || hi->ref_dynamic)
                  *dynsym = TRUE;
              }
             else
              {
                if (hi->ref_regular)
                  *dynsym = TRUE;
              }
           }
       }
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2898 of file elflink.c.

{
  struct elf_link_hash_table *hash_table;
  const struct elf_backend_data *bed;
  asection *s;
  bfd_size_type newsize;
  bfd_byte *newcontents;
  Elf_Internal_Dyn dyn;

  hash_table = elf_hash_table (info);
  if (! is_elf_hash_table (hash_table))
    return FALSE;

  bed = get_elf_backend_data (hash_table->dynobj);
  s = bfd_get_section_by_name (hash_table->dynobj, ".dynamic");
  BFD_ASSERT (s != NULL);

  newsize = s->size + bed->s->sizeof_dyn;
  newcontents = bfd_realloc (s->contents, newsize);
  if (newcontents == NULL)
    return FALSE;

  dyn.d_tag = tag;
  dyn.d_un.d_val = val;
  bed->s->swap_dyn_out (hash_table->dynobj, &dyn, newcontents + s->size);

  s->size = newsize;
  s->contents = newcontents;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2486 of file elflink.c.

{
  struct elf_info_failed *eif = data;
  bfd *dynobj;
  const struct elf_backend_data *bed;

  if (! is_elf_hash_table (eif->info->hash))
    return FALSE;

  if (h->root.type == bfd_link_hash_warning)
    {
      h->got = elf_hash_table (eif->info)->init_got_offset;
      h->plt = elf_hash_table (eif->info)->init_plt_offset;

      /* 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;
    }

  /* Ignore indirect symbols.  These are added by the versioning code.  */
  if (h->root.type == bfd_link_hash_indirect)
    return TRUE;

  /* Fix the symbol flags.  */
  if (! _bfd_elf_fix_symbol_flags (h, eif))
    return FALSE;

  /* 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->needs_plt
      && (h->def_regular
         || !h->def_dynamic
         || (!h->ref_regular
             && (h->u.weakdef == NULL || h->u.weakdef->dynindx == -1))))
    {
      h->plt = elf_hash_table (eif->info)->init_plt_offset;
      return TRUE;
    }

  /* If we've already adjusted this symbol, don't do it again.  This
     can happen via a recursive call.  */
  if (h->dynamic_adjusted)
    return TRUE;

  /* 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->dynamic_adjusted = 1;

  /* 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->u.weakdef != NULL)
    {
      /* 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->U.WEAKDEF before it finds H?  */
      h->u.weakdef->ref_regular = 1;

      if (! _bfd_elf_adjust_dynamic_symbol (h->u.weakdef, eif))
       return FALSE;
    }

  /* 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->needs_plt)
    (*_bfd_error_handler)
      (_("warning: type and size of dynamic symbol `%s' are not defined"),
       h->root.root.string);

  dynobj = elf_hash_table (eif->info)->dynobj;
  bed = get_elf_backend_data (dynobj);
  if (! (*bed->elf_backend_adjust_dynamic_symbol) (eif->info, h))
    {
      eif->failed = TRUE;
      return FALSE;
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4641 of file elflink.c.

{
  struct elf_link_hash_entry *h;
  char *p, *copy;
  size_t len, first;

  h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
  if (h != NULL)
    return h;

  /* If this is a default version (the name contains @@), 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.  */

  p = strchr (name, ELF_VER_CHR);
  if (p == NULL || p[1] != ELF_VER_CHR)
    return h;

  /* First check with only one `@'.  */
  len = strlen (name);
  copy = bfd_alloc (abfd, len);
  if (copy == NULL)
    return (struct elf_link_hash_entry *) 0 - 1;

  first = p - name + 1;
  memcpy (copy, name, first);
  memcpy (copy + first, name + first + 1, len - first);

  h = elf_link_hash_lookup (elf_hash_table (info), copy, FALSE, FALSE, FALSE);
  if (h == NULL)
    {
      /* 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), copy,
                            FALSE, FALSE, FALSE);
    }

  bfd_release (abfd, copy);
  return h;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3495 of file elf.c.

{
  if (align)
    {
      unsigned int al;

      al = i_shdrp->sh_addralign;
      if (al > 1)
       offset = BFD_ALIGN (offset, al);
    }
  i_shdrp->sh_offset = offset;
  if (i_shdrp->bfd_section != NULL)
    i_shdrp->bfd_section->filepos = offset;
  if (i_shdrp->sh_type != SHT_NOBITS)
    offset += i_shdrp->sh_size;
  return offset;
}

Here is the caller graph for this function:

Definition at line 5029 of file elf.c.

{
  file_ptr off;
  unsigned int i, num_sec;
  Elf_Internal_Shdr **shdrpp;

  off = elf_tdata (abfd)->next_file_pos;

  num_sec = elf_numsections (abfd);
  for (i = 1, shdrpp = elf_elfsections (abfd) + 1; i < num_sec; i++, shdrpp++)
    {
      Elf_Internal_Shdr *shdrp;

      shdrp = *shdrpp;
      if ((shdrp->sh_type == SHT_REL || shdrp->sh_type == SHT_RELA)
         && shdrp->sh_offset == -1)
       off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
    }

  elf_tdata (abfd)->next_file_pos = off;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bfd_boolean _bfd_elf_can_make_relative ( bfd input_bfd,
struct bfd_link_info info,
asection eh_frame_section 
)

Definition at line 6635 of file elf.c.

{
  bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
  asection *s;
  long ret;

  if (elf_dynsymtab (abfd) == 0)
    {
      bfd_set_error (bfd_error_invalid_operation);
      return -1;
    }

  slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
  ret = 0;
  for (s = abfd->sections; s != NULL; s = s->next)
    {
      if ((s->flags & SEC_LOAD) != 0
         && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
         && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
             || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
       {
         arelent *p;
         long count, i;

         if (! (*slurp_relocs) (abfd, s, syms, TRUE))
           return -1;
         count = s->size / elf_section_data (s)->this_hdr.sh_entsize;
         p = s->relocation;
         for (i = 0; i < count; i++)
           *storage++ = p++;
         ret += count;
       }
    }

  *storage = NULL;

  return ret;
}

Here is the call graph for this function:

Definition at line 6586 of file elf.c.

{
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
  long symcount = bed->s->slurp_symbol_table (abfd, allocation, TRUE);

  if (symcount >= 0)
    bfd_get_dynamic_symcount (abfd) = symcount;
  return symcount;
}

Definition at line 6553 of file elf.c.

{
  arelent *tblptr;
  unsigned int i;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);

  if (! bed->s->slurp_reloc_table (abfd, section, symbols, FALSE))
    return -1;

  tblptr = section->relocation;
  for (i = 0; i < section->reloc_count; i++)
    *relptr++ = tblptr++;

  *relptr = NULL;

  return section->reloc_count;
}

Definition at line 6575 of file elf.c.

{
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
  long symcount = bed->s->slurp_symbol_table (abfd, allocation, FALSE);

  if (symcount >= 0)
    bfd_get_symcount (abfd) = symcount;
  return symcount;
}

Definition at line 8015 of file elflink.c.

{
  asection *kept;

  kept = sec->kept_section;
  if (kept != NULL)
    {
      if ((kept->flags & SEC_GROUP) != 0)
       kept = match_group_member (sec, kept, info);
      if (kept != NULL && sec->size != kept->size)
       kept = NULL;
      sec->kept_section = kept;
    }
  return kept;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7388 of file elf.c.

Here is the call graph for this function:

Here is the caller graph for this function:

bfd_boolean _bfd_elf_common_definition ( Elf_Internal_Sym *  )

Definition at line 11240 of file elflink.c.

{
  return sym->st_shndx == SHN_COMMON;
}

Definition at line 3520 of file elf.c.

{
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
  bfd_boolean failed;
  struct bfd_strtab_hash *strtab = NULL;
  Elf_Internal_Shdr *shstrtab_hdr;

  if (abfd->output_has_begun)
    return TRUE;

  /* Do any elf backend specific processing first.  */
  if (bed->elf_backend_begin_write_processing)
    (*bed->elf_backend_begin_write_processing) (abfd, link_info);

  if (! prep_headers (abfd))
    return FALSE;

  /* Post process the headers if necessary.  */
  if (bed->elf_backend_post_process_headers)
    (*bed->elf_backend_post_process_headers) (abfd, link_info);

  failed = FALSE;
  bfd_map_over_sections (abfd, elf_fake_sections, &failed);
  if (failed)
    return FALSE;

  if (!assign_section_numbers (abfd, link_info))
    return FALSE;

  /* The backend linker builds symbol table information itself.  */
  if (link_info == NULL && bfd_get_symcount (abfd) > 0)
    {
      /* Non-zero if doing a relocatable link.  */
      int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC));

      if (! swap_out_syms (abfd, &strtab, relocatable_p))
       return FALSE;
    }

  if (link_info == NULL)
    {
      bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed);
      if (failed)
       return FALSE;
    }

  shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
  /* sh_name was set in prep_headers.  */
  shstrtab_hdr->sh_type = SHT_STRTAB;
  shstrtab_hdr->sh_flags = 0;
  shstrtab_hdr->sh_addr = 0;
  shstrtab_hdr->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
  shstrtab_hdr->sh_entsize = 0;
  shstrtab_hdr->sh_link = 0;
  shstrtab_hdr->sh_info = 0;
  /* sh_offset is set in assign_file_positions_except_relocs.  */
  shstrtab_hdr->sh_addralign = 1;

  if (!assign_file_positions_except_relocs (abfd, link_info))
    return FALSE;

  if (link_info == NULL && bfd_get_symcount (abfd) > 0)
    {
      file_ptr off;
      Elf_Internal_Shdr *hdr;

      off = elf_tdata (abfd)->next_file_pos;

      hdr = &elf_tdata (abfd)->symtab_hdr;
      off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);

      hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
      if (hdr->sh_size != 0)
       off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);

      hdr = &elf_tdata (abfd)->strtab_hdr;
      off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);

      elf_tdata (abfd)->next_file_pos = off;

      /* Now that we know where the .strtab section goes, write it
         out.  */
      if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
         || ! _bfd_stringtab_emit (abfd, strtab))
       return FALSE;
      _bfd_stringtab_free (strtab);
    }

  abfd->output_has_begun = TRUE;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1098 of file elf.c.

{
  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    return TRUE;

  BFD_ASSERT (!elf_flags_init (obfd)
             || (elf_elfheader (obfd)->e_flags
                == elf_elfheader (ibfd)->e_flags));

  elf_gp (obfd) = elf_gp (ibfd);
  elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
  elf_flags_init (obfd) = TRUE;
  return TRUE;
}

Here is the caller graph for this function:

Definition at line 6118 of file elf.c.

{
  asection *isec;

  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    return TRUE;

  /* Copy over private BFD data if it has not already been copied.
     This must be done here, rather than in the copy_private_bfd_data
     entry point, because the latter is called after the section
     contents have been set, which means that the program headers have
     already been worked out.  */
  if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL)
    {
      if (! copy_private_bfd_data (ibfd, obfd))
       return FALSE;
    }

  /* _bfd_elf_copy_private_section_data copied over the SHF_GROUP flag
     but this might be wrong if we deleted the group section.  */
  for (isec = ibfd->sections; isec != NULL; isec = isec->next)
    if (elf_section_type (isec) == SHT_GROUP
       && isec->output_section == NULL)
      {
       asection *first = elf_next_in_group (isec);
       asection *s = first;
       while (s != NULL)
         {
           if (s->output_section != NULL)
             {
              elf_section_flags (s->output_section) &= ~SHF_GROUP;
              elf_group_name (s->output_section) = NULL;
             }
           s = elf_next_in_group (s);
           if (s == first)
             break;
         }
      }

  return TRUE;
}

Here is the call graph for this function:

Definition at line 6089 of file elf.c.

{
  Elf_Internal_Shdr *ihdr, *ohdr;

  if (ibfd->xvec->flavour != bfd_target_elf_flavour
      || obfd->xvec->flavour != bfd_target_elf_flavour)
    return TRUE;

  ihdr = &elf_section_data (isec)->this_hdr;
  ohdr = &elf_section_data (osec)->this_hdr;

  ohdr->sh_entsize = ihdr->sh_entsize;

  if (ihdr->sh_type == SHT_SYMTAB
      || ihdr->sh_type == SHT_DYNSYM
      || ihdr->sh_type == SHT_GNU_verneed
      || ihdr->sh_type == SHT_GNU_verdef)
    ohdr->sh_info = ihdr->sh_info;

  return _bfd_elf_init_private_section_data (ibfd, isec, obfd, osec,
                                        NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6174 of file elf.c.

{
  elf_symbol_type *isym, *osym;

  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    return TRUE;

  isym = elf_symbol_from (ibfd, isymarg);
  osym = elf_symbol_from (obfd, osymarg);

  if (isym != NULL
      && osym != NULL
      && bfd_is_abs_section (isym->symbol.section))
    {
      unsigned int shndx;

      shndx = isym->internal_elf_sym.st_shndx;
      if (shndx == elf_onesymtab (ibfd))
       shndx = MAP_ONESYMTAB;
      else if (shndx == elf_dynsymtab (ibfd))
       shndx = MAP_DYNSYMTAB;
      else if (shndx == elf_tdata (ibfd)->strtab_section)
       shndx = MAP_STRTAB;
      else if (shndx == elf_tdata (ibfd)->shstrtab_section)
       shndx = MAP_SHSTRTAB;
      else if (shndx == elf_tdata (ibfd)->symtab_shndx_section)
       shndx = MAP_SYM_SHNDX;
      osym->internal_elf_sym.st_shndx = shndx;
    }

  return TRUE;
}

Definition at line 272 of file elflink.c.

{
  flagword flags, pltflags;
  struct elf_link_hash_entry *h;
  asection *s;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);

  /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
     .rel[a].bss sections.  */
  flags = bed->dynamic_sec_flags;

  pltflags = flags;
  if (bed->plt_not_loaded)
    /* We do not clear SEC_ALLOC here because we still want the OS to
       allocate space for the section; it's just that there's nothing
       to read in from the object file.  */
    pltflags &= ~ (SEC_CODE | SEC_LOAD | SEC_HAS_CONTENTS);
  else
    pltflags |= SEC_ALLOC | SEC_CODE | SEC_LOAD;
  if (bed->plt_readonly)
    pltflags |= SEC_READONLY;

  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
  if (s == NULL
      || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
    return FALSE;

  /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
     .plt section.  */
  if (bed->want_plt_sym)
    {
      h = _bfd_elf_define_linkage_sym (abfd, info, s,
                                   "_PROCEDURE_LINKAGE_TABLE_");
      elf_hash_table (info)->hplt = h;
      if (h == NULL)
       return FALSE;
    }

  s = bfd_make_section_with_flags (abfd,
                               (bed->default_use_rela_p
                                ? ".rela.plt" : ".rel.plt"),
                               flags | SEC_READONLY);
  if (s == NULL
      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
    return FALSE;

  if (! _bfd_elf_create_got_section (abfd, info))
    return FALSE;

  if (bed->want_dynbss)
    {
      /* The .dynbss section is a place to put symbols which are defined
        by dynamic objects, are referenced by regular objects, and are
        not functions.  We must allocate space for them in the process
        image and use a R_*_COPY reloc to tell the dynamic linker to
        initialize them at run time.  The linker script puts the .dynbss
        section into the .bss section of the final image.  */
      s = bfd_make_section_with_flags (abfd, ".dynbss",
                                   (SEC_ALLOC
                                   | SEC_LINKER_CREATED));
      if (s == NULL)
       return FALSE;

      /* The .rel[a].bss section holds copy relocs.  This section is not
        normally needed.  We need to create it here, though, so that the
        linker will map it to an output section.  We can't just create it
        only if we need it, because we will not know whether we need it
        until we have seen all the input files, and the first time the
        main linker code calls BFD after examining all the input files
        (size_dynamic_sections) the input sections have already been
        mapped to the output sections.  If the section turns out not to
        be needed, we can discard it later.  We will never need this
        section when generating a shared object, since they do not use
        copy relocs.  */
      if (! info->shared)
       {
         s = bfd_make_section_with_flags (abfd,
                                      (bed->default_use_rela_p
                                       ? ".rela.bss" : ".rel.bss"),
                                      flags | SEC_READONLY);
         if (s == NULL
             || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
           return FALSE;
       }
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 70 of file elflink.c.

{
  flagword flags;
  asection *s;
  struct elf_link_hash_entry *h;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
  int ptralign;

  /* This function may be called more than once.  */
  s = bfd_get_section_by_name (abfd, ".got");
  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
    return TRUE;

  switch (bed->s->arch_size)
    {
    case 32:
      ptralign = 2;
      break;

    case 64:
      ptralign = 3;
      break;

    default:
      bfd_set_error (bfd_error_bad_value);
      return FALSE;
    }

  flags = bed->dynamic_sec_flags;

  s = bfd_make_section_with_flags (abfd, ".got", flags);
  if (s == NULL
      || !bfd_set_section_alignment (abfd, s, ptralign))
    return FALSE;

  if (bed->want_got_plt)
    {
      s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
      if (s == NULL
         || !bfd_set_section_alignment (abfd, s, ptralign))
       return FALSE;
    }

  if (bed->want_got_sym)
    {
      /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
        (or .got.plt) section.  We don't do this in the linker script
        because we don't want to define the symbol if we are not creating
        a global offset table.  */
      h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
      elf_hash_table (info)->hgot = h;
      if (h == NULL)
       return FALSE;
    }

  /* The first bit of the global offset table is the header.  */
  s->size += bed->got_header_size;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 34 of file elflink.c.

{
  struct elf_link_hash_entry *h;
  struct bfd_link_hash_entry *bh;
  const struct elf_backend_data *bed;

  h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
  if (h != NULL)
    {
      /* Zap symbol defined in an as-needed lib that wasn't linked.
        This is a symptom of a larger problem:  Absolute symbols
        defined in shared libraries can't be overridden, because we
        lose the link to the bfd which is via the symbol section.  */
      h->root.type = bfd_link_hash_new;
    }

  bh = &h->root;
  if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL,
                                    sec, 0, NULL, FALSE,
                                    get_elf_backend_data (abfd)->collect,
                                    &bh))
    return NULL;
  h = (struct elf_link_hash_entry *) bh;
  h->def_regular = 1;
  h->type = STT_OBJECT;
  h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;

  bed = get_elf_backend_data (abfd);
  (*bed->elf_backend_hide_symbol) (info, h, TRUE);
  return h;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 433 of file elf-eh-frame.c.

{
#define REQUIRE(COND)                                   \
  do                                             \
    if (!(COND))                                 \
      goto free_no_table;                        \
  while (0)

  bfd_byte *ehbuf = NULL, *buf;
  bfd_byte *last_fde;
  struct eh_cie_fde *ent, *this_inf;
  unsigned int hdr_length, hdr_id;
  struct extended_cie
    {
      struct cie cie;
      unsigned int offset;
      unsigned int usage_count;
      unsigned int entry;
    } *ecies = NULL, *ecie;
  unsigned int ecie_count = 0, ecie_alloced = 0;
  struct cie *cie;
  struct elf_link_hash_table *htab;
  struct eh_frame_hdr_info *hdr_info;
  struct eh_frame_sec_info *sec_info = NULL;
  unsigned int offset;
  unsigned int ptr_size;
  unsigned int entry_alloced;

  if (sec->size == 0)
    {
      /* This file does not contain .eh_frame information.  */
      return FALSE;
    }

  if (bfd_is_abs_section (sec->output_section))
    {
      /* At least one of the sections is being discarded from the
        link, so we should just ignore them.  */
      return FALSE;
    }

  htab = elf_hash_table (info);
  hdr_info = &htab->eh_info;

  if (hdr_info->cies == NULL && !info->relocatable)
    hdr_info->cies = htab_try_create (1, cie_hash, cie_eq, free);

  /* Read the frame unwind information from abfd.  */

  REQUIRE (bfd_malloc_and_get_section (abfd, sec, &ehbuf));

  if (sec->size >= 4
      && bfd_get_32 (abfd, ehbuf) == 0
      && cookie->rel == cookie->relend)
    {
      /* Empty .eh_frame section.  */
      free (ehbuf);
      return FALSE;
    }

  /* If .eh_frame section size doesn't fit into int, we cannot handle
     it (it would need to use 64-bit .eh_frame format anyway).  */
  REQUIRE (sec->size == (unsigned int) sec->size);

  ptr_size = (get_elf_backend_data (abfd)
             ->elf_backend_eh_frame_address_size (abfd, sec));
  REQUIRE (ptr_size != 0);

  buf = ehbuf;
  sec_info = bfd_zmalloc (sizeof (struct eh_frame_sec_info)
                       + 99 * sizeof (struct eh_cie_fde));
  REQUIRE (sec_info);

  entry_alloced = 100;

#define ENSURE_NO_RELOCS(buf)                           \
  REQUIRE (!(cookie->rel < cookie->relend        \
            && (cookie->rel->r_offset                   \
               < (bfd_size_type) ((buf) - ehbuf))       \
            && cookie->rel->r_info != 0))

#define SKIP_RELOCS(buf)                         \
  while (cookie->rel < cookie->relend                   \
        && (cookie->rel->r_offset                \
            < (bfd_size_type) ((buf) - ehbuf)))  \
    cookie->rel++

#define GET_RELOC(buf)                                  \
  ((cookie->rel < cookie->relend                 \
    && (cookie->rel->r_offset                           \
       == (bfd_size_type) ((buf) - ehbuf)))             \
   ? cookie->rel : NULL)

  for (;;)
    {
      char *aug;
      bfd_byte *start, *end, *insns, *insns_end;
      bfd_size_type length;
      unsigned int set_loc_count;

      if (sec_info->count == entry_alloced)
       {
         sec_info = bfd_realloc (sec_info,
                              sizeof (struct eh_frame_sec_info)
                              + ((entry_alloced + 99)
                                 * sizeof (struct eh_cie_fde)));
         REQUIRE (sec_info);

         memset (&sec_info->entry[entry_alloced], 0,
                100 * sizeof (struct eh_cie_fde));
         entry_alloced += 100;
       }

      this_inf = sec_info->entry + sec_info->count;
      last_fde = buf;

      if ((bfd_size_type) (buf - ehbuf) == sec->size)
       break;

      /* Read the length of the entry.  */
      REQUIRE (skip_bytes (&buf, ehbuf + sec->size, 4));
      hdr_length = bfd_get_32 (abfd, buf - 4);

      /* 64-bit .eh_frame is not supported.  */
      REQUIRE (hdr_length != 0xffffffff);

      /* The CIE/FDE must be fully contained in this input section.  */
      REQUIRE ((bfd_size_type) (buf - ehbuf) + hdr_length <= sec->size);
      end = buf + hdr_length;

      this_inf->offset = last_fde - ehbuf;
      this_inf->size = 4 + hdr_length;

      if (hdr_length == 0)
       {
         /* A zero-length CIE should only be found at the end of
            the section.  */
         REQUIRE ((bfd_size_type) (buf - ehbuf) == sec->size);
         ENSURE_NO_RELOCS (buf);
         sec_info->count++;
         break;
       }

      REQUIRE (skip_bytes (&buf, end, 4));
      hdr_id = bfd_get_32 (abfd, buf - 4);

      if (hdr_id == 0)
       {
         unsigned int initial_insn_length;

         /* CIE  */
         this_inf->cie = 1;

         if (ecie_count == ecie_alloced)
           {
             ecies = bfd_realloc (ecies,
                               (ecie_alloced + 20) * sizeof (*ecies));
             REQUIRE (ecies);
             memset (&ecies[ecie_alloced], 0, 20 * sizeof (*ecies));
             ecie_alloced += 20;
           }

         cie = &ecies[ecie_count].cie;
         ecies[ecie_count].offset = this_inf->offset;
         ecies[ecie_count++].entry = sec_info->count;
         cie->length = hdr_length;
         start = buf;
         REQUIRE (read_byte (&buf, end, &cie->version));

         /* Cannot handle unknown versions.  */
         REQUIRE (cie->version == 1 || cie->version == 3);
         REQUIRE (strlen ((char *) buf) < sizeof (cie->augmentation));

         strcpy (cie->augmentation, (char *) buf);
         buf = (bfd_byte *) strchr ((char *) buf, '\0') + 1;
         ENSURE_NO_RELOCS (buf);
         if (buf[0] == 'e' && buf[1] == 'h')
           {
             /* GCC < 3.0 .eh_frame CIE */
             /* We cannot merge "eh" CIEs because __EXCEPTION_TABLE__
               is private to each CIE, so we don't need it for anything.
               Just skip it.  */
             REQUIRE (skip_bytes (&buf, end, ptr_size));
             SKIP_RELOCS (buf);
           }
         REQUIRE (read_uleb128 (&buf, end, &cie->code_align));
         REQUIRE (read_sleb128 (&buf, end, &cie->data_align));
         if (cie->version == 1)
           {
             REQUIRE (buf < end);
             cie->ra_column = *buf++;
           }
         else
           REQUIRE (read_uleb128 (&buf, end, &cie->ra_column));
         ENSURE_NO_RELOCS (buf);
         cie->lsda_encoding = DW_EH_PE_omit;
         cie->fde_encoding = DW_EH_PE_omit;
         cie->per_encoding = DW_EH_PE_omit;
         aug = cie->augmentation;
         if (aug[0] != 'e' || aug[1] != 'h')
           {
             if (*aug == 'z')
              {
                aug++;
                REQUIRE (read_uleb128 (&buf, end, &cie->augmentation_size));
                ENSURE_NO_RELOCS (buf);
              }

             while (*aug != '\0')
              switch (*aug++)
                {
                case 'L':
                  REQUIRE (read_byte (&buf, end, &cie->lsda_encoding));
                  ENSURE_NO_RELOCS (buf);
                  REQUIRE (get_DW_EH_PE_width (cie->lsda_encoding, ptr_size));
                  break;
                case 'R':
                  REQUIRE (read_byte (&buf, end, &cie->fde_encoding));
                  ENSURE_NO_RELOCS (buf);
                  REQUIRE (get_DW_EH_PE_width (cie->fde_encoding, ptr_size));
                  break;
                case 'S':
                  break;
                case 'P':
                  {
                    int per_width;

                    REQUIRE (read_byte (&buf, end, &cie->per_encoding));
                    per_width = get_DW_EH_PE_width (cie->per_encoding,
                                                ptr_size);
                    REQUIRE (per_width);
                    if ((cie->per_encoding & 0xf0) == DW_EH_PE_aligned)
                     {
                       length = -(buf - ehbuf) & (per_width - 1);
                       REQUIRE (skip_bytes (&buf, end, length));
                     }
                    ENSURE_NO_RELOCS (buf);
                    /* Ensure we have a reloc here, against
                      a global symbol.  */
                    if (GET_RELOC (buf) != NULL)
                     {
                       unsigned long r_symndx;

#ifdef BFD64
                       if (ptr_size == 8)
                         r_symndx = ELF64_R_SYM (cookie->rel->r_info);
                       else
#endif
                         r_symndx = ELF32_R_SYM (cookie->rel->r_info);
                       if (r_symndx >= cookie->locsymcount)
                         {
                           struct elf_link_hash_entry *h;

                           r_symndx -= cookie->extsymoff;
                           h = cookie->sym_hashes[r_symndx];

                           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;

                           cie->personality = h;
                         }
                       /* Cope with MIPS-style composite relocations.  */
                       do
                         cookie->rel++;
                       while (GET_RELOC (buf) != NULL);
                     }
                    REQUIRE (skip_bytes (&buf, end, per_width));
                    REQUIRE (cie->personality);
                  }
                  break;
                default:
                  /* Unrecognized augmentation. Better bail out.  */
                  goto free_no_table;
                }
           }

         /* For shared libraries, try to get rid of as many RELATIVE relocs
            as possible.  */
         if (info->shared
             && (get_elf_backend_data (abfd)
                ->elf_backend_can_make_relative_eh_frame
                (abfd, info, sec)))
           {
             if ((cie->fde_encoding & 0xf0) == DW_EH_PE_absptr)
              cie->make_relative = 1;
             /* If the CIE doesn't already have an 'R' entry, it's fairly
               easy to add one, provided that there's no aligned data
               after the augmentation string.  */
             else if (cie->fde_encoding == DW_EH_PE_omit
                     && (cie->per_encoding & 0xf0) != DW_EH_PE_aligned)
              {
                if (*cie->augmentation == 0)
                  this_inf->add_augmentation_size = 1;
                this_inf->add_fde_encoding = 1;
                cie->make_relative = 1;
              }
           }

         if (info->shared
             && (get_elf_backend_data (abfd)
                ->elf_backend_can_make_lsda_relative_eh_frame
                (abfd, info, sec))
             && (cie->lsda_encoding & 0xf0) == DW_EH_PE_absptr)
           cie->make_lsda_relative = 1;

         /* If FDE encoding was not specified, it defaults to
            DW_EH_absptr.  */
         if (cie->fde_encoding == DW_EH_PE_omit)
           cie->fde_encoding = DW_EH_PE_absptr;

         initial_insn_length = end - buf;
         if (initial_insn_length <= sizeof (cie->initial_instructions))
           {
             cie->initial_insn_length = initial_insn_length;
             memcpy (cie->initial_instructions, buf, initial_insn_length);
           }
         insns = buf;
         buf += initial_insn_length;
         ENSURE_NO_RELOCS (buf);
       }
      else
       {
         /* Find the corresponding CIE.  */
         unsigned int cie_offset = this_inf->offset + 4 - hdr_id;
         for (ecie = ecies; ecie < ecies + ecie_count; ++ecie)
           if (cie_offset == ecie->offset)
             break;

         /* Ensure this FDE references one of the CIEs in this input
            section.  */
         REQUIRE (ecie != ecies + ecie_count);
         cie = &ecie->cie;

         ENSURE_NO_RELOCS (buf);
         REQUIRE (GET_RELOC (buf));

         if ((*reloc_symbol_deleted_p) (buf - ehbuf, cookie))
           /* This is a FDE against a discarded section.  It should
              be deleted.  */
           this_inf->removed = 1;
         else
           {
             if (info->shared
                && (((cie->fde_encoding & 0xf0) == DW_EH_PE_absptr
                     && cie->make_relative == 0)
                    || (cie->fde_encoding & 0xf0) == DW_EH_PE_aligned))
              {
                /* If a shared library uses absolute pointers
                   which we cannot turn into PC relative,
                   don't create the binary search table,
                   since it is affected by runtime relocations.  */
                hdr_info->table = FALSE;
              }
             ecie->usage_count++;
             hdr_info->fde_count++;
             this_inf->cie_inf = (void *) (ecie - ecies);
           }

         /* Skip the initial location and address range.  */
         start = buf;
         length = get_DW_EH_PE_width (cie->fde_encoding, ptr_size);
         REQUIRE (skip_bytes (&buf, end, 2 * length));

         /* Skip the augmentation size, if present.  */
         if (cie->augmentation[0] == 'z')
           REQUIRE (read_uleb128 (&buf, end, &length));
         else
           length = 0;

         /* Of the supported augmentation characters above, only 'L'
            adds augmentation data to the FDE.  This code would need to
            be adjusted if any future augmentations do the same thing.  */
         if (cie->lsda_encoding != DW_EH_PE_omit)
           {
             this_inf->lsda_offset = buf - start;
             /* If there's no 'z' augmentation, we don't know where the
               CFA insns begin.  Assume no padding.  */
             if (cie->augmentation[0] != 'z')
              length = end - buf;
           }

         /* Skip over the augmentation data.  */
         REQUIRE (skip_bytes (&buf, end, length));
         insns = buf;

         buf = last_fde + 4 + hdr_length;
         SKIP_RELOCS (buf);
       }

      /* Try to interpret the CFA instructions and find the first
        padding nop.  Shrink this_inf's size so that it doesn't
        include the padding.  */
      length = get_DW_EH_PE_width (cie->fde_encoding, ptr_size);
      set_loc_count = 0;
      insns_end = skip_non_nops (insns, end, length, &set_loc_count);
      /* If we don't understand the CFA instructions, we can't know
        what needs to be adjusted there.  */
      if (insns_end == NULL
         /* For the time being we don't support DW_CFA_set_loc in
            CIE instructions.  */
         || (set_loc_count && this_inf->cie))
       goto free_no_table;
      this_inf->size -= end - insns_end;
      if (insns_end != end && this_inf->cie)
       {
         cie->initial_insn_length -= end - insns_end;
         cie->length -= end - insns_end;
       }
      if (set_loc_count
         && ((cie->fde_encoding & 0xf0) == DW_EH_PE_pcrel
             || cie->make_relative))
       {
         unsigned int cnt;
         bfd_byte *p;

         this_inf->set_loc = bfd_malloc ((set_loc_count + 1)
                                     * sizeof (unsigned int));
         REQUIRE (this_inf->set_loc);
         this_inf->set_loc[0] = set_loc_count;
         p = insns;
         cnt = 0;
         while (p < end)
           {
             if (*p == DW_CFA_set_loc)
              this_inf->set_loc[++cnt] = p + 1 - start;
             REQUIRE (skip_cfa_op (&p, end, length));
           }
       }

      this_inf->fde_encoding = cie->fde_encoding;
      this_inf->lsda_encoding = cie->lsda_encoding;
      sec_info->count++;
    }

  elf_section_data (sec)->sec_info = sec_info;
  sec->sec_info_type = ELF_INFO_TYPE_EH_FRAME;

  /* Look at all CIEs in this section and determine which can be
     removed as unused, which can be merged with previous duplicate
     CIEs and which need to be kept.  */
  for (ecie = ecies; ecie < ecies + ecie_count; ++ecie)
    {
      if (ecie->usage_count == 0)
       {
         sec_info->entry[ecie->entry].removed = 1;
         continue;
       }
      ecie->cie.output_sec = sec->output_section;
      ecie->cie.cie_inf = sec_info->entry + ecie->entry;
      cie_compute_hash (&ecie->cie);
      if (hdr_info->cies != NULL)
       {
         void **loc = htab_find_slot_with_hash (hdr_info->cies, &ecie->cie,
                                           ecie->cie.hash, INSERT);
         if (loc != NULL)
           {
             if (*loc != HTAB_EMPTY_ENTRY)
              {
                sec_info->entry[ecie->entry].removed = 1;
                ecie->cie.cie_inf = ((struct cie *) *loc)->cie_inf;
                continue;
              }

             *loc = malloc (sizeof (struct cie));
             if (*loc == NULL)
              *loc = HTAB_DELETED_ENTRY;
             else
              memcpy (*loc, &ecie->cie, sizeof (struct cie));
           }
       }
      ecie->cie.cie_inf->make_relative = ecie->cie.make_relative;
      ecie->cie.cie_inf->make_lsda_relative = ecie->cie.make_lsda_relative;
      ecie->cie.cie_inf->per_encoding_relative
       = (ecie->cie.per_encoding & 0x70) == DW_EH_PE_pcrel;
    }

  /* Ok, now we can assign new offsets.  */
  offset = 0;
  for (ent = sec_info->entry; ent < sec_info->entry + sec_info->count; ++ent)
    if (!ent->removed)
      {
       if (!ent->cie)
         {
           ecie = ecies + (unsigned long) ent->cie_inf;
           ent->cie_inf = ecie->cie.cie_inf;
         }
       ent->new_offset = offset;
       offset += size_of_output_cie_fde (ent, ptr_size);
      }

  /* Resize the sec as needed.  */
  sec->rawsize = sec->size;
  sec->size = offset;

  free (ehbuf);
  if (ecies)
    free (ecies);
  return offset != sec->rawsize;

free_no_table:
  if (ehbuf)
    free (ehbuf);
  if (sec_info)
    free (sec_info);
  if (ecies)
    free (ecies);
  hdr_info->table = FALSE;
  return FALSE;

#undef REQUIRE
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 954 of file elf-eh-frame.c.

{
  struct elf_link_hash_table *htab;
  struct eh_frame_hdr_info *hdr_info;
  asection *sec;

  htab = elf_hash_table (info);
  hdr_info = &htab->eh_info;

  if (hdr_info->cies != NULL)
    {
      htab_delete (hdr_info->cies);
      hdr_info->cies = NULL;
    }

  sec = hdr_info->hdr_sec;
  if (sec == NULL)
    return FALSE;

  sec->size = EH_FRAME_HDR_SIZE;
  if (hdr_info->table)
    sec->size += 4 + hdr_info->fde_count * 8;

  elf_tdata (abfd)->eh_frame_hdr = sec;
  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2638 of file elflink.c.

{
  bfd_boolean binding_stays_local_p;

  if (h == NULL)
    return FALSE;

  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 it was forced local, then clearly it's not dynamic.  */
  if (h->dynindx == -1)
    return FALSE;
  if (h->forced_local)
    return FALSE;

  /* Identify the cases where name binding rules say that a
     visible symbol resolves locally.  */
  binding_stays_local_p = info->executable || SYMBOLIC_BIND (info, h);

  switch (ELF_ST_VISIBILITY (h->other))
    {
    case STV_INTERNAL:
    case STV_HIDDEN:
      return FALSE;

    case STV_PROTECTED:
      /* Proper resolution for function pointer equality may require
        that these symbols perhaps be resolved dynamically, even though
        we should be resolving them to the current module.  */
      if (!ignore_protected || h->type != STT_FUNC)
       binding_stays_local_p = TRUE;
      break;

    default:
      break;
    }

  /* If it isn't defined locally, then clearly it's dynamic.  */
  if (!h->def_regular)
    return TRUE;

  /* Otherwise, the symbol is dynamic if binding rules don't tell
     us that it remains local.  */
  return !binding_stays_local_p;
}

Here is the caller graph for this function:

Here is the caller graph for this function:

bfd_byte _bfd_elf_encode_eh_address ( bfd abfd,
struct bfd_link_info info,
asection osec,
bfd_vma  offset,
asection loc_sec,
bfd_vma  loc_offset,
bfd_vma encoded 
)

Here is the caller graph for this function:

Definition at line 1669 of file elflink.c.

{
  struct elf_info_failed *eif = data;

  /* Ignore this if we won't export it.  */
  if (!eif->info->export_dynamic && !h->dynamic)
    return TRUE;

  /* Ignore indirect symbols.  These are added by the versioning code.  */
  if (h->root.type == bfd_link_hash_indirect)
    return TRUE;

  if (h->root.type == bfd_link_hash_warning)
    h = (struct elf_link_hash_entry *) h->root.u.i.link;

  if (h->dynindx == -1
      && (h->def_regular
         || h->ref_regular))
    {
      struct bfd_elf_version_tree *t;
      struct bfd_elf_version_expr *d;

      for (t = eif->verdefs; t != NULL; t = t->next)
       {
         if (t->globals.list != NULL)
           {
             d = (*t->match) (&t->globals, NULL, h->root.root.string);
             if (d != NULL)
              goto doit;
           }

         if (t->locals.list != NULL)
           {
             d = (*t->match) (&t->locals, NULL, h->root.root.string);
             if (d != NULL)
              return TRUE;
           }
       }

      if (!eif->verdefs)
       {
       doit:
         if (! bfd_elf_link_record_dynamic_symbol (eif->info, h))
           {
             eif->failed = TRUE;
             return FALSE;
           }
       }
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bfd_boolean _bfd_elf_find_inliner_info ( bfd ,
const char **  ,
const char **  ,
unsigned int  
)

Definition at line 7219 of file elf.c.

{
  bfd_boolean found;
  found = _bfd_dwarf2_find_inliner_info (abfd, filename_ptr,
                                    functionname_ptr, line_ptr,
                                    & elf_tdata (abfd)->dwarf2_find_line_info);
  return found;
}

Here is the call graph for this function:

bfd_boolean _bfd_elf_find_line ( bfd ,
asymbol **  ,
asymbol ,
const char **  ,
unsigned int  
)

Definition at line 7204 of file elf.c.

{
  return _bfd_dwarf2_find_line (abfd, symbols, symbol,
                            filename_ptr, line_ptr, 0,
                            &elf_tdata (abfd)->dwarf2_find_line_info);
}

Here is the call graph for this function:

bfd_boolean _bfd_elf_find_nearest_line ( bfd ,
asection ,
asymbol **  ,
bfd_vma  ,
const char **  ,
const char **  ,
unsigned int  
)

Definition at line 7147 of file elf.c.

{
  bfd_boolean found;

  if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
                                 filename_ptr, functionname_ptr,
                                 line_ptr))
    {
      if (!*functionname_ptr)
       elf_find_function (abfd, section, symbols, offset,
                        *filename_ptr ? NULL : filename_ptr,
                        functionname_ptr);

      return TRUE;
    }

  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
                                 filename_ptr, functionname_ptr,
                                 line_ptr, 0,
                                 &elf_tdata (abfd)->dwarf2_find_line_info))
    {
      if (!*functionname_ptr)
       elf_find_function (abfd, section, symbols, offset,
                        *filename_ptr ? NULL : filename_ptr,
                        functionname_ptr);

      return TRUE;
    }

  if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
                                        &found, filename_ptr,
                                        functionname_ptr, line_ptr,
                                        &elf_tdata (abfd)->line_info))
    return FALSE;
  if (found && (*functionname_ptr || *line_ptr))
    return TRUE;

  if (symbols == NULL)
    return FALSE;

  if (! elf_find_function (abfd, section, symbols, offset,
                        filename_ptr, functionname_ptr))
    return FALSE;

  *line_ptr = 0;
  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2337 of file elflink.c.

{
  const struct elf_backend_data *bed = NULL;

  /* 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->non_elf)
    {
      while (h->root.type == bfd_link_hash_indirect)
       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)
       {
         h->ref_regular = 1;
         h->ref_regular_nonweak = 1;
       }
      else
       {
         if (h->root.u.def.section->owner != NULL
             && (bfd_get_flavour (h->root.u.def.section->owner)
                == bfd_target_elf_flavour))
           {
             h->ref_regular = 1;
             h->ref_regular_nonweak = 1;
           }
         else
           h->def_regular = 1;
       }

      if (h->dynindx == -1
         && (h->def_dynamic
             || h->ref_dynamic))
       {
         if (! bfd_elf_link_record_dynamic_symbol (eif->info, h))
           {
             eif->failed = TRUE;
             return FALSE;
           }
       }
    }
  else
    {
      /* Unfortunately, NON_ELF is only correct if the symbol
        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.  */
      if ((h->root.type == bfd_link_hash_defined
          || h->root.type == bfd_link_hash_defweak)
         && !h->def_regular
         && (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->def_dynamic)))
       h->def_regular = 1;
    }

  /* Backend specific symbol fixup.  */
  if (elf_hash_table (eif->info)->dynobj)
    {
      bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
      if (bed->elf_backend_fixup_symbol
         && !(*bed->elf_backend_fixup_symbol) (eif->info, h))
       return FALSE;
    }

  /* 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 DEF_REGULAR
     flag will not have been set.  */
  if (h->root.type == bfd_link_hash_defined
      && !h->def_regular
      && h->ref_regular
      && !h->def_dynamic
      && (h->root.u.def.section->owner->flags & DYNAMIC) == 0)
    h->def_regular = 1;

  /* 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
     need a PLT entry.  Likewise, if the symbol has non-default
     visibility.  If the symbol has hidden or internal visibility, we
     will force it local.  */
  if (h->needs_plt
      && eif->info->shared
      && is_elf_hash_table (eif->info->hash)
      && (SYMBOLIC_BIND (eif->info, h)
         || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
      && h->def_regular)
    {
      bfd_boolean force_local;

      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);
    }

  /* If a weak undefined symbol has non-default visibility, we also
     hide it from the dynamic linker.  */
  if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
      && h->root.type == bfd_link_hash_undefweak)
    {
      const struct elf_backend_data *bed;
      bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
      (*bed->elf_backend_hide_symbol) (eif->info, h, TRUE);
    }

  /* 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->u.weakdef != NULL)
    {
      struct elf_link_hash_entry *weakdef;

      weakdef = h->u.weakdef;
      if (h->root.type == bfd_link_hash_indirect)
       h = (struct elf_link_hash_entry *) h->root.u.i.link;

      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->def_dynamic);

      /* If the real definition is defined by a regular object file,
        don't do anything special.  See the longer description in
        _bfd_elf_adjust_dynamic_symbol, below.  */
      if (weakdef->def_regular)
       h->u.weakdef = NULL;
      else
       (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef,
                                            h);
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _bfd_elf_fprintf_vma ( bfd ,
void *  ,
bfd_vma   
)
bfd_boolean _bfd_elf_gc_mark ( struct bfd_link_info ,
asection ,
asection *)(asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym * 
)

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 6603 of file elf.c.

{
  long ret;
  asection *s;

  if (elf_dynsymtab (abfd) == 0)
    {
      bfd_set_error (bfd_error_invalid_operation);
      return -1;
    }

  ret = sizeof (arelent *);
  for (s = abfd->sections; s != NULL; s = s->next)
    if ((s->flags & SEC_LOAD) != 0
       && elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd)
       && (elf_section_data (s)->this_hdr.sh_type == SHT_REL
           || elf_section_data (s)->this_hdr.sh_type == SHT_RELA))
      ret += ((s->size / elf_section_data (s)->this_hdr.sh_entsize)
             * sizeof (arelent *));

  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6523 of file elf.c.

{
  long symcount;
  long symtab_size;
  Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->dynsymtab_hdr;

  if (elf_dynsymtab (abfd) == 0)
    {
      bfd_set_error (bfd_error_invalid_operation);
      return -1;
    }

  symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
  symtab_size = (symcount + 1) * (sizeof (asymbol *));
  if (symcount > 0)
    symtab_size -= sizeof (asymbol *);

  return symtab_size;
}

Here is the call graph for this function:

alent* _bfd_elf_get_lineno ( bfd ,
asymbol  
)

Definition at line 2478 of file elf.c.

{
  int i;
  const struct bfd_elf_special_section *spec;
  const struct elf_backend_data *bed;

  /* See if this is one of the special sections.  */
  if (sec->name == NULL)
    return NULL;

  bed = get_elf_backend_data (abfd);
  spec = bed->special_sections;
  if (spec)
    {
      spec = _bfd_elf_get_special_section (sec->name,
                                      bed->special_sections,
                                      sec->use_rela_p);
      if (spec != NULL)
       return spec;
    }

  if (sec->name[0] != '.')
    return NULL;

  i = sec->name[1] - 'b';
  if (i < 0 || i > 't' - 'b')
    return NULL;

  spec = special_sections[i];

  if (spec == NULL)
    return NULL;

  return _bfd_elf_get_special_section (sec->name, spec, sec->use_rela_p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2430 of file elf.c.

{
  int i;
  int len;

  len = strlen (name);

  for (i = 0; spec[i].prefix != NULL; i++)
    {
      int suffix_len;
      int prefix_len = spec[i].prefix_length;

      if (len < prefix_len)
       continue;
      if (memcmp (name, spec[i].prefix, prefix_len) != 0)
       continue;

      suffix_len = spec[i].suffix_length;
      if (suffix_len <= 0)
       {
         if (name[prefix_len] != 0)
           {
             if (suffix_len == 0)
              continue;
             if (name[prefix_len] != '.'
                && (suffix_len == -2
                    || (rela && spec[i].type == SHT_REL)))
              continue;
           }
       }
      else
       {
         if (len < prefix_len + suffix_len)
           continue;
         if (memcmp (name + len - suffix_len,
                    spec[i].prefix + prefix_len,
                    suffix_len) != 0)
           continue;
       }
      return &spec[i];
    }

  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _bfd_elf_get_symbol_info ( bfd ,
asymbol ,
symbol_info  
)

Definition at line 6508 of file elf.c.

{
  long symcount;
  long symtab_size;
  Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr;

  symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
  symtab_size = (symcount + 1) * (sizeof (asymbol *));
  if (symcount > 0)
    symtab_size -= sizeof (asymbol *);

  return symtab_size;
}
long _bfd_elf_get_synthetic_symtab ( bfd ,
long  ,
asymbol **  ,
long  ,
asymbol **  ,
asymbol **   
)

Definition at line 5054 of file elflink.c.

{
  return !(h->forced_local
          || h->root.type == bfd_link_hash_undefined
          || h->root.type == bfd_link_hash_undefweak
          || ((h->root.type == bfd_link_hash_defined
              || h->root.type == bfd_link_hash_defweak)
              && h->root.u.def.section->output_section == NULL));
}

Here is the caller graph for this function:

Definition at line 5963 of file elflink.c.

{
  asection *s;

  for (s = output_bfd->sections; s != NULL; s = s->next)
    if ((s->flags & (SEC_EXCLUDE | SEC_ALLOC)) == SEC_ALLOC
       && !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
      {
       elf_hash_table (info)->text_index_section = s;
       break;
      }
}

Here is the call graph for this function:

Definition at line 5979 of file elflink.c.

{
  asection *s;

  for (s = output_bfd->sections; s != NULL; s = s->next)
    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY))
        == (SEC_ALLOC | SEC_READONLY))
       && !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
      {
       elf_hash_table (info)->text_index_section = s;
       break;
      }

  for (s = output_bfd->sections; s != NULL; s = s->next)
    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
       && !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
      {
       elf_hash_table (info)->data_index_section = s;
       break;
      }

  if (elf_hash_table (info)->text_index_section == NULL)
    elf_hash_table (info)->text_index_section
      = elf_hash_table (info)->data_index_section;
}

Here is the call graph for this function:

Definition at line 6022 of file elf.c.

{
  Elf_Internal_Shdr *ihdr, *ohdr;
  bfd_boolean need_group = link_info == NULL || link_info->relocatable;

  if (ibfd->xvec->flavour != bfd_target_elf_flavour
      || obfd->xvec->flavour != bfd_target_elf_flavour)
    return TRUE;

  /* Don't copy the output ELF section type from input if the
     output BFD section flags have been set to something different.
     elf_fake_sections will set ELF section type based on BFD
     section flags.  */
  if (osec->flags == isec->flags || !osec->flags)
    {
      BFD_ASSERT (osec->flags == isec->flags 
                || (!osec->flags
                    && elf_section_type (osec) == SHT_NULL));
      elf_section_type (osec) = elf_section_type (isec);
    }

  /* FIXME: Is this correct for all OS/PROC specific flags?  */
  elf_section_flags (osec) |= (elf_section_flags (isec)
                            & (SHF_MASKOS | SHF_MASKPROC));

  /* Set things up for objcopy and relocatable link.  The output
     SHT_GROUP section will have its elf_next_in_group pointing back
     to the input group members.  Ignore linker created group section.
     See elfNN_ia64_object_p in elfxx-ia64.c.  */
  if (need_group)
    {
      if (elf_sec_group (isec) == NULL
         || (elf_sec_group (isec)->flags & SEC_LINKER_CREATED) == 0)
       {
         if (elf_section_flags (isec) & SHF_GROUP)
           elf_section_flags (osec) |= SHF_GROUP;
         elf_next_in_group (osec) = elf_next_in_group (isec);
         elf_group_name (osec) = elf_group_name (isec);
       }
    }

  ihdr = &elf_section_data (isec)->this_hdr;

  /* We need to handle elf_linked_to_section for SHF_LINK_ORDER. We
     don't use the output section of the linked-to section since it
     may be NULL at this point.  */
  if ((ihdr->sh_flags & SHF_LINK_ORDER) != 0)
    {
      ohdr = &elf_section_data (osec)->this_hdr;
      ohdr->sh_flags |= SHF_LINK_ORDER;
      elf_linked_to_section (osec) = elf_linked_to_section (isec);
    }

  osec->use_rela_p = isec->use_rela_p;

  return TRUE;
}

Here is the caller graph for this function:

Definition at line 2703 of file elf.c.

{
  char *name;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
  bfd_size_type amt = sizeof ".rela" + strlen (asect->name);

  name = bfd_alloc (abfd, amt);
  if (name == NULL)
    return FALSE;
  sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
  rel_hdr->sh_name =
    (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name,
                                   FALSE);
  if (rel_hdr->sh_name == (unsigned int) -1)
    return FALSE;
  rel_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL;
  rel_hdr->sh_entsize = (use_rela_p
                      ? bed->s->sizeof_rela
                      : bed->s->sizeof_rel);
  rel_hdr->sh_addralign = 1 << bed->s->log_file_align;
  rel_hdr->sh_flags = 0;
  rel_hdr->sh_addr = 0;
  rel_hdr->sh_size = 0;
  rel_hdr->sh_offset = 0;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 1805 of file elflink.c.

{
  struct elf_assign_sym_version_info *sinfo;
  struct bfd_link_info *info;
  const struct elf_backend_data *bed;
  struct elf_info_failed eif;
  char *p;
  bfd_size_type amt;

  sinfo = data;
  info = sinfo->info;

  if (h->root.type == bfd_link_hash_warning)
    h = (struct elf_link_hash_entry *) h->root.u.i.link;

  /* Fix the symbol flags.  */
  eif.failed = FALSE;
  eif.info = info;
  if (! _bfd_elf_fix_symbol_flags (h, &eif))
    {
      if (eif.failed)
       sinfo->failed = TRUE;
      return FALSE;
    }

  /* We only need version numbers for symbols defined in regular
     objects.  */
  if (!h->def_regular)
    return TRUE;

  bed = get_elf_backend_data (sinfo->output_bfd);
  p = strchr (h->root.root.string, ELF_VER_CHR);
  if (p != NULL && h->verinfo.vertree == NULL)
    {
      struct bfd_elf_version_tree *t;
      bfd_boolean hidden;

      hidden = TRUE;

      /* There are two consecutive ELF_VER_CHR characters if this is
        not a hidden symbol.  */
      ++p;
      if (*p == ELF_VER_CHR)
       {
         hidden = FALSE;
         ++p;
       }

      /* If there is no version string, we can just return out.  */
      if (*p == '\0')
       {
         if (hidden)
           h->hidden = 1;
         return TRUE;
       }

      /* 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)
           {
             size_t len;
             char *alc;
             struct bfd_elf_version_expr *d;

             len = p - h->root.root.string;
             alc = bfd_malloc (len);
             if (alc == NULL)
              return FALSE;
             memcpy (alc, h->root.root.string, len - 1);
             alc[len - 1] = '\0';
             if (alc[len - 2] == ELF_VER_CHR)
              alc[len - 2] = '\0';

             h->verinfo.vertree = t;
             t->used = TRUE;
             d = NULL;

             if (t->globals.list != NULL)
              d = (*t->match) (&t->globals, NULL, alc);

             /* See if there is anything to force this symbol to
               local scope.  */
             if (d == NULL && t->locals.list != NULL)
              {
                d = (*t->match) (&t->locals, NULL, alc);
                if (d != NULL
                    && h->dynindx != -1
                    && ! info->export_dynamic)
                  (*bed->elf_backend_hide_symbol) (info, h, TRUE);
              }

             free (alc);
             break;
           }
       }

      /* If we are building an application, we need to create a
        version node for this version.  */
      if (t == NULL && info->executable)
       {
         struct bfd_elf_version_tree **pp;
         int version_index;

         /* If we aren't going to export this symbol, we don't need
            to worry about it.  */
         if (h->dynindx == -1)
           return TRUE;

         amt = sizeof *t;
         t = bfd_zalloc (sinfo->output_bfd, amt);
         if (t == NULL)
           {
             sinfo->failed = TRUE;
             return FALSE;
           }

         t->name = p;
         t->name_indx = (unsigned int) -1;
         t->used = TRUE;

         version_index = 1;
         /* Don't count anonymous version tag.  */
         if (sinfo->verdefs != NULL && sinfo->verdefs->vernum == 0)
           version_index = 0;
         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
            generating a shared archive.  Return an error.  */
         (*_bfd_error_handler)
           (_("%B: undefined versioned symbol name %s"),
            sinfo->output_bfd, h->root.root.string);
         bfd_set_error (bfd_error_bad_value);
         sinfo->failed = TRUE;
         return FALSE;
       }

      if (hidden)
       h->hidden = 1;
    }

  /* 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;
      struct bfd_elf_version_tree *local_ver;
      struct bfd_elf_version_expr *d;

      /* See if can find what version this symbol is in.  If the
        symbol is supposed to be local, then don't actually register
        it.  */
      local_ver = NULL;
      for (t = sinfo->verdefs; t != NULL; t = t->next)
       {
         if (t->globals.list != NULL)
           {
             bfd_boolean matched;

             matched = FALSE;
             d = NULL;
             while ((d = (*t->match) (&t->globals, d,
                                   h->root.root.string)) != NULL)
              if (d->symver)
                matched = TRUE;
              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;
                }
             if (d != NULL)
              break;
             else if (matched)
              /* There is no undefined version for this symbol. Hide the
                 default one.  */
              (*bed->elf_backend_hide_symbol) (info, h, TRUE);
           }

         if (t->locals.list != NULL)
           {
             d = NULL;
             while ((d = (*t->match) (&t->locals, d,
                                   h->root.root.string)) != NULL)
              {
                local_ver = t;
                /* If the match is "*", keep looking for a more
                   explicit, perhaps even global, match.
                   XXX: Shouldn't this be !d->wildcard instead?  */
                if (d->pattern[0] != '*' || d->pattern[1] != '\0')
                  break;
              }

             if (d != NULL)
              break;
           }
       }

      if (local_ver != NULL)
       {
         h->verinfo.vertree = local_ver;
         if (h->dynindx != -1
             && ! info->export_dynamic)
           {
             (*bed->elf_backend_hide_symbol) (info, h, TRUE);
           }
       }
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 158 of file elflink.c.

{
  flagword flags;
  register asection *s;
  const struct elf_backend_data *bed;

  if (! is_elf_hash_table (info->hash))
    return FALSE;

  if (elf_hash_table (info)->dynamic_sections_created)
    return TRUE;

  if (!_bfd_elf_link_create_dynstrtab (abfd, info))
    return FALSE;

  abfd = elf_hash_table (info)->dynobj;
  bed = get_elf_backend_data (abfd);

  flags = bed->dynamic_sec_flags;

  /* A dynamically linked executable has a .interp section, but a
     shared library does not.  */
  if (info->executable)
    {
      s = bfd_make_section_with_flags (abfd, ".interp",
                                   flags | SEC_READONLY);
      if (s == NULL)
       return FALSE;
    }

  /* Create sections to hold version informations.  These are removed
     if they are not needed.  */
  s = bfd_make_section_with_flags (abfd, ".gnu.version_d",
                               flags | SEC_READONLY);
  if (s == NULL
      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
    return FALSE;

  s = bfd_make_section_with_flags (abfd, ".gnu.version",
                               flags | SEC_READONLY);
  if (s == NULL
      || ! bfd_set_section_alignment (abfd, s, 1))
    return FALSE;

  s = bfd_make_section_with_flags (abfd, ".gnu.version_r",
                               flags | SEC_READONLY);
  if (s == NULL
      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
    return FALSE;

  s = bfd_make_section_with_flags (abfd, ".dynsym",
                               flags | SEC_READONLY);
  if (s == NULL
      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
    return FALSE;

  s = bfd_make_section_with_flags (abfd, ".dynstr",
                               flags | SEC_READONLY);
  if (s == NULL)
    return FALSE;

  s = bfd_make_section_with_flags (abfd, ".dynamic", flags);
  if (s == NULL
      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
    return FALSE;

  /* The special symbol _DYNAMIC is always set to the start of the
     .dynamic section.  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.  */
  if (!_bfd_elf_define_linkage_sym (abfd, info, s, "_DYNAMIC"))
    return FALSE;

  if (info->emit_hash)
    {
      s = bfd_make_section_with_flags (abfd, ".hash", flags | SEC_READONLY);
      if (s == NULL
         || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
       return FALSE;
      elf_section_data (s)->this_hdr.sh_entsize = bed->s->sizeof_hash_entry;
    }

  if (info->emit_gnu_hash)
    {
      s = bfd_make_section_with_flags (abfd, ".gnu.hash",
                                   flags | SEC_READONLY);
      if (s == NULL
         || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
       return FALSE;
      /* For 64-bit ELF, .gnu.hash is a non-uniform entity size section:
        4 32-bit words followed by variable count of 64-bit words, then
        variable count of 32-bit words.  */
      if (bed->s->arch_size == 64)
       elf_section_data (s)->this_hdr.sh_entsize = 0;
      else
       elf_section_data (s)->this_hdr.sh_entsize = 4;
    }

  /* 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))
    return FALSE;

  elf_hash_table (info)->dynamic_sections_created = TRUE;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1728 of file elflink.c.

{
  struct elf_find_verdep_info *rinfo = data;
  Elf_Internal_Verneed *t;
  Elf_Internal_Vernaux *a;
  bfd_size_type amt;

  if (h->root.type == bfd_link_hash_warning)
    h = (struct elf_link_hash_entry *) h->root.u.i.link;

  /* We only care about symbols defined in shared objects with version
     information.  */
  if (!h->def_dynamic
      || h->def_regular
      || h->dynindx == -1
      || h->verinfo.verdef == NULL)
    return TRUE;

  /* 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)
         return TRUE;

      break;
    }

  /* This is a new version.  Add it to tree we are building.  */

  if (t == NULL)
    {
      amt = sizeof *t;
      t = bfd_zalloc (rinfo->output_bfd, amt);
      if (t == NULL)
       {
         rinfo->failed = TRUE;
         return FALSE;
       }

      t->vn_bfd = h->verinfo.verdef->vd_bfd;
      t->vn_nextref = elf_tdata (rinfo->output_bfd)->verref;
      elf_tdata (rinfo->output_bfd)->verref = t;
    }

  amt = sizeof *a;
  a = bfd_zalloc (rinfo->output_bfd, amt);

  /* 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;

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1532 of file elf.c.

{
  struct elf_link_hash_table *htab;

  /* Copy down any references that we may have already seen to the
     symbol which just became indirect.  */

  dir->ref_dynamic |= ind->ref_dynamic;
  dir->ref_regular |= ind->ref_regular;
  dir->ref_regular_nonweak |= ind->ref_regular_nonweak;
  dir->non_got_ref |= ind->non_got_ref;
  dir->needs_plt |= ind->needs_plt;
  dir->pointer_equality_needed |= ind->pointer_equality_needed;

  if (ind->root.type != bfd_link_hash_indirect)
    return;

  /* Copy over the global and procedure linkage table refcount entries.
     These may have been already set up by a check_relocs routine.  */
  htab = elf_hash_table (info);
  if (ind->got.refcount > htab->init_got_refcount.refcount)
    {
      if (dir->got.refcount < 0)
       dir->got.refcount = 0;
      dir->got.refcount += ind->got.refcount;
      ind->got.refcount = htab->init_got_refcount.refcount;
    }

  if (ind->plt.refcount > htab->init_plt_refcount.refcount)
    {
      if (dir->plt.refcount < 0)
       dir->plt.refcount = 0;
      dir->plt.refcount += ind->plt.refcount;
      ind->plt.refcount = htab->init_plt_refcount.refcount;
    }

  if (ind->dynindx != -1)
    {
      if (dir->dynindx != -1)
       _bfd_elf_strtab_delref (htab->dynstr, dir->dynstr_index);
      dir->dynindx = ind->dynindx;
      dir->dynstr_index = ind->dynstr_index;
      ind->dynindx = -1;
      ind->dynstr_index = 0;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2319 of file elflink.c.

{
  if (info->pie
      && h->dynindx == -1
      && h->root.type == bfd_link_hash_undefweak)
    return bfd_elf_link_record_dynamic_symbol (info, h);

  return TRUE;
}

Here is the call graph for this function:

Definition at line 1582 of file elf.c.

{
  h->plt = elf_hash_table (info)->init_plt_offset;
  h->needs_plt = 0;
  if (force_local)
    {
      h->forced_local = 1;
      if (h->dynindx != -1)
       {
         h->dynindx = -1;
         _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
                              h->dynstr_index);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1491 of file elf.c.

{
  /* Allocate the structure if it has not already been allocated by a
     subclass.  */
  if (entry == NULL)
    {
      entry = bfd_hash_allocate (table, sizeof (struct elf_link_hash_entry));
      if (entry == NULL)
       return entry;
    }

  /* Call the allocation method of the superclass.  */
  entry = _bfd_link_hash_newfunc (entry, table, string);
  if (entry != NULL)
    {
      struct elf_link_hash_entry *ret = (struct elf_link_hash_entry *) entry;
      struct elf_link_hash_table *htab = (struct elf_link_hash_table *) table;

      /* Set local fields.  */
      ret->indx = -1;
      ret->dynindx = -1;
      ret->got = htab->init_got_refcount;
      ret->plt = htab->init_plt_refcount;
      memset (&ret->size, 0, (sizeof (struct elf_link_hash_entry)
                           - offsetof (struct elf_link_hash_entry, size)));
      /* Assume that we have been called by a non-ELF symbol reader.
         This flag is then reset by the code which reads an ELF input
         file.  This ensures that a symbol created by a non-ELF symbol
         reader will have the flag set correctly.  */
      ret->non_elf = 1;
    }

  return entry;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1631 of file elf.c.

{
  struct elf_link_hash_table *ret;
  bfd_size_type amt = sizeof (struct elf_link_hash_table);

  ret = bfd_malloc (amt);
  if (ret == NULL)
    return NULL;

  if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc,
                                   sizeof (struct elf_link_hash_entry)))
    {
      free (ret);
      return NULL;
    }

  return &ret->root;
}

Here is the call graph for this function:

bfd_boolean _bfd_elf_link_hash_table_init ( struct elf_link_hash_table ,
bfd ,
struct bfd_hash_entry *)(struct bfd_hash_entry *, struct bfd_hash_table *, const char *,
unsigned  int 
)

Here is the caller graph for this function:

Definition at line 1084 of file elf.c.

{
  sec->output_section = bfd_abs_section_ptr;
  sec->output_offset = sec->vma;
  if (!is_elf_hash_table (info->hash))
    return;

  sec->sec_info_type = ELF_INFO_TYPE_JUST_SYMS;
}

Definition at line 650 of file elflink.c.

{
  struct elf_link_local_dynamic_entry *e;

  for (e = elf_hash_table (info)->dynlocal; e ; e = e->next)
    if (e->input_bfd == input_bfd && e->input_indx == input_indx)
      return e->dynindx;
  return -1;
}

Here is the caller graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 2116 of file elflink.c.

{
  Elf_Internal_Shdr *rel_hdr;
  void *alloc1 = NULL;
  Elf_Internal_Rela *alloc2 = NULL;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);

  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)
    {
      bfd_size_type size;

      size = o->reloc_count;
      size *= bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
      if (keep_memory)
       internal_relocs = bfd_alloc (abfd, size);
      else
       internal_relocs = alloc2 = bfd_malloc (size);
      if (internal_relocs == NULL)
       goto error_return;
    }

  if (external_relocs == NULL)
    {
      bfd_size_type size = rel_hdr->sh_size;

      if (elf_section_data (o)->rel_hdr2)
       size += elf_section_data (o)->rel_hdr2->sh_size;
      alloc1 = bfd_malloc (size);
      if (alloc1 == NULL)
       goto error_return;
      external_relocs = alloc1;
    }

  if (!elf_link_read_relocs_from_section (abfd, o, rel_hdr,
                                     external_relocs,
                                     internal_relocs))
    goto error_return;
  if (elf_section_data (o)->rel_hdr2
      && (!elf_link_read_relocs_from_section
         (abfd, o,
          elf_section_data (o)->rel_hdr2,
          ((bfd_byte *) external_relocs) + rel_hdr->sh_size,
          internal_relocs + (NUM_SHDR_ENTRIES (rel_hdr)
                           * bed->s->int_rels_per_ext_rel))))
    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;
}

Here is the call graph for this function:

Definition at line 2609 of file elflink.c.

{
  asection *sec;

  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_defined
       || h->root.type == bfd_link_hash_defweak)
      && ((sec = h->root.u.def.section)->flags & SEC_MERGE)
      && sec->sec_info_type == ELF_INFO_TYPE_MERGE)
    {
      bfd *output_bfd = data;

      h->root.u.def.value =
       _bfd_merged_section_offset (output_bfd,
                                &h->root.u.def.section,
                                elf_section_data (sec)->sec_info,
                                h->root.u.def.value);
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2198 of file elflink.c.

{
  bfd_size_type reloc_count;
  bfd_size_type num_rel_hashes;

  /* 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;

  num_rel_hashes = o->reloc_count;
  if (num_rel_hashes < reloc_count)
    num_rel_hashes = reloc_count;

  /* That allows us to calculate the size of the section.  */
  rel_hdr->sh_size = rel_hdr->sh_entsize * reloc_count;

  /* The contents field must last into write_object_contents, so we
     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 = bfd_zalloc (abfd, rel_hdr->sh_size);
  if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
    return FALSE;

  /* We only allocate one set of hash entries, so we only do it the
     first time we are called.  */
  if (elf_section_data (o)->rel_hashes == NULL
      && num_rel_hashes)
    {
      struct elf_link_hash_entry **p;

      p = bfd_zmalloc (num_rel_hashes * sizeof (struct elf_link_hash_entry *));
      if (p == NULL)
       return FALSE;

      elf_section_data (o)->rel_hashes = p;
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3737 of file elf.c.

{
  struct elf_segment_map *m;

  m = bfd_zalloc (abfd, sizeof (struct elf_segment_map));
  if (m == NULL)
    return NULL;
  m->next = NULL;
  m->p_type = PT_DYNAMIC;
  m->count = 1;
  m->sections[0] = dynsec;
  
  return m;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6991 of file elf.c.

{
  elf_symbol_type *newsym;
  bfd_size_type amt = sizeof (elf_symbol_type);

  newsym = bfd_zalloc (abfd, amt);
  if (!newsym)
    return NULL;
  else
    {
      newsym->symbol.the_bfd = abfd;
      return &newsym->symbol;
    }
}

Here is the call graph for this function:

bfd_boolean _bfd_elf_make_section_from_phdr ( bfd ,
Elf_Internal_Phdr *  ,
int  ,
const char *   
)

Definition at line 2577 of file elf.c.

{
  asection *newsect;
  char *name;
  char namebuf[64];
  size_t len;
  int split;

  split = ((hdr->p_memsz > 0)
           && (hdr->p_filesz > 0)
           && (hdr->p_memsz > hdr->p_filesz));
  sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : "");
  len = strlen (namebuf) + 1;
  name = bfd_alloc (abfd, len);
  if (!name)
    return FALSE;
  memcpy (name, namebuf, len);
  newsect = bfd_make_section (abfd, name);
  if (newsect == NULL)
    return FALSE;
  newsect->vma = hdr->p_vaddr;
  newsect->lma = hdr->p_paddr;
  newsect->size = hdr->p_filesz;
  newsect->filepos = hdr->p_offset;
  newsect->flags |= SEC_HAS_CONTENTS;
  newsect->alignment_power = bfd_log2 (hdr->p_align);
  if (hdr->p_type == PT_LOAD)
    {
      newsect->flags |= SEC_ALLOC;
      newsect->flags |= SEC_LOAD;
      if (hdr->p_flags & PF_X)
       {
         /* FIXME: all we known is that it has execute PERMISSION,
            may be data.  */
         newsect->flags |= SEC_CODE;
       }
    }
  if (!(hdr->p_flags & PF_W))
    {
      newsect->flags |= SEC_READONLY;
    }

  if (split)
    {
      sprintf (namebuf, "%s%db", typename, index);
      len = strlen (namebuf) + 1;
      name = bfd_alloc (abfd, len);
      if (!name)
       return FALSE;
      memcpy (name, namebuf, len);
      newsect = bfd_make_section (abfd, name);
      if (newsect == NULL)
       return FALSE;
      newsect->vma = hdr->p_vaddr + hdr->p_filesz;
      newsect->lma = hdr->p_paddr + hdr->p_filesz;
      newsect->size = hdr->p_memsz - hdr->p_filesz;
      if (hdr->p_type == PT_LOAD)
       {
         newsect->flags |= SEC_ALLOC;
         if (hdr->p_flags & PF_X)
           newsect->flags |= SEC_CODE;
       }
      if (!(hdr->p_flags & PF_W))
       newsect->flags |= SEC_READONLY;
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 770 of file elf.c.

{
  asection *newsect;
  flagword flags;
  const struct elf_backend_data *bed;

  if (hdr->bfd_section != NULL)
    {
      BFD_ASSERT (strcmp (name,
                       bfd_get_section_name (abfd, hdr->bfd_section)) == 0);
      return TRUE;
    }

  newsect = bfd_make_section_anyway (abfd, name);
  if (newsect == NULL)
    return FALSE;

  hdr->bfd_section = newsect;
  elf_section_data (newsect)->this_hdr = *hdr;
  elf_section_data (newsect)->this_idx = shindex;

  /* Always use the real type/flags.  */
  elf_section_type (newsect) = hdr->sh_type;
  elf_section_flags (newsect) = hdr->sh_flags;

  newsect->filepos = hdr->sh_offset;

  if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
      || ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
      || ! bfd_set_section_alignment (abfd, newsect,
                                  bfd_log2 ((bfd_vma) hdr->sh_addralign)))
    return FALSE;

  flags = SEC_NO_FLAGS;
  if (hdr->sh_type != SHT_NOBITS)
    flags |= SEC_HAS_CONTENTS;
  if (hdr->sh_type == SHT_GROUP)
    flags |= SEC_GROUP | SEC_EXCLUDE;
  if ((hdr->sh_flags & SHF_ALLOC) != 0)
    {
      flags |= SEC_ALLOC;
      if (hdr->sh_type != SHT_NOBITS)
       flags |= SEC_LOAD;
    }
  if ((hdr->sh_flags & SHF_WRITE) == 0)
    flags |= SEC_READONLY;
  if ((hdr->sh_flags & SHF_EXECINSTR) != 0)
    flags |= SEC_CODE;
  else if ((flags & SEC_LOAD) != 0)
    flags |= SEC_DATA;
  if ((hdr->sh_flags & SHF_MERGE) != 0)
    {
      flags |= SEC_MERGE;
      newsect->entsize = hdr->sh_entsize;
      if ((hdr->sh_flags & SHF_STRINGS) != 0)
       flags |= SEC_STRINGS;
    }
  if (hdr->sh_flags & SHF_GROUP)
    if (!setup_group (abfd, hdr, newsect))
      return FALSE;
  if ((hdr->sh_flags & SHF_TLS) != 0)
    flags |= SEC_THREAD_LOCAL;

  if ((flags & SEC_ALLOC) == 0)
    {
      /* The debugging sections appear to be recognized only by name,
        not any sort of flag.  Their SEC_ALLOC bits are cleared.  */
      static const struct
       {
         const char *name;
         int len;
       } debug_sections [] =
       {
         { STRING_COMMA_LEN ("debug") },  /* 'd' */
         { NULL,             0  }, /* 'e' */
         { NULL,             0  }, /* 'f' */
         { STRING_COMMA_LEN ("gnu.linkonce.wi.") },     /* 'g' */
         { NULL,             0  }, /* 'h' */
         { NULL,             0  }, /* 'i' */
         { NULL,             0  }, /* 'j' */
         { NULL,             0  }, /* 'k' */
         { STRING_COMMA_LEN ("line") },   /* 'l' */
         { NULL,             0  }, /* 'm' */
         { NULL,             0  }, /* 'n' */
         { NULL,             0  }, /* 'o' */
         { NULL,             0  }, /* 'p' */
         { NULL,             0  }, /* 'q' */
         { NULL,             0  }, /* 'r' */
         { STRING_COMMA_LEN ("stab") }    /* 's' */
       };
      
      if (name [0] == '.')
       {
         int i = name [1] - 'd';
         if (i >= 0
             && i < (int) ARRAY_SIZE (debug_sections)
             && debug_sections [i].name != NULL
             && strncmp (&name [1], debug_sections [i].name,
                       debug_sections [i].len) == 0)
           flags |= SEC_DEBUGGING;
       }
    }

  /* As a GNU extension, if the name begins with .gnu.linkonce, we
     only link a single copy of the section.  This is used to support
     g++.  g++ will emit each template expansion in its own section.
     The symbols will be defined as weak, so that multiple definitions
     are permitted.  The GNU linker extension is to actually discard
     all but one of the sections.  */
  if (CONST_STRNEQ (name, ".gnu.linkonce")
      && elf_next_in_group (newsect) == NULL)
    flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;

  bed = get_elf_backend_data (abfd);
  if (bed->elf_backend_section_flags)
    if (! bed->elf_backend_section_flags (&flags, hdr))
      return FALSE;

  if (! bfd_set_section_flags (abfd, newsect, flags))
    return FALSE;

  if ((flags & SEC_ALLOC) != 0)
    {
      Elf_Internal_Phdr *phdr;
      unsigned int i;

      /* Look through the phdrs to see if we need to adjust the lma.
         If all the p_paddr fields are zero, we ignore them, since
         some ELF linkers produce such output.  */
      phdr = elf_tdata (abfd)->phdr;
      for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
       {
         if (phdr->p_paddr != 0)
           break;
       }
      if (i < elf_elfheader (abfd)->e_phnum)
       {
         phdr = elf_tdata (abfd)->phdr;
         for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
           {
             /* This section is part of this segment if its file
               offset plus size lies within the segment's memory
               span and, if the section is loaded, the extent of the
               loaded data lies within the extent of the segment.

               Note - we used to check the p_paddr field as well, and
               refuse to set the LMA if it was 0.  This is wrong
               though, as a perfectly valid initialised segment can
               have a p_paddr of zero.  Some architectures, eg ARM,
                place special significance on the address 0 and
                executables need to be able to have a segment which
                covers this address.  */
             if (phdr->p_type == PT_LOAD
                && (bfd_vma) hdr->sh_offset >= phdr->p_offset
                && (hdr->sh_offset + hdr->sh_size
                    <= phdr->p_offset + phdr->p_memsz)
                && ((flags & SEC_LOAD) == 0
                    || (hdr->sh_offset + hdr->sh_size
                       <= phdr->p_offset + phdr->p_filesz)))
              {
                if ((flags & SEC_LOAD) == 0)
                  newsect->lma = (phdr->p_paddr
                                + hdr->sh_addr - phdr->p_vaddr);
                else
                  /* We used to use the same adjustment for SEC_LOAD
                     sections, but that doesn't work if the segment
                     is packed with code from multiple VMAs.
                     Instead we calculate the section LMA based on
                     the segment LMA.  It is assumed that the
                     segment will contain sections with contiguous
                     LMAs, even if the VMAs are not.  */
                  newsect->lma = (phdr->p_paddr
                                + hdr->sh_offset - phdr->p_offset);

                /* With contiguous segments, we can't tell from file
                   offsets whether a section with zero size should
                   be placed at the end of one segment or the
                   beginning of the next.  Decide based on vaddr.  */
                if (hdr->sh_addr >= phdr->p_vaddr
                    && (hdr->sh_addr + hdr->sh_size
                       <= phdr->p_vaddr + phdr->p_memsz))
                  break;
              }
           }
       }
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3801 of file elf.c.

{
  unsigned int count;
  struct elf_segment_map *m;
  asection **sections = NULL;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);

  if (elf_tdata (abfd)->segment_map == NULL
      && bfd_count_sections (abfd) != 0)
    {
      asection *s;
      unsigned int i;
      struct elf_segment_map *mfirst;
      struct elf_segment_map **pm;
      asection *last_hdr;
      bfd_vma last_size;
      unsigned int phdr_index;
      bfd_vma maxpagesize;
      asection **hdrpp;
      bfd_boolean phdr_in_segment = TRUE;
      bfd_boolean writable;
      int tls_count = 0;
      asection *first_tls = NULL;
      asection *dynsec, *eh_frame_hdr;
      bfd_size_type amt;

      /* Select the allocated sections, and sort them.  */

      sections = bfd_malloc2 (bfd_count_sections (abfd), sizeof (asection *));
      if (sections == NULL)
       goto error_return;

      i = 0;
      for (s = abfd->sections; s != NULL; s = s->next)
       {
         if ((s->flags & SEC_ALLOC) != 0)
           {
             sections[i] = s;
             ++i;
           }
       }
      BFD_ASSERT (i <= bfd_count_sections (abfd));
      count = i;

      qsort (sections, (size_t) count, sizeof (asection *), elf_sort_sections);

      /* Build the mapping.  */

      mfirst = NULL;
      pm = &mfirst;

      /* If we have a .interp section, then create a PT_PHDR segment for
        the program headers and a PT_INTERP segment for the .interp
        section.  */
      s = bfd_get_section_by_name (abfd, ".interp");
      if (s != NULL && (s->flags & SEC_LOAD) != 0)
       {
         amt = sizeof (struct elf_segment_map);
         m = bfd_zalloc (abfd, amt);
         if (m == NULL)
           goto error_return;
         m->next = NULL;
         m->p_type = PT_PHDR;
         /* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not.  */
         m->p_flags = PF_R | PF_X;
         m->p_flags_valid = 1;
         m->includes_phdrs = 1;

         *pm = m;
         pm = &m->next;

         amt = sizeof (struct elf_segment_map);
         m = bfd_zalloc (abfd, amt);
         if (m == NULL)
           goto error_return;
         m->next = NULL;
         m->p_type = PT_INTERP;
         m->count = 1;
         m->sections[0] = s;

         *pm = m;
         pm = &m->next;
       }

      /* Look through the sections.  We put sections in the same program
        segment when the start of the second section can be placed within
        a few bytes of the end of the first section.  */
      last_hdr = NULL;
      last_size = 0;
      phdr_index = 0;
      maxpagesize = bed->maxpagesize;
      writable = FALSE;
      dynsec = bfd_get_section_by_name (abfd, ".dynamic");
      if (dynsec != NULL
         && (dynsec->flags & SEC_LOAD) == 0)
       dynsec = NULL;

      /* Deal with -Ttext or something similar such that the first section
        is not adjacent to the program headers.  This is an
        approximation, since at this point we don't know exactly how many
        program headers we will need.  */
      if (count > 0)
       {
         bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;

         if (phdr_size == (bfd_size_type) -1)
           phdr_size = get_program_header_size (abfd, info);
         if ((abfd->flags & D_PAGED) == 0
             || sections[0]->lma < phdr_size
             || sections[0]->lma % maxpagesize < phdr_size % maxpagesize)
           phdr_in_segment = FALSE;
       }

      for (i = 0, hdrpp = sections; i < count; i++, hdrpp++)
       {
         asection *hdr;
         bfd_boolean new_segment;

         hdr = *hdrpp;

         /* See if this section and the last one will fit in the same
            segment.  */

         if (last_hdr == NULL)
           {
             /* If we don't have a segment yet, then we don't need a new
               one (we build the last one after this loop).  */
             new_segment = FALSE;
           }
         else if (last_hdr->lma - last_hdr->vma != hdr->lma - hdr->vma)
           {
             /* If this section has a different relation between the
               virtual address and the load address, then we need a new
               segment.  */
             new_segment = TRUE;
           }
         else if (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize)
                 < BFD_ALIGN (hdr->lma, maxpagesize))
           {
             /* If putting this section in this segment would force us to
               skip a page in the segment, then we need a new segment.  */
             new_segment = TRUE;
           }
         else if ((last_hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0
                 && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0)
           {
             /* We don't want to put a loadable section after a
               nonloadable section in the same segment.
               Consider .tbss sections as loadable for this purpose.  */
             new_segment = TRUE;
           }
         else if ((abfd->flags & D_PAGED) == 0)
           {
             /* If the file is not demand paged, which means that we
               don't require the sections to be correctly aligned in the
               file, then there is no other reason for a new segment.  */
             new_segment = FALSE;
           }
         else if (! writable
                 && (hdr->flags & SEC_READONLY) == 0
                 && (((last_hdr->lma + last_size - 1)
                     & ~(maxpagesize - 1))
                     != (hdr->lma & ~(maxpagesize - 1))))
           {
             /* We don't want to put a writable section in a read only
               segment, unless they are on the same page in memory
               anyhow.  We already know that the last section does not
               bring us past the current section on the page, so the
               only case in which the new section is not on the same
               page as the previous section is when the previous section
               ends precisely on a page boundary.  */
             new_segment = TRUE;
           }
         else
           {
             /* Otherwise, we can use the same segment.  */
             new_segment = FALSE;
           }

         /* Allow interested parties a chance to override our decision.  */
         if (last_hdr && info->callbacks->override_segment_assignment)
           new_segment = info->callbacks->override_segment_assignment (info, abfd, hdr, last_hdr, new_segment);

         if (! new_segment)
           {
             if ((hdr->flags & SEC_READONLY) == 0)
              writable = TRUE;
             last_hdr = hdr;
             /* .tbss sections effectively have zero size.  */
             if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD))
                != SEC_THREAD_LOCAL)
              last_size = hdr->size;
             else
              last_size = 0;
             continue;
           }

         /* We need a new program segment.  We must create a new program
            header holding all the sections from phdr_index until hdr.  */

         m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
         if (m == NULL)
           goto error_return;

         *pm = m;
         pm = &m->next;

         if ((hdr->flags & SEC_READONLY) == 0)
           writable = TRUE;
         else
           writable = FALSE;

         last_hdr = hdr;
         /* .tbss sections effectively have zero size.  */
         if ((hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) != SEC_THREAD_LOCAL)
           last_size = hdr->size;
         else
           last_size = 0;
         phdr_index = i;
         phdr_in_segment = FALSE;
       }

      /* Create a final PT_LOAD program segment.  */
      if (last_hdr != NULL)
       {
         m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
         if (m == NULL)
           goto error_return;

         *pm = m;
         pm = &m->next;
       }

      /* If there is a .dynamic section, throw in a PT_DYNAMIC segment.  */
      if (dynsec != NULL)
       {
         m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
         if (m == NULL)
           goto error_return;
         *pm = m;
         pm = &m->next;
       }

      /* For each loadable .note section, add a PT_NOTE segment.  We don't
        use bfd_get_section_by_name, because if we link together
        nonloadable .note sections and loadable .note sections, we will
        generate two .note sections in the output file.  FIXME: Using
        names for section types is bogus anyhow.  */
      for (s = abfd->sections; s != NULL; s = s->next)
       {
         if ((s->flags & SEC_LOAD) != 0
             && CONST_STRNEQ (s->name, ".note"))
           {
             amt = sizeof (struct elf_segment_map);
             m = bfd_zalloc (abfd, amt);
             if (m == NULL)
              goto error_return;
             m->next = NULL;
             m->p_type = PT_NOTE;
             m->count = 1;
             m->sections[0] = s;

             *pm = m;
             pm = &m->next;
           }
         if (s->flags & SEC_THREAD_LOCAL)
           {
             if (! tls_count)
              first_tls = s;
             tls_count++;
           }
       }

      /* If there are any SHF_TLS output sections, add PT_TLS segment.  */
      if (tls_count > 0)
       {
         int i;

         amt = sizeof (struct elf_segment_map);
         amt += (tls_count - 1) * sizeof (asection *);
         m = bfd_zalloc (abfd, amt);
         if (m == NULL)
           goto error_return;
         m->next = NULL;
         m->p_type = PT_TLS;
         m->count = tls_count;
         /* Mandated PF_R.  */
         m->p_flags = PF_R;
         m->p_flags_valid = 1;
         for (i = 0; i < tls_count; ++i)
           {
             BFD_ASSERT (first_tls->flags & SEC_THREAD_LOCAL);
             m->sections[i] = first_tls;
             first_tls = first_tls->next;
           }

         *pm = m;
         pm = &m->next;
       }

      /* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME
        segment.  */
      eh_frame_hdr = elf_tdata (abfd)->eh_frame_hdr;
      if (eh_frame_hdr != NULL
         && (eh_frame_hdr->output_section->flags & SEC_LOAD) != 0)
       {
         amt = sizeof (struct elf_segment_map);
         m = bfd_zalloc (abfd, amt);
         if (m == NULL)
           goto error_return;
         m->next = NULL;
         m->p_type = PT_GNU_EH_FRAME;
         m->count = 1;
         m->sections[0] = eh_frame_hdr->output_section;

         *pm = m;
         pm = &m->next;
       }

      if (elf_tdata (abfd)->stack_flags)
       {
         amt = sizeof (struct elf_segment_map);
         m = bfd_zalloc (abfd, amt);
         if (m == NULL)
           goto error_return;
         m->next = NULL;
         m->p_type = PT_GNU_STACK;
         m->p_flags = elf_tdata (abfd)->stack_flags;
         m->p_flags_valid = 1;

         *pm = m;
         pm = &m->next;
       }

      if (dynsec != NULL && elf_tdata (abfd)->relro)
       {
         /* We make a PT_GNU_RELRO segment only when there is a
            PT_DYNAMIC segment.  */
         amt = sizeof (struct elf_segment_map);
         m = bfd_zalloc (abfd, amt);
         if (m == NULL)
           goto error_return;
         m->next = NULL;
         m->p_type = PT_GNU_RELRO;
         m->p_flags = PF_R;
         m->p_flags_valid = 1;

         *pm = m;
         pm = &m->next;
       }

      free (sections);
      elf_tdata (abfd)->segment_map = mfirst;
    }

  if (!elf_modify_segment_map (abfd, info))
    return FALSE;

  for (count = 0, m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
    ++count;
  elf_tdata (abfd)->program_header_size = count * bed->s->sizeof_phdr;

  return TRUE;

 error_return:
  if (sections != NULL)
    free (sections);
  return FALSE;
}

Here is the call graph for this function:

Definition at line 9148 of file elf.c.

{
  if (asec == NULL
      || bsec == NULL
      || abfd->xvec->flavour != bfd_target_elf_flavour
      || bbfd->xvec->flavour != bfd_target_elf_flavour)
    return TRUE;

  return elf_section_type (asec) == elf_section_type (bsec);
}

Definition at line 987 of file elf-eh-frame.c.

{
  asection *o;
  bfd *abfd;
  struct elf_link_hash_table *htab;
  struct eh_frame_hdr_info *hdr_info;

  htab = elf_hash_table (info);
  hdr_info = &htab->eh_info;
  if (hdr_info->hdr_sec == NULL)
    return TRUE;

  if (bfd_is_abs_section (hdr_info->hdr_sec->output_section))
    {
      hdr_info->hdr_sec = NULL;
      return TRUE;
    }

  abfd = NULL;
  if (info->eh_frame_hdr)
    for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
      {
       /* Count only sections which have at least a single CIE or FDE.
          There cannot be any CIE or FDE <= 8 bytes.  */
       o = bfd_get_section_by_name (abfd, ".eh_frame");
       if (o && o->size > 8 && !bfd_is_abs_section (o->output_section))
         break;
      }

  if (abfd == NULL)
    {
      hdr_info->hdr_sec->flags |= SEC_EXCLUDE;
      hdr_info->hdr_sec = NULL;
      return TRUE;
    }

  hdr_info->table = TRUE;
  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1052 of file elf.c.

{
  bfd *ibfd;
  asection *sec;

  if (!is_elf_hash_table (info->hash))
    return FALSE;

  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
    if ((ibfd->flags & DYNAMIC) == 0)
      for (sec = ibfd->sections; sec != NULL; sec = sec->next)
       if ((sec->flags & SEC_MERGE) != 0
           && !bfd_is_abs_section (sec->output_section))
         {
           struct bfd_elf_section_data *secdata;

           secdata = elf_section_data (sec);
           if (! _bfd_add_merge_section (abfd,
                                     &elf_hash_table (info)->merge_info,
                                     sec, &secdata->sec_info))
             return FALSE;
           else if (secdata->sec_info)
             sec->sec_info_type = ELF_INFO_TYPE_MERGE;
         }

  if (elf_hash_table (info)->merge_info != NULL)
    _bfd_merge_sections (abfd, info, elf_hash_table (info)->merge_info,
                      merge_sections_remove_hook);
  return TRUE;
}

Here is the call graph for this function:

bfd_boolean _bfd_elf_merge_symbol ( bfd ,
struct bfd_link_info ,
const char *  ,
Elf_Internal_Sym *  ,
asection **  ,
bfd_vma ,
unsigned int ,
struct elf_link_hash_entry **  ,
bfd_boolean ,
bfd_boolean ,
bfd_boolean ,
bfd_boolean  
)

Definition at line 815 of file elflink.c.

{
  asection *sec, *oldsec;
  struct elf_link_hash_entry *h;
  struct elf_link_hash_entry *flip;
  int bind;
  bfd *oldbfd;
  bfd_boolean newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon;
  bfd_boolean newweak, oldweak;
  const struct elf_backend_data *bed;

  *skip = FALSE;
  *override = FALSE;

  sec = *psec;
  bind = ELF_ST_BIND (sym->st_info);

  /* Silently discard TLS symbols from --just-syms.  There's no way to
     combine a static TLS block with a new TLS block for this executable.  */
  if (ELF_ST_TYPE (sym->st_info) == STT_TLS
      && sec->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
    {
      *skip = TRUE;
      return TRUE;
    }

  if (! bfd_is_und_section (sec))
    h = elf_link_hash_lookup (elf_hash_table (info), name, TRUE, FALSE, FALSE);
  else
    h = ((struct elf_link_hash_entry *)
        bfd_wrapped_link_hash_lookup (abfd, info, name, TRUE, FALSE, FALSE));
  if (h == NULL)
    return FALSE;
  *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)
    return TRUE;

  /* 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;

  /* We have to check it for every instance since the first few may be
     refereences and not all compilers emit symbol type for undefined
     symbols.  */
  bfd_elf_link_mark_dynamic_symbol (info, h, sym);

  /* 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->non_elf = 0;
      return TRUE;
    }

  /* OLDBFD and OLDSEC are a BFD and an ASECTION associated with the
     existing symbol.  */

  switch (h->root.type)
    {
    default:
      oldbfd = NULL;
      oldsec = NULL;
      break;

    case bfd_link_hash_undefined:
    case bfd_link_hash_undefweak:
      oldbfd = h->root.u.undef.abfd;
      oldsec = NULL;
      break;

    case bfd_link_hash_defined:
    case bfd_link_hash_defweak:
      oldbfd = h->root.u.def.section->owner;
      oldsec = h->root.u.def.section;
      break;

    case bfd_link_hash_common:
      oldbfd = h->root.u.c.p->section->owner;
      oldsec = h->root.u.c.p->section;
      break;
    }

  /* 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
     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->def_regular))
    return TRUE;

  /* NEWDYN and OLDDYN indicate whether the new or old symbol,
     respectively, is from a dynamic object.  */

  newdyn = (abfd->flags & DYNAMIC) != 0;

  olddyn = FALSE;
  if (oldbfd != NULL)
    olddyn = (oldbfd->flags & DYNAMIC) != 0;
  else if (oldsec != NULL)
    {
      /* This handles the special SHN_MIPS_{TEXT,DATA} section
        indices used by MIPS ELF.  */
      olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0;
    }

  /* NEWDEF and OLDDEF indicate whether the new or old symbol,
     respectively, appear to be a definition rather than reference.  */

  newdef = !bfd_is_und_section (sec) && !bfd_is_com_section (sec);

  olddef = (h->root.type != bfd_link_hash_undefined
           && h->root.type != bfd_link_hash_undefweak
           && h->root.type != bfd_link_hash_common);

  /* When we try to create a default indirect symbol from the dynamic
     definition with the default version, we skip it if its type and
     the type of existing regular definition mismatch.  We only do it
     if the existing regular definition won't be dynamic.  */
  if (pold_alignment == NULL
      && !info->shared
      && !info->export_dynamic
      && !h->ref_dynamic
      && newdyn
      && newdef
      && !olddyn
      && (olddef || h->root.type == bfd_link_hash_common)
      && ELF_ST_TYPE (sym->st_info) != h->type
      && ELF_ST_TYPE (sym->st_info) != STT_NOTYPE
      && h->type != STT_NOTYPE)
    {
      *skip = TRUE;
      return TRUE;
    }

  /* Check TLS symbol.  We don't check undefined symbol introduced by
     "ld -u".  */
  if ((ELF_ST_TYPE (sym->st_info) == STT_TLS || h->type == STT_TLS)
      && ELF_ST_TYPE (sym->st_info) != h->type
      && oldbfd != NULL)
    {
      bfd *ntbfd, *tbfd;
      bfd_boolean ntdef, tdef;
      asection *ntsec, *tsec;

      if (h->type == STT_TLS)
       {
         ntbfd = abfd;
         ntsec = sec;
         ntdef = newdef;
         tbfd = oldbfd;
         tsec = oldsec;
         tdef = olddef;
       }
      else
       {
         ntbfd = oldbfd;
         ntsec = oldsec;
         ntdef = olddef;
         tbfd = abfd;
         tsec = sec;
         tdef = newdef;
       }

      if (tdef && ntdef)
       (*_bfd_error_handler)
         (_("%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"),
          tbfd, tsec, ntbfd, ntsec, h->root.root.string);
      else if (!tdef && !ntdef)
       (*_bfd_error_handler)
         (_("%s: TLS reference in %B mismatches non-TLS reference in %B"),
          tbfd, ntbfd, h->root.root.string);
      else if (tdef)
       (*_bfd_error_handler)
         (_("%s: TLS definition in %B section %A mismatches non-TLS reference in %B"),
          tbfd, tsec, ntbfd, h->root.root.string);
      else
       (*_bfd_error_handler)
         (_("%s: TLS reference in %B mismatches non-TLS definition in %B section %A"),
          tbfd, ntbfd, ntsec, h->root.root.string);

      bfd_set_error (bfd_error_bad_value);
      return FALSE;
    }

  /* We need to remember if a symbol has a definition in a dynamic
     object or is weak in all dynamic objects. Internal and hidden
     visibility will make it unavailable to dynamic objects.  */
  if (newdyn && !h->dynamic_def)
    {
      if (!bfd_is_und_section (sec))
       h->dynamic_def = 1;
      else
       {
         /* Check if this symbol is weak in all dynamic objects. If it
            is the first time we see it in a dynamic object, we mark
            if it is weak. Otherwise, we clear it.  */
         if (!h->ref_dynamic)
           {
             if (bind == STB_WEAK)
              h->dynamic_weak = 1;
           }
         else if (bind != STB_WEAK)
           h->dynamic_weak = 0;
       }
    }

  /* If the old symbol has non-default visibility, we ignore the new
     definition from a dynamic object.  */
  if (newdyn
      && ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
      && !bfd_is_und_section (sec))
    {
      *skip = TRUE;
      /* Make sure this symbol is dynamic.  */
      h->ref_dynamic = 1;
      /* A protected symbol has external availability. Make sure it is
        recorded as dynamic.

        FIXME: Should we check type and size for protected symbol?  */
      if (ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
       return bfd_elf_link_record_dynamic_symbol (info, h);
      else
       return TRUE;
    }
  else if (!newdyn
          && ELF_ST_VISIBILITY (sym->st_other) != STV_DEFAULT
          && h->def_dynamic)
    {
      /* If the new symbol with non-default visibility comes from a
        relocatable file and the old definition comes from a dynamic
        object, we remove the old definition.  */
      if ((*sym_hash)->root.type == bfd_link_hash_indirect)
       {
         /* Handle the case where the old dynamic definition is
            default versioned.  We need to copy the symbol info from
            the symbol with default version to the normal one if it
            was referenced before.  */
         if (h->ref_regular)
           {
             const struct elf_backend_data *bed
              = get_elf_backend_data (abfd);
             struct elf_link_hash_entry *vh = *sym_hash;
             vh->root.type = h->root.type;
             h->root.type = bfd_link_hash_indirect;
             (*bed->elf_backend_copy_indirect_symbol) (info, vh, h);
             /* Protected symbols will override the dynamic definition
               with default version.  */
             if (ELF_ST_VISIBILITY (sym->st_other) == STV_PROTECTED)
              {
                h->root.u.i.link = (struct bfd_link_hash_entry *) vh;
                vh->dynamic_def = 1;
                vh->ref_dynamic = 1;
              }
             else
              {
                h->root.type = vh->root.type;
                vh->ref_dynamic = 0;
                /* We have to hide it here since it was made dynamic
                   global with extra bits when the symbol info was
                   copied from the old dynamic definition.  */
                (*bed->elf_backend_hide_symbol) (info, vh, TRUE);
              }
             h = vh;
           }
         else
           h = *sym_hash;
       }

      if ((h->root.u.undef.next || info->hash->undefs_tail == &h->root)
         && bfd_is_und_section (sec))
       {
         /* If the new symbol is undefined and the old symbol was
            also undefined before, we need to make sure
            _bfd_generic_link_add_one_symbol doesn't mess
            up the linker hash table undefs list.  Since the old
            definition came from a dynamic object, it is still on the
            undefs list.  */
         h->root.type = bfd_link_hash_undefined;
         h->root.u.undef.abfd = abfd;
       }
      else
       {
         h->root.type = bfd_link_hash_new;
         h->root.u.undef.abfd = NULL;
       }

      if (h->def_dynamic)
       {
         h->def_dynamic = 0;
         h->ref_dynamic = 1;
         h->dynamic_def = 1;
       }
      /* FIXME: Should we check type and size for protected symbol?  */
      h->size = 0;
      h->type = 0;
      return TRUE;
    }

  /* Differentiate strong and weak symbols.  */
  newweak = bind == STB_WEAK;
  oldweak = (h->root.type == bfd_link_hash_defweak
            || h->root.type == bfd_link_hash_undefweak);

  /* If a new weak symbol definition comes from a regular file and the
     old symbol comes from a dynamic library, we treat the new one as
     strong.  Similarly, an old weak symbol definition from a regular
     file is treated as strong when the new symbol comes from a dynamic
     library.  Further, an old weak symbol from a dynamic library is
     treated as strong if the new symbol is from a dynamic library.
     This reflects the way glibc's ld.so works.

     Do this before setting *type_change_ok or *size_change_ok so that
     we warn properly when dynamic library symbols are overridden.  */

  if (newdef && !newdyn && olddyn)
    newweak = FALSE;
  if (olddef && newdyn)
    oldweak = FALSE;

  /* It's OK to change the type if either the existing symbol or the
     new symbol is weak.  A type change is also OK if the old symbol
     is undefined and the new symbol is defined.  */

  if (oldweak
      || newweak
      || (newdef
         && h->root.type == bfd_link_hash_undefined))
    *type_change_ok = TRUE;

  /* 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)
    *size_change_ok = TRUE;

  /* 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
      && !newweak
      && (sec->flags & SEC_ALLOC) != 0
      && (sec->flags & SEC_LOAD) == 0
      && sym->st_size > 0
      && ELF_ST_TYPE (sym->st_info) != STT_FUNC)
    newdyncommon = TRUE;
  else
    newdyncommon = FALSE;

  if (olddyn
      && olddef
      && h->root.type == bfd_link_hash_defined
      && h->def_dynamic
      && (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)
    olddyncommon = TRUE;
  else
    olddyncommon = FALSE;

  /* We now know everything about the old and new symbols.  We ask the
     backend to check if we can merge them.  */
  bed = get_elf_backend_data (abfd);
  if (bed->merge_symbol
      && !bed->merge_symbol (info, sym_hash, h, sym, psec, pvalue,
                          pold_alignment, skip, override,
                          type_change_ok, size_change_ok,
                          &newdyn, &newdef, &newdyncommon, &newweak,
                          abfd, &sec,
                          &olddyn, &olddef, &olddyncommon, &oldweak,
                          oldbfd, &oldsec))
    return FALSE;

  /* 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
        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.  */

      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)))
       return FALSE;

      if (sym->st_size > h->size)
       h->size = sym->st_size;

      *size_change_ok = TRUE;
    }

  /* 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
     object to override a weak symbol in a shared object.  */

  if (newdyn
      && newdef
      && (olddef
         || (h->root.type == bfd_link_hash_common
             && (newweak
                || ELF_ST_TYPE (sym->st_info) == STT_FUNC))))
    {
      *override = TRUE;
      newdef = FALSE;
      newdyncommon = FALSE;

      *psec = sec = bfd_und_section_ptr;
      *size_change_ok = TRUE;

      /* If we get here when the old symbol is a common symbol, then
        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.  */

      if (h->root.type == bfd_link_hash_common)
       *type_change_ok = TRUE;
    }

  /* 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 do the
     right thing.  */

  if (newdyncommon
      && h->root.type == bfd_link_hash_common)
    {
      *override = TRUE;
      newdef = FALSE;
      newdyncommon = FALSE;
      *pvalue = sym->st_size;
      *psec = sec = bed->common_section (oldsec);
      *size_change_ok = TRUE;
    }

  /* Skip weak definitions of symbols that are already defined.  */
  if (newdef && olddef && newweak)
    *skip = TRUE;

  /* 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
     symbol is a function or is weak.  */

  flip = NULL;
  if (!newdyn
      && (newdef
         || (bfd_is_com_section (sec)
             && (oldweak
                || h->type == STT_FUNC)))
      && olddyn
      && olddef
      && h->def_dynamic)
    {
      /* 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;
      *size_change_ok = TRUE;

      olddef = FALSE;
      olddyncommon = FALSE;

      /* We again permit a type change when a common symbol may be
        overriding a function.  */

      if (bfd_is_com_section (sec))
       *type_change_ok = TRUE;

      if ((*sym_hash)->root.type == bfd_link_hash_indirect)
       flip = *sym_hash;
      else
       /* 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;
    }

  /* 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)))
       return FALSE;

      /* If the presumed common symbol in the dynamic object is
        larger, pretend that the new symbol has its size.  */

      if (h->size > *pvalue)
       *pvalue = h->size;

      /* We need to remember the alignment required by the symbol
        in the dynamic object.  */
      BFD_ASSERT (pold_alignment);
      *pold_alignment = h->root.u.def.section->alignment_power;

      olddef = FALSE;
      olddyncommon = FALSE;

      h->root.type = bfd_link_hash_undefined;
      h->root.u.undef.abfd = h->root.u.def.section->owner;

      *size_change_ok = TRUE;
      *type_change_ok = TRUE;

      if ((*sym_hash)->root.type == bfd_link_hash_indirect)
       flip = *sym_hash;
      else
       h->verinfo.vertree = NULL;
    }

  if (flip != NULL)
    {
      /* Handle the case where we had a versioned symbol in a dynamic
        library and now find a definition in a normal object.  In this
        case, we make the versioned symbol point to the normal one.  */
      const struct elf_backend_data *bed = get_elf_backend_data (abfd);
      flip->root.type = h->root.type;
      h->root.type = bfd_link_hash_indirect;
      h->root.u.i.link = (struct bfd_link_hash_entry *) flip;
      (*bed->elf_backend_copy_indirect_symbol) (info, flip, h);
      flip->root.u.undef.abfd = h->root.u.undef.abfd;
      if (h->def_dynamic)
       {
         h->def_dynamic = 0;
         flip->ref_dynamic = 1;
       }
    }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2515 of file elf.c.

{
  struct bfd_elf_section_data *sdata;
  const struct elf_backend_data *bed;
  const struct bfd_elf_special_section *ssect;

  sdata = (struct bfd_elf_section_data *) sec->used_by_bfd;
  if (sdata == NULL)
    {
      sdata = bfd_zalloc (abfd, sizeof (*sdata));
      if (sdata == NULL)
       return FALSE;
      sec->used_by_bfd = sdata;
    }

  /* Indicate whether or not this section should use RELA relocations.  */
  bed = get_elf_backend_data (abfd);
  sec->use_rela_p = bed->default_use_rela_p;

  /* When we read a file, we don't need to set ELF section type and
     flags.  They will be overridden in _bfd_elf_make_section_from_shdr
     anyway.  We will set ELF section type and flags for all linker
     created sections.  If user specifies BFD section flags, we will
     set ELF section type and flags based on BFD section flags in
     elf_fake_sections.  */
  if ((!sec->flags && abfd->direction != read_direction)
      || (sec->flags & SEC_LINKER_CREATED) != 0)
    {
      ssect = (*bed->get_sec_type_attr) (abfd, sec);
      if (ssect != NULL)
       {
         elf_section_type (sec) = ssect->type;
         elf_section_flags (sec) = ssect->attr;
       }
    }

  return _bfd_generic_new_section_hook (abfd, sec);
}

Here is the call graph for this function:

Here is the caller graph for this function: