[LLVMdev] MCFixup for distance from instruction to end of .text section

Eric Christopher echristo at gmail.com
Mon Jul 14 19:17:16 PDT 2014


On Sun, Jul 13, 2014 at 12:55 AM, Tim Northover <t.p.northover at gmail.com> wrote:
> Hi Tom,
>
> On 12 July 2014 22:52, Tom Stellard <tom at stellard.net> wrote:
>> I would like to use a MCFixup to encode the distance in number of bytes
>> from an instruction to the end of the .text section.  Is there an
>> existing MCFixup type I can use for this?  If not, does anyone have any
>> suggestions for how to add a new MCFixup type that will do this?
>
> If that end-point is going to be resolved at compile-time, I think
> we'd usually create a dummy (local) label and then emit it at the
> correct place; you'd probably just need a generic FK_PCRel_N fixup.
>
> Otherwise, it's probably a target-specific FixupKind that gets emitted
> as a relocation and some assembly syntax that you make up. I suppose
> you could do the same trick with a real symbol and demand that the
> linker defines it (similar to how "_GLOBAL_OFFSET_TABLE_" gets
> defined, for example).
>

In addition to what Tim has said I'm curious why you need or want to
do it at that time? Can you describe more of your aims/goals/etc with
this? I'd probably just set up a temporary for the end of the text
section and make sure it's emitted (take a look at what debug info
does here ;) and then just use subtraction for the expression.

-eric



More information about the llvm-dev mailing list