On Sun, 13 Nov 2022, Pali Rohár wrote:

Anyway, there are other bloatware parts which are statically linked into
every .exe / .dll binary and which in most cases are not needed. But
elimination of them probably would be possible only for LTO builds.

I have looked into one such case a couple years ago - the code for handling pseudo relocations gets linked into all binaries, even if the binaries don't actually need any pseudo relocations.

If we could get rid of that, we could get rid of ~3 KB of code, and the two imports of VirtualProtect and VirtualQuery.

Unfortunately, to make that happen, the linker would need to actively pull in the code for the pseudo reloc handling, if the linker does generate pseudo relocs. Current lld doesn't do this. Current binutils ld.bfd does have code that seems to try to do this, but it doesn't work. (Binutils does try to reference _pei386_runtime_relocator, in order to pull it in, but if the symbol wasn't already included, it just flat out fails to link.) I do have a patch for lld that would implement it on that side though.

So in order to proceed with that debloating, we would need to fix binutils ld to successfully pull in the pseudo reloc code when it already hasn't been included, and upstream the lld patch. Then after that, we'd need to wait for these linker versions to become commonly available, and break support for any older versions of the linkers, in order to actually do the debloating.

So going ahead with that is rather problematic in practice, unfortunately. But it would give nice gains, and it would be nice for cleanliness to avoid needing to reference VirtualProtect and VirtualQuery.

// Martin


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to