Commit: Fix clang compile time warnings in pe.em & pep.em
Fixes 'variable set but not used' warnings in PE/COFF emulation files when compiled with Clang.
This commit addresses ‘variable set but not used’ warnings generated by Clang when compiling the pe.em and pep.em files, which handle PE/COFF emulation in binutils. The fix involves conditionally defining certain variables only when they are actually used, thereby cleaning up the compiler warnings without altering the linker’s functionality.
In Details
This patch targets ld/emultempl/pe.em and ld/emultempl/pep.em, which are template files used by GNU ld to generate PE (Portable Executable) format emulation code for targets like Windows. The commit specifically addresses compiler warnings, particularly those related to unused variables, when these templates are processed by Clang. The solution involves wrapping the declaration of some variables (support_old_code, thumb_entry_symbol, image_base_statement) within appropriate preprocessor conditional blocks (#if defined(...) or #ifdef ...), ensuring they are only defined when rele…
- PE/COFF
- Portable Executable/Common Object File Format. The file format used for executables, object code, and DLLs on 32-bit and 64-bit versions of Windows.
- emulation
- The ability of a computer program or system to behave like another system. In this context, it refers to the linker emulating the behavior of a target system's executable format (PE/COFF).
- pe.em
- A template file used by GNU ld to generate code for PE (Portable Executable) format object files.
- pep.em
- Another template file, likely related to PE/COFF format processing in GNU ld.
- compiler warnings
- Messages issued by a compiler indicating potential problems or stylistic issues in the source code that do not necessarily prevent compilation but may lead to errors or unexpected behavior.