x86: Move x86-specific linker options to elf_linker_x86_params
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 6 Apr 2019 14:25:10 +0000 (07:25 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 6 Apr 2019 14:25:31 +0000 (07:25 -0700)
Remove x86-specific linker options from bfd_link_info and put them in
elf_linker_x86_params.  Add _bfd_elf_linker_x86_set_options to pass
x86-specific linker options from ld to bfd.

bfd/

* elf-linker-x86.h: New file.
* elf32-i386.c (elf_i386_convert_load_reloc): Use htab->params
to get x86-specific linker options.
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
(elf_x86_64_check_relocs): Likewise.
(elf_x86_64_relocate_section): Likewise.
(elf_x86_64_link_setup_gnu_properties): Likewise.
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Likewise.
(_bfd_x86_elf_link_setup_gnu_properties): Likewise.
(_bfd_elf_linker_x86_set_options): New function.
* elfxx-x86.h: Include "elf-linker-x86.h".
(elf_x86_link_hash_table): Add params.

include/

* bfdlink.h (bfd_link_info): Remove x86-specific linker options.

ld/

* Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emultempl/elf-x86.em.
(eelf_i386_sol2.c): Also depend on
$(srcdir)/emultempl/solaris2-x86.em.
(eelf_x86_64_sol2.c): Likewise.
* Makefile.in: Regenerated.
* emulparams/call_nop.sh: Set x86-specific linker options via
params.
* emulparams/cet.sh: Likewise.
* emulparams/reloc_overflow.sh: Likewise.
* emulparams/elf32_x86_64.sh (EXTRA_EM_FILE): New.  Set to
"elf-x86".
* emulparams/elf_i386.sh: Likewise.
* emulparams/elf_i386_be.sh: Likewise.
* emulparams/elf_i386_chaos.sh: Likewise.
* emulparams/elf_i386_ldso.sh: Likewise.
* emulparams/elf_i386_vxworks.sh: Likewise.
* emulparams/elf_iamcu.sh: Likewise.
* emulparams/elf_k1om.sh: Likewise.
* emulparams/elf_l1om.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/elf_i386_sol2.sh (EXTRA_EM_FILE): Changed to
"solaris2-x86".
* emulparams/elf_x86_64_sol2.sh: Likewise.
* emultempl/elf-x86.em: New file.
* emultempl/solaris2-x86.em: Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't
set link_info.call_nop_byte.

29 files changed:
bfd/ChangeLog
bfd/elf-linker-x86.h [new file with mode: 0644]
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.c
bfd/elfxx-x86.h
include/ChangeLog
include/bfdlink.h
ld/ChangeLog
ld/Makefile.am
ld/Makefile.in
ld/emulparams/call_nop.sh
ld/emulparams/cet.sh
ld/emulparams/elf32_x86_64.sh
ld/emulparams/elf_i386.sh
ld/emulparams/elf_i386_be.sh
ld/emulparams/elf_i386_chaos.sh
ld/emulparams/elf_i386_ldso.sh
ld/emulparams/elf_i386_sol2.sh
ld/emulparams/elf_i386_vxworks.sh
ld/emulparams/elf_iamcu.sh
ld/emulparams/elf_k1om.sh
ld/emulparams/elf_l1om.sh
ld/emulparams/elf_x86_64.sh
ld/emulparams/elf_x86_64_sol2.sh
ld/emulparams/reloc_overflow.sh
ld/emultempl/elf-x86.em [new file with mode: 0644]
ld/emultempl/elf32.em
ld/emultempl/solaris2-x86.em [new file with mode: 0644]

index 7953c840cd79317d560580b675bf7da6a7139c8e..72156b972244c331314a27602453181f5f4c4259 100644 (file)
@@ -1,3 +1,18 @@
+2019-04-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf-linker-x86.h: New file.
+       * elf32-i386.c (elf_i386_convert_load_reloc): Use htab->params
+       to get x86-specific linker options.
+       * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
+       (elf_x86_64_check_relocs): Likewise.
+       (elf_x86_64_relocate_section): Likewise.
+       (elf_x86_64_link_setup_gnu_properties): Likewise.
+       * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Likewise.
+       (_bfd_x86_elf_link_setup_gnu_properties): Likewise.
+       (_bfd_elf_linker_x86_set_options): New function.
+       * elfxx-x86.h: Include "elf-linker-x86.h".
+       (elf_x86_link_hash_table): Add params.
+
 2019-04-03  Alan Modra  <amodra@gmail.com>
 
        * coff-i386.c, * coff-x86_64.c, * coffgen.c, * dwarf2.c,
diff --git a/bfd/elf-linker-x86.h b/bfd/elf-linker-x86.h
new file mode 100644 (file)
index 0000000..bd14b71
--- /dev/null
@@ -0,0 +1,47 @@
+/* x86-specific ELF linker support between ld and bfd.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+/* Used to pass x86-specific linker options from ld to bfd.  */
+struct elf_linker_x86_params
+{
+  /* TRUE if BND prefix in PLT entries is always generated.  */
+  unsigned int bndplt: 1;
+
+  /* TRUE if IBT-enabled PLT entries should be generated.  */
+  unsigned int ibtplt: 1;
+
+  /* TRUE if GNU_PROPERTY_X86_FEATURE_1_IBT should be generated.  */
+  unsigned int ibt: 1;
+
+  /* TRUE if GNU_PROPERTY_X86_FEATURE_1_SHSTK should be generated.  */
+  unsigned int shstk: 1;
+
+  /* TRUE if we shouldn't check relocation overflow.  */
+  unsigned int no_reloc_overflow_check: 1;
+
+  /* TRUE if generate a 1-byte NOP as suffix for x86 call instruction.  */
+  unsigned int call_nop_as_suffix : 1;
+
+  /* The 1-byte NOP for x86 call instruction.  */
+  char call_nop_byte;
+};
+
+extern void _bfd_elf_linker_x86_set_options
+  (struct bfd_link_info *, struct elf_linker_x86_params *);
index 79cd8c65bc150781b9783cfc591b08fc36785890..5d3f2eb4b529247f2f56e1748720f500d2babfe8 100644 (file)
@@ -1343,8 +1343,8 @@ convert_branch:
                }
              else
                {
-                 nop = link_info->call_nop_byte;
-                 if (link_info->call_nop_as_suffix)
+                 nop = htab->params->call_nop_byte;
+                 if (htab->params->call_nop_as_suffix)
                    {
                      nop_offset = roff + 3;
                      irel->r_offset -= 1;
index ecd4c6d03c6d8c946b0260bc18cbb165e7bbfc90..6790228271b38c9ed5e44a59d715171f0f456f8a 100644 (file)
@@ -1676,8 +1676,8 @@ convert:
            }
          else
            {
-             nop = link_info->call_nop_byte;
-             if (link_info->call_nop_as_suffix)
+             nop = htab->params->call_nop_byte;
+             if (htab->params->call_nop_as_suffix)
                {
                  nop_offset = irel->r_offset + 3;
                  disp = bfd_get_32 (abfd, contents + irel->r_offset);
@@ -2149,7 +2149,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
             run-time relocation overflow.  Don't error out for
             sections we don't care about, such as debug sections or
             when relocation overflow check is disabled.  */
-         if (!info->no_reloc_overflow_check
+         if (!htab->params->no_reloc_overflow_check
              && !converted_reloc
              && (bfd_link_pic (info)
                  || (bfd_link_executable (info)
@@ -3206,7 +3206,7 @@ direct:
                     convert R_X86_64_32 to dynamic R_X86_64_RELATIVE.  */
                  if (r_type == htab->pointer_r_type
                      || (r_type == R_X86_64_32
-                         && info->no_reloc_overflow_check))
+                         && htab->params->no_reloc_overflow_check))
                    {
                      relocate = TRUE;
                      outrel.r_info = htab->r_info (0, R_X86_64_RELATIVE);
@@ -5048,7 +5048,13 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
 
   if (get_elf_x86_backend_data (info->output_bfd)->target_os != is_nacl)
     {
-      if (info->bndplt)
+      const struct elf_backend_data *bed
+       = get_elf_backend_data (info->output_bfd);
+      struct elf_x86_link_hash_table *htab
+       = elf_x86_hash_table (info, bed->target_id);
+      if (!htab)
+       abort ();
+      if (htab->params->bndplt)
        {
          init_table.lazy_plt = &elf_x86_64_lazy_bnd_plt;
          init_table.non_lazy_plt = &elf_x86_64_non_lazy_bnd_plt;
index 5703b5f389a0fafd4a086c22c357d060a6c042a1..8d08a69d22c3800f5b3ba6183463c45691bc0dfe 100644 (file)
@@ -2479,12 +2479,18 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
         2. If APROP is NULL, remove x86 feature.
         3. Otherwise, do nothing.
        */
+      const struct elf_backend_data *bed
+       = get_elf_backend_data (info->output_bfd);
+      struct elf_x86_link_hash_table *htab
+       = elf_x86_hash_table (info, bed->target_id);
+      if (!htab)
+       abort ();
       if (aprop != NULL && bprop != NULL)
        {
          features = 0;
-         if (info->ibt)
+         if (htab->params->ibt)
            features = GNU_PROPERTY_X86_FEATURE_1_IBT;
-         if (info->shstk)
+         if (htab->params->shstk)
            features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
          number = aprop->u.number;
          /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
@@ -2501,9 +2507,9 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
             have them.  Set IBT and SHSTK properties for -z ibt and -z
             shstk if needed.  */
          features = 0;
-         if (info->ibt)
+         if (htab->params->ibt)
            features = GNU_PROPERTY_X86_FEATURE_1_IBT;
-         if (info->shstk)
+         if (htab->params->shstk)
            features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
          if (features)
            {
@@ -2556,12 +2562,6 @@ _bfd_x86_elf_link_setup_gnu_properties
   unsigned int class_align = ABI_64_P (info->output_bfd) ? 3 : 2;
   unsigned int got_align;
 
-  features = 0;
-  if (info->ibt)
-    features = GNU_PROPERTY_X86_FEATURE_1_IBT;
-  if (info->shstk)
-    features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
-
   /* Find a normal input file with GNU property note.  */
   for (pbfd = info->input_bfds;
        pbfd != NULL;
@@ -2581,6 +2581,12 @@ _bfd_x86_elf_link_setup_gnu_properties
   if (htab == NULL)
     return pbfd;
 
+  features = 0;
+  if (htab->params->ibt)
+    features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+  if (htab->params->shstk)
+    features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
+
   if (ebfd != NULL)
     {
       prop = NULL;
@@ -2630,7 +2636,7 @@ error_alignment:
 
   htab->plt0_pad_byte = init_table->plt0_pad_byte;
 
-  use_ibt_plt = info->ibtplt || info->ibt;
+  use_ibt_plt = htab->params->ibtplt || htab->params->ibt;
   if (!use_ibt_plt && pbfd != NULL)
     {
       /* Check if GNU_PROPERTY_X86_FEATURE_1_IBT is on.  */
@@ -2853,7 +2859,7 @@ error_alignment:
                                                  plt_alignment))
                    goto error_alignment;
                }
-             else if (info->bndplt && ABI_64_P (dynobj))
+             else if (htab->params->bndplt && ABI_64_P (dynobj))
                {
                  /* Create the second PLT for Intel MPX support.  MPX
                     PLT is supported only for non-NaCl target in 64-bit
@@ -2984,3 +2990,15 @@ _bfd_x86_elf_link_fixup_gnu_properties
        }
     }
 }
+
+void
+_bfd_elf_linker_x86_set_options (struct bfd_link_info * info,
+                                struct elf_linker_x86_params *params)
+{
+  const struct elf_backend_data *bed
+    = get_elf_backend_data (info->output_bfd);
+  struct elf_x86_link_hash_table *htab
+    = elf_x86_hash_table (info, bed->target_id);
+  if (htab != NULL)
+    htab->params = params;
+}
index 4df2173a5842f92b691e4680156bad70e2043507..013ac4b761e4503d6bdbcad968ba16d0150f44f9 100644 (file)
@@ -24,6 +24,7 @@
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "hashtab.h"
+#include "elf-linker-x86.h"
 
 #define PLT_CIE_LENGTH         20
 #define PLT_FDE_LENGTH         36
@@ -530,6 +531,9 @@ struct elf_x86_link_hash_table
   int dynamic_interpreter_size;
   const char *dynamic_interpreter;
   const char *tls_get_addr;
+
+  /* Options passed from the linker.  */
+  struct elf_linker_x86_params *params;
 };
 
 /* Architecture-specific backend data for x86.  */
index c1639b882c0d13a7d5b52868b9bb88700d0f8537..0a6759ffa4a949b16f53c4dbfcebab9618ad093e 100644 (file)
@@ -1,3 +1,7 @@
+2019-04-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * bfdlink.h (bfd_link_info): Remove x86-specific linker options.
+
 2019-04-01  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * opcode/arm.h (FPU_NEON_ARMV8_1): New.
index bad52f9c50807ff850d5ef8f2614f9e35be94705..c35469dd11ef49e5faa827cdd5a8638819667740 100644 (file)
@@ -482,36 +482,15 @@ struct bfd_link_info
      been opened.  */
   unsigned int check_relocs_after_open_input: 1;
 
-  /* TRUE if BND prefix in PLT entries is always generated.  */
-  unsigned int bndplt: 1;
-
-  /* TRUE if IBT-enabled PLT entries should be generated.  */
-  unsigned int ibtplt: 1;
-
-  /* TRUE if GNU_PROPERTY_X86_FEATURE_1_IBT should be generated.  */
-  unsigned int ibt: 1;
-
-  /* TRUE if GNU_PROPERTY_X86_FEATURE_1_SHSTK should be generated.  */
-  unsigned int shstk: 1;
-
   /* TRUE if generation of .interp/PT_INTERP should be suppressed.  */
   unsigned int nointerp: 1;
 
-  /* TRUE if we shouldn't check relocation overflow.  */
-  unsigned int no_reloc_overflow_check: 1;
-
-  /* TRUE if generate a 1-byte NOP as suffix for x86 call instruction.  */
-  unsigned int call_nop_as_suffix : 1;
-
   /* TRUE if common symbols should be treated as undefined.  */
   unsigned int inhibit_common_definition : 1;
 
   /* TRUE if "-Map map" is passed to linker.  */
   unsigned int has_map_file : 1;
 
-  /* The 1-byte NOP for x86 call instruction.  */
-  char call_nop_byte;
-
   /* Char that may appear as the first char of a symbol, but should be
      skipped (like symbol_leading_char) when looking up symbols in
      wrap_hash.  Used by PowerPC Linux for 'dot' symbols.  */
index 3beaa4141a56e4bb30c0b824427694981203434f..88044d199039bc2bd185b881aef072559a366a87 100644 (file)
@@ -1,3 +1,33 @@
+2019-04-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emultempl/elf-x86.em.
+       (eelf_i386_sol2.c): Also depend on
+       $(srcdir)/emultempl/solaris2-x86.em.
+       (eelf_x86_64_sol2.c): Likewise.
+       * Makefile.in: Regenerated.
+       * emulparams/call_nop.sh: Set x86-specific linker options via
+       params.
+       * emulparams/cet.sh: Likewise.
+       * emulparams/reloc_overflow.sh: Likewise.
+       * emulparams/elf32_x86_64.sh (EXTRA_EM_FILE): New.  Set to
+       "elf-x86".
+       * emulparams/elf_i386.sh: Likewise.
+       * emulparams/elf_i386_be.sh: Likewise.
+       * emulparams/elf_i386_chaos.sh: Likewise.
+       * emulparams/elf_i386_ldso.sh: Likewise.
+       * emulparams/elf_i386_vxworks.sh: Likewise.
+       * emulparams/elf_iamcu.sh: Likewise.
+       * emulparams/elf_k1om.sh: Likewise.
+       * emulparams/elf_l1om.sh: Likewise.
+       * emulparams/elf_x86_64.sh: Likewise.
+       * emulparams/elf_i386_sol2.sh (EXTRA_EM_FILE): Changed to
+       "solaris2-x86".
+       * emulparams/elf_x86_64_sol2.sh: Likewise.
+       * emultempl/elf-x86.em: New file.
+       * emultempl/solaris2-x86.em: Likewise.
+       * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't
+       set link_info.call_nop_byte.
+
 2019-04-05  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-powerpc/tlsexe32.d: Remove trailing spaces.
index c2c798b4fe3c7840d65a14fa8aa80a6642776a00..6d750c8db2049a9deaa8b855b287cf5a504898ef 100644 (file)
@@ -618,7 +618,8 @@ GENSCRIPTS = LIB_PATH='${LIB_PATH}' $(SHELL) $(srcdir)/genscripts.sh "${srcdir}"
 GEN_DEPENDS = $(srcdir)/genscripts.sh stringify.sed
 ELF_DEPS = $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/scripttempl/DWARF.sc
 ELF_GEN_DEPS = $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/emultempl/genelf.em $(srcdir)/scripttempl/DWARF.sc
-ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emulparams/plt_unwind.sh \
+ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emultempl/elf-x86.em \
+              $(srcdir)/emulparams/plt_unwind.sh \
               $(srcdir)/emulparams/extern_protected_data.sh \
               $(srcdir)/emulparams/dynamic_undefined_weak.sh \
               $(srcdir)/emulparams/reloc_overflow.sh \
@@ -1310,6 +1311,7 @@ eelf_i386_nacl.c: $(srcdir)/emulparams/elf_i386_nacl.sh \
 eelf_i386_sol2.c: $(srcdir)/emulparams/elf_i386_sol2.sh \
   $(srcdir)/emulparams/solaris2.sh \
   $(srcdir)/emultempl/solaris2.em \
+  $(srcdir)/emultempl/solaris2-x86.em \
   $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 
 eelf_i386_vxworks.c: $(srcdir)/emulparams/elf_i386_vxworks.sh \
@@ -1866,6 +1868,7 @@ eelf_x86_64_sol2.c: $(srcdir)/emulparams/elf_x86_64_sol2.sh \
   $(srcdir)/emulparams/elf_x86_64.sh \
   $(srcdir)/emulparams/solaris2.sh \
   $(srcdir)/emultempl/solaris2.em \
+  $(srcdir)/emultempl/solaris2-x86.em \
   $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 
 ehppa64linux.c: $(srcdir)/emulparams/hppa64linux.sh \
index fc687fc5166a1cef1526c23ed174613d5def546b..0f3c11a31e7f5089431a44c7419e49c99ead4b90 100644 (file)
@@ -986,7 +986,8 @@ GENSCRIPTS = LIB_PATH='${LIB_PATH}' $(SHELL) $(srcdir)/genscripts.sh "${srcdir}"
 GEN_DEPENDS = $(srcdir)/genscripts.sh stringify.sed
 ELF_DEPS = $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/scripttempl/DWARF.sc
 ELF_GEN_DEPS = $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/emultempl/genelf.em $(srcdir)/scripttempl/DWARF.sc
-ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emulparams/plt_unwind.sh \
+ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emultempl/elf-x86.em \
+              $(srcdir)/emulparams/plt_unwind.sh \
               $(srcdir)/emulparams/extern_protected_data.sh \
               $(srcdir)/emulparams/dynamic_undefined_weak.sh \
               $(srcdir)/emulparams/reloc_overflow.sh \
@@ -2914,6 +2915,7 @@ eelf_i386_nacl.c: $(srcdir)/emulparams/elf_i386_nacl.sh \
 eelf_i386_sol2.c: $(srcdir)/emulparams/elf_i386_sol2.sh \
   $(srcdir)/emulparams/solaris2.sh \
   $(srcdir)/emultempl/solaris2.em \
+  $(srcdir)/emultempl/solaris2-x86.em \
   $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 
 eelf_i386_vxworks.c: $(srcdir)/emulparams/elf_i386_vxworks.sh \
@@ -3470,6 +3472,7 @@ eelf_x86_64_sol2.c: $(srcdir)/emulparams/elf_x86_64_sol2.sh \
   $(srcdir)/emulparams/elf_x86_64.sh \
   $(srcdir)/emulparams/solaris2.sh \
   $(srcdir)/emultempl/solaris2.em \
+  $(srcdir)/emultempl/solaris2-x86.em \
   $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 
 ehppa64linux.c: $(srcdir)/emulparams/hppa64linux.sh \
index c114e95c441a6c88f537ac1cfd0aba0de5cb529b..b1e2e73cbf83801a009d29f04005a208c9f61491 100644 (file)
@@ -7,31 +7,31 @@ PARSE_AND_LIST_ARGS_CASE_Z_CALL_NOP='
        {
          if (strcmp (optarg + 9, "prefix-addr") == 0)
            {
-             link_info.call_nop_as_suffix = FALSE;
-             link_info.call_nop_byte = 0x67;
+             params.call_nop_as_suffix = FALSE;
+             params.call_nop_byte = 0x67;
            }
          else if (strcmp (optarg + 9, "suffix-nop") == 0)
            {
-             link_info.call_nop_as_suffix = TRUE;
-             link_info.call_nop_byte = 0x90;
+             params.call_nop_as_suffix = TRUE;
+             params.call_nop_byte = 0x90;
            }
          else if (strncmp (optarg + 9, "prefix-", 7) == 0)
            {
              char *end;
-             link_info.call_nop_byte = strtoul (optarg + 16 , &end, 0);
+             params.call_nop_byte = strtoul (optarg + 16 , &end, 0);
              if (*end)
                einfo (_("%F%P: invalid number for -z call-nop=prefix-: %s\n"),
                       optarg + 16);
-             link_info.call_nop_as_suffix = FALSE;
+             params.call_nop_as_suffix = FALSE;
            }
          else if (strncmp (optarg + 9, "suffix-", 7) == 0)
            {
              char *end;
-             link_info.call_nop_byte = strtoul (optarg + 16, &end, 0);
+             params.call_nop_byte = strtoul (optarg + 16, &end, 0);
              if (*end)
                einfo (_("%F%P: invalid number for -z call-nop=suffix-: %s\n"),
                       optarg + 16);
-             link_info.call_nop_as_suffix = TRUE;
+             params.call_nop_as_suffix = TRUE;
            }
          else
            einfo (_("%F%P: unsupported option: -z %s\n"), optarg);
index 7c49b9557eff1f07348b146d76684d12a9ae4978..1d45b16283054184330b470c40924bc888a09d70 100644 (file)
@@ -8,11 +8,11 @@ PARSE_AND_LIST_OPTIONS_CET='
 '
 PARSE_AND_LIST_ARGS_CASE_Z_CET='
       else if (strcmp (optarg, "ibtplt") == 0)
-       link_info.ibtplt = TRUE;
+       params.ibtplt = TRUE;
       else if (strcmp (optarg, "ibt") == 0)
-       link_info.ibt = TRUE;
+       params.ibt = TRUE;
       else if (strcmp (optarg, "shstk") == 0)
-       link_info.shstk = TRUE;
+       params.shstk = TRUE;
 '
 
 PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_CET"
index 9ce6533bd9329ad3db5781ec454b0caa78167350..6fddf626af1f6a0b64e919ec0789a486b343756c 100644 (file)
@@ -14,6 +14,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 ARCH="i386:x64-32"
 MACHINE=
 TEMPLATE_NAME=elf32
+EXTRA_EM_FILE="elf-x86"
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
index 2cef106e3dcde427f6a194e0bb9c85aa9cb0cd3f..5d3f71f10bdae1c91a212ff49e6c7cf6a2dc2797 100644 (file)
@@ -12,6 +12,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 ARCH=i386
 MACHINE=
 TEMPLATE_NAME=elf32
+EXTRA_EM_FILE="elf-x86"
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
index 70db443239597eeef9575777104c4572bfbc4f64..8d4cffe901ab3659eca0190d8d6b11945ca227b3 100644 (file)
@@ -3,6 +3,7 @@
 . ${srcdir}/emulparams/call_nop.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
+EXTRA_EM_FILE="elf-x86"
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x80000000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
index aa36cb51c2d38962df88bf87b66fa15bac5b6d1a..ec2bb7f4a546e44176a7426749b0e5595182c2fd 100644 (file)
@@ -4,6 +4,7 @@
 . ${srcdir}/emulparams/call_nop.sh
 SCRIPT_NAME=elf_chaos
 OUTPUT_FORMAT="elf32-i386"
+EXTRA_EM_FILE="elf-x86"
 TEXT_START_ADDR=0x40000000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
 ARCH=i386
index 1328520c57cfc5828cde151abd78efeab994ea40..981c7014a3df6b2a825355f5758edf721d16ca5b 100644 (file)
@@ -4,6 +4,7 @@
 . ${srcdir}/emulparams/call_nop.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
+EXTRA_EM_FILE="elf-x86"
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x08048000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
index 7c18fc6e17dd113c254eef9d03f6ab305daf0523..c45a586e8e92fce5c35f0d36c6bb7cc0d2bcbbe1 100644 (file)
@@ -1,4 +1,4 @@
 . ${srcdir}/emulparams/elf_i386_ldso.sh
 . ${srcdir}/emulparams/solaris2.sh
-EXTRA_EM_FILE=solaris2
+EXTRA_EM_FILE="solaris2-x86"
 OUTPUT_FORMAT="elf32-i386-sol2"
index aaea8c48743438ca8c5eac2999755532b91e66fc..efc164f68947f79a7ba7388c0fbc0053484988d9 100644 (file)
@@ -7,6 +7,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 ARCH=i386
 MACHINE=
 TEMPLATE_NAME=elf32
+EXTRA_EM_FILE="elf-x86"
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
index d910b653c36cd87f486d9ed1a68dbe7f3a79b23c..d30a155293599e47c9dc9defe87781c971212e4a 100644 (file)
@@ -12,6 +12,7 @@ ARCH=iamcu
 MACHINE=
 COMPILE_IN=yes
 TEMPLATE_NAME=elf32
+EXTRA_EM_FILE="elf-x86"
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
index 494efcc6c909bd19b90d2c453d7457338552c0e8..ec84bd0b9f85d9ffc98e6848f4c3427e3d6130c6 100644 (file)
@@ -13,6 +13,7 @@ ARCH="k1om"
 MACHINE=
 COMPILE_IN=yes
 TEMPLATE_NAME=elf32
+EXTRA_EM_FILE="elf-x86"
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
index b1158791f46820032a0fdd05bfce47800a618b13..fade2da88fee758eaf6676c2536b248c589f5564 100644 (file)
@@ -13,6 +13,7 @@ ARCH="l1om"
 MACHINE=
 COMPILE_IN=yes
 TEMPLATE_NAME=elf32
+EXTRA_EM_FILE="elf-x86"
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
index d8c6e54894c0d8fbada96bfe2089746ac93130ff..241911dab3e71162c02a439f0a9b759145d6b1c2 100644 (file)
@@ -14,6 +14,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 ARCH="i386:x86-64"
 MACHINE=
 TEMPLATE_NAME=elf32
+EXTRA_EM_FILE="elf-x86"
 GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
@@ -47,7 +48,7 @@ case "$target" in
 '
        PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT='
       else if (strcmp (optarg, "bndplt") == 0)
-       link_info.bndplt = TRUE;
+       params.bndplt = TRUE;
 '
        PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_BNDPLT"
        PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT"
index 993f458249c252f5d7f6126ef559bca008a3b495..3bd975ffc795e6c682c6efb69542d7244b999b52 100644 (file)
@@ -1,4 +1,4 @@
 . ${srcdir}/emulparams/elf_x86_64.sh
 . ${srcdir}/emulparams/solaris2.sh
-EXTRA_EM_FILE=solaris2
+EXTRA_EM_FILE="solaris2-x86"
 OUTPUT_FORMAT="elf64-x86-64-sol2"
index 7ba0ee50d80a09e454f6b9eaf14064e8b1537083..6bf0abced7c53c7cc385ca0767c29671f968f096 100644 (file)
@@ -4,7 +4,7 @@ PARSE_AND_LIST_OPTIONS_RELOC_OVERFLOW='
 '
 PARSE_AND_LIST_ARGS_CASE_Z_RELOC_OVERFLOW='
       else if (strcmp (optarg, "noreloc-overflow") == 0)
-       link_info.no_reloc_overflow_check = TRUE;
+       params.no_reloc_overflow_check = TRUE;
 '
 
 PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_RELOC_OVERFLOW"
diff --git a/ld/emultempl/elf-x86.em b/ld/emultempl/elf-x86.em
new file mode 100644 (file)
index 0000000..09780a1
--- /dev/null
@@ -0,0 +1,57 @@
+# This shell script emits a C file. -*- C -*-
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the license, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not,
+# see <http://www.gnu.org/licenses/>.
+#
+
+# This file is sourced from elf32.em, and defines x86 specific routines.
+#
+fragment <<EOF
+
+#include "elf-linker-x86.h"
+
+static struct elf_linker_x86_params params;
+
+/* This is a convenient point to tell BFD about target specific flags.
+   After the output has been created, but before inputs are read.  */
+
+static void
+elf_x86_create_output_section_statements (void)
+{
+  _bfd_elf_linker_x86_set_options (&link_info, &params);
+}
+
+EOF
+
+LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=elf_x86_create_output_section_statements
+
+if test -n "$CALL_NOP_BYTE"; then
+
+fragment <<EOF
+
+static void
+elf_x86_before_parse (void)
+{
+  params.call_nop_byte = $CALL_NOP_BYTE;
+
+  gld${EMULATION_NAME}_before_parse ();
+}
+
+EOF
+
+LDEMUL_BEFORE_PARSE=elf_x86_before_parse
+fi
index f4f7ad6b4e115e93ac08b0cf1c5a5bbb47353be4..3e8ee4693e67851e9f497a7393784a8c17bbf8bd 100644 (file)
@@ -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;
diff --git a/ld/emultempl/solaris2-x86.em b/ld/emultempl/solaris2-x86.em
new file mode 100644 (file)
index 0000000..559cb8f
--- /dev/null
@@ -0,0 +1,23 @@
+# This shell script emits a C file. -*- C -*-
+#   Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+source_em "${srcdir}/emultempl/elf-x86.em"
+source_em "${srcdir}/emultempl/solaris2.em"
This page took 0.03947 seconds and 4 git commands to generate.