Difference between revisions of "NaplesPU LLD Linker"

From NaplesPU Documentation
Jump to: navigation, search
(linker)
Line 42: Line 42:
 
To correctly link the different sections, it is also created a [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/scripts.html linker script]. It is located in "/misc/lnkrscrpt.ld". Other then instruct the linker on where the different sections must be located, it also defines the stack starting address for each core thread. the stacks are defined by a starting address and their dimension.  
 
To correctly link the different sections, it is also created a [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/scripts.html linker script]. It is located in "/misc/lnkrscrpt.ld". Other then instruct the linker on where the different sections must be located, it also defines the stack starting address for each core thread. the stacks are defined by a starting address and their dimension.  
 
Note that mclinker does not correctly support the linker script syntax, so the stacks definition for the mclinker liner script is a workaround. A better solution is to define them in the "SECTIONS" section.
 
Note that mclinker does not correctly support the linker script syntax, so the stacks definition for the mclinker liner script is a workaround. A better solution is to define them in the "SECTIONS" section.
 
 
 
  
 
== elf2hex ==
 
== elf2hex ==

Revision as of 12:27, 27 October 2017

When adding a new target architecture to llvm, some changes are required to the tools located in the llvm/tools folder.

llvm-objdump

This is the llvm object file dumper. The full documentation for llvm-objdump is maintained as a Texinfo manual. If the info and llvm-objdump programs are properly installed, the command info llvm-objdump should give you access to the complete manual.

In order to be properly used with the NuPlus architecture the following change is required.

template <class ELFT>
static std::error_code getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
                                                const RelocationRef &RelRef,
                                                SmallVectorImpl<char> &Result) {
  ...
  switch (EF.getHeader()->e_machine) {
  ...
  case ELF::EM_NUPLUS:
    res = Target;
    break;

llvm-readobj

The llvm-readobj tool displays low-level format-specific information about one or more object files. In order to be properly used with the NuPlus architecture the following change is required.

static const EnumEntry<unsigned> ElfMachineType[] = {
  ...
  ENUM_ENT(EM_NUPLUS,        "EM_NUPLUS")

linker

mclinker is the linker used with the LLVM ver. 3.9. However, it is not under active development so we must migrate towards LLD.

The linker main purpose is to link object files in order to generate an executable file. It must resolve symbol names and relocations in order to produce a proper executable.

The nu+ version of mclinker is located in "/compiler/tools". The modifications reside in the "NuPlus" folder at the "mclinker/lib/Target" subdirectory.

The main modifications are the relocations and the scratchpad symbols resolution. The compiler is responsible of emitting these symbols, while the linker must recognize and resolve them by substituting with the correct offset. This is done through a different functions defined in the NuPlusRelocator class. The symbol-function binding is don in the NuPlusRelocationFunctions.h file.

To correctly link the different sections, it is also created a linker script. It is located in "/misc/lnkrscrpt.ld". Other then instruct the linker on where the different sections must be located, it also defines the stack starting address for each core thread. the stacks are defined by a starting address and their dimension. Note that mclinker does not correctly support the linker script syntax, so the stacks definition for the mclinker liner script is a workaround. A better solution is to define them in the "SECTIONS" section.

elf2hex

lldb

TBD