]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf-bfd.h
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / bfd / elf-bfd.h
index 99e13e00f35a27f1dffae6a4fb215d8a61df9adb..5741c60264b5be23a975c6bdf459aa7f63669e93 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end data structures for ELF files.
-   Copyright (C) 1992-2017 Free Software Foundation, Inc.
+   Copyright (C) 1992-2019 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -216,20 +216,22 @@ struct elf_link_hash_entry
   /* Symbol is __start_SECNAME or __stop_SECNAME to mark section
      SECNAME.  */
   unsigned int start_stop : 1;
+  /* Symbol is or was a weak defined symbol from a dynamic object with
+     a strong defined symbol alias.  U.ALIAS points to a list of aliases,
+     the definition having is_weakalias clear.  */
+  unsigned int is_weakalias : 1;
 
   /* String table index in .dynstr if this is a dynamic symbol.  */
   unsigned long dynstr_index;
 
   union
   {
-    /* If this is a weak defined symbol from a dynamic object, this
-       field points to a defined symbol with the same value, if there is
-       one.  Otherwise it is NULL.  */
-    struct elf_link_hash_entry *weakdef;
+    /* Points to a circular list of non-function symbol aliases.  */
+    struct elf_link_hash_entry *alias;
 
     /* Hash value of the name computed using the ELF hash function.
        Used part way through size_dynamic_sections, after we've finished
-       with weakdefs.  */
+       with aliases.  */
     unsigned long elf_hash_value;
   } u;
 
@@ -257,6 +259,16 @@ struct elf_link_hash_entry
   } u2;
 };
 
+/* Return the strong definition for a weak symbol with aliases.  */
+
+static inline struct elf_link_hash_entry *
+weakdef (struct elf_link_hash_entry *h)
+{
+  while (h->is_weakalias)
+    h = h->u.alias;
+  return h;
+}
+
 /* Will references to this symbol always reference the symbol
    in this object?  */
 #define SYMBOL_REFERENCES_LOCAL(INFO, H) \
@@ -336,8 +348,8 @@ struct eh_cie_fde
           .eh_frame input section that contains the CIE.  */
       union {
        struct cie *full_cie;
-       struct eh_cie_fde *merged_with;
-       asection *sec;
+       struct eh_cie_fde *merged_with;
+       asection *sec;
       } u;
 
       /* The offset of the personality data from the start of the CIE,
@@ -477,6 +489,7 @@ enum elf_target_id
   AVR_ELF_DATA,
   BFIN_ELF_DATA,
   CRIS_ELF_DATA,
+  CSKY_ELF_DATA,
   FRV_ELF_DATA,
   HPPA32_ELF_DATA,
   HPPA64_ELF_DATA,
@@ -503,7 +516,6 @@ enum elf_target_id
   TIC6X_ELF_DATA,
   X86_64_ELF_DATA,
   XTENSA_ELF_DATA,
-  XGATE_ELF_DATA,
   TILEGX_ELF_DATA,
   TILEPRO_ELF_DATA,
   RISCV_ELF_DATA,
@@ -531,6 +543,9 @@ struct elf_link_hash_table
      when linking against or generating a shared object.  */
   bfd_boolean dynamic_sections_created;
 
+  /* Whether dynamic relocations are present.  */
+  bfd_boolean dynamic_relocs;
+
   /* True if this target has relocatable executables, so needs dynamic
      section symbols.  */
   bfd_boolean is_relocatable_executable;
@@ -657,7 +672,7 @@ struct elf_link_hash_table
 #define elf_hash_table_id(table)       ((table) -> hash_table_id)
 
 /* Returns TRUE if the hash table is a struct elf_link_hash_table.  */
-#define is_elf_hash_table(htab)                                                \
+#define is_elf_hash_table(htab)                                                \
   (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
 
 /* Used by bfd_sym_from_r_symndx to cache a small number of local
@@ -731,10 +746,11 @@ struct elf_size_info {
 };
 
 #define elf_symbol_from(ABFD,S) \
-       (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
-         && (S)->the_bfd->tdata.elf_obj_data != 0) \
-        ? (elf_symbol_type *) (S) \
-        : 0)
+  (((S)->the_bfd != NULL                                       \
+    && (S)->the_bfd->xvec->flavour == bfd_target_elf_flavour   \
+    && (S)->the_bfd->tdata.elf_obj_data != 0)                  \
+   ? (elf_symbol_type *) (S)                                   \
+   : 0)
 
 enum elf_reloc_type_class {
   reloc_class_normal,
@@ -851,6 +867,9 @@ struct elf_backend_data
   /* The common page size for this backend.  */
   bfd_vma commonpagesize;
 
+  /* The value of commonpagesize to use when -z relro for this backend.  */
+  bfd_vma relropagesize;
+
   /* The BFD flags applied to sections created for dynamic linking.  */
   flagword dynamic_sec_flags;
 
@@ -859,13 +878,13 @@ struct elf_backend_data
   const void *arch_data;
 
   /* A function to translate an ELF RELA relocation to a BFD arelent
-     structure.  */
-  void (*elf_info_to_howto)
+     structure.  Returns TRUE upon success, FALSE otherwise.  */
+  bfd_boolean (*elf_info_to_howto)
     (bfd *, arelent *, Elf_Internal_Rela *);
 
   /* A function to translate an ELF REL relocation to a BFD arelent
-     structure.  */
-  void (*elf_info_to_howto_rel)
+     structure.  Returns TRUE upon success, FALSE otherwise.  */
+  bfd_boolean (*elf_info_to_howto_rel)
     (bfd *, arelent *, Elf_Internal_Rela *);
 
   /* A function to determine whether a symbol is global when
@@ -1339,7 +1358,7 @@ struct elf_backend_data
     (bfd *);
 
   reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
-    (unsigned int, bfd_boolean);
+    (bfd *, unsigned int, bfd_boolean);
 
   /* The swapping table to use when dealing with ECOFF information.
      Used for the MIPS ELF .mdebug section.  */
@@ -1397,7 +1416,7 @@ struct elf_backend_data
   bfd_boolean (*elf_backend_copy_special_section_fields)
     (const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *isection,
      Elf_Internal_Shdr *osection);
-               
+
   /* Used to handle bad SHF_LINK_ORDER input.  */
   void (*link_order_error_handler) (const char *, ...);
 
@@ -1460,6 +1479,10 @@ struct elf_backend_data
   /* Set up GNU properties.  */
   bfd *(*setup_gnu_properties) (struct bfd_link_info *);
 
+  /* Fix up GNU properties.  */
+  void (*fixup_gnu_properties) (struct bfd_link_info *,
+                               elf_property_list **);
+
   /* Encoding used for compact EH tables.  */
   int (*compact_eh_encoding) (struct bfd_link_info *);
 
@@ -1655,6 +1678,7 @@ struct bfd_elf_section_data
 #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_section_info(sec)  (elf_section_data(sec)->this_hdr.sh_info)
 #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)
@@ -1679,17 +1703,20 @@ struct bfd_elf_section_data
 
 /* The value of an object attribute.  The type indicates whether the attribute
    holds and integer, a string, or both.  It can also indicate that there can
-   be no default (i.e. all values must be written to file, even zero).  */
+   be no default (i.e. all values must be written to file, even zero), or
+   that the value is in error and should not be written to file.  */
 
 typedef struct obj_attribute
 {
 #define ATTR_TYPE_FLAG_INT_VAL    (1 << 0)
 #define ATTR_TYPE_FLAG_STR_VAL    (1 << 1)
 #define ATTR_TYPE_FLAG_NO_DEFAULT (1 << 2)
+#define ATTR_TYPE_FLAG_ERROR     (1 << 3)
 
 #define ATTR_TYPE_HAS_INT_VAL(TYPE)    ((TYPE) & ATTR_TYPE_FLAG_INT_VAL)
 #define ATTR_TYPE_HAS_STR_VAL(TYPE)    ((TYPE) & ATTR_TYPE_FLAG_STR_VAL)
 #define ATTR_TYPE_HAS_NO_DEFAULT(TYPE) ((TYPE) & ATTR_TYPE_FLAG_NO_DEFAULT)
+#define ATTR_TYPE_HAS_ERROR(TYPE)      ((TYPE) & ATTR_TYPE_FLAG_ERROR)
 
   int type;
   unsigned int i;
@@ -1796,8 +1823,8 @@ enum elf_gnu_symbols
 
 typedef struct elf_section_list
 {
-  Elf_Internal_Shdr          hdr;
-  unsigned int               ndx;
+  Elf_Internal_Shdr         hdr;
+  unsigned int              ndx;
   struct elf_section_list *  next;
 } elf_section_list;
 
@@ -1896,6 +1923,10 @@ struct elf_obj_tdata
   Elf_Internal_Shdr **group_sect_ptr;
   int num_group;
 
+  /* Index into group_sect_ptr, updated by setup_group when finding a
+     section's group.  Used to optimize subsequent group searches.  */
+  unsigned int group_search_offset;
+
   unsigned int symtab_section, dynsymtab_section;
   unsigned int dynversym_section, dynverdef_section, dynverref_section;
 
@@ -2065,6 +2096,8 @@ extern void _bfd_elf_link_hash_copy_indirect
    struct elf_link_hash_entry *);
 extern void _bfd_elf_link_hash_hide_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
+extern void _bfd_elf_link_hide_symbol
+  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
   (struct bfd_link_info *, struct elf_link_hash_entry *);
 extern bfd_boolean _bfd_elf_link_hash_table_init
@@ -2163,8 +2196,11 @@ extern const struct bfd_elf_special_section *_bfd_elf_get_special_section
 extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
   (bfd *, asection *);
 
+extern bfd_boolean _bfd_elf_link_hide_sym_by_version
+  (struct bfd_link_info *, struct elf_link_hash_entry *);
+
 /* If the target doesn't have reloc handling written yet:  */
-extern void _bfd_elf_no_info_to_howto
+extern bfd_boolean _bfd_elf_no_info_to_howto
   (bfd *, arelent *, Elf_Internal_Rela *);
 
 extern bfd_boolean bfd_section_from_shdr
@@ -2253,7 +2289,9 @@ extern bfd_boolean _bfd_elf_validate_reloc
 
 extern bfd_boolean _bfd_elf_link_create_dynamic_sections
   (bfd *, struct bfd_link_info *);
-extern bfd_boolean _bfd_elf_link_omit_section_dynsym
+extern bfd_boolean _bfd_elf_omit_section_dynsym_default
+  (bfd *, struct bfd_link_info *, asection *);
+extern bfd_boolean _bfd_elf_omit_section_dynsym_all
   (bfd *, struct bfd_link_info *, asection *);
 extern bfd_boolean _bfd_elf_create_dynamic_sections
   (bfd *, struct bfd_link_info *);
@@ -2514,7 +2552,8 @@ extern unsigned int _bfd_elf_ppc_at_tprel_transform
 /* PowerPC elf_object_p tweak.  */
 extern bfd_boolean _bfd_elf_ppc_set_arch (bfd *);
 /* PowerPC .gnu.attributes handling common to both 32-bit and 64-bit.  */
-extern void _bfd_elf_ppc_merge_fp_attributes (bfd *, struct bfd_link_info *);
+extern bfd_boolean _bfd_elf_ppc_merge_fp_attributes
+  (bfd *, struct bfd_link_info *);
 
 /* Exported interface for writing elf corefile notes.  */
 extern char *elfcore_write_note
@@ -2535,6 +2574,32 @@ extern char *elfcore_write_ppc_vmx
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_ppc_vsx
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tar
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_ppr
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_dscr
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_ebb
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_pmu
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_cgpr
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_cfpr
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_cvmx
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_cvsx
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_spr
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_ctar
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_cppr
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_tm_cdscr
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_s390_timer
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_s390_todcmp
@@ -2567,6 +2632,8 @@ extern char *elfcore_write_aarch_hw_break
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_aarch_hw_watch
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_aarch_sve
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_lwpstatus
   (bfd *, char *, int *, long, int, const void *);
 extern char *elfcore_write_register_note
@@ -2642,6 +2709,10 @@ extern elf_property * _bfd_elf_get_property
   (bfd *, unsigned int, unsigned int);
 extern bfd *_bfd_elf_link_setup_gnu_properties
   (struct bfd_link_info *);
+extern bfd_size_type _bfd_elf_convert_gnu_property_size
+  (bfd *, bfd *);
+extern bfd_boolean _bfd_elf_convert_gnu_properties
+  (bfd *, asection *, bfd *, bfd_byte **, bfd_size_type *);
 
 /* The linker may need to keep track of the number of relocs that it
    decides to copy as dynamic relocs in check_relocs for each symbol.
@@ -2776,7 +2847,7 @@ extern asection _bfd_elf_large_com_section;
   {                                                                    \
     int i_;                                                            \
     _bfd_clear_contents (howto, input_bfd, input_section,              \
-                        contents + rel[index].r_offset);               \
+                        contents, rel[index].r_offset);                \
                                                                        \
     if (bfd_link_relocatable (info)                                    \
        && (input_section->flags & SEC_DEBUGGING))                      \