View Single Post
  #1   Spotlight this post!  
Unread 15-01-2017, 00:42
Thomas DeSilva's Avatar
Thomas DeSilva Thomas DeSilva is offline
Programming Fury
FRC #1983 (Skunkworks)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Des Moines, WA
Posts: 22
Thomas DeSilva is on a distinguished road
libNiFpgaLv.so has wrong SONAME in ELF header?

I'm currently trying to get Google Test to work with a WPILib project so we can have tests integrated smoothly into our codebase (the rationale here could be a thread of its own, so let's not get into it). I've managed to get an executable compiled and linked, but I've been struggling to get the loader to cooperate. My procedure thus far:

1. Install qemu-user, the current FRC C++ toolchain, Eclipse, and the WPILib plugin on an Ubuntu machine.
2. Create a build configuration in Eclipse which links with both WPILib and gtest, with the test executable as the build artifact.
3. Build the executable.
4. Consolidate all relevant shared object files in one directory so that qemu's loader can find them.
5. Set up symlinks for the libraries that came with WPILib (the symlinks between different versions of libraries, e.g. libi2c.so -> libi2c.so.2, were created as regular files by the Eclipse plugin installer, so I wrote a script to remake them).
5. Run the executable using qemu-arm with a sufficiently large kernel version number and the loader path set to the directory containing the consolidated shared object files.

On the last step, qemu throws an error which reads, "src/eclipse/2017Steamworks/test/Test: error while loading shared libraries: libNiFpgaLv.so.13: cannot open shared object file: No such file or directory". I found it strange that it was trying to load that version of the library, as the one that WPILib comes with is 16.0.0, not 13. However, when I checked the ELF header of the library, I found that the SONAME doesn't match the filename:

Code:
$ readelf -d libNiFpgaLv.so.16.0.0 
Dynamic section at offset 0xc3a0 contains 30 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libNiFpga.so.13]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [librt.so.1]
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000e (SONAME)                     Library soname: [libNiFpgaLv.so.13]
This also seems to be the case for some other NI libraries, like NiFpga and NiRioSrv. Is this intentional? How does the RoboRIO's loader handle this without having the same failure I am?
__________________
Programmer 2009-2011
Driver 2011
WPI Class of 2015

Last edited by Thomas DeSilva : 15-01-2017 at 00:52.
Reply With Quote