[llvm-dev] Prevent Instruction Fixup from using relocations (original) (raw)

Zhang via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 11 02:43:16 PST 2021


Hi:

I'm trying to build a toy backend that produces code without relocation for my toy ELF loader. For now, my InstructionSelection works as intended and for MCInstLowering, I just lower MO_GlobalAddress operands with the following code:

MCOperand::createExpr(MCSymbolRefExpr::create(getSymbol(MO.getGlobal())))

However the backend still tries to use relocation even when I've set RelocationModel to Reloc::Static. Further debugging shows that in MCAssembler::evaluateFixup, which in turn calls MCExpr::evaluateAsRelocatableImpl, the evaluation failed due to the MCSymbol is not variable. 

That's where I'm lost with what does variable MCSymbol means, where does it come from and what should I do to fix it. Any help would be appreciated.

Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210311/c842f998/attachment.html>



More information about the llvm-dev mailing list