]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Control powerpc64-ld provision of register save/restore
authorAlan Modra <amodra@gmail.com>
Wed, 19 Feb 2014 03:53:12 +0000 (14:23 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 12 Jun 2014 15:29:03 +0000 (00:59 +0930)
This patch allows the user to override powerpc64-ld's default for
providing linker generated register save and restore functions as used
by gcc -Os code.  Normally these are not provided by ld -r, so Linux
kernel modules have needed to include their own copies.

bfd/
* elf64-ppc.h (struct ppc64_elf_params): Add save_restore_funcs.
* elf64-ppc.c (ppc64_elf_func_desc_adjust): Use it to control
provision of out-of-line register save/restore routines.
ld/
* emultempl/ppc64elf.em (params): Init new field.
(ppc_create_output_section_statements): Set params.save_restore_funcs
default.
(PARSE_AND_LIST_*): Add support for --save-restore-funcs and
--no-save-restore-funcs.

bfd/ChangeLog
bfd/elf64-ppc.c
bfd/elf64-ppc.h
ld/ChangeLog
ld/emultempl/ppc64elf.em

index 2f3405da7cd465c9925aa105d68d285ebe719d7b..31e7ec5b3f870ac943d878003c14dc142b1139ae 100644 (file)
@@ -1,6 +1,11 @@
 2014-06-12  Alan Modra  <amodra@gmail.com>
 
        Backport mainline patches
+       2014-02-19  Alan Modra  <amodra@gmail.com>
+       * elf64-ppc.h (struct ppc64_elf_params): Add save_restore_funcs.
+       * elf64-ppc.c (ppc64_elf_func_desc_adjust): Use it to control
+       provision of out-of-line register save/restore routines.
+
        2014-02-17  Alan Modra  <amodra@gmail.com>
        * elf64-ppc.h (struct ppc64_elf_params): Define.
        (ppc64_elf_init_stub_bfd, ppc64_elf_edit_opd, ppc64_elf_tls_setup,
index cb4409ef259fe5c7a2f21d7257c118860fe9e74d..971426e117d60996d92c891c844faf30fbcab2c9 100644 (file)
@@ -6841,7 +6841,7 @@ ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED,
 
   /* Provide any missing _save* and _rest* functions.  */
   htab->sfpr->size = 0;
-  if (!info->relocatable)
+  if (htab->params->save_restore_funcs)
     for (i = 0; i < sizeof (funcs) / sizeof (funcs[0]); i++)
       if (!sfpr_define (info, &funcs[i]))
        return FALSE;
index 3a2299ad1681628ae75da99efbdaaa2a4bc1140c..c4c7688daa3f7f337ba9f91946e7188dbba6baa4 100644 (file)
@@ -55,6 +55,9 @@ struct ppc64_elf_params
 
   /* Whether to emit symbols for stubs.  */
   int emit_stub_syms;
+
+  /* Whether to generate out-of-line register save/restore for gcc -Os code.  */
+  int save_restore_funcs;
 };
 
 bfd_boolean ppc64_elf_init_stub_bfd
index 75e2aaaac6cf000965b4d8ddf476e52ec8d28982..9e3303d905fc1293239e0a240057c9eb57912f47 100644 (file)
@@ -1,6 +1,13 @@
 2014-06-12  Alan Modra  <amodra@gmail.com>
 
        Backport mainline patches
+       2014-02-19  Alan Modra  <amodra@gmail.com>
+       * emultempl/ppc64elf.em (params): Init new field.
+       (ppc_create_output_section_statements): Set params.save_restore_funcs
+       default.
+       (PARSE_AND_LIST_*): Add support for --save-restore-funcs and
+       --no-save-restore-funcs.
+
        2014-02-17  Alan Modra  <amodra@gmail.com>
        * emultemps/ppc64elf.em (params): New static struct replacing
        various other static vars.  Adjust code throughout file.
index a9e1b5821c9031b0076127db049dcc3c14cd349c..12bfe412a236ec748acd1154b1902cb349842739 100644 (file)
@@ -39,7 +39,7 @@ static struct ppc64_elf_params params = { NULL,
                                          &ppc_layout_sections_again,
                                          1, 0, 0,
                                          ${DEFAULT_PLT_STATIC_CHAIN-0}, -1, 0,
-                                         0, -1};
+                                         0, -1, -1};
 
 /* Fake input file for stubs.  */
 static lang_input_statement_type *stub_file;
@@ -96,6 +96,8 @@ ppc_create_output_section_statements (void)
   stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
   ldlang_add_file (stub_file);
   params.stub_bfd = stub_file->the_bfd;
+  if (params.save_restore_funcs < 0)
+    params.save_restore_funcs = !link_info.relocatable;
   if (!ppc64_elf_init_stub_bfd (&link_info, &params))
     einfo ("%F%P: can not init BFD: %E\n");
 }
@@ -648,7 +650,9 @@ PARSE_AND_LIST_PROLOGUE=${PARSE_AND_LIST_PROLOGUE}'
 #define OPTION_NO_PLT_ALIGN            (OPTION_PLT_ALIGN + 1)
 #define OPTION_STUBSYMS                        (OPTION_NO_PLT_ALIGN + 1)
 #define OPTION_NO_STUBSYMS             (OPTION_STUBSYMS + 1)
-#define OPTION_DOTSYMS                 (OPTION_NO_STUBSYMS + 1)
+#define OPTION_SAVRES                  (OPTION_NO_STUBSYMS + 1)
+#define OPTION_NO_SAVRES               (OPTION_SAVRES + 1)
+#define OPTION_DOTSYMS                 (OPTION_NO_SAVRES + 1)
 #define OPTION_NO_DOTSYMS              (OPTION_DOTSYMS + 1)
 #define OPTION_NO_TLS_OPT              (OPTION_NO_DOTSYMS + 1)
 #define OPTION_NO_TLS_GET_ADDR_OPT     (OPTION_NO_TLS_OPT + 1)
@@ -671,6 +675,8 @@ PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST_LONGOPTS}'
   { "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
   { "dotsyms", no_argument, NULL, OPTION_DOTSYMS },
   { "no-dotsyms", no_argument, NULL, OPTION_NO_DOTSYMS },
+  { "save-restore-funcs", no_argument, NULL, OPTION_SAVRES },
+  { "no-save-restore-funcs", no_argument, NULL, OPTION_NO_SAVRES },
   { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
   { "no-tls-get-addr-optimize", no_argument, NULL, OPTION_NO_TLS_GET_ADDR_OPT },
   { "no-opd-optimize", no_argument, NULL, OPTION_NO_OPD_OPT },
@@ -725,6 +731,14 @@ PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'
   --no-dotsyms                Don'\''t do anything special in version scripts.\n"
                   ));
   fprintf (file, _("\
+  --save-restore-funcs        Provide register save and restore routines used\n\
+                                by gcc -Os code.  Defaults to on for normal\n\
+                                final link, off for ld -r.\n"
+                  ));
+  fprintf (file, _("\
+  --no-save-restore-funcs     Don'\''t provide these routines.\n"
+                  ));
+  fprintf (file, _("\
   --no-tls-optimize           Don'\''t try to optimize TLS accesses.\n"
                   ));
   fprintf (file, _("\
@@ -807,6 +821,14 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
       dotsyms = 0;
       break;
 
+    case OPTION_SAVRES:
+      params.save_restore_funcs = 1;
+      break;
+
+    case OPTION_NO_SAVRES:
+      params.save_restore_funcs = 0;
+      break;
+
     case OPTION_NO_TLS_OPT:
       no_tls_opt = 1;
       break;