Generic ELF target group signature symbol
[deliverable/binutils-gdb.git] / ld / emultempl / elf32.em
index 1ad9d6b6fa815ebaa93fb151fc6ae3e1bf8c58c7..3e8ee4693e67851e9f497a7393784a8c17bbf8bd 100644 (file)
@@ -12,7 +12,7 @@ fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
-   Copyright (C) 1991-2018 Free Software Foundation, Inc.
+   Copyright (C) 1991-2019 Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    ELF support by Ian Lance Taylor <ian@cygnus.com>
 
@@ -103,7 +103,6 @@ gld${EMULATION_NAME}_before_parse (void)
   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
-  `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
   link_info.check_relocs_after_open_input = TRUE;
   link_info.relro = DEFAULT_LD_Z_RELRO;
   link_info.separate_code = DEFAULT_LD_Z_SEPARATE_CODE;
@@ -1680,11 +1679,6 @@ gld${EMULATION_NAME}_append_to_separated_string (char **to, char *op_arg)
     }
 }
 
-#if defined(__GNUC__) && GCC_VERSION < 4006
-  /* Work around a GCC uninitialized warning bug fixed in GCC 4.6.  */
-static struct bfd_link_hash_entry ehdr_start_empty;
-#endif
-
 /* This is called after the sections have been attached to output
    sections, but before any sizes or addresses have been set.  */
 
@@ -1694,13 +1688,10 @@ gld${EMULATION_NAME}_before_allocation (void)
   const char *rpath;
   asection *sinterp;
   bfd *abfd;
-  struct elf_link_hash_entry *ehdr_start = NULL;
-#if defined(__GNUC__) && GCC_VERSION < 4006
-  /* Work around a GCC uninitialized warning bug fixed in GCC 4.6.  */
-  struct bfd_link_hash_entry ehdr_start_save = ehdr_start_empty;
-#else
-  struct bfd_link_hash_entry ehdr_start_save;
-#endif
+  struct bfd_link_hash_entry *ehdr_start = NULL;
+  unsigned char ehdr_start_save_type = 0;
+  char ehdr_start_save_u[sizeof ehdr_start->u
+                        - sizeof ehdr_start->u.def.next] = "";
 
   if (is_elf_hash_table (link_info.hash))
     {
@@ -1732,11 +1723,14 @@ gld${EMULATION_NAME}_before_allocation (void)
                 we most likely will need dynamic relocations for
                 __ehdr_start if we are building a PIE or shared
                 library.  */
-             ehdr_start = h;
-             ehdr_start_save = h->root;
-             h->root.type = bfd_link_hash_defined;
-             h->root.u.def.section = bfd_abs_section_ptr;
-             h->root.u.def.value = 0;
+             ehdr_start = &h->root;
+             ehdr_start_save_type = ehdr_start->type;
+             memcpy (ehdr_start_save_u,
+                     (char *) &ehdr_start->u + sizeof ehdr_start->u.def.next,
+                     sizeof ehdr_start_save_u);
+             ehdr_start->type = bfd_link_hash_defined;
+             ehdr_start->u.def.section = bfd_abs_section_ptr;
+             ehdr_start->u.def.value = 0;
            }
        }
 
@@ -1855,8 +1849,10 @@ ${ELF_INTERPRETER_SET_DEFAULT}
     {
       /* If we twiddled __ehdr_start to defined earlier, put it back
         as it was.  */
-      ehdr_start->root.type = ehdr_start_save.type;
-      ehdr_start->root.u = ehdr_start_save.u;
+      ehdr_start->type = ehdr_start_save_type;
+      memcpy ((char *) &ehdr_start->u + sizeof ehdr_start->u.def.next,
+             ehdr_start_save_u,
+             sizeof ehdr_start_save_u);
     }
 }
 
@@ -1957,7 +1953,7 @@ fragment <<EOF
 /* A variant of lang_output_section_find used by place_orphan.  */
 
 static lang_output_section_statement_type *
-output_rel_find (asection *sec, int isdyn)
+output_rel_find (int isdyn, int rela)
 {
   lang_output_section_statement_type *lookup;
   lang_output_section_statement_type *last = NULL;
@@ -1965,7 +1961,6 @@ output_rel_find (asection *sec, int isdyn)
   lang_output_section_statement_type *last_ro_alloc = NULL;
   lang_output_section_statement_type *last_rel = NULL;
   lang_output_section_statement_type *last_rel_alloc = NULL;
-  int rela = sec->name[4] == 'a';
 
   for (lookup = &lang_output_section_statement.head->output_section_statement;
        lookup != NULL;
@@ -2273,8 +2268,9 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
   else if ((flags & SEC_ALLOC) == 0)
     ;
   else if ((flags & SEC_LOAD) != 0
-          && ((elfinput && sh_type == SHT_NOTE)
-              || (!elfinput && CONST_STRNEQ (secname, ".note"))))
+          && (elfinput
+              ? sh_type == SHT_NOTE
+              : CONST_STRNEQ (secname, ".note")))
     place = &hold[orphan_interp];
   else if ((flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
     place = &hold[orphan_bss];
@@ -2284,9 +2280,10 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
     place = &hold[orphan_tdata];
   else if ((flags & SEC_READONLY) == 0)
     place = &hold[orphan_data];
-  else if (((elfinput && (sh_type == SHT_RELA || sh_type == SHT_REL))
-           || (!elfinput && CONST_STRNEQ (secname, ".rel")))
-          && (flags & SEC_LOAD) != 0)
+  else if ((flags & SEC_LOAD) != 0
+          && (elfinput
+              ? sh_type == SHT_RELA || sh_type == SHT_REL
+              : CONST_STRNEQ (secname, ".rel")))
     place = &hold[orphan_rel];
   else if ((flags & SEC_CODE) == 0)
     place = &hold[orphan_rodata];
@@ -2301,7 +2298,10 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
          if (place->name != NULL)
            place->os = lang_output_section_find (place->name);
          else
-           place->os = output_rel_find (s, isdyn);
+           {
+             int rela = elfinput ? sh_type == SHT_RELA : secname[4] == 'a';
+             place->os = output_rel_find (isdyn, rela);
+           }
        }
       after = place->os;
       if (after == NULL)
@@ -2376,17 +2376,41 @@ echo '             && link_info.combreloc'              >> e${EMULATION_NAME}.c
 echo '             && link_info.relro'                 >> e${EMULATION_NAME}.c
 echo '             && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xdw                        >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_pie (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.combreloc'             >> e${EMULATION_NAME}.c
+echo '             && link_info.separate_code'         >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xdceo              >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (bfd_link_pie (&link_info)'          >> e${EMULATION_NAME}.c
 echo '             && link_info.separate_code'         >> e${EMULATION_NAME}.c
 echo '             && link_info.combreloc) return'     >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xdce               >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_pie (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.combreloc'             >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xdco               >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (bfd_link_pie (&link_info)'          >> e${EMULATION_NAME}.c
 echo '             && link_info.combreloc) return'     >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xdc                        >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_pie (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.separate_code'         >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xdeo               >> e${EMULATION_NAME}.c
+fi
 fi
 echo '  ; else if (bfd_link_pie (&link_info)'          >> e${EMULATION_NAME}.c
 echo '             && link_info.separate_code) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xde                        >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_pie (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xdo                >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (bfd_link_pie (&link_info)) return'  >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xd                 >> e${EMULATION_NAME}.c
 fi
@@ -2402,17 +2426,41 @@ echo '             && link_info.combreloc'              >> e${EMULATION_NAME}.c
 echo '             && link_info.relro'                 >> e${EMULATION_NAME}.c
 echo '             && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xsw                        >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_dll (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.combreloc'             >> e${EMULATION_NAME}.c
+echo '             && link_info.separate_code'         >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xsceo              >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (bfd_link_dll (&link_info)'          >> e${EMULATION_NAME}.c
 echo '             && link_info.combreloc'             >> e${EMULATION_NAME}.c
 echo '             && link_info.separate_code) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xsce                       >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_dll (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.combreloc'             >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xsco               >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (bfd_link_dll (&link_info)'          >> e${EMULATION_NAME}.c
 echo '             && link_info.combreloc) return'     >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xsc                        >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_dll (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.separate_code'         >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xseo               >> e${EMULATION_NAME}.c
+fi
 fi
 echo '  ; else if (bfd_link_dll (&link_info)'          >> e${EMULATION_NAME}.c
 echo '             && link_info.separate_code) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xse                        >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (bfd_link_dll (&link_info)'          >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xso               >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (bfd_link_dll (&link_info)) return'  >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xs                 >> e${EMULATION_NAME}.c
 fi
@@ -2425,14 +2473,34 @@ echo '  ; else if (link_info.combreloc'                 >> e${EMULATION_NAME}.c
 echo '             && link_info.relro'                 >> e${EMULATION_NAME}.c
 echo '             && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xw                 >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (link_info.combreloc'                 >> e${EMULATION_NAME}.c
+echo '             && link_info.separate_code'         >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'          >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xceo                >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (link_info.combreloc'                        >> e${EMULATION_NAME}.c
 echo '             && link_info.separate_code) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xce                        >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (link_info.combreloc'                 >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'          >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xco                 >> e${EMULATION_NAME}.c
+fi
 echo '  ; else if (link_info.combreloc) return'                >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xc                 >> e${EMULATION_NAME}.c
 fi
-echo '  ; else if (link_info.separate_code) return'            >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (link_info.separate_code'             >> e${EMULATION_NAME}.c
+echo '             && link_info.relro) return'          >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xeo                 >> e${EMULATION_NAME}.c
+fi
+echo '  ; else if (link_info.separate_code) return'     >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xe                 >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+echo '  ; else if (link_info.relro) return'             >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xo                  >> e${EMULATION_NAME}.c
+fi
 echo '  ; else return'                                 >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
 echo '; }'                                             >> e${EMULATION_NAME}.c
@@ -2471,6 +2539,21 @@ fragment <<EOF
       else
        return "ldscripts/${EMULATION_NAME}.xdw";
     }
+EOF
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+fragment <<EOF
+  else if (bfd_link_pie (&link_info)
+          && link_info.combreloc
+          && link_info.relro)
+    {
+      if (link_info.separate_code)
+       return "ldscripts/${EMULATION_NAME}.xdceo";
+      else
+       return "ldscripts/${EMULATION_NAME}.xdco";
+    }
+EOF
+fi
+fragment <<EOF
   else if (bfd_link_pie (&link_info)
           && link_info.combreloc)
     {
@@ -2481,6 +2564,18 @@ fragment <<EOF
     }
 EOF
 fi
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+fragment <<EOF
+  else if (bfd_link_pie (&link_info)
+          && link_info.relro)
+    {
+      if (link_info.separate_code)
+       return "ldscripts/${EMULATION_NAME}.xdeo";
+      else
+       return "ldscripts/${EMULATION_NAME}.xdo";
+    }
+EOF
+fi
 fragment <<EOF
   else if (bfd_link_pie (&link_info))
     {
@@ -2502,6 +2597,21 @@ fragment <<EOF
       else
        return "ldscripts/${EMULATION_NAME}.xsw";
     }
+EOF
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+fragment <<EOF
+  else if (bfd_link_dll (&link_info)
+          && link_info.combreloc
+          && link_info.relro)
+    {
+      if (link_info.separate_code)
+       return "ldscripts/${EMULATION_NAME}.xsceo";
+      else
+       return "ldscripts/${EMULATION_NAME}.xsco";
+    }
+EOF
+fi
+fragment <<EOF
   else if (bfd_link_dll (&link_info) && link_info.combreloc)
     {
       if (link_info.separate_code)
@@ -2511,6 +2621,18 @@ fragment <<EOF
     }
 EOF
 fi
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+fragment <<EOF
+  else if (bfd_link_dll (&link_info)
+          && link_info.relro)
+    {
+      if (link_info.separate_code)
+       return "ldscripts/${EMULATION_NAME}.xseo";
+      else
+       return "ldscripts/${EMULATION_NAME}.xso";
+    }
+EOF
+fi
 fragment <<EOF
   else if (bfd_link_dll (&link_info))
     {
@@ -2531,6 +2653,20 @@ fragment <<EOF
       else
        return "ldscripts/${EMULATION_NAME}.xw";
     }
+EOF
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+fragment <<EOF
+  else if (link_info.combreloc
+          && link_info.relro)
+    {
+      if (link_info.separate_code)
+       return "ldscripts/${EMULATION_NAME}.xceo";
+      else
+       return "ldscripts/${EMULATION_NAME}.xco";
+    }
+EOF
+fi
+fragment <<EOF
   else if (link_info.combreloc)
     {
       if (link_info.separate_code)
@@ -2540,6 +2676,17 @@ fragment <<EOF
     }
 EOF
 fi
+if test -n "$GENERATE_RELRO_SCRIPT" ; then
+fragment <<EOF
+  else if (link_info.relro)
+    {
+      if (link_info.separate_code)
+       return "ldscripts/${EMULATION_NAME}.xeo";
+      else
+       return "ldscripts/${EMULATION_NAME}.xo";
+    }
+EOF
+fi
 fragment <<EOF
   else
     {
This page took 0.028457 seconds and 4 git commands to generate.