From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18805 invoked by alias); 16 Jan 2002 10:26:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 18759 invoked by uid 71); 16 Jan 2002 10:26:01 -0000 Resent-Date: 16 Jan 2002 10:26:01 -0000 Resent-Message-ID: <20020116102601.18758.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Adrian von Bidder Received:(qmail 17866 invoked from network); 16 Jan 2002 10:22:12 -0000 Received: from unknown (HELO atlas.acter.ch) (212.126.160.108) by sources.redhat.com with SMTP; 16 Jan 2002 10:22:12 -0000 Received: (from avbidder@localhost) by atlas.acter.ch (8.11.6/8.11.6/SuSE Linux 0.5) id g0GAMAi07550; Wed, 16 Jan 2002 11:22:10 +0100 Message-Id:<200201161022.g0GAMAi07550@atlas.acter.ch> Date: Wed, 16 Jan 2002 02:26:00 -0000 From: Adrian von Bidder To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:3.113 Subject: target/5399: arm/thumb: pointer indirections when using -fpic X-SW-Source: 2002-01/txt/msg00585.txt.bz2 List-Id: >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: