[uClibc] ld segfault with -Map option and binutils prior to

Andrew Reusch andrew.reusch at wiline.com
Thu Dec 2 17:06:03 UTC 2004


    Just ran into a problem trying to compile the u-boot bootloader 
using the latest GCC 2.95 toolchain from cvs. The linker, ld, exits 
because of a segfault that is triggered by passing the -Map option. In 
the version of binutils used by the toolchain, in this case, 
a dynamically allocated hash table is accessed after it has been freed 
in the lang_map() function called in ldmain.c.  Doing a little research 
it seems this was picked up and fixed on Jun 14th, 2004. Here is the 
relevant link from the cvsweb for binutils.


The fix just comments out the code that freed the hash table. Since the 
code only executes once memleaks aren't a big deal and from looking at 
the source it seems they wrap malloc and free to implement some sort of 
memory management scheme (maybe they cleanup on exit). This bug was 
fixed after the release of binutils and it could exist prior 
to version but I didn't check. I'm not sure if this is 
helpful to anyone and if it's worth fixing but here is a diff from cvsweb.

RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -r1.153 -r1.154
--- src/ld/ldlang.c 2004/05/29 04:30:41 1.153
+++ src/ld/ldlang.c 2004/06/14 12:46:43 1.154
@@ -3802,7 +3802,8 @@

- bfd_hash_table_free (&lang_definedness_table);
+ /* Don't bfd_hash_table_free (&lang_definedness_table);
+ map file output may result in a call of lang_track_definedness. */

/* This is a small function used when we want to ignore errors from

Link to diff from cvsweb.



More information about the uClibc mailing list