Skip to content

Commit

Permalink
Force PIE usage on linux (shadps4-emu#625)
Browse files Browse the repository at this point in the history
* force PIE usage on linux

* get rid of explicit -pie linker flag

* change UNIX with UNIX AND NOT APPLE in CMakeLists.txt

* cmake: add proper check for PIE support at link time

---------

Co-authored-by: Mikhail Paulyshka <[email protected]>
  • Loading branch information
Random06457 and Mixaill authored Sep 1, 2024
1 parent 63d78ae commit 0276ed9
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ endif()

project(shadPS4)

# Forcing PIE makes sure that the base address is high enough so that it doesn't clash with the PS4 memory.
if(UNIX AND NOT APPLE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

# check PIE support at link time
include(CheckPIESupported)
check_pie_supported(OUTPUT_VARIABLE pie_check LANGUAGES C CXX)
if(NOT CMAKE_C_LINK_PIE_SUPPORTED OR NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
message(WARNING "PIE is not supported at link time: ${pie_check}")
endif()
endif()

option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)

# This function should be passed a list of all files in a target. It will automatically generate file groups
Expand Down Expand Up @@ -151,7 +163,7 @@ set(GNM_LIB src/core/libraries/gnmdriver/gnmdriver.cpp
src/core/libraries/gnmdriver/gnm_error.h
)

set(KERNEL_LIB
set(KERNEL_LIB
src/core/libraries/kernel/event_flag/event_flag.cpp
src/core/libraries/kernel/event_flag/event_flag.h
src/core/libraries/kernel/event_flag/event_flag_obj.cpp
Expand Down Expand Up @@ -347,7 +359,7 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/cpu_patches.cpp
src/core/cpu_patches.h
src/core/crypto/crypto.cpp
src/core/crypto/crypto.h
src/core/crypto/crypto.h
src/core/crypto/keys.h
src/core/file_format/pfs.h
src/core/file_format/pkg.cpp
Expand All @@ -372,7 +384,7 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/loader/elf.h
src/core/loader/symbols_resolver.h
src/core/loader/symbols_resolver.cpp
src/core/libraries/error_codes.h
src/core/libraries/error_codes.h
src/core/libraries/libs.h
src/core/libraries/libs.cpp
${AUDIO_LIB}
Expand Down

0 comments on commit 0276ed9

Please sign in to comment.