Why GNU LD puts ".?tor*" sections into ".text" section when linking a PE image?
Igor Kudrin
ikudrin@accesssoftek.com
Tue Nov 29 14:51:00 GMT 2016
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
More information about the Binutils
mailing list