Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a linker

Tags:

I have written a compiler for C that outputs byte code. The reason for this was to be able to write applications for an embedded platform that runs on multiple platforms.

I have the compiler and the assembler.

I need to write a linker, and am stuck.

The object format is a custom one, designed around the byte code interpreter, so I cant really use any existing linkers.

My biggest hurdle is how to organize the object code to output the linked binary. Dynamic linking is not necessary, at this time. I need to get static linking working first.

like image 430
The Big Spark Avatar asked Oct 21 '09 19:10

The Big Spark


People also ask

What is linker with example?

Linkers are words or phrases that we use to link (i.e. connect or join) ideas. It was raining. I stayed at home. In this example, we can see that the first idea, 'It was raining. ' is the reason for the second idea, 'I stayed at home.

What is linker in simple words?

In computing, a linker or link editor is a computer system program that takes one or more object files (generated by a compiler or an assembler) and combines them into a single executable file, library file, or another "object" file.

What is a linker and how does it work?

In computer science, a linker is a computer program that takes one or more object files generated by a compiler and combines them into one, executable program. Computer programs are usually made up of multiple modules that span separate object files, each being a compiled computer program.


2 Answers

Ian Lance Taylor, one of the main developers on the gold linker(now part of binutils), posted a series of blogs on how linkers work. You can find it here.

like image 127
greatwolf Avatar answered Sep 24 '22 22:09

greatwolf


http://linker.iecc.com is the only book I know about this subject.

like image 20
AProgrammer Avatar answered Sep 24 '22 22:09

AProgrammer