Skip to content

Using /WHOLEARCHIVE on a COFF import library with an MSVC linker fails to link #19

Closed
@ChrisDenton

Description

@ChrisDenton

Every COFF import library has a special object file containing the null import descriptor. This is exactly the same between import libraries, which causes a conflict if using /WHOLEARCHIVE.

The fact that it's exactly the same does however allow for a possible fix: add a COMDAT record to the special .idata$3 section so it behaves as if it's still in a library even if all objects are forced to be included. The downside would be that import libraries generated by this crate would no longer be byte-for-byte the same as LLVM import libraries.

Pseudo code:

// Placed before the `__NULL_IMPORT_DESCRIPTOR` in the COFF symbol table
ImageSymbol {
    name: *b".idata$3",
    section_number: 1,
    storage_class: IMAGE_SYM_CLASS_STATIC,
    number_of_aux_symbols: 1,
    ...
};
ImageAuxSymbolSection {
    length: mem::size_of::<ImageImportDescriptor>(),
    selection: IMAGE_COMDAT_SELECT_ANY,
    ...
};

cc @dpaoliello

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions