[LLVMdev] Adding fixups and relocations late in code generation

Carter, Jack jcarter at mips.com
Mon Oct 10 11:41:18 PDT 2011


Jim,

Both the branch and the branch target are in the same function. This is known delta and should not matter where it is relocated because the delta will remain the same once it is a .o or later.

I just want to know how to tell the compiler that this expression is target offset - branch offset.

More generally, I want to know the rules for setting up expressions in general. I have no idea if one uses post fix, in fix or pre fix. How does one layer different relocations? This will really come in to play for embedded assembler where the gentle user can be as perverse as they want with expressions, resulting with possibly multiple relocations and an immediate for a given instruction operand.

Is expression layering described in the documentation anywhere?

Cheers,

Jack
________________________________________
>
> Later in MipsAsmBackend.cpp:ApplyFixup() I find the value is the offset
> of the target value from the beginning of the section and not the delta
> from the branch address.
>

I'm not sure I follow. Wouldn't that still require a relocation from the start of the section?

> I also get a relocation request even though the label should be
> resolved.
>

The logic for which cases are considered resolved and which require relocations is in MCAssembler::EvaluateFixup(). It's currently not factored all that well, with some target-specific knowledge embedded in the generic code. It's entirely possible we need to create a target hook there to handle any special cases.





More information about the llvm-dev mailing list