How to relocate for COFF object files?

Nick Clifton nickc@cambridge.redhat.com
Mon Jun 11 01:52:00 GMT 2001


Hi David,

> That is, I am working similarly to the linker ld.

Why not just use the linker ?  ie why duplicate all the code and
effort that has gone into producing the linker.

> How do bytes needed relocation in object file differ from others?

They are incomplete.  That is they are missing some important
information.  If the bytes are instructions, then the missing
information is usually offsets in the operand fields.  If the bytes
are data then they are usually missing their correct value.

> Do all kind of types need relocation?

Yes.  Well all of the types for a particular architecture.  Each
architecture has its own list of relocations that need to be
supported.  Usually the list is defined by the ABI for the
architecture.

> For the arm-coff case, the value of r_type might be defined in
> coff-arm.c (bintuils/bfd/coff-arm.c) such as ARM_8, ARM_16, ARM_32,
> etc.  Several values is defined in internal.h
> (binutils/include/coff/internal.h) such as R_DIR16, R_DIR32,
> R_IMAGEBASE, R_RELBYTE, R_RELWORD and R_RELLONG, etc. I am confused
> that which class of values indicates the arm-coff r_type. 

The values in the aoutarm_std_reloc_howto[] table in coff-arm.c are
the ones that you need to handle.  The values defined in internal.h
are semi-generic values in that they are are used by more than one
architecture, but not all architectures.

> Is there any place could I find the answer?

Have a look at the documentation in bfd/doc/bfdint.texi.  In
particular there is a section called "BFD relocation handling" which
you ought to read.

Cheers
        Nick



More information about the Binutils mailing list