[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ld (bfd?) bug: unmatched excluded include in stabs

From: Mattias Engdegård
Subject: ld (bfd?) bug: unmatched excluded include in stabs
Date: Mon, 17 Nov 2003 19:14:13 +0100

It seems that recent binutils (at least 2.14, but not 2.13) merge
repeated include-file stabs when linking partially. When these partial
linked objects then are linked again, this can cause the generation of
excluded stabs that do not refer to any include file stab. I found
this when linking the Linux kernel.

For instance, consider the following files:

 #include "alfa.h"
 #include "beta.h"
 #include "gamma.h"
 struct A { int a; }
 struct B { float b; }
 #include "gamma.h"

Then gamma.o will have the stabs

  BINCL gamma.h
   LSYM (definition of B)

and alfa.o will contain the stabs

  BINCL alfa.h
   BINCL beta.h
    LSYM (definition of A)
   BINCL gamma.h
    LSYM (definition of B)

When partially linked together (-r), ld will compute checksums to BINCL stabs
and replace some BINCL/EINCL pairs by matching EXCL stabs:

  BINCL gamma.h (with a nonzero checksum)
   LSYM (definition of B)
  BINCL alfa.h  (with checksum == 0)
   BINCL beta.h
    LSYM (definition of A)
   EXCL gamma.h  (with a checksum that matches that of BINCL gamma.h)

The alfa.h checksum is zero, because there are no non-nested stabs there
(the EXCL stab is added afterwards).

Now consider another object file that includes alfa.h. Its stabs will be
roughly equal to those of alfa.o above. When this is linked to the partial
link, the resulting BINCL of alfa.h will have checksum != 0 (since this
time the EXCL gamma.h contributes), but the use will have checksum == 0.

Thus a debugger sees, in the final executable

  BINCL alfa.h, checksum != 0
  EXCL  alfa.h, checksum == 0

and won't be able to match them. GDB complains about this, if complaints
are turned on.

I have a testcase for this, which I could wrap up if someone is interested.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]