From 30ec75ee74483d2dbb2e16eb2fa5f6567557583f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 10 Jun 2026 00:23:27 +0200 Subject: [PATCH] Meta: Enable full RELRO on Linux Pass -z relro and -z now to ELF linkers on Linux when the linker supports them. This makes relocation sections read-only after startup and disables lazy binding so the GOT is protected as well. --- Meta/CMake/compile_options.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Meta/CMake/compile_options.cmake b/Meta/CMake/compile_options.cmake index dc271181f6..00f0926236 100644 --- a/Meta/CMake/compile_options.cmake +++ b/Meta/CMake/compile_options.cmake @@ -199,6 +199,8 @@ endif() if (LINUX) add_cxx_compile_definitions(_FILE_OFFSET_BITS=64) + add_cxx_link_option_if_supported(LINKER:-z,relro) + add_cxx_link_option_if_supported(LINKER:-z,now) endif() if (APPLE)