Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make recent MSVC linkers to merge import data with the .rdata section?

In recent years, my observation has been that MSVC linkers up to version 11 (Visual Studio 2012, _MSVC_VER 1700) merged the import data table with the .rdata section by default. Starting with version 12 of the linker (Visual Studio 2013, _MSVC_VER 1800), this table was then moved to the independent section .idata. My attempts to get these newer linkers to continue merging the import data with .rdata were unsuccessful (e.g. the option /merge:.idata=.rdata led to the error message fatal error LNK1272: cannot merge '.idata' with any section).

By chance I came across the executable files of PySide2 (version 5.13.0), which were apparently created with the linker version 14.15, but which merged the import table with .rdata again. This astonished me very much and now I ask myself:

How do I get recent MSVC linkers to merge the import tables with .rdata?

BTW: This is not about the solution of any problem. I'm just curious.

like image 780
RoMa Avatar asked Oct 26 '25 21:10

RoMa


1 Answers

It seems that I myself contributed to my confusion: A long time ago I had started to build all my projects with the /merge:.rdata=.text switch. And it is exactly this switch that is now treated differently. With older linkers the import table was merged with .rdata first. Then the /merge:.rdata=.text switch could still merge .rdata with .text. With newer linkers the switch /merge:.rdata=.text seems to be processed first. When the linker then searches for a storage location for the import table, .rdata no longer exists. Then the section .idata has to be created for this table.

Disclaimer: I have no 'proof' for this. These are just my conclusions from my observations.

like image 138
RoMa Avatar answered Oct 29 '25 14:10

RoMa