Repository navigation
coff: initial rewrite of the COFF/PE linker - #12677
Merged
Merged
Conversation
Maximum number is always 16, and this also unbreaks `dumpbin.exe` run on a simple section-less PE image created with our linker.
I believe this is going to be vital for section headers having names that require the use of a string table.
This is not technically correct, but given that we are not yet able to link against the CRT, it's a good default until then. Add basic logging of generated symbol table in the linker.
Given that COFF will want to support PIC from ground-up, there is no point in leaving outdated code for COFF in other backends such as arm or aarch64. Instead, when we are ready to look into those, we can start figuring out what to add and where.
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.
tl;dr we can correctly link and execute a very crude and hacky program of the form:
This is clearly not a program you'd expect to every see for Windows as we call into a syscall directly, but nonetheless, it was minimal enough just to test some basic assumptions about the PE/COFF structure. Also, for interested,
0x2ccorresponds toNtTerminateProcessin latest Win10 (a word of warning, Microsoft changes those very regularly).In order to simplify working on the incremental COFF linker, I have move all code that deals with LLD into
Coff/lld.zig- this way,Coff.zighas manageable LOCs.Finally, you have hopefully noticed that in the example above I have made
_startthe default entry point for COFF - this is incorrect, andwWinMainCRTStartuporwMainCRTStartup(or any of the million alternatives) are the right way to go, however, for simplicity and for the time being, I will leave it at_start. Once I figure out how to link withntdllin the linker, I will bring it back.