While porting Linux to the Fujitsu RISC I observed that pointers within a structure were not initialized with the right addresses. After some investigation it boiled down to the linker. Following testcase shows the problem. foo.s: .globl foo .data .p2align 2 .type foo, @object .size foo, 8 foo: .word 286331153 .word foo+4 .word foo+4 .word -1 .globl bar .data .p2align 2 .type bar, @object .size bar, 40 bar: .word 286331153 .word bar+4 .word bar+4 .word -1 assembled with: bash-2.05b$ fr30-elf-as foo.s -o foo.o and linked with: bash-2.05b$ fr30-elf-ld -t -stats foo.o fr30-elf-ld: mode elf32fr30 foo.o fr30-elf-ld: warning: cannot find entry symbol _start; defaulting to 00010000 What I would expect is: a2.out 00001000: 11111111 foo 00001004: 00010004 00001008: 00010004 0000100c: ffffffff 00001010: 11111111 bar 00001014: 00010014 < 00001018: 00010014 < 0000101c: ffffffff But what I get is: a.out 00001000: 11111111 foo 00001004: 00010004 00001008: 00010004 0000100c: ffffffff 00001010: 11111111 bar 00001014: 00010024 < 00001018: 00010024 < 0000101c: ffffffff
Created attachment 2183 [details] testcase
Created attachment 2184 [details] assembler output
Created attachment 2185 [details] linker output
For a2.out I removed h->root.u.def.value *** /fme/users/mhaigl/essen-gcc/binutils-2.18/bfd/elf-bfd.h 2008-01-08 14:36:57.000000000 +0100 --- /fme/users/mhaigl/cross/binutils-2.18/bfd/elf-bfd.h 2007-08-06 21:59:22.000000000 +0200 *************** extern bfd_boolean _sh_elf_set_mach_from *** 2096,2102 **** library. */ \ unresolved_reloc = TRUE; \ else \ ! relocation = ( \ + sec->output_section->vma \ + sec->output_offset); \ } \ --- 2096,2102 ---- library. */ \ unresolved_reloc = TRUE; \ else \ ! relocation = (h->root.u.def.value \ + sec->output_section->vma \ + sec->output_offset); \ } \ This helped to produce the right adresses for the testcase, but altough I do not know much about the linker I am pretty sure that this will break almost everything else. So this is only a hint where it goes wrong.
The assembler output is already broken. foo.o: file format elf32-fr30 RELOCATION RECORDS FOR [.data]: OFFSET TYPE VALUE 00000004 R_FR30_32 foo+0x00000004 00000008 R_FR30_32 foo+0x00000004 00000014 R_FR30_32 bar+0x00000014 00000018 R_FR30_32 bar+0x00000014 ^^
So should this one be moved to gas or should I open a new one and we close this bug?
Created attachment 2191 [details] Set partial_inplace to FALSE for FR30 relocs
Hi Markus, This was a problem with the reloc descriptions in the elf32-fr30.c file - they had the partial_inplace field set to TRUE which is the wrong thing to do for ports which use RELA type relocs. I have applied the uploaded patch to fix this. Cheers Nick bfd/ChangeLog PR gas/5552 * elf32-fr30.c (fr30_elf_howto_table): Set partial_inplace field to FALSE for all relocs.