27

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.

Seki
  • 11,135
  • 7
  • 46
  • 70
The Big Spark
  • 327
  • 1
  • 4
  • 8

3 Answers3

28

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.

greatwolf
  • 20,287
  • 13
  • 71
  • 105
  • 4
    The above links to the first post in the series. For a list of all the posts, see https://www.airs.com/blog/index.php?s=linkers – Nico Burns Sep 06 '18 at 12:37
26

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

AProgrammer
  • 51,233
  • 8
  • 91
  • 143
5

I second the Linkers and Loaders book. You state that your object format is a custom one. If the format is under your control, you could consider using the ELF format with your bytecode as a new machine architecture, a la x86, SPARC, ARM, etc. The GNU binutils sources are sufficiently malleable to allow you to incorporate your "architecture".

themis
  • 1,047
  • 11
  • 16