-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ldd libcoreclr.so failing on Alpine Linux #6295
Comments
@jkotas, please let me know if there is more info required to diagnose this issue. :) |
Useful link: https://wiki.gentoo.org/wiki/Hardened/Textrels_Guide (note |
The linker command for libcoreclr.so produced by cmake is: (executed in dir:
Seems like the issue lie in either |
Ah, it was grsec thingy. So I ran:
and it passed that step. Not sure if there is anything we can do here to support hardended/grsec kernels OOTB (without tearing the security protection). Onto the next step (getting |
This looks like a linker bug. My guess is that there's a relocation that would have been a textrel if -Bsymbolic hadn't bound it at link-time, and the linker wrongly retained the conclusion that textrels were needed even after dropping it. |
@richfelker, would be nice if we could get to cc someone here who deals with ld stuff on musl-powered operating systems. I already have my hands muddy with this stuff, can provide more logs/info if need be.:smile: |
Can you first confirm which linker (bfd, gold, or lld) is being used by clang when it links? That will determine where the bug report needs to go. Passing -v on the linking command line is probably sufficient to see that but if not strace would be another method. |
@richfelker, with -v to clang++ linker command above, I get: clang version 3.8.0 (tags/RELEASE_380/final)
Target: x86_64-alpine-linux-musl
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/usr/bin/ld" -z now -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -shared -o libcoreclr.so /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../crti.o /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0/crtbeginS.o -L/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0 -L/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/lib -L/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib --version-script=/home/peterj/coreclr/bin/obj/Linux.x64.Debug/src/dlls/mscoree/coreclr/coreclr.exports --build-id=sha1 -Bsymbolic -Bsymbolic-functions -soname libcoreclr.so CMakeFiles/coreclr.dir/__/mscoree.cpp.o CMakeFiles/coreclr.dir/__/unixinterface.cpp.o CMakeFiles/coreclr.dir/__/__/__/__/version.cpp.o ../../../utilcode/dyncrt/libutilcode.a --start-group ../../../debug/ee/wks/libcordbee_wks.a ../../../debug/debug-pal/libdebug-pal.a ../../../unwinder/wks/libunwinder_wks.a ../../../vm/wks/libcee_wks.a -Bsymbolic-functions --end-group ../../../md/compiler/wks/libmdcompiler_wks.a ../../../md/runtime/wks/libmdruntime_wks.a ../../../md/enc/wks/libmdruntimerw_wks.a ../../../md/hotdata/full/libmdhotdata_full.a ../../../classlibnative/bcltype/libbcltype.a ../../../md/ceefilegen/libceefgen.a ../../../classlibnative/float/libcomfloat_wks.a ../../../inc/libcorguids.a ../../../gcinfo/lib/libgcinfo.a ../../../debug/ildbsymlib/libildbsymlib.a ../../../strongname/api/wks/libstrongname_wks.a ../../../utilcode/dyncrt/libutilcode.a ../../../binder/v3binder/libv3binder.a --whole-archive ../../../pal/src/libcoreclrpal.a ../../../pal/src/libtracepointprovider.a --no-whole-archive ../../mscorrc/full/libmscorrc_debug.a ../../../palrt/libpalrt.a ../../../pal/src/eventprovider/libeventprovider.a ../../../nativeresources/libnativeresourcestring.a -lgcc_s -lpthread -lrt -ldl -luuid -lunwind -lunwind-generic -lunwind-x86_64 -lintl -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0/crtendS.o /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../crtn.o Here is the strace: https://bpaste.net/show/60e76ae46172 Last but not the least: $ file /usr/bin/ld
/usr/bin/ld: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, stripped |
Version info: $ ld --version
GNU ld (GNU Binutils) 2.26.20160125
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty. |
Among all the .so files produced by CoreCLR, ldd has issue with
libcoreclr.so
; it complains:It seems like ld.so (the linker) does mprotect(..., rwx) if there's DT_TEXTREL. strace reveals an EACCES when doing mprotect:
Checking for text relocations results in:
And
scalelf -t
outputs:alp:~/coreclr$ scanelf -t bin/Product/Linux.x64.Debug/libcoreclr.so TYPE TEXTREL FILE ET_DYN TEXTREL bin/Product/Linux.x64.Debug/libcoreclr.so
scanelf -qT
is even weirder:Here is the full output of
readelf -a
: https://bpaste.net/raw/c268701a9312 (WARNING: 6.7 MBs of raw text, better usecurl -O https://bpaste.net/raw/c268701a9312
and grep the intended section)To build CoreCLR from scratch on Alpine, https://gist.github.com/jasonwilliams200OK/7d6f5594d3bf697a27c9c1036d349fce.
/cc @amonakov, @richfelker, @barthalion
The text was updated successfully, but these errors were encountered: