public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* patch (gas): fix XCOFF RTOC addend
@ 2007-10-22 15:46 Tristan Gingold
  2007-11-05 12:50 ` Ping: PATCH " Tristan Gingold
  2007-11-06 12:08 ` patch " Nick Clifton
  0 siblings, 2 replies; 3+ messages in thread
From: Tristan Gingold @ 2007-10-22 15:46 UTC (permalink / raw)
  To: binutils

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Ping: PATCH (gas): fix XCOFF RTOC addend
  2007-10-22 15:46 patch (gas): fix XCOFF RTOC addend Tristan Gingold
@ 2007-11-05 12:50 ` Tristan Gingold
  2007-11-06 12:08 ` patch " Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Tristan Gingold @ 2007-11-05 12:50 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils

Just a ping.

On Oct 22, 2007, at 3:53 PM, Tristan Gingold wrote:

> 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
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patch (gas): fix XCOFF RTOC addend
  2007-10-22 15:46 patch (gas): fix XCOFF RTOC addend Tristan Gingold
  2007-11-05 12:50 ` Ping: PATCH " Tristan Gingold
@ 2007-11-06 12:08 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2007-11-06 12:08 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils

Hi 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.

Approved - please apply.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-06 12:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-22 15:46 patch (gas): fix XCOFF RTOC addend Tristan Gingold
2007-11-05 12:50 ` Ping: PATCH " Tristan Gingold
2007-11-06 12:08 ` patch " Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).