This is the mail archive of the
mailing list for the binutils project.
Re: Computing .long .L123-.L100
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: binutils at sources dot redhat dot com
- Date: 21 Jan 2004 19:24:56 -0500
- Subject: Re: Computing .long .L123-.L100
- References: <firstname.lastname@example.org>
Kazu Hirata <email@example.com> writes:
> I have a question about computing the difference of two labels at
> assembly time. Does gas/tc-<target>.c have to do something special?
> I thought defining DIFF_EXPR_OK would do the job, but it doesn't seem
You don't really need to define DIFF_EXPR_OK merely to compute the
difference of two labels. gas will attempt to do that for you in all
cases. DIFF_EXPR_OK really means that it's OK for gas to generate a
relocation for something like `foo - .'.
> Is a difference of two labels computed as soon as the values of both
> labels become available?
Well, it depends, but, in general, if both labels are in the same
frag, gas will reduce the subtraction immediately. Note that this is
somewhat arbitrary, and in particular will generally not be the case
when producing a listing.
> While assembling the following piece of code
> on sh-elf, which does support the difference of two labels, I found
> that the value of .L3-.L9 seems to be computed from colon () in
I'm not really sure what you mean here. I would expect the colon()
function to define the label's value, not to do any computation.
> Another related question is that sh_cons_fix_new() outputs a reloc for
> .long .L3-.L9., but the disassembly of the resulting object file does
> not contain the reloc anymore. Where is such a reloc deleted?
In gas terminology, sh_cons_fix_new() generates a fixup. Some fixups
are then computed by fixup_segment(). Others are passed to
tc_gen_reloc() to generate a reloc.