Page 1 of 1

Linker

Posted: Mon Nov 07, 2005 12:43 pm
by khc0d
hey!
i want to write linker which makes .exe files.What do you think about it?

Re:Linker

Posted: Mon Nov 07, 2005 1:13 pm
by Candy
khc0d wrote: hey!
i want to write linker which makes .exe files.What do you think about it?
That's a nice idea. You might want to pick up a copy of Aho, Sethi and Ullman's Compilers - Principles, Techniques and Tools and the book Linkers and Loaders (which you can download and print for free, use google).

If you use those two to the letter you should get quite far. Remember that writing a linker is quite hard, complex and can get you debugging for days.

Do you have any experience with the file format you want to use as input or output? Try to understand the format first. Then try to understand all of its details and quirks, think up a nice way to structure the linker and make a hello world input file (whichever type you like). Then, make that part work using the design. If you get this working and the design is good, you can pretty much use it to finish up.

Good luck. Writing a proper linker is a few years of work for somebody who knows how it all should be.

Hint: Try searching for PE and/or COFF exe files, that should give more useful results.

Re:Linker

Posted: Mon Nov 07, 2005 11:47 pm
by khc0d
hey!
yeah,i know format of PE-files. and i am making programm(Exeditor),.it's PE-editor.
And i have "Linkers and loaders". But i have few questions about it.

Re:Linker

Posted: Tue Nov 08, 2005 1:34 am
by Candy
khc0d wrote: yeah,i know format of PE-files. and i am making programm(Exeditor),.it's PE-editor.
Nice. What should it be able to do? Did you design it yet?
And i have "Linkers and loaders". But i have few questions about it.
Then... what are your questions?

Re:Linker

Posted: Tue Nov 08, 2005 8:45 am
by khc0d
Questions: 1).for what we are need in obj-files.

Re:Linker

Posted: Tue Nov 08, 2005 9:05 am
by Solar
For what are object files needed?

Erm...

You know how the translation process works in C, usually? You translate each .c (source) file into an .o (object) file. These are either put together into a linker library, or linked to form an executable / runtime library.

The advantages are that, 1) if you have changed one source file, you only have to re-translate a fraction of the source as compared to when all source files were compiled directly into an executable. And 2), a linker library put together by multiple object files means that the linker has to link in only those object files that are actually needed, instead of all of them.

If that really was your question, though, I doubt that writing a linker is the right project for you...

Re:Linker

Posted: Tue Nov 08, 2005 9:37 am
by khc0d
Hey Solar!Do you can sent me sources of any simply linker?

Re:Linker

Posted: Tue Nov 08, 2005 9:45 am
by Solar
Oi, oi, oi...

1) Source is documentation for compilers, not for people.

2) You just reinforced my impression that writing a linker is at least two leagues over your head. (It's at least one league over my head.)

If you insist, try GNU 'binutils'. It includes 'ld', which is one of the most powerful linkers available.

Re:Linker

Posted: Tue Nov 08, 2005 9:58 am
by khc0d
Solar
Do you write linker???

Re:Linker

Posted: Tue Nov 08, 2005 10:24 am
by Candy
Solar wrote: 2) You just reinforced my impression that writing a linker is at least two leagues over your head. (It's at least one league over my head.)
I can confirm this.

For the record, a league is 4828.03 meters.

Re:Linker

Posted: Wed Nov 09, 2005 12:21 am
by Solar
@ khc0d:

No, I don't write linker.