This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Option -K in GNU assembler


> From: Nick Clifton <nickc@cambridge.redhat.com>
> Date: 17 Apr 2001 10:11:03 +0100

> Difference tables created by .word directives which are the difference
> between two symbols.  eg:
> 
>         .word foo - bar
> 
> This creates a word which is the difference between the address of
> symbol 'foo' and symbol 'bar'.
> 
> On some systems the implementation of .word cannot handle this
> expression if the difference evaluates to a number that will not fit
> into 16 signed bits.  In such cases the assembler tries to work around
> this by storing the expression as a symbol and allowing the linker to
> sort it out.  (A really horrible hack).

The description how a difference table can change isn't
completely accurate.  (Well, yes this "feature" *is*
horrible. ;-)

The difference tables are here supposed to pointing to code,
like a table for a C switch construct.  For targets not defining
WORKING_DOT_WORD, if a displacement for *any* 16-bits emission
(like the mentioned .word pseudoinstruction on some targets) for
a subtraction expression as above does not fit in 16 bits, the
displacement is changed.  Nothing is left to the linker though;
the assembler changes the displacement to point to entries in a
secondary table located at the end of the first table.  This
secondary table can supposedly be reached with that 16-bit
displacement.  In the secondary table there are jump
instructions to each "foo" label that were in the first table.
See example in gas/testsuite/gas/cris/brokw-3.s.

This feature is considered broken by design by those of us who
believe an assembler should just do an obvious translation to
bits or give errors when it can't.  For an example of badness:
if the assembly code has an error so such a 16-bit expression
does not fit in 16 bits, but it isn't within a switch-table or
equivalent, wrong code will silently be generated.

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]