mold
mold copied to clipboard
Linking fails with "cannot open text-segment: No such file or directory"
trafficstars
Linking box64 fails with mold:
mold: fatal: cannot open text-segment: No such file or directory
Among linker flags I see -Wl,-Ttext-segment,0x64800000 which is likely related.
mold doesn't currently support -Ttext-segment. We may want to support it, but besides that, the following patch may work as a workaround for you.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3467aea9..39609170 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -598,20 +598,12 @@ endif()
if(${CMAKE_VERSION} VERSION_LESS "3.13")
if(NOT NOLOADADDR)
- if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-Wl,--image-base=${BOX64_ELF_ADDRESS}")
- else()
- set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-Wl,-Ttext-segment,${BOX64_ELF_ADDRESS}")
- endif()
+ set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-Wl,--image-base=${BOX64_ELF_ADDRESS}")
endif()
else()
# If symbols are missing, try this: target_link_options(${BOX64} PUBLIC -rdynamic)
if(NOT NOLOADADDR)
- if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOX64} PUBLIC LINKER:--image-base=${BOX64_ELF_ADDRESS})
- else()
- target_link_options(${BOX64} PUBLIC LINKER:-Ttext-segment,${BOX64_ELF_ADDRESS})
- endif()
+ target_link_options(${BOX64} PUBLIC LINKER:--image-base=${BOX64_ELF_ADDRESS})
endif()
endif()
Thanks for letting me know about --image-base= it solved my problem wonderfully.