ld/ppc32elf: Limit 'old_got' definition to non-VxWorks targets
The `old_got` variable and related logic are now conditionally compiled only for non-VxWorks targets in the ppc32elf linker.
This change refactors the ppc32elf.em linker script to conditionally define and use the old_got variable. Previously, old_got was always defined, leading to unused variable warnings with newer compilers on VxWorks targets. It is now restricted to non-VxWorks builds, resolving the warning and correctly handling the --sdata-got option’s absence for VxWorks.
In Details
In ld/emultempl/ppc32elf.em, the old_got global variable and its associated handling for OPTION_OLD_GOT are now guarded by a test -z "$VXWORKS_BASE_EM_FILE" condition. This prevents the variable from being defined and flagged as unused by modern compilers (like Clang) when building for VxWorks targets, where it is not needed and the --sdata-got option is not registered.
- ld
- The GNU linker. It combines multiple object files and libraries into a single executable or shared library.
- ppc32elf
- Specifies the target architecture (PowerPC 32-bit) and the object file format (ELF) for the linker script.
- VxWorks
- A real-time operating system (RTOS) developed by Wind River Systems.
- old_got
- A flag or variable within the linker script that controls how the Global Offset Table (GOT) is handled, specifically for older conventions or configurations.
- GOT
- Global Offset Table. A data structure used in position-independent code (PIC) on some architectures to store addresses of global variables and functions, allowing them to be resolved at runtime.
- unused-but-set-global warning
- A compiler warning indicating that a global variable has been assigned a value but is never subsequently read or used in the program.