This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: about Reloc Type: BFD_RELOC_8/16/32


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


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