-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(PA-6383) Enable PIE for Ubuntu and Debian
- Loading branch information
Showing
7 changed files
with
33 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Define default CFLAGS and LDFLAGS for most platforms, and then | ||
# tweak or adjust them as needed. | ||
proj.setting(:cppflags, "-I#{proj.includedir} -I/opt/pl-build-tools/include") | ||
proj.setting(:cflags, "#{proj.cppflags}") | ||
proj.setting(:ldflags, "-L#{proj.libdir} -L/opt/pl-build-tools/lib -Wl,-rpath=#{proj.libdir}") | ||
|
||
# Platform specific overrides or settings, which may override the defaults | ||
|
||
# Harden Linux ELF binaries by compiling with PIE (Position Independent Executables) support, | ||
# stack canary and full RELRO. | ||
# We only do this on platforms that use their default OS toolchain since pl-gcc versions | ||
# are too old to support these flags. | ||
|
||
if((platform.is_sles? && platform.os_version.to_i >= 15) || | ||
(platform.is_el? && platform.os_version.to_i == 8 && platform.architecture !~ /ppc64/) || | ||
(platform.is_debian? && platform.os_version.to_i >= 10) || | ||
(platform.is_ubuntu? && platform.os_version.to_i >= 22) || | ||
platform.is_fedora? | ||
) | ||
proj.setting(:supports_pie, true) | ||
proj.setting(:cppflags, "-I#{proj.includedir} -D_FORTIFY_SOURCE=2") | ||
proj.setting(:cflags, '-fstack-protector-strong -fno-plt -O2') | ||
proj.setting(:ldflags, "-L#{proj.libdir} -Wl,-rpath=#{proj.libdir},-z,relro,-z,now") | ||
end |