Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm-dlltool] Fix renamed imports without a separate regular import entry #98229

Merged
merged 1 commit into from
Jul 16, 2024

Commits on Jul 16, 2024

  1. [llvm-dlltool] Fix renamed imports without a separate regular import …

    …entry
    
    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.
    mstorsjo committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    04ca324 View commit details
    Browse the repository at this point in the history