On Sat, 8 Mar 2025, LIU Hao wrote: > 在 2025-3-8 10:23, Jeremy Drake via Mingw-w64-public 写道: > > > This patch unfortunately does a few different things at this point: > > > * moves delay load directory table into .didat$2 section, and puts this > > > into .idata(!) > > > * fills in the delay import descriptor table data directory entry > > I didn't add it because I am uncertain whether it is needed. > > btw, in the case of MSVC, `.idata` only exists in libraries; it seems to be > merged into `.rdata` before the final output. Therefore, all these data other > than the delay IAT should be put into `.rdata`.
In mingw-w64 code it is at least needed for __HrLoadAllImportsForDll. In the Windows implementation, who knows but I bet they look at the directory for something (at least for their ResolveDelayLoadsFromDll, and probably to know what pages/section to change protection on on image load). > > > * fills in the load config table data directory entry if _load_config_used > > > is present (it isn't unless it's actually referenced by an object) > > Oh thank you. I didn't know how to calculate the size of the load config > directory. LLD gets it from the first 4 bytes (little endian) at the _load_config_used symbol. The docs say this is supposed to be Characteristics, but when docs disagree with code, trust the code. > > > I'm not at all convinced that your initial idea to put all of the delay > > > load stuff into the new .didat section isn't the way to go. It seemed to > > > me like only the IAT needed to go in the section where its protection > > > changed. The module handle is still in .data, do you think it was > > > intended to put that in .didat also so it also gets write protected? The > > > docs do say: > > > Delayload import table in its own .didat section (with nothing else in it) > > > that can be freely reprotected. > > As said above, ideally all the pieces in `.idata` and `.didat`, other than > `.didat$5`, should be put into `.rdata` and not entire new sections on their > own. I previously attempted to move `R_IDATA` etc. into `.rdata` but the > program crashed upon startup. Interesting, I could try that but probably not until Monday. > > @@ -61,6 +63,7 @@ > > R_IDATA234= > > R_IDATA5= > > R_IDATA67= > > + R_DIDAT5= > > R_CRT_XC= > > R_CRT_XI= > > R_CRT_XL= > > You probably also need `R_DIDAT2=` here, in both 'ld/scripttempl/pe.sc' and > 'ld/scripttempl/pep.sc'. Thanks, I missed that. _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public