This is the mail archive of the binutils@sources.redhat.com 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]

SHT_RELA sections produced by gas: addend badly specified?


I have noticed that the addend of relocation records of object files produced by gas
(at least for the sh-linux-elf target) are specified in the relocatable field rather than
in the relocation record of the SHT_RELA section.


My understanding of the ELF specification is that the addend should rather be specified
in the relocation record.


Note: you will find some materials to test binutils with below the 'Questions' section.

Questions:

   * is my understanding of ELF correct?
   * is it a known bug of binutils?
   * are the fixupS properly created in gas?
   * where should I look at if we have to fix them?

Many thanks,
Cedric

Materials:

I have configured and built the source snapshot 2.13.92 for the sh-linux-elf target.

I have a simple C file to compile:

int FirstFunction (int a) {
return a;
}
static int Function (int a) {
return a;
}
int entry (int argc, char **argv) {
FirstFunction (argc); // will produce an abs. reloc against _FirstFunction
return Function (argc); // will produce an abs. reloc against .text
}


I am compiling with gcc 2.95.3, the assembly that it produces is the following:

.file "simple_c_file.c"
gcc2_compiled.:
.text
.align 2
.global _FirstFunction
.type _FirstFunction,@function
_FirstFunction:
mov.l r14,@-r15
add #-4,r15
mov r15,r14
mov.l r4,@r14
mov.l @r14,r1
mov r1,r0
bra .L2
nop
.align 2
.L2:
add #4,r14
mov r14,r15
mov.l @r15+,r14
rts
nop
.Lfe1:
.size _FirstFunction,.Lfe1-_FirstFunction
.align 2
.type _Function,@function
_Function:
mov.l r14,@-r15
add #-4,r15
mov r15,r14
mov.l r4,@r14
mov.l @r14,r1
mov r1,r0
bra .L3
nop
.align 2
.L3:
add #4,r14
mov r14,r15
mov.l @r15+,r14
rts
nop
.Lfe2:
.size _Function,.Lfe2-_Function
.align 2
.global _entry
.type _entry,@function
_entry:
mov.l r8,@-r15
mov.l r14,@-r15
sts.l pr,@-r15
add #-8,r15
mov r15,r14
mov.l r4,@r14
mov.l r5,@(4,r14)
mov r15,r1
mov.l @r14,r4
mov.l .L5,r8
jsr @r8
nop
mov r15,r1
mov.l @r14,r4
mov.l .L6,r8
jsr @r8
nop
mov r0,r1
mov r1,r0
bra .L4
nop
.align 2
.L4:
add #8,r14
mov r14,r15
lds.l @r15+,pr
mov.l @r15+,r14
mov.l @r15+,r8
rts
nop
.L7:
.align 2
.L5:
.long _FirstFunction
.L6:
.long _Function
.Lfe3:
.size _entry,.Lfe3-_entry
.ident "GCC: (GNU) 2.95.3 20010315 (release)"

Dump of the relocation records:

There are 9 section headers, starting at offset 0x110:

Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000034 00007c 00 AX 0 0 4
[ 2] .rela.text RELA 00000000 000358 000018 0c 7 1 4
[ 3] .data PROGBITS 00000000 0000b0 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 0000b0 000000 00 WA 0 0 1
[ 5] .comment PROGBITS 00000000 0000b0 000026 00 0 0 1
[ 6] .shstrtab STRTAB 00000000 0000d6 00003a 00 0 0 1
[ 7] .symtab SYMTAB 00000000 000278 0000a0 10 8 8 4
[ 8] .strtab STRTAB 00000000 000318 000040 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)

Relocation section '.rela.text' at offset 0x358 contains 2 entries:
Offset Info Type Sym.Value Sym. Name + Addend
00000074 00000801 R_SH_DIR32 00000000 _FirstFunction + 0
00000078 00000201 R_SH_DIR32 00000000 .text + 0



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