]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld/PE: Handle MS style import libraries for files named *.exe too
authorMartin Storsjö <martin@martin.st>
Fri, 6 Sep 2024 13:18:02 +0000 (16:18 +0300)
committerMartin Storsjö <martin@martin.st>
Fri, 22 Nov 2024 10:39:42 +0000 (12:39 +0200)
commit3c557e1ae9c320efcfd4a7a91b752413a7bfd280
treef2dc4ad45a901f2064238def01dfcc1dc27d95d7
parent595e49a4b7c6769ef23a2573148db72872c61935
ld/PE: Handle MS style import libraries for files named *.exe too

When handling MS style import libraries (also called short import
libraries, or ILF), we need to detect the kind of library.

So far, this has been done by looking at the member file names
in the import library - in an MS style import library, all the
member files for a specific library have the same member file
name - the name of the runtime module to link against. Usually
this is a DLL - thus we do a case insensitive comparison and
check if the suffix is .dll.

However, an .exe can also export symbols which can be linked
against in the same way. In particular, if linking against
WDK (Windows Driver Kit) import libraries, e.g. wdmsec.lib, the
import libraries can provide imports for ntoskrnl.exe.

Instead of specifically checking for *.dll (and *.exe, etc),
invert the condition and skip archive members named *.o and *.obj.
For any remaining archive members, that do contain .idata
sections, apply the renaming. (The renaming is also mostly
harmless if applied where it isn't needed; if archive members
already have unique file names, their relative ordering should
remain intact except for very contrieved cases.)

Signed-off-by: Martin Storsjö <martin@martin.st>
ld/emultempl/pe.em
ld/emultempl/pep.em