From 625c4bdacef4173f94200632362e25e537ad5d21 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Mon, 22 Jan 2024 10:47:42 +0200 Subject: [Linux] Add support for PCK embedding section with non GNU-ld linkers. --- platform/linuxbsd/godot_linuxbsd.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'platform/linuxbsd/godot_linuxbsd.cpp') diff --git a/platform/linuxbsd/godot_linuxbsd.cpp b/platform/linuxbsd/godot_linuxbsd.cpp index efad9c8594..a2b6fbeb25 100644 --- a/platform/linuxbsd/godot_linuxbsd.cpp +++ b/platform/linuxbsd/godot_linuxbsd.cpp @@ -41,6 +41,18 @@ #include #endif +// For export templates, add a section; the exporter will patch it to enclose +// the data appended to the executable (bundled PCK). +#if !defined(TOOLS_ENABLED) && defined(__GNUC__) +static const char dummy[8] __attribute__((section("pck"), used)) = { 0 }; + +// Dummy function to prevent LTO from discarding "pck" section. +extern "C" const char *pck_section_dummy_call() __attribute__((used)); +extern "C" const char *pck_section_dummy_call() { + return &dummy[0]; +} +#endif + int main(int argc, char *argv[]) { #if defined(SANITIZERS_ENABLED) // Note: Set stack size to be at least 30 MB (vs 8 MB default) to avoid overflow, address sanitizer can increase stack usage up to 3 times. -- cgit v1.2.3