Link with PIC Static Ada Runtime When -pie Is Specified
The Ada compiler now correctly links with the position-independent code (PIC) static runtime when the `-pie` flag is used for building executables.
This commit modifies the Ada compiler to ensure it links with the correct static runtime library when building position-independent executables (PIE). When the -pie flag is specified, the compiler will now append _pic to the name of the static Ada runtime library, ensuring that the position-independent version is used. This fix is necessary for building secure and relocatable executables.
In Details
The Ada compiler's gnatlink tool is responsible for linking Ada programs. This commit modifies gnatlink.adb to append _pic to the name of the static Ada runtime when the -pie flag is passed, ensuring that the PIC version of the runtime is linked in. This is necessary for correct code generation and execution of PIE binaries.
For Context
Position-independent executables (PIE) are a type of executable that can be loaded at any memory address without requiring modification. This is important for security, as it makes it more difficult for attackers to predict where code will be located in memory. This commit ensures the Ada compiler creates programs that can be loaded anywhere in memory, improving the overall security of Ada applications.