This is the mail archive of the binutils@sourceware.org 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: PR ld/12730: regression] crash when allocating in a static constructor


On Thu, May 5, 2011 at 1:27 AM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, May 04, 2011 at 10:18:32PM -0700, H.J. Lu wrote:
>> When we put .ctors into .init_array, we have to reverse copy .ctors secton.
>> Otherwise, constructor function may not work with C++ run-time library
>> correctly. ?OK for trunk?
>
> What about .dtors? ?You have the same problem there. ?I suspect, but

You are right.  Here is the updated patch to handle .dtors sections
with the updated testcase.  OK for trunk?

> haven't verified, that .ctors.* and .dtors.* also need reversing. ?If
> that is true then it would be better to do your reversing trick for
> anything going to the .init_array output section that isn't named
> .init_array* and similarly for .fini_array.
>
> You also need to reverse any dynamic relocations applying to the
> sections you are reversing.

It isn't a problem since we apply relocations on the input sections
first and copy relocated input sections to output where I reverse
copy .ctors/.dtors sections if needed.

Thanks.


-- 
H.J.
---
bfd/

2011-05-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12730
	* elflink.c (elf_link_input_bfd): Reverse copy .ctors/.dtors
	sections if needed.

include/

2011-05-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12730
	* bfdlink.h (bfd_link_info): Add reverse_copy_ctors_dtors.

ld/

2011-05-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12730
	* emultempl/elf32.em (gld${EMULATION_NAME}_after_parse): New.
	(ld_${EMULATION_NAME}_emulation): Replace after_parse_default
	with gld${EMULATION_NAME}_after_parse.

ld/testsuite/

2011-05-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12730
	* ld-elf/elf.exp (array_tests): Add pr12730".
	(array_tests_static): Add "static pr12730".

	* ld-elf/init-mixed.c (ctor65535): Renamed to ...
	(ctor65535a): This.
	(ctor65535b): New.
	(ctors65535): Remove ctor65535.  Add ctor65535b and ctor65535a.
	(dtor65535): Renamed to ...
	(dtor65535a): This.
	(dtor65535b): New.
	(dtors65535): Remove dtor65535.  Add dtor65535b and dtor65535a.

	* ld-elf/pr12730.cc: New.
	* ld-elf/pr12730.out: Likewise.

Attachment: binutils-pr12730-2.patch
Description: Text document


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