public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tristan Gingold <gingold@adacore.com>
To: binutils@sourceware.org
Subject: patch (gas): fix XCOFF RTOC addend
Date: Mon, 22 Oct 2007 15:46:00 -0000	[thread overview]
Message-ID: <1242791C-5637-4943-8527-4388A6C26533@adacore.com> (raw)

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


             reply	other threads:[~2007-10-22 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-22 15:46 Tristan Gingold [this message]
2007-11-05 12:50 ` Ping: PATCH " Tristan Gingold
2007-11-06 12:08 ` patch " Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242791C-5637-4943-8527-4388A6C26533@adacore.com \
    --to=gingold@adacore.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).