Linker

Programming, for all ages and all languages.
Post Reply
khc0d

Linker

Post by khc0d »

hey!
i want to write linker which makes .exe files.What do you think about it?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Linker

Post 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.
khc0d

Re:Linker

Post 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.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Linker

Post 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?
khc0d

Re:Linker

Post by khc0d »

Questions: 1).for what we are need in obj-files.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Linker

Post 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...
Every good solution is obvious once you've found it.
khc0d

Re:Linker

Post by khc0d »

Hey Solar!Do you can sent me sources of any simply linker?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Linker

Post 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.
Every good solution is obvious once you've found it.
khc0d

Re:Linker

Post by khc0d »

Solar
Do you write linker???
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Linker

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Linker

Post by Solar »

@ khc0d:

No, I don't write linker.
Every good solution is obvious once you've found it.
Post Reply