[all-commits] [llvm/llvm-project] f2d6d7: [llvm-dlltool] Fix renamed imports without a separ...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Tue Jul 16 13:20:01 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f2d6d74cd2a8dccc5ec47bb5debb003e06249db3
      https://github.com/llvm/llvm-project/commit/f2d6d74cd2a8dccc5ec47bb5debb003e06249db3
  Author: Martin Storsjö <martin at martin.st>
  Date:   2024-07-16 (Tue, 16 Jul 2024)

  Changed paths:
    M lld/test/COFF/lib.test
    M llvm/include/llvm/Object/COFFImportFile.h
    M llvm/lib/Object/COFFImportFile.cpp
    M llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
    M llvm/test/tools/llvm-dlltool/coff-decorated.def
    M llvm/test/tools/llvm-dlltool/coff-weak-exports.def
    A llvm/test/tools/llvm-dlltool/renaming.def

  Log Message:
  -----------
  [llvm-dlltool] Fix renamed imports without a separate regular import entry (#98229)

Normally, when doing renamed imports, we do this by providing a
weak alias, towards another regular import, for the symbol we
want to actually import. In a def file, this looks like this:

    regularfunc
    renamedfunc == regularfunc

However, if we want to link against a function in a DLL, where we
(intentionally) don't provide a regular import for that symbol
with the name in its DLL, doing the renamed import with a weak
alias doesn't work, as there's no symbol that the weak alias can
point towards.

We can't make up such an import either, as we may intentionally
not want to provide a regular import for that name.

This situation can either be resolved by using the "long" import
library format (as e.g. produced by GNU dlltool), or by using the
new short import library name type "export as".

This patch implements it by using the "export as" name type.

When producing a renamed import, defer emitting it until all regular
imports have been produced. If the renamed import refers to a
symbol that does exist as a regular import entry, produce a
weak alias, just as before. (This implementation also avoids needing
to know whether the symbol that the alias points towards actually
is prefixed or not, too.)

If the renamed import points at a symbol that isn't otherwise
available (or is available as a renamed symbol itself), generate
an "export as" import entry.

This name type is new, and is normally used in ARM64EC import
libraries, but can also be used for other architectures.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list