2020-10-10 18:17:49 +03:00
|
|
|
set(LOADER_SOURCES
|
|
|
|
main.cpp
|
|
|
|
misc.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB AK_SOURCES "../../AK/*.cpp")
|
2021-01-12 14:17:30 +03:00
|
|
|
file(GLOB ELF_SOURCES "../Libraries/LibELF/*.cpp")
|
|
|
|
file(GLOB LIBC_SOURCES1 "../Libraries/LibC/*.cpp")
|
|
|
|
file(GLOB LIBC_SOURCES2 "../Libraries/LibC/*/*.cpp")
|
2021-02-25 17:26:08 +03:00
|
|
|
|
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "i686")
|
|
|
|
file(GLOB LIBC_SOURCES3 "../Libraries/LibC/arch/i386/*.S")
|
2021-03-07 18:11:25 +03:00
|
|
|
set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/i386/plt_trampoline.S)
|
2021-02-25 17:26:08 +03:00
|
|
|
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
2021-07-01 12:15:19 +03:00
|
|
|
file(GLOB LIBC_SOURCES3 "../Libraries/LibC/arch/x86_64/*.S")
|
2021-03-07 18:11:25 +03:00
|
|
|
set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/x86_64/plt_trampoline.S)
|
2021-02-25 17:26:08 +03:00
|
|
|
endif()
|
|
|
|
|
2021-02-05 14:16:30 +03:00
|
|
|
file(GLOB LIBSYSTEM_SOURCES "../Libraries/LibSystem/*.cpp")
|
2020-10-10 18:17:49 +03:00
|
|
|
|
2021-05-24 04:40:22 +03:00
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
|
|
|
set(LOADER_SOURCES ${LOADER_SOURCES} ../Libraries/LibSanitizer/UBSanitizer.cpp)
|
|
|
|
endif()
|
|
|
|
|
2021-04-17 19:38:32 +03:00
|
|
|
add_definitions(-D_DYNAMIC_LOADER)
|
2020-10-10 18:17:49 +03:00
|
|
|
|
2021-02-05 14:16:30 +03:00
|
|
|
set(SOURCES ${LOADER_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${LIBC_SOURCES1} ${LIBC_SOURCES2} ${LIBC_SOURCES3} ${LIBSYSTEM_SOURCES})
|
2020-10-10 18:17:49 +03:00
|
|
|
|
2021-05-07 12:08:41 +03:00
|
|
|
# FIXME: Remove -fbuilding-libgcc after the next toolchain update
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fbuilding-libgcc -fno-rtti -nostdlib -pie -fpic -DNO_TLS")
|
2020-10-10 18:17:49 +03:00
|
|
|
|
2021-01-12 14:17:30 +03:00
|
|
|
set_source_files_properties (../Libraries/LibC/ssp.cpp PROPERTIES COMPILE_FLAGS
|
2021-01-02 02:27:42 +03:00
|
|
|
"-fno-stack-protector")
|
|
|
|
|
2020-10-10 18:17:49 +03:00
|
|
|
add_executable(Loader.so ${SOURCES})
|
2021-05-07 12:08:41 +03:00
|
|
|
target_link_libraries(Loader.so gcc)
|
2021-01-01 03:51:21 +03:00
|
|
|
target_link_options(Loader.so PRIVATE LINKER:--no-dynamic-linker)
|
2020-10-10 18:17:49 +03:00
|
|
|
install(TARGETS Loader.so RUNTIME DESTINATION usr/lib/)
|