Musl ldd: error relocating ... symbol not found

When compiling tvheadend with musl, it segfaults, and looking at the libraries, facing some weird issues:

# ldd /usr/bin/tvheadend 
/lib/ld-musl-armhf.so.1 (0x7f645000)
libdvben50221.so => /usr/lib/libdvben50221.so (0xb6b4f000)
libdvbapi.so => /usr/lib/libdvbapi.so (0xb6b3c000)
libucsi.so => /usr/lib/libucsi.so (0xb6b18000)
libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0xb6ac4000)
libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0xb698f000)
libz.so.1 => /usr/lib/libz.so.1 (0xb696d000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6953000)
libc.so => /lib/ld-musl-armhf.so.1 (0x7f645000)

# ldd /usr/lib/libdvben50221.so
ldd (0x7f62e000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6f6b000)
libc.so => ldd (0x7f62e000)
Error relocating /usr/lib/libdvben50221.so: dvbca_hlci_read: symbol not found
Error relocating /usr/lib/libdvben50221.so: dvbca_link_read: symbol not found 
Error relocating /usr/lib/libdvben50221.so: dvbca_hlci_write: symbol not found
Error relocating /usr/lib/libdvben50221.so: dvbca_get_interface_type: symbol not found 
Error relocating /usr/lib/libdvben50221.so: dvbca_open: symbol not found
Error relocating /usr/lib/libdvben50221.so: dvbca_get_cam_state: symbol not found
Error relocating /usr/lib/libdvben50221.so: dvbca_reset: symbol not found
Error relocating /usr/lib/libdvben50221.so: dvbca_link_write: symbol not found
Error relocating /usr/lib/libdvben50221.so: dvbca_get_cam_state: symbol not found
Error relocating /usr/lib/libdvben50221.so: unixtime_to_dvbdate: symbol not found
Error relocating /usr/lib/libdvben50221.so: dvbca_link_write: symbol not found

# ldd /usr/lib/libdvbapi.so
ldd (0x7f5d4000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6f7f000)
libc.so => ldd (0x7f5d4000)

# readelf -s /usr/lib/libdvbapi.so | grep dvbca_hlci_read
 6: 0000139c   244 FUNC    GLOBAL DEFAULT   10 dvbca_hlci_read

so ldd doesn't find the symbols although libdvbapi.so has them...

even more weird, if I compile with glibc, tvheadend works ( doesn't segfault ), but if I try to ldd the libs it segfaults...

# ldd /usr/bin/tvheadend 
libdvben50221.so => /usr/lib/libdvben50221.so (0xb6f9c000)
libdvbapi.so => /usr/lib/libdvbapi.so (0xb6f89000)
libucsi.so => /usr/lib/libucsi.so (0xb6f65000)
libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0xb6f13000)
libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0xb6de3000)
libz.so.1 => /usr/lib/libz.so.1 (0xb6dc1000)
libdl.so.2 => /lib/libdl.so.2 (0xb6dae000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb6d85000)
libm.so.6 => /lib/libm.so.6 (0xb6d06000)
librt.so.1 => /lib/librt.so.1 (0xb6cef000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6cd5000)
libc.so.6 => /lib/libc.so.6 (0xb6b92000)
/lib/ld-linux-armhf.so.3 (0xb6fb8000)

# ldd /usr/lib/libdvben50221.so
Segmentation fault
# ldd /usr/lib/libdvbapi.so 
Segmentation fault
# ldd /usr/lib/libucsi.so 
Segmentation fault
# ldd /usr/lib/libssl.so.1.0.0 
-ash: /usr/lib/libssl.so.1.0.0: Permission denied
# ldd /usr/lib/libcrypto.so.1.0.0 
-ash: /usr/lib/libcrypto.so.1.0.0: Permission denied
#

PS. to avoid confusions, lede is compiled accordingly with musl and glibc.

2 Likes

can you check if those libraries are marked as executable. i mean chmod 0775.

I guess you meant the ones with permission denied. those don’t have x, only 644. ldd on other libs with execute work fine. So the only question remains why is ldd complaining about missing symbols if readelf says the symbols are in the lib?

Did you end up figuring out what caused this? I seem to be having a very similar issue.

hi, sorry for the late reply, unfortunately I'm not sure anymore, but if IIRC, it was a bug in tvheadend.

Hi,
Thanks for getting back to me. From my side it looks like the issue was a combination of slightly different architectures (gnu vs musl) - resolved by compiling strictly with SDK tools - and it turns out the other bit was a dependency deep buried in an underlying sub-library which was trying to link in an OpenSSL bit when it really should be using only TLS. cargo tree to the rescue!