Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/bfd/elf-bfd.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by monabuilder, Sun Dec 28 03:31:28 2008 UTC revision 21 by monamour, Mon Jul 27 20:34:36 2009 UTC
# Line 1  Line 1 
1  /* BFD back-end data structures for ELF files.  /* BFD back-end data structures for ELF files.
2     Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,     Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3     2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.     2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4       Free Software Foundation, Inc.
5     Written by Cygnus Support.     Written by Cygnus Support.
6    
7     This file is part of BFD, the Binary File Descriptor library.     This file is part of BFD, the Binary File Descriptor library.
# Line 30  Line 31 
31    
32  /* The number of entries in a section is its size divided by the size  /* The number of entries in a section is its size divided by the size
33     of a single entry.  This is normally only applicable to reloc and     of a single entry.  This is normally only applicable to reloc and
34     symbol table sections.  */     symbol table sections.
35  #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)     PR 9934: It is possible to have relocations that do not refer to
36       symbols, thus it is also possible to have a relocation section in
37       an object file, but no symbol table.  */
38    #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_entsize > 0 ? (shdr)->sh_size / (shdr)->sh_entsize : 0)
39    
40  /* If size isn't specified as 64 or 32, NAME macro should fail.  */  /* If size isn't specified as 64 or 32, NAME macro should fail.  */
41  #ifndef NAME  #ifndef NAME
# Line 134  struct elf_link_hash_entry Line 138  struct elf_link_hash_entry
138    /* Symbol st_other value, symbol visibility.  */    /* Symbol st_other value, symbol visibility.  */
139    unsigned int other : 8;    unsigned int other : 8;
140    
141    /* Symbol is referenced by a non-shared object.  */    /* Symbol is referenced by a non-shared object (other than the object
142         in which it is defined).  */
143    unsigned int ref_regular : 1;    unsigned int ref_regular : 1;
144    /* Symbol is defined by a non-shared object.  */    /* Symbol is defined by a non-shared object.  */
145    unsigned int def_regular : 1;    unsigned int def_regular : 1;
# Line 142  struct elf_link_hash_entry Line 147  struct elf_link_hash_entry
147    unsigned int ref_dynamic : 1;    unsigned int ref_dynamic : 1;
148    /* Symbol is defined by a shared object.  */    /* Symbol is defined by a shared object.  */
149    unsigned int def_dynamic : 1;    unsigned int def_dynamic : 1;
150    /* Symbol has a non-weak reference from a non-shared object.  */    /* Symbol has a non-weak reference from a non-shared object (other than
151         the object in which it is defined).  */
152    unsigned int ref_regular_nonweak : 1;    unsigned int ref_regular_nonweak : 1;
153    /* Dynamic symbol has been adjustd.  */    /* Dynamic symbol has been adjustd.  */
154    unsigned int dynamic_adjusted : 1;    unsigned int dynamic_adjusted : 1;
# Line 172  struct elf_link_hash_entry Line 178  struct elf_link_hash_entry
178    /* Symbol is referenced with a relocation where C/C++ pointer equality    /* Symbol is referenced with a relocation where C/C++ pointer equality
179       matters.  */       matters.  */
180    unsigned int pointer_equality_needed : 1;    unsigned int pointer_equality_needed : 1;
181      /* Symbol is a unique global symbol.  */
182      unsigned int unique_global : 1;
183    
184    /* String table index in .dynstr if this is a dynamic symbol.  */    /* String table index in .dynstr if this is a dynamic symbol.  */
185    unsigned long dynstr_index;    unsigned long dynstr_index;
# Line 453  struct elf_link_hash_table Line 461  struct elf_link_hash_table
461    
462    /* A linked list of BFD's loaded in the link.  */    /* A linked list of BFD's loaded in the link.  */
463    struct elf_link_loaded_list *loaded;    struct elf_link_loaded_list *loaded;
464    
465      /* Short-cuts to get to dynamic linker sections.  */
466      asection *sgot;
467      asection *sgotplt;
468      asection *srelgot;
469      asection *splt;
470      asection *srelplt;
471      asection *igotplt;
472      asection *iplt;
473      asection *irelplt;
474      asection *irelifunc;
475  };  };
476    
477  /* Look up an entry in an ELF linker hash table.  */  /* Look up an entry in an ELF linker hash table.  */
# Line 478  struct elf_link_hash_table Line 497  struct elf_link_hash_table
497  #define is_elf_hash_table(htab)                                         \  #define is_elf_hash_table(htab)                                         \
498    (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)    (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
499    
500  /* Used by bfd_section_from_r_symndx to cache a small number of local  /* Used by bfd_sym_from_r_symndx to cache a small number of local
501     symbol to section mappings.  */     symbols.  */
502  #define LOCAL_SYM_CACHE_SIZE 32  #define LOCAL_SYM_CACHE_SIZE 32
503  struct sym_sec_cache  struct sym_cache
504  {  {
505    bfd *abfd;    bfd *abfd;
506    unsigned long indx[LOCAL_SYM_CACHE_SIZE];    unsigned long indx[LOCAL_SYM_CACHE_SIZE];
507    unsigned int shndx[LOCAL_SYM_CACHE_SIZE];    Elf_Internal_Sym sym[LOCAL_SYM_CACHE_SIZE];
508  };  };
509    
510  /* Constant information held for an ELF backend.  */  /* Constant information held for an ELF backend.  */
# Line 594  struct bfd_elf_special_section Line 613  struct bfd_elf_special_section
613       PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX.  */       PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX.  */
614    int suffix_length;    int suffix_length;
615    int type;    int type;
616    int attr;    bfd_vma attr;
617  };  };
618    
619  enum action_discarded  enum action_discarded
# Line 741  struct elf_backend_data Line 760  struct elf_backend_data
760       const char **name, flagword *flags, asection **sec, bfd_vma *value);       const char **name, flagword *flags, asection **sec, bfd_vma *value);
761    
762    /* If this field is not NULL, it is called by the elf_link_output_sym    /* If this field is not NULL, it is called by the elf_link_output_sym
763       phase of a link for each symbol which will appear in the object file.  */       phase of a link for each symbol which will appear in the object file.
764    bfd_boolean (*elf_backend_link_output_symbol_hook)       On error, this function returns 0.  1 is returned when the symbol
765         should be output, 2 is returned when the symbol should be discarded.  */
766      int (*elf_backend_link_output_symbol_hook)
767      (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,      (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
768       asection *, struct elf_link_hash_entry *);       asection *, struct elf_link_hash_entry *);
769    
# Line 1166  struct elf_backend_data Line 1187  struct elf_backend_data
1187    /* The section type to use for an attributes section.  */    /* The section type to use for an attributes section.  */
1188    unsigned int obj_attrs_section_type;    unsigned int obj_attrs_section_type;
1189    
1190      /* This function determines the order in which any attributes are written.
1191         It must be defined for input in the range 4..NUM_KNOWN_OBJ_ATTRIBUTES-1
1192         (this range is used in order to make unity easy).  The returned value is
1193         the actual tag number to place in the input position.  */
1194      int (*obj_attrs_order) (int);
1195    
1196    /* This is TRUE if the linker should act like collect and gather    /* This is TRUE if the linker should act like collect and gather
1197       global constructors and destructors by name.  This is TRUE for       global constructors and destructors by name.  This is TRUE for
1198       MIPS ELF because the Irix 5 tools can not handle the .init       MIPS ELF because the Irix 5 tools can not handle the .init
# Line 1327  struct bfd_elf_section_data Line 1354  struct bfd_elf_section_data
1354  #define get_elf_backend_data(abfd) \  #define get_elf_backend_data(abfd) \
1355     xvec_get_elf_backend_data ((abfd)->xvec)     xvec_get_elf_backend_data ((abfd)->xvec)
1356    
 /* This struct is used to pass information to routines called via  
    elf_link_hash_traverse which must return failure.  */  
   
 struct elf_info_failed  
 {  
   bfd_boolean failed;  
   struct bfd_link_info *info;  
   struct bfd_elf_version_tree *verdefs;  
 };  
   
 /* This structure is used to pass information to  
    _bfd_elf_link_assign_sym_version.  */  
   
 struct elf_assign_sym_version_info  
 {  
   /* Output BFD.  */  
   bfd *output_bfd;  
   /* General link information.  */  
   struct bfd_link_info *info;  
   /* Version tree.  */  
   struct bfd_elf_version_tree *verdefs;  
   /* Whether we had a failure.  */  
   bfd_boolean failed;  
 };  
   
 /* This structure is used to pass information to  
    _bfd_elf_link_find_version_dependencies.  */  
   
 struct elf_find_verdep_info  
 {  
   /* Output BFD.  */  
   bfd *output_bfd;  
   /* General link information.  */  
   struct bfd_link_info *info;  
   /* The number of dependencies.  */  
   unsigned int vers;  
   /* Whether we had a failure.  */  
   bfd_boolean failed;  
 };  
   
1357  /* The maximum number of known object attributes for any target.  */  /* The maximum number of known object attributes for any target.  */
1358  #define NUM_KNOWN_OBJ_ATTRIBUTES 32  #define NUM_KNOWN_OBJ_ATTRIBUTES 71
1359    
1360  /* The value of an object attribute.  type & 1 indicates whether there  /* The value of an object attribute.  The type indicates whether the attribute
1361     is an integer value; type & 2 indicates whether there is a string     holds and integer, a string, or both.  It can also indicate that there can
1362     value.  */     be no default (i.e. all values must be written to file, even zero).  */
1363    
1364  typedef struct obj_attribute  typedef struct obj_attribute
1365  {  {
1366    #define ATTR_TYPE_FLAG_INT_VAL    (1 << 0)
1367    #define ATTR_TYPE_FLAG_STR_VAL    (1 << 1)
1368    #define ATTR_TYPE_FLAG_NO_DEFAULT (1 << 2)
1369    
1370    #define ATTR_TYPE_HAS_INT_VAL(TYPE)     ((TYPE) & ATTR_TYPE_FLAG_INT_VAL)
1371    #define ATTR_TYPE_HAS_STR_VAL(TYPE)     ((TYPE) & ATTR_TYPE_FLAG_STR_VAL)
1372    #define ATTR_TYPE_HAS_NO_DEFAULT(TYPE)  ((TYPE) & ATTR_TYPE_FLAG_NO_DEFAULT)
1373    
1374    int type;    int type;
1375    unsigned int i;    unsigned int i;
1376    char *s;    char *s;
# Line 1581  struct elf_obj_tdata Line 1576  struct elf_obj_tdata
1576    bfd_size_type build_id_size;    bfd_size_type build_id_size;
1577    bfd_byte *build_id;    bfd_byte *build_id;
1578    
1579      /* True if the bfd contains symbols that have the STT_GNU_IFUNC
1580         symbol type.  Used to set the osabi field in the ELF header
1581         structure.  */
1582      bfd_boolean has_ifunc_symbols;
1583    
1584    /* An identifier used to distinguish different target    /* An identifier used to distinguish different target
1585       specific extensions to this structure.  */       specific extensions to this structure.  */
1586    enum elf_object_id object_id;    enum elf_object_id object_id;
# Line 1651  extern unsigned int _bfd_elf_section_fro Line 1651  extern unsigned int _bfd_elf_section_fro
1651    (bfd *, asection *);    (bfd *, asection *);
1652  extern char *bfd_elf_string_from_elf_section  extern char *bfd_elf_string_from_elf_section
1653    (bfd *, unsigned, unsigned);    (bfd *, unsigned, unsigned);
 extern char *bfd_elf_get_str_section  
   (bfd *, unsigned);  
1654  extern Elf_Internal_Sym *bfd_elf_get_elf_syms  extern Elf_Internal_Sym *bfd_elf_get_elf_syms
1655    (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,    (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,
1656     Elf_External_Sym_Shndx *);     Elf_External_Sym_Shndx *);
# Line 1696  extern bfd_boolean bfd_elf_make_generic_ Line 1694  extern bfd_boolean bfd_elf_make_generic_
1694    (bfd *);    (bfd *);
1695  extern bfd_boolean bfd_elf_mkcorefile  extern bfd_boolean bfd_elf_mkcorefile
1696    (bfd *);    (bfd *);
 extern Elf_Internal_Shdr *bfd_elf_find_section  
   (bfd *, char *);  
1697  extern bfd_boolean _bfd_elf_make_section_from_shdr  extern bfd_boolean _bfd_elf_make_section_from_shdr
1698    (bfd *, Elf_Internal_Shdr *, const char *, int);    (bfd *, Elf_Internal_Shdr *, const char *, int);
1699  extern bfd_boolean _bfd_elf_make_section_from_phdr  extern bfd_boolean _bfd_elf_make_section_from_phdr
# Line 1815  extern bfd_boolean bfd_section_from_phdr Line 1811  extern bfd_boolean bfd_section_from_phdr
1811  extern int _bfd_elf_symbol_from_bfd_symbol  extern int _bfd_elf_symbol_from_bfd_symbol
1812    (bfd *, asymbol **);    (bfd *, asymbol **);
1813    
1814  extern asection *bfd_section_from_r_symndx  extern Elf_Internal_Sym *bfd_sym_from_r_symndx
1815    (bfd *, struct sym_sec_cache *, asection *, unsigned long);    (struct sym_cache *, bfd *, unsigned long);
1816  extern asection *bfd_section_from_elf_index  extern asection *bfd_section_from_elf_index
1817    (bfd *, unsigned int);    (bfd *, unsigned int);
1818  extern struct bfd_strtab_hash *_bfd_elf_stringtab_init  extern struct bfd_strtab_hash *_bfd_elf_stringtab_init
# Line 1872  extern bfd_boolean _bfd_elf_merge_symbol Line 1868  extern bfd_boolean _bfd_elf_merge_symbol
1868    
1869  extern bfd_boolean _bfd_elf_hash_symbol (struct elf_link_hash_entry *);  extern bfd_boolean _bfd_elf_hash_symbol (struct elf_link_hash_entry *);
1870    
 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);  
   
 extern bfd_boolean _bfd_elf_export_symbol  
   (struct elf_link_hash_entry *, void *);  
   
 extern bfd_boolean _bfd_elf_link_find_version_dependencies  
   (struct elf_link_hash_entry *, void *);  
   
 extern bfd_boolean _bfd_elf_link_assign_sym_version  
   (struct elf_link_hash_entry *, void *);  
   
1871  extern long _bfd_elf_link_lookup_local_dynindx  extern long _bfd_elf_link_lookup_local_dynindx
1872    (struct bfd_link_info *, bfd *, long);    (struct bfd_link_info *, bfd *, long);
1873  extern bfd_boolean _bfd_elf_compute_section_file_positions  extern bfd_boolean _bfd_elf_compute_section_file_positions
# Line 1921  extern char *_bfd_elfcore_strndup Line 1903  extern char *_bfd_elfcore_strndup
1903  extern Elf_Internal_Rela *_bfd_elf_link_read_relocs  extern Elf_Internal_Rela *_bfd_elf_link_read_relocs
1904    (bfd *, asection *, void *, Elf_Internal_Rela *, bfd_boolean);    (bfd *, asection *, void *, Elf_Internal_Rela *, bfd_boolean);
1905    
 extern bfd_boolean _bfd_elf_link_size_reloc_section  
   (bfd *, Elf_Internal_Shdr *, asection *);  
   
1906  extern bfd_boolean _bfd_elf_link_output_relocs  extern bfd_boolean _bfd_elf_link_output_relocs
1907    (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,    (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
1908     struct elf_link_hash_entry **);     struct elf_link_hash_entry **);
1909    
 extern bfd_boolean _bfd_elf_fix_symbol_flags  
   (struct elf_link_hash_entry *, struct elf_info_failed *);  
   
 extern bfd_boolean _bfd_elf_adjust_dynamic_symbol  
   (struct elf_link_hash_entry *, void *);  
   
1910  extern bfd_boolean _bfd_elf_adjust_dynamic_copy  extern bfd_boolean _bfd_elf_adjust_dynamic_copy
1911    (struct elf_link_hash_entry *, asection *);    (struct elf_link_hash_entry *, asection *);
1912    
 extern bfd_boolean _bfd_elf_link_sec_merge_syms  
   (struct elf_link_hash_entry *, void *);  
   
1913  extern bfd_boolean _bfd_elf_dynamic_symbol_p  extern bfd_boolean _bfd_elf_dynamic_symbol_p
1914    (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);    (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
1915    
# Line 2061  extern bfd_boolean bfd_elf_link_record_d Line 2031  extern bfd_boolean bfd_elf_link_record_d
2031  extern int bfd_elf_link_record_local_dynamic_symbol  extern int bfd_elf_link_record_local_dynamic_symbol
2032    (struct bfd_link_info *, bfd *, long);    (struct bfd_link_info *, bfd *, long);
2033    
 extern void bfd_elf_link_mark_dynamic_symbol  
   (struct bfd_link_info *, struct elf_link_hash_entry *,  
    Elf_Internal_Sym *);  
   
2034  extern bfd_boolean _bfd_elf_close_and_cleanup  extern bfd_boolean _bfd_elf_close_and_cleanup
2035    (bfd *);    (bfd *);
2036    
# Line 2183  extern void bfd_elf_add_obj_attr_int (bf Line 2149  extern void bfd_elf_add_obj_attr_int (bf
2149  extern void bfd_elf_add_obj_attr_string (bfd *, int, int, const char *);  extern void bfd_elf_add_obj_attr_string (bfd *, int, int, const char *);
2150  #define bfd_elf_add_proc_attr_string(BFD, TAG, VALUE) \  #define bfd_elf_add_proc_attr_string(BFD, TAG, VALUE) \
2151    bfd_elf_add_obj_attr_string ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))    bfd_elf_add_obj_attr_string ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
2152  extern void bfd_elf_add_obj_attr_compat (bfd *, int, unsigned int,  extern void bfd_elf_add_obj_attr_int_string (bfd *, int, int, unsigned int,
2153                                           const char *);                                               const char *);
2154  #define bfd_elf_add_proc_attr_compat(BFD, INTVAL, STRVAL) \  #define bfd_elf_add_proc_attr_int_string(BFD, TAG, INTVAL, STRVAL) \
2155    bfd_elf_add_obj_attr_compat ((BFD), OBJ_ATTR_PROC, (INTVAL), (STRVAL))    bfd_elf_add_obj_attr_int_string ((BFD), OBJ_ATTR_PROC, (TAG), \
2156                                       (INTVAL), (STRVAL))
2157    
2158  extern char *_bfd_elf_attr_strdup (bfd *, const char *);  extern char *_bfd_elf_attr_strdup (bfd *, const char *);
2159  extern void _bfd_elf_copy_obj_attributes (bfd *, bfd *);  extern void _bfd_elf_copy_obj_attributes (bfd *, bfd *);
# Line 2194  extern int _bfd_elf_obj_attrs_arg_type ( Line 2161  extern int _bfd_elf_obj_attrs_arg_type (
2161  extern void _bfd_elf_parse_attributes (bfd *, Elf_Internal_Shdr *);  extern void _bfd_elf_parse_attributes (bfd *, Elf_Internal_Shdr *);
2162  extern bfd_boolean _bfd_elf_merge_object_attributes (bfd *, bfd *);  extern bfd_boolean _bfd_elf_merge_object_attributes (bfd *, bfd *);
2163    
2164    /* The linker may needs to keep track of the number of relocs that it
2165       decides to copy as dynamic relocs in check_relocs for each symbol.
2166       This is so that it can later discard them if they are found to be
2167       unnecessary.  We can store the information in a field extending the
2168       regular ELF linker hash table.  */
2169    
2170    struct elf_dyn_relocs
2171    {
2172      struct elf_dyn_relocs *next;
2173    
2174      /* The input section of the reloc.  */
2175      asection *sec;
2176    
2177      /* Total number of relocs copied for the input section.  */
2178      bfd_size_type count;
2179    
2180      /* Number of pc-relative relocs copied for the input section.  */
2181      bfd_size_type pc_count;
2182    };
2183    
2184    extern bfd_boolean _bfd_elf_create_ifunc_sections
2185      (bfd *, struct bfd_link_info *);
2186    extern asection * _bfd_elf_create_ifunc_dyn_reloc
2187      (bfd *, struct bfd_link_info *, asection *sec, asection *sreloc,
2188       struct elf_dyn_relocs **);
2189    extern bfd_boolean _bfd_elf_allocate_ifunc_dyn_relocs
2190      (struct bfd_link_info *, struct elf_link_hash_entry *,
2191       struct elf_dyn_relocs **, unsigned int, unsigned int);
2192    
2193  /* Large common section.  */  /* Large common section.  */
2194  extern asection _bfd_elf_large_com_section;  extern asection _bfd_elf_large_com_section;
2195    
2196  /* SH ELF specific routine.  */  /* Hash for local symbol with the first section id, ID, in the input
2197       file and the local symbol index, SYM.  */
2198  extern bfd_boolean _sh_elf_set_mach_from_flags  #define ELF_LOCAL_SYMBOL_HASH(ID, SYM) \
2199    (bfd *);    (((((ID) & 0xff) << 24) | (((ID) & 0xff00) << 8)) \
2200       ^ (SYM) ^ ((ID) >> 16))
2201    
2202  /* This is the condition under which finish_dynamic_symbol will be called.  /* This is the condition under which finish_dynamic_symbol will be called.
2203     If our finish_dynamic_symbol isn't called, we'll need to do something     If our finish_dynamic_symbol isn't called, we'll need to do something

Legend:
Removed from v.20  
changed lines
  Added in v.21

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26