This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ld (bfd) bug: discarded N_EXCL stab in repeated link [PATCH]


Sometimes ld throws away N_EXCL stabs found in the input file.
This can occur when the input file is the result of a (partial) link.
I ran into this bug when linking the Linux kernel.

When a repeated include file is excluded, then the N_BINCL stab is
changed to N_EXCL, and all the contained stabs up to and including the
corresponding N_EINCL stab are removed. The bug is here that an N_EXCL
stab (mark of a file that was excluded in a previous link) is also
removed. This is always an error --- N_EXCL stabs must remain untouched
in order for the include file number in stab types to be correct.

I have a testcase which I can wrap up if anyone is interested (and gdb
complains when being fed the result).

The following patch (apply to mainline) fixes it:

--- stabs.c.old Tue Mar 16 18:50:32 2004
+++ stabs.c     Tue Mar 16 18:50:44 2004
@@ -456,6 +456,8 @@
                    }
                  else if (incl_type == (int) N_BINCL)
                    ++nest;
+                  else if (incl_type == (int) N_EXCL)
+                    continue;   /* keep existing exclusion marks */
                  else if (nest == 0)
                    {
                      *incl_pstridx = (bfd_size_type) -1;

Someone, please apply.

(I submitted a patch for a related bug recently. This problem is orthogonal
but I should have caught it at the same time; sorry about that.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]