bfd/
[deliverable/binutils-gdb.git] / bfd / elf-bfd.h
index 8059b4e244d120d8cb8312a1f5931328c6846148..a5e52abe31e2714b0a4b81fa0e447584e78dee29 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end data structures for ELF files.
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003 Free Software Foundation, Inc.
+   2002, 2003, 2004 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -200,6 +200,9 @@ struct elf_link_hash_entry
 #define ELF_LINK_DYNAMIC_DEF 020000
   /* Symbol is weak in all shared objects.  */
 #define ELF_LINK_DYNAMIC_WEAK 040000
+  /* Symbol is referenced with a relocation where C/C++ pointer equality
+     matters.  */
+#define ELF_LINK_POINTER_EQUALITY_NEEDED 0100000
 };
 
 /* Will references to this symbol always reference the symbol
@@ -397,8 +400,8 @@ struct elf_link_hash_table
 #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
 
 /* Returns TRUE if the hash table is a struct elf_link_hash_table.  */
-#define is_elf_hash_table(p)                                           \
-  ((p)->hash->type == bfd_link_elf_hash_table)
+#define is_elf_hash_table(htab)                                                \
+  (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
 
 /* Used by bfd_section_from_r_symndx to cache a small number of local
    symbol to section mappings.  */
@@ -573,6 +576,11 @@ struct elf_backend_data
   int (*elf_backend_get_symbol_type)
     (Elf_Internal_Sym *, int);
 
+  /* Return true if local section symbols should have a non-null st_name.
+     NULL implies false.  */
+  bfd_boolean (*elf_backend_name_local_section_symbols)
+    (bfd *);
+
   /* A function to do additional processing on the ELF section header
      just before writing it out.  This is used to set the flags and
      type fields for some sections, or to actually write out data for
@@ -623,8 +631,8 @@ struct elf_backend_data
   /* If this field is not NULL, it is called by the elf_link_output_sym
      phase of a link for each symbol which will appear in the object file.  */
   bfd_boolean (*elf_backend_link_output_symbol_hook)
-    (bfd *, struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
-     asection *);
+    (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
+     asection *, struct elf_link_hash_entry *);
 
   /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
      linker the first time it encounters a dynamic object in the link.
@@ -757,7 +765,7 @@ struct elf_backend_data
   /* This function is called to modify an existing segment map in a
      backend specific fashion.  */
   bfd_boolean (*elf_backend_modify_segment_map)
-    (bfd *);
+    (bfd *, struct bfd_link_info *);
 
   /* This function is called during section gc to discover the section a
      particular relocation refers to.  */
@@ -785,12 +793,13 @@ struct elf_backend_data
     (bfd *, void *, asymbol *);
 
   /* This function, if defined, is called after all local symbols and
-     global symbols converted to locals are emited into the symtab
+     global symbols converted to locals are emitted into the symtab
      section.  It allows the backend to emit special global symbols
      not handled in the hash table.  */
   bfd_boolean (*elf_backend_output_arch_syms)
     (bfd *, struct bfd_link_info *, void *,
-     bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *));
+     bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
+                     struct elf_link_hash_entry *));
 
   /* Copy any information related to dynamic linking from a pre-existing
      symbol to a newly created symbol.  Also called to copy flags and
@@ -851,6 +860,24 @@ struct elf_backend_data
   bfd_boolean (*elf_backend_ignore_discarded_relocs)
     (asection *);
 
+  /* These functions tell elf-eh-frame whether to attempt to turn
+     absolute or lsda encodings into pc-relative ones.  The default
+     definition enables these transformations.  */
+  bfd_boolean (*elf_backend_can_make_relative_eh_frame)
+     (bfd *, struct bfd_link_info *, asection *);
+  bfd_boolean (*elf_backend_can_make_lsda_relative_eh_frame)
+     (bfd *, struct bfd_link_info *, asection *);
+
+  /* This function returns an encoding after computing the encoded
+     value (and storing it in ENCODED) for the given OFFSET into OSEC,
+     to be stored in at LOC_OFFSET into the LOC_SEC input section.
+     The default definition chooses a 32-bit PC-relative encoding.  */
+  bfd_byte (*elf_backend_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);
+
   /* This function, if defined, may write out the given section.
      Returns TRUE if it did so and FALSE if the caller should.  */
   bfd_boolean (*elf_backend_write_section)
@@ -1105,9 +1132,6 @@ struct elf_obj_tdata
   bfd_vma gp;                          /* The gp value */
   unsigned int gp_size;                        /* The gp size */
 
-  Elf_Internal_Shdr **group_sect_ptr;
-  int num_group;
-
   /* Information grabbed from an elf core file.  */
   int core_signal;
   int core_pid;
@@ -1115,10 +1139,6 @@ struct elf_obj_tdata
   char* core_program;
   char* core_command;
 
-  /* This is set to TRUE if the object was created by the backend
-     linker.  */
-  bfd_boolean linker;
-
   /* A mapping from external symbols to entries in the linker hash
      table, used when linking.  This is indexed by the symbol index
      minus the sh_info field of the symbol table header.  */
@@ -1144,21 +1164,6 @@ struct elf_obj_tdata
      one.  */
   const char *dt_name;
 
-  /* When a reference in a regular object is resolved by a shared
-     object is loaded into via the DT_NEEDED entries by the linker
-     ELF emulation code, we need to add the shared object to the
-     DT_NEEDED list of the resulting binary to indicate the dependency
-     as if the -l option is passed to the linker. This field holds the
-     name of the loaded shared object.  */
-  const char *dt_soname;
-
-  /* Irix 5 often screws up the symbol table, sorting local symbols
-     after global symbols.  This flag is set if the symbol table in
-     this BFD appears to be screwed up.  If it is, we ignore the
-     sh_info field in the symbol table header, and always read all the
-     symbols.  */
-  bfd_boolean bad_symtab;
-
   /* Records the result of `get_program_header_size'.  */
   bfd_size_type program_header_size;
 
@@ -1186,8 +1191,8 @@ struct elf_obj_tdata
      created.  */
   asection *eh_frame_hdr;
 
-  /* Used to determine if the e_flags field has been initialized */
-  bfd_boolean flags_init;
+  Elf_Internal_Shdr **group_sect_ptr;
+  int num_group;
 
   /* Number of symbol version definitions we are about to emit.  */
   unsigned int cverdefs;
@@ -1210,6 +1215,25 @@ struct elf_obj_tdata
   asymbol *elf_text_symbol;
   asection *elf_data_section;
   asection *elf_text_section;
+
+  /* Whether a dyanmic object was specified normally on the linker
+     command line, or was specified when --as-needed was in effect,
+     or was found via a DT_NEEDED entry.  */
+  enum dynamic_lib_link_class dyn_lib_class;
+
+  /* This is set to TRUE if the object was created by the backend
+     linker.  */
+  bfd_boolean linker;
+
+  /* Irix 5 often screws up the symbol table, sorting local symbols
+     after global symbols.  This flag is set if the symbol table in
+     this BFD appears to be screwed up.  If it is, we ignore the
+     sh_info field in the symbol table header, and always read all the
+     symbols.  */
+  bfd_boolean bad_symtab;
+
+  /* Used to determine if the e_flags field has been initialized */
+  bfd_boolean flags_init;
 };
 
 #define elf_tdata(bfd)         ((bfd) -> tdata.elf_obj_data)
@@ -1236,7 +1260,7 @@ struct elf_obj_tdata
 #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_dt_soname(bfd)     (elf_tdata(bfd) -> dt_soname)
+#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)
 \f
@@ -1292,10 +1316,16 @@ extern void _bfd_elf_sprintf_vma
 extern void _bfd_elf_fprintf_vma
   (bfd *, void *, bfd_vma);
 
+extern 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);
+extern bfd_boolean _bfd_elf_can_make_relative
+  (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section);
+
 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
   (const Elf_Internal_Rela *);
 extern bfd_vma _bfd_elf_rela_local_sym
-  (bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *);
+  (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
 extern bfd_vma _bfd_elf_rel_local_sym
   (bfd *, Elf_Internal_Sym *, asection **, bfd_vma);
 extern bfd_vma _bfd_elf_section_offset
@@ -1446,12 +1476,12 @@ extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr
 extern bfd_boolean _bfd_elf_merge_symbol
   (bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
    asection **, bfd_vma *, struct elf_link_hash_entry **, bfd_boolean *,
-   bfd_boolean *, bfd_boolean *, bfd_boolean *, bfd_boolean);
+   bfd_boolean *, bfd_boolean *, bfd_boolean *);
 
 extern 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_boolean *, bfd_boolean);
 
 extern bfd_boolean _bfd_elf_export_symbol
   (struct elf_link_hash_entry *, void *);
@@ -1514,6 +1544,9 @@ extern bfd_boolean _bfd_elf_dynamic_symbol_p
 extern bfd_boolean _bfd_elf_symbol_refs_local_p
   (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
 
+extern bfd_boolean _bfd_elf_link_add_archive_symbols
+  (bfd *, struct bfd_link_info *);
+
 extern const bfd_target *bfd_elf32_object_p
   (bfd *);
 extern const bfd_target *bfd_elf32_core_file_p
@@ -1721,8 +1754,7 @@ extern bfd_boolean _sh_elf_set_mach_from_flags
        }                                                                                                               \
       else if (h->root.type == bfd_link_hash_undefweak)                                                                        \
        ;                                                                                                               \
-      else if (!info->executable                                                                                       \
-              && info->unresolved_syms_in_objects == RM_IGNORE                                                         \
+      else if (info->unresolved_syms_in_objects == RM_IGNORE                                                           \
               && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)                                                          \
        ;                                                                                                               \
       else                                                                                                             \
@@ -1730,8 +1762,7 @@ extern bfd_boolean _sh_elf_set_mach_from_flags
          if (! info->callbacks->undefined_symbol                                                                       \
              (info, h->root.root.string, input_bfd,                                                                    \
               input_section, rel->r_offset,                                                                            \
-              ((info->shared && info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)                             \
-               || (!info->shared && info->unresolved_syms_in_objects == RM_GENERATE_ERROR)                             \
+              (info->unresolved_syms_in_objects == RM_GENERATE_ERROR                                                   \
                || ELF_ST_VISIBILITY (h->other))                                                                        \
               ))                                                                                                       \
            return FALSE;                                                                                               \
This page took 0.027476 seconds and 4 git commands to generate.