Checker and Binutils 2.12

Allen Barnett allen@lignumcomputing.com
Fri Mar 15 14:33:00 GMT 2002


Hi,

We've been trying to update Checker 
(http://www.gnu.org/software/checker/checker.html) to work with the C++ 
standard library and version 2.95.3 of GCC on a RedHat 7.2/i386 system. 
However, we've run into a problem in the latest version of the linker. The 
problem is that BFD reports undefined references to symbols which really are 
defined.

I've narrowed down the source of this problem to a change which was checked 
into CVS on November 7, 2001. It was a change to the elflink.h file in the 
BFD source.

I've tried to produce a simple example, but it is still complicated. Checker 
uses the -fprefix-function-name option to GCC in order to intercept and check 
the arguments of user-invoked functions before passing them on the real 
routines. One of the files which is compiled into a Checker stub is the C++ 
typeinfo header. This results in an object module which is contains both 
prefixed function names and un-prefixed references to data:

$ nm typeinfo.o
00000000 ? __FRAME_BEGIN__
00000008 C __ti9type_info
         U __tiv
00000000 V __vt_9type_info
00000000 T chkr._._9type_info
00000000 W chkr.__9type_infoPCc
         U chkr.__builtin_delete
00000038 T chkr.__rtti_user
00000000 W chkr.__tf9type_info
00000040 T chkr.__tfv
00000000 W chkr.name__C9type_info
00000000 t gcc2_compiled.

This object module and bunch of others go into an archive library which is 
included in the Checker link command.

If the user calls __rtti_user, for example, (well, it would really be 
chkr.__rtti_user) then this object module is pulled into the executable 
(along with several other Checker modules to satisfy references, like 
chkr.__builtin_delete). The references to the "type_info virtual table" 
(__vt_9type_info) and the "type_info type_info node" (__ti9type_info) should 
still be resolved from GCC's libgcc.a tinfo.o and tinfo2.o members.

Checker also tries to define some of the other type_info functions for
the built-in data types, for example, the "void type_info function"
(chkr.__tfv). Note that the "void type_info node" (__tiv) is not
modified by prefix-function-name and should be resolved from libgcc.a.

When version 2.12 of the linker tries to build the executable, it
gives the following errors:

$ GCC_EXEC_PREFIX=/usr/local/src/binutils-2.12/ld/ g++ -Wl,-v 
-Wl,-Map=listing -o
main main.o -L. -lg
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/libgcc.a(tinfo2.o): In 
function
`__throw_type_match_rtti':
/usr/local/src/gcc-2.95.3/gcc/./cp/tinfo2.cc:114: undefined reference to 
`__tf9type_info'
/usr/local/src/gcc-2.95.3/gcc/./cp/tinfo2.cc:119: undefined reference to 
`__tf9type_info'
/usr/local/src/gcc-2.95.3/gcc/./cp/tinfo2.cc:141: undefined reference to 
`__tf9type_info'
/usr/local/src/gcc-2.95.3/gcc/./cp/tinfo2.cc:158: undefined reference to 
`__tf9type_info'
/usr/local/src/gcc-2.95.3/gcc/./cp/tinfo2.cc:161: undefined reference to 
`__tf9type_info'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/libgcc.a(tinfo2.o):/usr/local/src/gcc-2.95.3/gcc/./cp/tinfo2.cc:167: 
more undefined references to `__tf9type_info' follow
GNU ld version 2.12

In this case, __tf9type_info is really defined in libgcc.a(tinfo.o). Also, 
versions of ld and bfd prior to 11/7/2001 seem to work ok.

A "simplified" test case (which doesn't require Checker) can be found at 
www.lignumcomputing.com/ld/ld-example.tar.gz (1.2k). Edit the LDPATH variable 
in the Makefile to pick a version of ld to use.

Thanks,
Allen



More information about the Binutils mailing list