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: bfd_get_relocated_section_contents on hppa and ia64


Hi Camm,

$ cat /tmp/hh.c
#include<stdio.h>

int main(int argc,char *argv[]) {
   printf("hello\n");
   return 0;
}

Target: i486-linux-gnu

$ ./binutils/readelf -R .text /tmp/hh.o

Hex dump of section '.text':
   0x00000000 5589e583 e4f083ec 10c70424 00000000 U..........$....
   0x00000010 e8ebffff ffb80000 0000c9c3          ............

Ah ha! You have chosen a target architecture which just happens not use a special reloc to handle function calls. If you have a look at the relocs in the hh.o file:


  % readelf -r hh.o
  Relocation section '.rel.text' at offset 0x340 contains 2 entries:
   Offset     Info    Type            Sym.Value  Sym. Name
  0000000c  00000501 R_386_32          00000000   .rodata
  00000011  00000902 R_386_PC32        00000000   puts

You will see that it only uses the R_386_32 (a 32-bit fixed-location reloc) and the R_386_PC32 (32-bit PC-relative) relocs. Both of which readelf implements because it can find them in debug sections.

If you try compiling your test program for a different architecture, say the IA64, then:

% ia64-elf-gcc -c hh.c
% ia64-elf-readelf -R .text hh.o
Hex dump of section '.text':
readelf: Warning: unable to apply unsupported reloc type 134 to section .text
readelf: Warning: unable to apply unsupported reloc type 135 to section .text
readelf: Warning: unable to apply unsupported reloc type 73 to section .text
0x00000000 00181d0c 80054002 30004280 0167fc8c ......@.0.B..g..


Or the HPPA:

% hppa-linux-gnu-gcc -c hh.c
% hppa-linux-gnu-readelf -R .text hh.o
Hex dump of section '.text':
readelf: Warning: unable to apply unsupported reloc type 2 to section .text
readelf: Warning: unable to apply unsupported reloc type 6 to section .text
readelf: Warning: unable to apply unsupported reloc type 12 to section .text
0x00000000 6bc23fd9 08030241 081e0243 6fc10080 k.?....A...Co...


Cheers
  Nick


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