This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Why GNU LD puts ".?tor*" sections into ".text" section when linking a PE image?
- From: Igor Kudrin <ikudrin at accesssoftek dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 29 Nov 2016 14:49:50 +0000
- Subject: Why GNU LD puts ".?tor*" sections into ".text" section when linking a PE image?
- Authentication-results: sourceware.org; auth=none
Hi,
When linking a PE image, LD adds flag IMAGE_SCN_CNT_INITIALIZED_DATA to the section ".text". The size of the section counts twice in the header, in both "SizeOfCode" and "SizeOfInitializedData" fields. All these look quite weird.
As I understand, this behavior comes from adding ".ctor*" and ".dtor*" input sections into the output ".text" section, as it stated in "ld/scripttempl/pep.sc". I tried to move those statements into a ".rdata" section and, at the first glance, the resulting image worked as expected.
Can anybody explain, why ".ctor*" and ".dtor*" sections were added into a ".text" section? Is it safe to move those statements to another place, like a ".rdata" section?
Best regards,
Igor Kudrin