This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: COFF relocation examples with PUSH, OPERAND and POP functionality
- From: Ian Lance Taylor <ian at airs dot com>
- To: Kerry Keal <kerry at industrialmusic dot com>
- Cc: binutils at sources dot redhat dot com
- Date: 28 Mar 2003 21:25:07 -0800
- Subject: Re: COFF relocation examples with PUSH, OPERAND and POP functionality
- References: <1048881907.2952.22.camel@ih8ms.industrialmusic.com>
Kerry Keal <kerry at industrialmusic dot com> writes:
> I'm working on porting the TI C55x to binutils (
> http://c55x-binutils.sourceforge.net/ ). I was wondering if anyone could
> point me to some examples that have COFF linker commands with PUSH, POP,
> and OPERAND type relocation instructions. For example: the instruction
>
> .global _symbol
> mov #(_symbol & 0xFFFF), AC0
>
> would have 4 relocations for 1 address in the relocation section:
> 1)push the value of _symbol on the stack
> 2)push the constant 0xFFFF on the stack
> 3)replace 2 elements on the stack with the AND operation of those 2
> elements
> 4) pop the value of the stack for the relocation
>
> I'm investigating using the "special_function" in the HOWTO declarations
> to implement this in bfd/coff-tic55x.c. For PUSH and OPERAND type I was
> returning bfd_reloc_ok. For the pop instruction I tried to set the value
> of the symbol and return bfd_reloc_cont but that crashes. So I was
> hoping someone could recommend some good example code.
Don't start with HOWTO structures. Use a relocate_section() function
instead. You only need HOWTO structures to support linking your
object files directly into a different format, and that is not common.
For examples of PUSH, etc., see alpha_relocate_section() in
coff-alpha.c. That is ECOFF, not COFF, but the approach should be
similar.
Ian