Re: [DynInst_API:] Cannot link to dyninst 8.0 on Ubuntu


Date: Sun, 24 Feb 2013 14:01:09 -0500
From: mkfs <semper.non.sequitur@xxxxxxxxx>
Subject: Re: [DynInst_API:] Cannot link to dyninst 8.0 on Ubuntu
Just a quick note -- the source code distro can be built to link
against the static DWARF library (thus resolving the missing .so
problem reported earlier) -- however, libsymtabAPI des not link to
this library correctly, so the dwarf symbols are all unresolved:

 bash$ g++ -I/usr/local/dyninst/include dyninst_test.cpp
-L/usr/local/dyninst/lib -ldyninstAPI -lcommon -lsymtabAPI -lpatchAPI
-lparseAPI -lstackwalk -lpcontrol -linstructionAPI -ldynC_API
-ldynDwarf -ldynElf -lsymLite -lsymtabAPI
/usr/local/dyninst/lib/libdynDwarf.so: undefined reference to
`dwarf_get_fde_info_for_cfa_reg3'
/usr/local/dyninst/lib/libsymtabAPI.so: undefined reference to `dwarf_errmsg'
/usr/local/dyninst/lib/libsymtabAPI.so: undefined reference to `dwarf_dieoffset'
/usr/local/dyninst/lib/libsymtabAPI.so: undefined reference to `dwarf_lowpc'
...
bash$


This can be fixed by linking against libdwarf.a correctly in the
application build:

bash$ g++ -I/usr/local/dyninst/include dyninst_test.cpp
-L/usr/local/dyninst/lib -ldyninstAPI -lcommon -lsymtabAPI -lpatchAPI
-lparseAPI -lstackwalk -lpcontrol -linstructionAPI -ldynC_API
-ldynDwarf -ldynElf -lsymLite -lsymtabAPI -Wl,--whole-archive
/usr/lib/libdwarf.a -Wl,--no-whole-archive
bash$


The requirement for the --whole-archive...--no-whole-archive archive
flags in GNU ld are somewhat new and broke a lot of my own projects
(which tend to build a single shared library from many static
libraries) a few years back. It appears this fix was applied to at
least part of the Dyninst build process, as the flag appears in the
test suite for PPC code:

bash$ grep -rI ldwarf .
...
./testsuite/ppc64_bgq_ion/Makefile:MYLINK_FLAGS += -Wl,--whole-archive
-ldwarf -Wl,--no-whole-archive
...


The proper fix is to use the --whole-archive flags in the build for
either libdynDwarf.so (the obvious place) or libsymtabAPI.so (where
all the libdwarf symbols seem to be referenced). Unfortunately, the
build system is rather baroque, and I couldn't find the proper place
to change "-ldwarf" to "-Wl,--whole-archive -ldwarf
-Wl,--no-whole-archive".

Have you considered using libtool to manage the building of the shared
libraries? It takes a day or two to get used to, but it should ease
the maintenance of the build system long-term.
[← Prev in Thread] Current Thread [Next in Thread→]