summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2019-01-20 20:20:16 -0600
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-01-21 18:28:38 -0500
commit64ce6afa21fadd751e1700af145ab77059abadc6 (patch)
tree54b48b266c178e3f4ca949dcaaa927f5b7e69817
parent7262a81585a52e019a7d85bc66fc906a629413ec (diff)
downloadhaskell-64ce6afa21fadd751e1700af145ab77059abadc6.tar.gz
Extend linker-script workaround to work with musl libc
GHC has code to handle unsuffixed .so files that are linker scripts pointing to the real shared library. The detection is done by parsing the result of `dlerror()` after calling `dlopen()` and looking for certain error strings. On musl libc, the error message is "Exec format error", which happens to be `strerror(ENOEXEC)`: ``` $ cat tmp.c #include <dlfcn.h> #include <stdio.h> int main(void) { dlopen("libz.so", RTLD_NOW | RTLD_GLOBAL); puts(dlerror()); return 0; } $ gcc -o tmp tmp.c $ ./tmp Error loading shared library libz.so: Exec format error $ ``` This change fixes the workaround to also work on musl libc. Link: https://phabricator.haskell.org/D5474
-rw-r--r--rts/Linker.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 5b10b798ec..ac030af837 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -483,7 +483,7 @@ initLinker_ (int retain_cafs)
# endif /* RTLD_DEFAULT */
compileResult = regcomp(&re_invalid,
- "(([^ \t()])+\\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)",
+ "(([^ \t()])+\\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format|Exec format error)",
REG_EXTENDED);
if (compileResult != 0) {
barf("Compiling re_invalid failed");