Repository navigation
coff split: let the linker regenerate a PE import table - #12
Merged
Merged
Conversation
A module with `generate_imports: true` gets its import directory from the linker instead of carrying the original's bytes. The split reads the original import directory back into: - imports.lib: a COFF archive of short-format import objects, one per imported function, with the original hint and imported name (IMPORT_OBJECT_NAME_EXPORTAS) or ordinal. All are DATA imports, so the linker defines only __imp_<symbol>; the image's own jmp stubs come from the split objects. - imports.order: the layout link.exe gave the tables, for a vc6-aware lld-link's /vc6imports: (descriptor order, IAT slot order, the hint/name area with the DLL names, and incremental-link padding). args.rsp passes both. The IAT slots must be named __imp_ in the symbols, and the splits must leave the original .idata$N out of the linked units.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
generate_importsmodule option: the linker builds the image's import directory instead of the split objects carrying the original's bytes. Needs openblack/llvm-project#4 for/vc6imports:.What the split writes (read back from the original import directory)
imports.lib: a COFF archive of short-format import objects, one per imported function.IMPORT_OBJECT_NAME_EXPORTAS), or the ordinal.__imp_<symbol>. The image's ownjmp [__imp_X]stubs stay in the split objects, where link.exe put them.imports.order: the layout link.exe gave the tables. link.exe 6 ordered them by its library-search order, which can't be redone without the original import libraries:padlines for the zero padding an incremental link leaves after each DLL's entries, or that the splits'.idata$5covers past the IAT.args.rsp: passes the library and/vc6imports:<order>.Requirements
__imp_…in the symbols..idata$Nout of the linked units; bw1-decomp holds those units back.Testing
cargo test: 36 pass, including new tests for the import objects, the archive's symbol table and member offsets, the order file, and both kinds of padding.build.sha1hashes match.🤖 Generated with Claude Code