This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix pe-dll.c segmentation fault with undefined export.


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

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]