Dear All,
I am working on a x86 backend machineFunction pass, where I am trying to save the hard coded address of an arbitrary machine basic block to memory in ASM. I know the assembly needed for this but am lost at how to construct the BuildMI().
Note that these machine basic blocks are not entry’s to a function. but in the middle of the function. so using addGlobalAddress or addExternalSymbol are no use to me and am trying to avoid having to make a separate jump table section. Is a jump table section with symbols associated with these new basic blocks the only option?
In x86 assembly this would look something like:
MOVQ 0x40044540, 0x8(%rsp) # Store address of trampoline basic block to stack
The BuildMI looks like:
BuildMI(MBB, MBIt, DL, TII->get(X86::MOV64mi32))
.addImm(0x1) // Scale
.addReg(X86::RSP) // Base
.addImm(0x8) // Disp
.addMBB(my_target_mbb); // Source
So far I have looked into the BuildMI API of LLVM and the only one that looks relevant is addMBB. While my LLVM pass compiles, my linker complains (and note that I am compiling with -fPIC):
/usr/bin/ld: /tmp/foo-d523b6.o: Unknown temporary symbol
or 2)
/usr/bin/ld: /tmp/foo-d523b6.o: relocation R_X86_64_32S against `.text’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
Any suggestions? Much appreciated for taking a look!
Sincerely,
K Jelesnianski