I feel like this is an issue because it's happening on a default installation of Debian 8, 64-bit. If it's not, feel free to close this and I will PM Brian on the forums, thanks!
Crystal 0.32.1 [41bd18fbe] (2019-12-18)
After following the Debian installation instructions, and running a blank .cr file, (crystal muffin.cr), this error will occur:
root@test:~# crystal muffin.cr
/usr/bin/ld: /usr/bin/../lib/crystal/lib/libgc.a(alloc.o): unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/root/.cache/crystal/crystal-run-muffin.tmp' -rdynamic -lpcre -lm /usr/bin/../lib/crystal/lib/libgc.a -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib`
I found this post on SO.
ld -v:
GNU ld (GNU Binutils for Debian) 2.25
This is to do with an old ld binary in debian 8. Perhaps we should compile libgc.a with an even older debian or centos, since debian 8 is still supported until june 30th.
A related issue was raised in https://travis-ci.community/t/fails-to-link-against-libgc-a-in-crystal-0-31-0/5197/5 and solved by upgrading binutils but I think you might be in the latest available for jessie
Another related issue is #8323
From the travis issue, a fix might be to ship a gc built with -fno-plt, or use an older debian.
As a workaround is to build/link against a gc other than the one it was shipped. As long as you don't use preview_mt that should be doable with the official package.
Aww, maybe I should just upgrade ;S. I think my server files will work on 9/10.
I don't want to bother you guys with older OS issues
From the travis issue, a fix might be to ship a gc built with
-fno-plt, or use an older debian.
I did not report to the board of Travis CI, but I have not succeeded with using gc with -fplt nor -fno-plt.
I have not tested (yet), but -fno-pie may affect, because they have given --enable-default-pie option while building GCC:
Singularity debian_10.sif:/home/lugia> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6'
--with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu-
--enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)
A simple test
Considering following simple C source, with Debian 10 (via Singularity container)
#include <stdio.h>
extern int foo(void);
int main(int argc, char **argv)
{
printf("%p\n", foo);
return 0;
}
R_X86_64_REX_GOTPCRELX relocation (bad)Singularity debian_10.sif:/home/lugia> gcc -c tmp.c
Singularity debian_10.sif:/home/lugia> readelf -r tmp.o
Relocation section '.rela.text' at offset 0x238 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000012 000b0000002a R_X86_64_REX_GOTP 0000000000000000 foo - 4
00000000001c 000500000002 R_X86_64_PC32 0000000000000000 .rodata - 4
000000000026 000c00000004 R_X86_64_PLT32 0000000000000000 printf - 4
Relocation section '.rela.eh_frame' at offset 0x280 contains 1 entry:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
-fplt options: no effect.Singularity debian_10.sif:/home/lugia> gcc -fplt -c tmp.c
Singularity debian_10.sif:/home/lugia> readelf -r tmp.o
Relocation section '.rela.text' at offset 0x238 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000012 000b0000002a R_X86_64_REX_GOTP 0000000000000000 foo - 4
00000000001c 000500000002 R_X86_64_PC32 0000000000000000 .rodata - 4
000000000026 000c00000004 R_X86_64_PLT32 0000000000000000 printf - 4
Relocation section '.rela.eh_frame' at offset 0x280 contains 1 entry:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
-fno-plt options: makes PLT32 (0x04) relocation to REX_GOTPCRELX (0x29) relocation, but REX_GOTPCRELX (0x2a), which is in the question, has not been changed (i.e. bad)Singularity debian_10.sif:/home/lugia> gcc -fno-plt -c tmp.c
Singularity debian_10.sif:/home/lugia> readelf -r tmp.o
Relocation section '.rela.text' at offset 0x238 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000012 000b0000002a R_X86_64_REX_GOTP 0000000000000000 foo - 4
00000000001c 000500000002 R_X86_64_PC32 0000000000000000 .rodata - 4
000000000027 000c00000029 R_X86_64_GOTPCREL 0000000000000000 printf - 4
Relocation section '.rela.eh_frame' at offset 0x280 contains 1 entry:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
-fno-pie: avoids use of REX_GOTPCRELX (success)Singularity debian_10.sif:/home/lugia> gcc -fno-pie -c tmp.c
Singularity debian_10.sif:/home/lugia> readelf -r tmp.o
Relocation section '.rela.text' at offset 0x200 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000010 000a0000000a R_X86_64_32 0000000000000000 foo + 0
000000000015 00050000000a R_X86_64_32 0000000000000000 .rodata + 0
00000000001f 000b00000004 R_X86_64_PLT32 0000000000000000 printf - 4
Relocation section '.rela.eh_frame' at offset 0x248 contains 1 entry:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
clang (LLVM8) won't use REX_GOTPCRELX in default for this example.Singularity debian_10.sif:/home/lugia> clang-8 -c tmp.c
Singularity debian_10.sif:/home/lugia> readelf -r tmp.o
Relocation section '.rela.text' at offset 0x1a0 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000018 000300000001 R_X86_64_64 0000000000000000 .rodata.str1.1 + 0
000000000022 000400000001 R_X86_64_64 0000000000000000 foo + 0
00000000002d 000600000004 R_X86_64_PLT32 0000000000000000 printf - 4
Relocation section '.rela.eh_frame' at offset 0x1e8 contains 1 entry:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
We don't want to include -fno-pie, since that is a huge security risk and disables ASLR.
PIE executables can be built and used on debian 8, it's about downgrading the toolchain version when building.
I just noticed that the distributed binaries are not reported as PIE (but as shared library, which can be ASLR enabled). (I'm using hardening-check version 2.6, which might generate different result to Debian's)
lugia@kanna:~> wget https://github.com/crystal-lang/crystal/releases/download/0.32.1/crystal-0.32.1-1-linux-x86_64.tar.gz
lugia@kanna:~> tar xf crystal-0.32.1-1-linux-x86_64.tar.gz
lugia@kanna:~> hardening-check crystal-0.32.1-1/lib/crystal/bin/crystal
crystal-0.32.1-1/lib/crystal/bin/crystal:
Position Independent Executable: no, regular shared library (ignored)
Stack protected: no, not found!
Fortify Source functions: unknown, no protectable libc functions used
Read-only relocations: yes
Immediate binding: yes
Built binaries by Crystal compiler becomes PIE only if -pie is included to the options in CC (Here, --enable-default-pie has not been included while building GCC in openSUSE Tumbleweed, which I'm using).
lugia@kanna:~> cat test2.cr
raise ""
lugia@kanna:~> CC="gcc -pie" crystal-0.32.1-1/bin/crystal build test2.cr
lugia@kanna:~> file test2
test2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1ff64018bda5e09482ffada008a6ace2cc3d3750, for GNU/Linux 3.2.0, with debug_info, not stripped
lugia@kanna:~> hardening-check test2
test2:
Position Independent Executable: yes
Stack protected: no, not found!
Fortify Source functions: no, only unprotected functions found!
Read-only relocations: yes
Immediate binding: no, not found!
lugia@kanna:~> crystal-0.32.1-1/bin/crystal build test2.cr
lugia@kanna:~> file test2
test2: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=427f36772e024db52865123abc63cc7ee60e6544, for GNU/Linux 3.2.0, with debug_info, not stripped
lugia@kanna:~> hardening-check test2
test2:
Position Independent Executable: no, normal executable!
Stack protected: no, not found!
Fortify Source functions: no, only unprotected functions found!
Read-only relocations: yes
Immediate binding: no, not found!
md5-5f632f3906e64e37d08f5c4886eb62b2
lugia@kanna:~/build/crystal-for-legacy-dist/distribution-scripts> make CRYSTAL_VERSION=0.32.1 PREVIOUS_CRYSTAL_RELEASE_LINUX64_TARGZ=https://github.com/crystal-lang/crystal/releases/download/0.32.1/crystal-0.32.1-1-linux-x86_64.tar.gz PREVIOUS_CRYSTAL_RELEASE_LINUX32_TARGZ=https://github.com/crystal-lang/crystal/releases/download/0.32.1/crystal-0.32.1-1-linux-i686.tar.gz
lugia@kanna:~/build/crystal-for-legacy-dist/distribution-scripts> cd ~/tmp
lugia@kanna:~/tmp> tar xf ~/build/crystal-for-legacy-dist/distribution-scripts/linux/build/crystal-0.32.1-1-linux-x86_64.tar.gz
lugia@kanna:~/tmp> CC="gcc -v -pie" crystal-0.32.1-1/bin/crystal build ../test2.cr
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/9/lto-wrapper
OFFLOAD_TARGET_NAMES=hsa:nvptx-none
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d --enable-offload-targets=hsa,nvptx-none=/usr/nvptx-none, --without-cuda-driver --disable-werror --with-gxx-include-dir=/usr/include/c++/9 --enable-ssp --disable-libssp --disable-libvtv --disable-cet --disable-libcc1 --enable-plugin --with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-libphobos --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function --program-suffix=-9 --without-system-libunwind --enable-multilib --with-arch-32=x86-64 --with-tune=generic --with-build-config=bootstrap-lto-lean --enable-link-mutex --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 9.2.1 20191209 [gcc-9-branch revision 279114] (SUSE Linux)
COMPILER_PATH=/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/
LIBRARY_PATH=/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/home/lugia/tmp/crystal-0.32.1-1/bin/../lib/crystal/lib/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/lib/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-pie' '-o' '/home/lugia/tmp/test2' '-rdynamic' '-L/home/lugia/tmp/crystal-0.32.1-1/bin/../lib/crystal/lib' '-L/usr/lib' '-L/usr/local/lib' '-mtune=generic' '-march=x86-64'
/usr/lib64/gcc/x86_64-suse-linux/9/collect2 -plugin /usr/lib64/gcc/x86_64-suse-linux/9/liblto_plugin.so -plugin-opt=/usr/lib64/gcc/x86_64-suse-linux/9/lto-wrapper -plugin-opt=-fresolution=/tmp/cceqEiHw.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o /home/lugia/tmp/test2 /usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/Scrt1.o /usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/9/crtbeginS.o -L/home/lugia/tmp/crystal-0.32.1-1/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib -L/usr/lib64/gcc/x86_64-suse-linux/9 -L/usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/lugia/tmp/crystal-0.32.1-1/bin/../lib/crystal/lib -L/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/9/../../.. _main.o S-lice40U-I-nt841.o P-ointer40U-I-nt841.o A-rgumentE-rror.o C-allS-tack.o A-rray40P-ointer40V-oid4141.o P-ointer40P-ointer40V-oid4141.o E-xception.o P-ointer40L-ibU-nwind5858E-xception41.o U-I-nt64.o U-I-nt8.o D-ir.o C-rystal5858S-ystem5858D-ir.o E-rrno.o S-tring.o G-C-.o R-eflect40I-nt3241.o I-nt32.o C-har.o S-taticA-rray40U-I-nt84432441.o I-ndexE-rror.o S-tring5858B-uilder.o S-lice40T-41.o I-O-5858E-ncoder.o I-conv.o S-taticA-rray40U-I-nt84432102441.o M-ath.o I-nvalidB-yteS-equenceE-rror.o S-taticA-rray40U-I-nt8443212941.o I-nt64.o D-ivisionB-yZ-eroE-rror.o A-rray40S-tring41.o P-ointer40S-tring41.o P-ointer40V-oid41.o P-roc40I-nt324432N-il41.o S-taticA-rray40I-nt8443225641.o P-ointer40I-nt841.o F-iber5858S-tackP-ool.o D-eque40P-ointer40V-oid4141.o T-hread5858M-utex.o F-ile5858P-ermissions.o F-iber.o T-hread5858L-inkedL-ist40F-iber41.o C-rystal5858S-ystem5858R-andom.o C-rystal5858S-cheduler.o T-hread.o A-tomic40U-I-nt841.o A-tomic40T-hread3212432N-il41.o F-iber5858C-ontext.o T-hread5858L-inkedL-ist40T-hread41.o N-il.o N-ilA-ssertionE-rror.o C-rystal5858S-pinL-ock.o D-eque40F-iber41.o P-ointer40F-iber41.o T-ime5858S-pan.o C-rystal5858E-ventL-oop.o C-rystal5858E-vent5858B-ase.o C-rystal5858E-vent.o L-ibC-5858T-imeval.o F-loat64.o C-rystal5858S-ystem.o E-N-V-.o C-rystal5858S-ystem5858E-nv.o F-ile.o C-rystal5858S-ystem5858F-ile.o C-har5858R-eader.o U-I-nt32.o C-rystal5858T-hre-1a3c0c3e3b0f8107f598df47513fbad7.o H-ash40T-hread4432D-eque40F-iber4141.o P-ointer40H-ash58-ba622b1c6ea9db0b943e2b37ba0c5af2.o C-rystal5858T-hre-328ba26086c06ca27f79c0f6529d7399.o H-ash40T-hread4432C-rystal5858E-vent41.o P-ointer40H-ash58-e27196573eea5e5746b383aacfde8695.o C-rystal5858S-ystem5858F-ileD-escriptor.o I-O-5858E-rror.o H-ash5858E-ntry40T-hread4432D-eque40F-iber4141.o C-rystal5858H-asher.o S-taticA-rray40U-I-nt644432241.o P-ointer40U-I-nt6441.o P-ointer40U-I-nt1641.o P-ointer40U-I-nt3241.o H-ash5858E-ntry40T-hread4432C-rystal5858E-vent41.o L-ibE-vent25858E-ventF-lags.o I-O-5858T-imeout.o R-ange40B-4432E-41.o R-ange40I-nt324432I-nt3241.o D-ebug5858E-L-F-.o I-O-5858F-ileD-escriptor43.o D-ebug5858E-L-F-5858E-rror.o D-ebug5858E-L-F-5858E-ndianness.o D-ebug5858E-L-F-5858O-S-A-B-I-.o S-taticA-rray40U-I-nt84432409641.o I-O-5858E-O-F-E-rror.o D-ebug5858E-L-F-5858I-dent.o U-I-nt16.o I-O-5858B-yteF-ormat5858B-igE-ndian.o S-taticA-rray40U-I-nt84432241.o I-O-5858B-yteF-ormat5858L-ittleE-ndian.o D-ebug5858E-L-F-5858K-lass.o S-taticA-rray40U-I-nt84432841.o A-rray40D-ebug5858E-L-F-5858S-ectionH-eader41.o P-ointer40D-ebug5858E-L-F-5858S-ectionH-eader41.o I-O-5858S-eek.o D-ebug5858E-L-F-5858S-ectionH-eader.o I-O-5858D-ecoder.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers.o A-rray40A-rray40D-d5580c0e9cb0bd8af7e90c96221706e1.o P-ointer40A-rray4-6533bdad81433bcf155b99ac74756686.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858S-equence.o A-rray40T-uple40S-5992430a1a7ef1627717adfb71332538.o P-ointer40T-uple4-13415771527eed75ea796bf4f3711255.o A-rray40U-I-nt841.o I-nt8.o S-taticA-rray40U-I-nt84432141.o D-ebug5858D-W-A-R-F-.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858R-egister.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858R-ow.o A-rray40D-ebug585-1d195a7f864d2d3790ebeadd84b7a4df.o P-ointer40D-ebug5-a50eac5c43900f6bca76f68ff8c8549d.o D-ebug5858D-W-A-R-F-5858L-N-E-.o D-ebug5858D-W-A-R-F-5858L-N-S-.o D-ebug5858D-W-A-R-F-5858S-trings.o A-rray40T-uple40U-997f9e533f193da5e605a2014e7947d9.o P-ointer40T-uple4-aa2454898accd295538d997a0365d41d.o D-ebug5858D-W-A-R-F-5858I-nfo.o D-ebug5858D-W-A-R-F-5858A-bbrev.o A-rray40D-ebug5858D-W-A-R-F-5858A-bbrev41.o P-ointer40D-ebug5858D-W-A-R-F-5858A-bbrev41.o A-rray40D-ebug585-b448de41619185732a02b2b0c778beb9.o P-ointer40D-ebug5-038cd8f166075bfacc819464bf65667a.o D-ebug5858D-W-A-R-F-5858A-bbrev5858A-ttribute.o A-rray40T-uple40D-2934b2835f929d23ac3adb7e5b7b0afe.o P-ointer40T-uple4-6ff119ef58145d1144587389190a4e25.o D-ebug5858D-W-A-R-F-5858F-O-R-M-.o U-nicode5858C-aseO-ptions.o U-nicode.o A-rray40T-uple40I-nt324432I-nt324432I-nt324141.o P-ointer40T-uple40I-nt324432I-nt324432I-nt324141.o H-ash40I-nt324432-c36c7b59ada9577e04b34b7156d26117.o P-ointer40H-ash58-df002967aa38240c2ffc8370480b96df.o H-ash5858E-ntry40-ea883736b6a497e8c0f2d29083b2162a.o A-rray40T-uple40I-nt324432I-nt324141.o P-ointer40T-uple40I-nt324432I-nt324141.o D-ebug5858D-W-A-R-F-5858T-A-G-.o D-ebug5858D-W-A-R-F-5858A-T-.o B-ool.o T-ypeC-astE-rror.o S-tring5858T-oU-64I-nfo.o A-tE-xitH-andlers.o A-rray40P-roc40I--412183da1a81233e2c20c488cb2e890d.o P-ointer40P-roc40-6252237c86bac28658266374d639ebc8.o I-O-5858F-ileD-escriptor.o S-taticA-rray40U-I-nt8443225641.o E-xception43.o T-ime5858L-ocatio-c92d7ae948ed8f4d38520c6d460d1469.o T-ime5858L-ocation5858I-nvalidL-ocationN-ameE-rror.o T-ime5858L-ocation5858I-nvalidT-Z-D-ataE-rror.o T-ime5858F-ormat5858E-rror.o T-ime5858F-loatingT-imeC-onversionE-rror.o B-ase645858E-rror.o P-ath5858E-rror.o F-ile5858B-adP-atternE-rror.o C-oncurrentE-xecutionE-xception.o C-oncurrent5858C-anceledE-rror.o C-hannel5858C-losedE-rror.o E-numerable5858E-mptyE-rror.o N-otI-mplementedE-rror.o O-verflowE-rror.o K-eyE-rror.o P-rocess.o C-rystal5858S-ystem5858F-ileI-nfo.o F-ile5858T-ype.o C-rystal5858S-ystem5858F-iber.o P-roc40F-iber4432-6eb246a0a45118d3c5507cc830b14a70.o S-ignal.o A-tomic5858F-lag.o L-ibC-5858S-igsetT-.o C-rystal5858S-ignal.o I-O-.o S-taticA-rray40I-nt324432241.o P-ointer40I-nt3241.o H-ash40S-ignal4432P-roc40S-ignal4432N-il4141.o P-ointer40H-ash58-0716a66562827a635360751c7a0bfb0b.o H-ash5858E-ntry40-37a9b13947932e73bc9389d755897071.o C-rystal5858S-ignalC-hildH-andler.o M-utex.o A-tomic40I-nt3241.o M-utex5858P-rotection.o I-ntrinsics.o H-ash40I-nt324432C-hannel40I-nt324141.o P-ointer40H-ash58-438550d1ae4863022fe79cbb17acca82.o H-ash5858E-ntry40I-nt324432C-hannel40I-nt324141.o C-hannel40I-nt3241.o C-hannel5858S-ender40I-nt3241.o P-ointer40C-hannel5858S-ender40I-nt324141.o C-rystal5858P-oin-c4f99d9688c0365d7ded28861381dd6c.o P-ointer40C-hannel5858R-eceiver40I-nt324141.o C-hannel5858R-eceiver40I-nt3241.o C-hannel5858S-electC-ontext40I-nt3241.o C-hannel5858S-electC-ontextS-haredS-tate.o A-tomic40C-hannel5858S-electS-tate41.o D-eque40I-nt3241.o C-hannel5858D-eliveryS-tate.o C-rystal5858P-oin-50c6dff1ac01adb5932ab2c073b74d07.o C-hannel5858S-electC-ontext40N-il41.o H-ash40I-nt324432I-nt3241.o P-ointer40H-ash5858E-ntry40I-nt324432I-nt324141.o H-ash5858E-ntry40I-nt324432I-nt3241.o H-ash40T-uple40U-I-nt644432S-ymbol414432B-ool41.o P-ointer40H-ash58-60a3eb55c544b99184778abc7dcee256.o H-ash40S-tring443-d0ef6a484ca24b5e9e1cd150630d96a3.o P-ointer40H-ash58-78e716075e5ec360a5549c235b8e9c11.o C-rystal5858O-nceS-tate.o A-rray40P-ointer40B-ool4141.o P-ointer40P-ointer40B-ool4141.o P-ointer40B-ool41.o P-roc40N-il41.o L-E-B-R-eader.o L-ibU-nwind5858A-ction.o L-ibU-nwind5858R-easonC-ode.o C-allS-tack5858R-epeatedF-rame.o C-rystal.o -lpcre -lm /home/lugia/tmp/crystal-0.32.1-1/bin/../lib/crystal/lib/libgc.a -lpthread /home/lugia/tmp/crystal-0.32.1-1/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib64/gcc/x86_64-suse-linux/9/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/crtn.o
COLLECT_GCC_OPTIONS='-v' '-pie' '-o' '/home/lugia/tmp/test2' '-rdynamic' '-L/home/lugia/tmp/crystal-0.32.1-1/bin/../lib/crystal/lib' '-L/usr/lib' '-L/usr/local/lib' '-mtune=generic' '-march=x86-64'
lugia@kanna:~/tmp> hardening-check test2
test2:
Position Independent Executable: yes
Stack protected: no, not found!
Fortify Source functions: no, only unprotected functions found!
Read-only relocations: yes
Immediate binding: no, not found!
lugia@kanna:~/tmp> ldd test2
linux-vdso.so.1 (0x00007ffd77dc9000)
libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007ff0b9166000)
libm.so.6 => /lib64/libm.so.6 (0x00007ff0b9021000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff0b8fff000)
libevent-2.1.so.7 => /usr/lib64/libevent-2.1.so.7 (0x00007ff0b8fa5000)
librt.so.1 => /lib64/librt.so.1 (0x00007ff0b8f9a000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ff0b8f95000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff0b8f79000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff0b8db2000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff0b9574000)
lugia@kanna:~/tmp> LANG=C readelf -r crystal-0.32.1-1/lib/crystal/lib/libgc.a | awk '/^Relocation|^ *Offset/ {}; /^[0-9a-f]/ { print $2,$3 }' | sort -k2 | uniq -f1
000900000001 R_X86_64_64
000300000009 R_X86_64_GOTPCREL
000200000002 R_X86_64_PC32
000300000004 R_X86_64_PLT32
001b00000013 R_X86_64_TLSGD
For distributed binary, the output of the last command will be following. So only relocation `0x2a` has been avoided.
lugia@kanna:~> LANG=C readelf -r crystal-0.32.1-1/lib/crystal/lib/libgc.a | awk '/^Relocation|^ *Offset/ {}; /^[0-9a-f]/ { print $2,$3 }' | sort -k2 | uniq -f1
000700000001 R_X86_64_64
001a00000009 R_X86_64_GOTPCREL
000200000002 R_X86_64_PC32
000800000004 R_X86_64_PLT32
00080000002a R_X86_64_REX_GOTP
000d00000013 R_X86_64_TLSGD
```
Most helpful comment
This is to do with an old
ldbinary in debian 8. Perhaps we should compilelibgc.awith an even older debian or centos, since debian 8 is still supported until june 30th.