This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [Patch] Fix pe-dll.c segmentation fault with undefined export.
- From: Christopher Faylor <cgf at redhat dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Wed, 25 Feb 2004 10:01:03 -0500
- Subject: Re: [Patch] Fix pe-dll.c segmentation fault with undefined export.
- References: <20040225093526.19028.qmail@web61002.mail.yahoo.com>
On Wed, Feb 25, 2004 at 08:35:26PM +1100, Danny Smith wrote:
> --- Danny Smith wrote: >
>
>Sorry for empty message.
>Here is the bug report and patch.
>
>
>The following testcase cause a segmentation fault in ld
>on mingw32.
>
>/* clib.def */
>LIBRARY clib.dll
>EXPORTS
>i @ 1 ;
>j @ 2 ;
>
>
>/* clib.c */
>int i = 1;
>/* int j = 1; */
>
>gcc -shared -oclib.dll clib.def clib.c
>results in
>"ld.exe caused an Access Violation at location 0042e527 in module ld.exe."
>
>
>The crash can be prevented by checking for a null pointer
>in pe-dll.c (fill_edata). With the following patch I get the
>correct error message, rather than a segfault:
>
>"Cannot export j: symbol not defined":
>
>
>2004-02-25 Danny Smith <dannysmith@users.sourceforge.net>
>
> * pe-dll.c (fill_edata): Check that exported_symbol_sections is
> not NULL.
Looks pretty safe to me. I think it's fine to check in.
cgf
>Index: pe-dll.c
>===================================================================
>RCS file: /cvs/src/src/ld/pe-dll.c,v
>retrieving revision 1.66
>diff -c -3 -p -r1.66 pe-dll.c
>*** pe-dll.c 20 Jan 2004 21:08:16 -0000 1.66
>--- pe-dll.c 25 Feb 2004 09:25:10 -0000
>*************** fill_edata (bfd *abfd, struct bfd_link_i
>*** 964,974 ****
> http://sources.redhat.com/ml/binutils/2003-04/msg00379.html
> for more information. */
> hint = 0;
> for (s = 0; s < NE; s++)
> {
>! if (pe_def_file->exports[s].ordinal != -1)
> {
>- struct bfd_section *ssec = exported_symbol_sections[s];
> unsigned long srva = (exported_symbol_offsets[s]
> + ssec->output_section->vma
> + ssec->output_offset);
>--- 964,975 ----
> http://sources.redhat.com/ml/binutils/2003-04/msg00379.html
> for more information. */
> hint = 0;
>+
> for (s = 0; s < NE; s++)
> {
>! struct bfd_section *ssec = exported_symbol_sections[s];
>! if (ssec && pe_def_file->exports[s].ordinal != -1)
> {
> unsigned long srva = (exported_symbol_offsets[s]
> + ssec->output_section->vma
> + ssec->output_offset);
>
>Find local movie times and trailers on Yahoo! Movies.
>http://au.movies.yahoo.com