'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:

  • The said libraries are compiled within the same project with the same toolchain
  • objdump doesn't list the .strtab section at all


Solution 1:[1]

There was a bug in ld.bfd prior to Binutils 2.33.

It tried to read ARM CMSE symbol names, but used .strtab instead of .dynstr. If symbols are stripped in a shared library, its .strtab section is shorter than .dynstr, so for some symbols in .dynsym, the offsets of their names (which actually reference .dynstr) exceed the size of .strtab. Thus, the linker issued the warning.

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1