Embedded Lua as a Linker-Script Replacement

After preprocessing, compilation, and assembler invocation, the linker (e.g. GNU ld or llvm-lld) collects all object files and binds them together into a single executable file. During this process, the linker extracts the sections (e.g. function or variable sections) from each object file, and filters and arranges them into segments, before dumping them to the final executable.

  . = 0x10000;
  .text : { *(.text) }
  . = 0x8000000;
  .data : { *(.data) }
  .bss : { *(.bss) }

This process, the filtering and the arrangement, can be controlled via the linkers "Command Language". Programs written in this language, which is an obscure, implementation-defined domain-specific language, are unexpressive and a pain to write. While linker script is mainly used in embedded systems, where the memory layout most peculiar, the obscurity of linker script make hard to experiment with link-time methods in other contexts as well.

As a way out of this misery, this thesis should explore the usage of Lua as an embedded scripting language. For this, the student should extend the LLVM Linker lld, which is written in C++, with Lua.