public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Adrian von Bidder <avbidder@atlas.acter.ch>
To: gcc-gnats@gcc.gnu.org
Subject: target/5399: arm/thumb: pointer indirections when using -fpic
Date: Wed, 16 Jan 2002 02:26:00 -0000	[thread overview]
Message-ID: <200201161022.g0GAMAi07550@atlas.acter.ch> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]


>Number:         5399
>Category:       target
>Synopsis:       arm/thumb: pointer indirections when using -fpic
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 16 02:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     avbidder@acter.ch (Adrian von Bidder)
>Release:        3.1 20020115 (experimental)
>Organization:
acter ag, zürich
>Environment:
System: Linux atlas 2.4.16 #4 Fri Dec 7 07:58:59 CET 2001 i686 unknown
Architecture: i686
binutils are cvs from 20010115 also. Same config opts as for gcc.
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: arm-unknown-elf
configured with: ../gcc-HEAD/configure --enable-checking --enable-languages=c --prefix=/home/avbidder/hacking-toolchain/inst --target=arm-elf --with-cpu=arm7tdmi
>Description:
The simple C program

main(){ 
        foo("hello george!\n");
}

compiled with -mthumb -fpic (other options don't matter. I use -O3
-mpic-register=r6 -msingle-pic-base as this is what I really use and I find the
asm output is more readable, too).

creates asm output:
=====
...
        .section        .rodata
...
.LC0:
        .ascii  "hello george!\n\000"
        .align  2
.LC1:
        .word   .LC0
... [main:]
    ldr     r0, .L2
    ldr     r1, [r6, r0]
    ldr     r0, [r1]
    bl      foo
...
.L2:
        .word   .LC1(GOTOFF)
...
====
The problem is - afaics - the GOTOFF (instead of GOT). In the linked binary,
.L2 contains the offset of .LC1 from start of GOT, which is start of data, too,
and not the offset of a GOT entry for .LC1. So the first load loads .L2, the
second load already loads the string pointer .LC1 and the third load then loads
the first four bytes of the string itself...


>How-To-Repeat:
see above
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-01-16 10:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-16  2:26 Adrian von Bidder [this message]
2002-01-16  3:16 Phil Blundell
2002-01-18  9:35 pb

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=200201161022.g0GAMAi07550@atlas.acter.ch \
    --to=avbidder@atlas.acter.ch \
    --cc=gcc-gnats@gcc.gnu.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).