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

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


Hi,

    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 2.14.90.0.7, 
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.

http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/ldlang.c?rev=1.154&content-type=text/x-cvsweb-markup&cvsroot=src&only_with_tag=MAIN 


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 2.15.91.0.1 and it could exist prior 
to version 2.14.90.0.7 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.

http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&only_with_tag=MAIN&r1=text&tr1=1.153&r2=text&tr2=1.154&f=u

regards,
Andrew




More information about the uClibc mailing list