[binutils-gdb] ld/ppc32elf: only define old_got for non-VxWorks targets

Simon Marchi simark@sourceware.org
Wed Nov 4 16:59:33 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ca25a669b3fac1b72673fca674c6483c10db07ea

commit ca25a669b3fac1b72673fca674c6483c10db07ea
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Fri Oct 30 11:01:53 2026 -0400

    ld/ppc32elf: only define old_got for non-VxWorks targets
    
    Building ld with a recent clang fails with:
    
        eelf32ppcvxworks.c:68:12: error: variable 'old_got' set but not used [-Werror,-Wunused-but-set-global]
    
    old_got is only read in ppc_after_check_relocs, which is not generated
    for VxWorks.  The --sdata-got option that sets it is not registered for
    VxWorks either.  Move the variable and the handling of OPTION_OLD_GOT
    inside the existing non-VxWorks conditionals.
    
    Cc: Surya Kumari Jangala <jskumari@linux.ibm.com>
    Cc: Peter Bergner <bergner@tenstorrent.com>

Diff:
---
 ld/emultempl/ppc32elf.em | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/ld/emultempl/ppc32elf.em b/ld/emultempl/ppc32elf.em
index 210af4c850f..ab177da3099 100644
--- a/ld/emultempl/ppc32elf.em
+++ b/ld/emultempl/ppc32elf.em
@@ -38,9 +38,6 @@ static int notlsopt = 0;
 /* Whether to convert inline PLT calls to direct.  */
 static int no_inline_opt = 0;
 
-/* Choose the correct place for .got.  */
-static int old_got = 0;
-
 static struct ppc_elf_params params = { PLT_UNSET, 0, -1,
 					0, 0, 0, 0, 0, 0, 0 };
 
@@ -62,6 +59,9 @@ EOF
 # No --secure-plt, --bss-plt, or --sdata-got for vxworks.
 if test -z "$VXWORKS_BASE_EM_FILE" ; then
   fragment <<EOF
+/* Choose the correct place for .got.  */
+static int old_got = 0;
+
 static void
 ppc_after_check_relocs (void)
 {
@@ -382,11 +382,15 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
     case OPTION_NO_INLINE_OPT:
       no_inline_opt = 1;
       break;
-
+'
+if test -z "$VXWORKS_BASE_EM_FILE" ; then
+  PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
     case OPTION_OLD_GOT:
       old_got = 1;
       break;
-
+'
+fi
+PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
     case OPTION_TRADITIONAL_FORMAT:
       notlsopt = 1;
       params.no_tls_get_addr_opt = 1;


More information about the Binutils-cvs mailing list