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]

patch (gas): fix XCOFF RTOC addend


Hi,

the current value of RTOC addend is not correct on ppc xcoff targets: the addend must be relative to the
beginning of the TOC csect and not the the beginning of the .data section.
This bug occurs very rarely (never) on GCC produced files as toc is the first csect of the section.


This simple files:
        .csect .dummy[RW]
        .long 1
.toc
        .globl xx
.csect .data[RW]
xx:
        .long 1
.toc
LC..0:
        .tc xx[TC],xx
.csect .text[PR]
        .globl .main
.main:
        lwz 0,LC..0(2)
        blr

generates these outputs with native aix as (nm and objdump -dr):
0000000c d .data
00000008 d .dummy
00000000 T .main
00000000 t .text
00000010 d TOC
00000010 d xx
0000000c D xx

Disassembly of section .text:

00000000 <.main>:
   0:   80 02 00 00     lwz     r0,0(r2)  ##### offset is 0
                        2: R_TOC        xx+0xfffffff0
   4:   4e 80 00 20     blr

With the unfixed gas:
00000010 d .data
00000008 d .dummy
00000000 T .main
00000000 t .text
0000000c d TOC
0000000c d xx
00000010 D xx

00000000 <.main>:
   0:   80 02 00 04     l       r0,4(r2) ##### wrong offset
                        2: R_TOC        xx+0xfffffff4
   4:   4e 80 00 20     br

With the patch:

00000000 <.main>:
   0:   80 02 00 00     l       r0,0(r2) ##### Correct offset
                        2: R_TOC        xx+0xfffffff4
   4:   4e 80 00 20     br

Tristan.

gas:
2007-10-22  Tristan Gingold  <gingold@adacore.com>

* config/tc-ppc.c (md_apply_fix): For PPC_TOC16 on XCOFF, uses offset
within the TOC instead of the VMA.



gas/testsuite: 2007-10-22 Tristan Gingold <gingold@adacore.com>

* gas/ppc/test1xcoff32.d: Updated to match RTOC bug fix.


*** gas/config/tc-ppc.c 19 Oct 2007 10:48:17 -0000 1.129
--- gas/config/tc-ppc.c 22 Oct 2007 13:20:45 -0000
***************
*** 6059,6068 ****
#ifdef TE_PE
fixP->fx_addnumber = 0;
#else
! /* We want to use the offset within the data segment of the
! symbol, not the actual VMA of the symbol. */
fixP->fx_addnumber =
! - bfd_get_section_vma (stdoutput, S_GET_SEGMENT (fixP- >fx_addsy));
#endif
}
#endif
--- 6059,6069 ----
#ifdef TE_PE
fixP->fx_addnumber = 0;
#else
! /* We want to use the offset within the toc, not the actual VMA
! of the symbol. */
fixP->fx_addnumber =
! - bfd_get_section_vma (stdoutput, S_GET_SEGMENT (fixP- >fx_addsy))
! - S_GET_VALUE (ppc_toc_csect);
#endif
}
#endif




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