This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: about Reloc Type: BFD_RELOC_8/16/32
- From: Nick Clifton <nickc at redhat dot com>
- To: daniel tian <daniel dot xntian at gmail dot com>
- Cc: binutils at sourceware dot org, peng dot zheng at mavrixtech dot com, vincent dot chen at mavrixtech dot com dot cn
- Date: Tue, 03 Nov 2009 12:07:03 +0000
- Subject: Re: about Reloc Type: BFD_RELOC_8/16/32
- References: <121fadb80910280254g3d66087cg98fa87ba937b9a14@mail.gmail.com> <4AE83204.50906@redhat.com> <121fadb80910290125n7a92ea84r11bcbef268f26503@mail.gmail.com> <4AE96A92.8080604@redhat.com> <121fadb80910300030g56803e67n9b2259d4507db23a@mail.gmail.com>
Hi Daniel,
So I wonder how to deal with the BFD_RELOC_32.
Treat it in the same way as a BFD_RELOC_16, except that the top 16 bits
are zero.
So for example in your assembler source you have:
[...]
.section .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
[...]
.section .debug_info
.4byte 0xb7
.2byte 0x2
.4byte .Ldebug_abbrev0
[...]
Which is generating a 32-bit reloc for the reference to Ldebug_abbrev0:
Relocation section '.rela.debug_info' at offset 0x940 contains 23
entries:
Offset Info Type Sym.Value Sym. Name + Addend
00000006 00000603 R_RICE_32 00000000 .debug_abbrev + 0
This relocation is here because the assembler does not know where the
.Ldebug_abbrev0 symbol will be located at run time. The relocation has
to be a R_RICE_32 because the DWARF2 standard specifies that this field
in the .debug_info header is a 4-byte value.
So in your code in bfd/elf16-rice.c (or whatever filename you have given
to the RICE specific code in the BFD library) you need to handle
R_RICE_32 relocations and insert a 32-bit value into the indicated place
in the output binary.
For this particular example all that the code will have to do is to
lookup the address of the Ldebug_abbrev0 symbol, (it is probably 0x0),
zero-extend this from 16-bits to 32-bits, (you are using a 16-bit
address space aren't you ?) and then store this 32-bit value into bytes
6,7,8 and 9 of the .debug_info section.
Cheers
Nick