ld/ppc32elf: only define old_got for non-VxWorks targets
Fixes unused variable warnings in ld/ppc32elf by making `old_got` conditional on non-VxWorks targets.
This patch resolves compiler warnings about an unused global variable old_got in the ld/ppc32elf linker script. The variable and its associated option handling (OPTION_OLD_GOT) are only relevant for non-VxWorks targets. The patch moves the definition of old_got and the parsing of --sdata-got (which sets it) into existing conditional blocks that exclude VxWorks. This change prevents the unused variable warnings reported by Clang.
- proposer
Submits a patch to make the `old_got` variable conditional on non-VxWorks targets in ld/ppc32elf to fix unused variable warnings.
“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.”
In Details
This patch addresses unused variable warnings in the PowerPC 32-bit ELF linker configuration, specifically within ld/emultempl/ppc32elf.em. The variable old_got is related to the --sdata-got linker option, which controls the placement of the Global Offset Table (GOT). This functionality is not applicable to VxWorks targets. The change conditionally defines old_got and handles OPTION_OLD_GOT only when the target is not VxWorks, thereby resolving Clang's [-Wunused-but-set-global] warnings.
- ld/ppc32elf
- The linker configuration for PowerPC 32-bit targets using the ELF object file format.
- VxWorks
- A real-time operating system (RTOS) often used in embedded systems. The linker needs specific configurations for different operating systems.
- Global Offset Table (GOT)
- A data structure used in executable and shared object code on many platforms that enables dynamic linking by holding addresses of external symbols and functions. The placement and handling of the GOT can vary between targets and link-time options.
- linker script
- A file that contains directives for the linker, specifying how to arrange code and data sections in the final executable or library, and how to resolve symbols.