* [PATCH] Prevent ld segementation fault
@ 2004-12-16 10:43 Martin Koegler
2004-12-16 15:42 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Martin Koegler @ 2004-12-16 10:43 UTC (permalink / raw)
To: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Prevent ld segementation fault
2004-12-16 10:43 [PATCH] Prevent ld segementation fault Martin Koegler
@ 2004-12-16 15:42 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2004-12-16 15:42 UTC (permalink / raw)
To: Martin Koegler; +Cc: binutils
Hi Martin,
> Can something like the following patch be applied to the CVS?
> (All it does, is to print a default value, if abfd is NULL).
Yes it can and in fact yes it has been.
> Or is there a better solution to fix this problem?
In theory users of vinfo() should check before passing a NULL BFD, but
that is no reason for vinfo() itself not being able to cope gracefully
with the problem.
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-12-16 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-16 10:43 [PATCH] Prevent ld segementation fault Martin Koegler
2004-12-16 15:42 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).