aboutsummaryrefslogtreecommitdiff
path: root/src/tomo.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-25 15:11:33 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-25 15:11:33 -0400
commite531c0179299de7fbaa84dda39ab1bd289cecf88 (patch)
treeef36533c3e27db68404ce787aaf7f0abe96ca327 /src/tomo.c
parent4740cc22f39f6eb1c056c07b66fec11d76340704 (diff)
Speculative fix for Mac: use llvm-objcopy instead of patchelf for Mach-O
shared library files
Diffstat (limited to 'src/tomo.c')
-rw-r--r--src/tomo.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/tomo.c b/src/tomo.c
index 1c4f39f9..9f273ab3 100644
--- a/src/tomo.c
+++ b/src/tomo.c
@@ -495,10 +495,19 @@ void build_library(Text_t lib_dir_name)
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
errx(WEXITSTATUS(status), "Failed to run `objcopy` to add library prefix to symbols");
+#if defined(__ELF__)
prog = run_cmd("patchelf --rename-dynamic-symbols .build/symbol_renames.txt 'lib", lib_dir_name, SHARED_SUFFIX, "'");
status = pclose(prog);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
errx(WEXITSTATUS(status), "Failed to run `patchelf` to rename dynamic symbols with library prefix");
+#elif defined(__MACH__)
+ prog = run_cmd("llvm-objcopy --redefine-syms=.build/symbol_renames.txt 'lib", lib_dir_name, SHARED_SUFFIX, "'");
+ status = pclose(prog);
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ errx(WEXITSTATUS(status), "Failed to run `llvm-objcopy` to rename dynamic symbols with library prefix");
+#else
+#error "Unknown platform (not ELF or MACH)"
+#endif
if (verbose)
print("Successfully renamed symbols with library prefix!");