[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When writing a `elfnn-cpu.c' file, you must do the following:
In the absence of a supplement, it's easier to work with `Rela' relocations. `Rela' relocations will require more space in object files (but not in executables, except when using dynamic linking). However, this is outweighed by the simplicity of addend handling when using `Rela' relocations. With `Rel' relocations, the addend must be stored in the section contents, which makes relocatable links more complex.
For example, consider C code like i = a[1000];
where `a' is
a global array. The instructions which load the value of `a[1000]'
will most likely use a relocation which refers to the symbol
representing `a', with an addend that gives the offset from the
start of `a' to element `1000'. When using `Rel'
relocations, that addend must be stored in the instructions themselves.
If you are adding support for a RISC chip which uses two or more
instructions to load an address, then the addend may not fit in a single
instruction, and will have to be somehow split among the instructions.
This makes linking awkward, particularly when doing a relocatable link
in which the addend may have to be updated. It can be done--the MIPS
ELF support does it--but it should be avoided when possible.
It is possible, though somewhat awkward, to support both `Rel' and `Rela' relocations for a single target; `elf64-mips.c' does it by overriding the relocation reading and writing routines.
You must also add the magic number for this processor to the `prep_headers' function in `elf.c'.
You must also create a header file in the `include/elf' directory called `cpu.h'. This file should define any target specific information which may be needed outside of the BFD code. In particular it should use the `START_RELOC_NUMBERS', `RELOC_NUMBER', `FAKE_RELOC', `EMPTY_RELOC' and `END_RELOC_NUMBERS' macros to create a table mapping the number used to identify a relocation to a name describing that relocation.
While not a BFD component, you probably also want to make the binutils
program `readelf' parse your ELF objects. For this, you need to add
code for EM_cpu
as appropriate in `binutils/readelf.c'.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |