c++gccldsections

ld: invalid string offset ... for section `.strtab'


I'm building a c++ project with GNU toolchain/gcc 4.9 on a new platform (debian stretch on a jetson K1 evalboard). The linker gives lots of messages like

usr/bin/ld: ../../../../lib/libsomething.so: invalid string offset 3118 >= 2767 for section `.strtab'

I don't even know whether this is an error, a warning or just some linker smalltalk. The project builds and runs, but this confuses me.

I've already built this project on a couple of ARM and intel platforms, with the same toolchain (but on Ubuntu or Debian Jessie), and never seen this stuff.

I've seen suggestions this could be related to parallel builds with make -j, but this also happens if I rebuild all libs without -j.

Please give me a hint what this is and how I can get rid of it.

Update:


Solution

  • There was a bug in ld.bfd before version 2.33.

    The linker tried to read ARM CMSE symbol names, but used .strtab instead of .dynstr. If symbols are stripped in a shared library, its .strtab section iss shorter than .dynstr, so for some symbols in .dynsym, the offsets of their names (which in fact refer to .dynstr) exceed the size of .strtab, and the linker complained about this with a warning.

    Here is a patch that fixed the issue if you need more details: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=baf46cd78048e1b959462567556e1de1ef6b9039.