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: Reloc question


Hi Richard,

: Is it better to have a reloc refer to the operand that needs fixing up, or
: to the instruction that contains it?  I'd expected the former, based on
: ports like the i386 and m68hc11.  But it seemed to be generally accepted
: on the cgen list that this was not a good thing in general.  If, for
: example, you have a 2-word instruction with an absolute address in the
: second word, you shouldn't use a standard 32-bit reloc on that operand,
: but instead have a reloc such as BFD_RELOC_2ND_32_BITS_OF_64_BIT_VALUE, or
: similar.

In general I would recommend that the reloc refer to the object that
it is going to modify, rather than the containing construct.  So in
the case you mention, I would make the reloc point at the operand, not
the instruction.  (Remember that relocs can also point to data
objects, and other non-instruction type objects, so it is not always
an operand that is being fixed up).

There are two reasons for my suggestion: simplicity and re-usability.
If the reloc can be expressed in terms of the operand only, then why
involve the whole instruction ?  Similarly, if you keep the reloc
simple, then maybe it can be used for more than one instruction.  A
2ND_32_BITS_OF_64_BIT reloc could not be used where a
32_BITS_OF_128_BITS reloc would be needed, but a 32BIT reloc could be
used in both places.

There are exceptions of course.  If the reloc needs access to the
entire instruction in order to be able to do its job, then the reloc
should point at the start of the instruction.  Keep them as simple as
possible, but not more so.

Cheers
	Nick

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