This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: FAIL: Link -r with zlib compressed debug output
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 24 Jul 2015 14:55:43 +0930
- Subject: Re: FAIL: Link -r with zlib compressed debug output
- Authentication-results: sourceware.org; auth=none
- References: <20150722131641 dot GG16511 at bubble dot grove dot modra dot org> <CAMe9rOpsJTv2kzZGfB9NCjgTJ8dNvKAJwHsO8P5SfypwZKKV4A at mail dot gmail dot com> <20150722151352 dot GI16511 at bubble dot grove dot modra dot org>
On Thu, Jul 23, 2015 at 12:43:52AM +0930, Alan Modra wrote:
> -ggdb3 fixed the failure. However, it seems to have introduced
> FAIL: Link with zlib-gnu compressed debug output
> FAIL: Link with zlib-gabi compressed debug output
OK, I've sorted this one out. Please commit the -ggdb3 patch.
Comparing map files for tmpdir/normal vs tmpdir/gnunormal shows that
.debug_macro/.zdebug_macro are being linked in different order.
@@ -521,30 +521,30 @@
.debug_macro 0x0000000000000000 0x1148
*(.debug_macro)
- .debug_macro 0x0000000000000000 0x69a tmpdir/begin.o
- .debug_macro 0x000000000000069a 0xec tmpdir/end.o
- .debug_macro 0x0000000000000786 0x19b tmpdir/end.o
-[snip more end.o groups]
- .debug_macro 0x0000000000001110 0x27 tmpdir/end.o
- .debug_macro 0x0000000000001137 0x11 tmpdir/begin.o
+ .debug_macro 0x0000000000000000 0x11 tmpdir/gnubegin.o
+ .debug_macro 0x0000000000000011 0x69a tmpdir/gnubegin.o
+ .debug_macro 0x00000000000006ab 0xec tmpdir/end.o
+ .debug_macro 0x0000000000000797 0x19b tmpdir/end.o
+[snip more end.o groups]
+ .debug_macro 0x0000000000001121 0x27 tmpdir/end.o
.gnu.attributes
*(.gnu.attributes)
Digging into this revealed a problem with bfd_get_section_by_name_if
hash chain traversal.
The function stops too soon, as I found when the hash chain happened
to contain two .debug_macro sections (one originally .zdebug_macro)
and a .bss section:
.debug_macro -> .bss -> .debug_macro
This thwarts ldlang.c:find_section checking for multiple sections of
the same name, which eventually leads to one of the .debug_macro
sections being treated as an orphan.
* section.c (bfd_get_section_by_name_if): Iterate over entire hash
chain.
diff --git a/bfd/section.c b/bfd/section.c
index 6af174a..aa652a4 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -994,14 +994,11 @@ bfd_get_section_by_name_if (bfd *abfd, const char *name,
return NULL;
hash = sh->root.hash;
- do
- {
- if ((*operation) (abfd, &sh->section, user_storage))
- return &sh->section;
- sh = (struct section_hash_entry *) sh->root.next;
- }
- while (sh != NULL && sh->root.hash == hash
- && strcmp (sh->root.string, name) == 0);
+ for (; sh != NULL; sh = (struct section_hash_entry *) sh->root.next)
+ if (sh->root.hash == hash
+ && strcmp (sh->root.string, name) == 0
+ && (*operation) (abfd, &sh->section, user_storage))
+ return &sh->section;
return NULL;
}
--
Alan Modra
Australia Development Lab, IBM