From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17091 invoked by alias); 19 Feb 2014 04:25:41 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 17079 invoked by uid 89); 19 Feb 2014 04:25:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f52.google.com Received: from mail-pb0-f52.google.com (HELO mail-pb0-f52.google.com) (209.85.160.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 19 Feb 2014 04:25:39 +0000 Received: by mail-pb0-f52.google.com with SMTP id jt11so17664121pbb.25 for ; Tue, 18 Feb 2014 20:25:37 -0800 (PST) X-Received: by 10.66.192.162 with SMTP id hh2mr14098336pac.150.1392783936117; Tue, 18 Feb 2014 20:25:36 -0800 (PST) Received: from bubble.grove.modra.org ([101.166.26.37]) by mx.google.com with ESMTPSA id tu3sm61356054pbc.40.2014.02.18.20.25.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 20:25:34 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 34DB2EA00D7; Wed, 19 Feb 2014 14:55:30 +1030 (CST) Date: Wed, 19 Feb 2014 04:25:00 -0000 From: Alan Modra To: binutils@sourceware.org Subject: Control powerpc64-ld provision of register save/restore Message-ID: <20140219042530.GB3386@bubble.grove.modra.org> Mail-Followup-To: binutils@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2014-02/txt/msg00110.txt.bz2 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. diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h index 3a2299a..c4c7688 100644 --- a/bfd/elf64-ppc.h +++ b/bfd/elf64-ppc.h @@ -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 diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 795d093..633d8db 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -6852,7 +6852,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; diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em index 56cd0af..2c2eb66 100644 --- a/ld/emultempl/ppc64elf.em +++ b/ld/emultempl/ppc64elf.em @@ -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, ¶ms)) einfo ("%F%P: can not init BFD: %E\n"); } @@ -646,7 +648,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) @@ -669,6 +673,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 }, @@ -723,6 +729,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, _("\ @@ -805,6 +819,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; -- Alan Modra Australia Development Lab, IBM