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]

[PATCH] Fix for "ld -r" crash in mingw32


Hello!

This patch fixes segmentation fault in mingw32 linker when it tries to
combine multiple object files into one.  Function
_bfd_XXi_swap_aouthdr_out() calculates the total virtual size by adding
virtual size of sections.  However, some sections don't provide this
information and should not be counted.

There are many other examples in the same file peXXigen.c, when
coff_section_data and pei_section_data are checked for being not NULL
before the virt_size field is accessed.  See functions add_data_entry(),
pe_print_pdata(), _bfd_XX_bfd_copy_private_section_data() in the same
file.

I tried to be consistent with the existing code style.  The code has been
tested with problematic object files.  The problematic object file can be
found here: http://www.red-bean.com/~proski/tmp/crt2.o

To test, run "ld -r -o out.o crt2.o" - it crashes without the patch.

Description of the problem can be found here:
http://sources.redhat.com/ml/binutils/2003-10/msg00189.html

The patch is against the head version in CVS.  I checked the sources and
I'm quite confident that the patch is correct.  Please review and apply.

-- 
Regards,
Pavel Roskin

Attachment: ld-r-crash.diff
Description: Text document


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