Skip to content

Rust programs require recent glibc due to __cxa_thread_atexit_impl #36826

Closed as not planned
@Timmmm

Description

@Timmmm

I think this is a bug but I'm not 100% sure. Anyway, I have cross-compiled a simple Rust program with the toolchain stable-x86_64-pc-windows-gnu and the target armv7-unknown-linux-gnueabihf, using this GCC cross compiler from Linaro.

However when I run it on a reasonably old system I get:

./foo: /lib/libc.so.6: version `GLIBC_2.18' not found (required by ./foo)

objdump -T foo reveals that this is the only symbol that needs glibc 2.18. The others all need 2.4.

00000000  w   DF *UND*  00000000  GLIBC_2.18  __cxa_thread_atexit_impl

The symbol is weakly defined, however the dependency on glibc 2.18 is still strong:

$ readelf -V foo
...
Version needs section '.gnu.version_r' contains 5 entries:
 Addr: 0x0000000000001e4c  Offset: 0x001e4c  Link: 6 (.dynstr)
  000000: Version: 1  File: ld-linux-armhf.so.3  Cnt: 1
  0x0010:   Name: GLIBC_2.4  Flags: none  Version: 9
  0x0020: Version: 1  File: librt.so.1  Cnt: 1
  0x0030:   Name: GLIBC_2.4  Flags: none  Version: 5
  0x0040: Version: 1  File: libgcc_s.so.1  Cnt: 4
  0x0050:   Name: GCC_4.3.0  Flags: none  Version: 10
  0x0060:   Name: GCC_3.0  Flags: none  Version: 7
  0x0070:   Name: GCC_3.5  Flags: none  Version: 6
  0x0080:   Name: GCC_3.3.1  Flags: none  Version: 4
  0x0090: Version: 1  File: libc.so.6  Cnt: 2
  0x00a0:   Name: GLIBC_2.18  Flags: none  Version: 8
  0x00b0:   Name: GLIBC_2.4  Flags: none  Version: 3
  0x00c0: Version: 1  File: libpthread.so.0  Cnt: 1
  0x00d0:   Name: GLIBC_2.4  Flags: none  Version: 2

I found a site where they should how to hex edit the binary so it shows this:

 0x00a0:   Name: GLIBC_2.18  Flags: WEAK   Version: 8

However it still doesn't work:

./foo: /lib/libc.so.6: weak version `GLIBC_2.18' not found (required by ./foo)
./foo: relocation error: ./foo: symbol __cxa_thread_atexit_impl, version GLIBC_2.18 not defined in file libc.so.6 with link time reference

Now, I wouldn't have thought this was a bug, except that the code that uses __cxa_thread_atexit_impl seems to have been written intending it to be a weak reference so it seems like a bug.

I'm not an expert on glibc's insanity though so I could be wrong. I posted a SO question but no answers yet. :-/

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.O-linuxOperating system: Linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions