[llvm-dev] Quick question: How to BuildMI mov64mi32 arbitrary MMB address to memory (original) (raw)

K Jelesnianski via llvm-dev llvm-dev at lists.llvm.org
Sat Sep 22 11:24:48 PDT 2018


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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180922/f830f042/attachment.html>



More information about the llvm-dev mailing list