Optlink is on github

Daniel Murphy yebblies at nospamgmail.com
Thu Mar 7 04:35:52 PST 2013


"Walter Bright" <newshound2 at digitalmars.com> wrote in message 
news:kh8q9e$2j02$1 at digitalmars.com...
> Some months ago, I did make the source to optlink available on github:
>
> https://github.com/DigitalMars/optlink
>
[snip]
>
> So, what I do, is look at the asm code where the seg fault occurs, and 
> then grep through the asm source till I find it.
>

Maybe I'm missing something, but I don't understand why this is necessary. 
It should be trivial to look at the map file for the closest preceding 
label.  On modern toolchains it should even be possible to compile the asm 
with debug line information.  Or is grepping more effective than it sounds?

> 2. Convert the source file where the seg fault occurs to C. I do this one 
> function at a time, running the full set of tests at each step. Otherwise, 
> it's just impossible to figure out where you made a mistake in the 
> conversion. Sometimes, you gotta go even finer grained - using the inline 
> assembler feature of dmc to convert asm code line by line.
>
> You gotta pay very, very close attention to which registers have 
> parameters passed through them, which registers are saved, and which 
> registers have parameters that are silently passed through a function to 
> callees of that function (!). This information is all pretty much utterly 
> lacking in the comments, and the comments are often dead wrong as they 
> refer to much older versions of the code.
>

This sounds completely insane. (But also fun, in an extremely frustrating 
way)
I suspect it would be easier to reverse-engineer microsoft's (or borland's?) 
old linker from the disassembly, if they wrote it in C.

> 3. Once it is in C, things get a lot easier. You can, for example, insert 
> printf's to figure out where things go wrong, and *then* fix it.
>
>
> The full test suite for optlink has a lot of stuff I cannot publish on 
> github. However, what you can do is run the win32 tests for dmd. I, of 
> course, will run the full one when verifying pulls.
>
> Happy hacking!

As a side note I actually wrote an omf (dmd-emitted subset) linker last year 
that gets through almost all of the dmd test suite.  It has no debug info 
support, which sucks, but it may work in some cases where optlink can't 
cope.  It is fairly naive performance-wise, but is written in a much 
friendlier language.

If anyone is interested I'll put it up on github. 




More information about the Digitalmars-d mailing list