Who patches the fixups?

Hi,

I am trying to undertand which code in LLVM patches the fixups generated by assembler.

Here is what I am doing: I use “llvm-mc” to compile X86 assembly code, like below:

$ echo “jmp 5000” | ./bin/llvm-mc -assemble -triple=i386 -show-encoding -x86-asm-syntax=att -output-asm-variant=1
.text
jmp 5000 # encoding: [0xeb,A]

fixup A - offset: 1, value: 5000-1, kind: FK_PCRel_1

Now there are fixups in the encoding, and this must be patches by LLVM somewhere. My best guess is that the next phase after assembly compilation will patch them, but not very sure where in LLVM compiler does this.

Any hints on how the compiler patch the fixups after assembler phase? (a pointer to source code is great, so i can read the source and have better understanding)

Thanks,

Jun

What do you mean exactly? The actual machine code is generated by MCCodeEmitter, for example
lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp

The relocations from the object files are applied by the linker, not LLVM.

-Krzysztof

I am trying to undertand which code in LLVM patches the fixups generated
by assembler.

What do you mean exactly? The actual machine code is generated by
MCCodeEmitter, for example
lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp

The relocations from the object files are applied by the linker, not LLVM.

Do you mean the LLVM linker will do the relocation?

Do you have any hints on where to look at linker source of LLVM to see how
this is done?

Thanks.

The lld's git repo is at http://llvm.org/git/lld.git

You can also view the code through the web interface, e.g.
http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/

I don't know the linker sources, so I can't really help with how it works.

-Krzysztof

Do you mean the LLVM linker will do the relocation?

Do you have any hints on where to look at linker source of LLVM to see
how this is done?

The lld's git repo is at http://llvm.org/git/lld.git

You can also view the code through the web interface, e.g.
http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/

Oh, according to
http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/, LLD
only support very few architectures: ARM, ARM64, X86, Mips & Hexagon.
Meanwhile, LLVM has assemblers for many other architectures: SystemZ,
XCore, PPC, Sparc, etc

Does this mean LLD is very much behind LLVM in development?

Thanks.

You can use any linker to link the object files that LLVM generates for your platform, including GNU ld. LLVM is not tied in any way to LLD.

-Krzysztof