This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Prevent ld segementation fault
- From: Martin Koegler <mkoegler at auto dot tuwien dot ac dot at>
- To: binutils at sources dot redhat dot com
- Date: Thu, 16 Dec 2004 11:42:56 +0100
- Subject: [PATCH] Prevent ld segementation fault
vfinfo (ldmisc.c) assumes that for %B a valid bfd handle is passed as parameter.
If the bfd handle is NULL, it will segfault.
reloc_overflow (ldmain.c) passes the content of entry->u.def.section->owner
to vfinfo to be printed with %B. If the entry is in the absolute section *ABS*,
it has no associated bfd. Therefore ld will produce an segmentation fault.
Can something like the following patch be applied to the CVS?
(All it does, is to print a default value, if abfd is NULL).
Or is there a better solution to fix this problem?
Index: ldmisc.c
===================================================================
RCS file: /cvs/src/src/ld/ldmisc.c,v
retrieving revision 1.20
diff -u -r1.20 ldmisc.c
--- ldmisc.c 13 Aug 2004 03:16:01 -0000 1.20
+++ ldmisc.c 16 Dec 2004 10:21:46 -0000
@@ -188,7 +188,9 @@
/* filename from a bfd */
{
bfd *abfd = va_arg (arg, bfd *);
- if (abfd->my_archive)
+ if (abfd == NULL)
+ fprintf (fp, "<none>");
+ else if (abfd->my_archive)
fprintf (fp, "%s(%s)", abfd->my_archive->filename,
abfd->filename);
else
mfg Martin Kögler
e9925248@stud4.tuwien.ac.at