]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Add support for IMPORT_CONST in ILF (MSVC style) import libraries
authorMartin Storsjö <martin@martin.st>
Sat, 11 Jan 2025 18:42:09 +0000 (20:42 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 15 Jan 2025 21:50:53 +0000 (23:50 +0200)
commitc2fe3b5642e94b6fc2f2a19e54b7d9f447c8a151
tree19ea47d001bcc23e6a4cb5eba7a8f161c837e087
parent1c136b8ee9b9fb402b66957bd51e89e47b94a0f6
Add support for IMPORT_CONST in ILF (MSVC style) import libraries

This is a very strange and obsolete kind of import type; it is
used for imported data just like IMPORT_DATA - but with an extra
odd caveat.

The behaviour is explained at [1]; generating such import libraries
with current MSVC tools produces "warning LNK4087: CONSTANT keyword is
obsolete; use DATA".

While obsolete, some import libraries within the Microsoft WDK (Windows
Driver Kit) do contain such symbols, which currently are ignored by
binutils and produce warnings about "file format not recognized".

For IMPORT_CONST for a DLL exported symbol "foo", we should provide
the import library symbols "__imp_foo" and "foo". For IMPORT_DATA, we
only provide "__imp_foo", and for IMPORT_CODE, "foo" points at a thunk.
The odd/surprising thing for IMPORT_CONST is that the "foo" symbol also
points at the same thing as "__imp_foo", i.e. directly at the IAT
entry.

[1] https://learn.microsoft.com/en-us/cpp/build/importing-using-def-files

Signed-off-by: Martin Storsjö <martin@martin.st>
bfd/peicode.h