public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: target/5399: arm/thumb: pointer indirections when using -fpic
@ 2002-01-18  9:35 pb
  0 siblings, 0 replies; 3+ messages in thread
From: pb @ 2002-01-18  9:35 UTC (permalink / raw)
  To: avbidder, gcc-bugs, gcc-prs, nobody, pb

Synopsis: arm/thumb: pointer indirections when using -fpic

Responsible-Changed-From-To: unassigned->pb
Responsible-Changed-By: pb
Responsible-Changed-When: Fri Jan 18 09:35:28 2002
Responsible-Changed-Why:
    .
State-Changed-From-To: open->analyzed
State-Changed-By: pb
State-Changed-When: Fri Jan 18 09:35:28 2002
State-Changed-Why:
    This is indeed a bug.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5399


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

* Re: target/5399: arm/thumb: pointer indirections when using -fpic
@ 2002-01-16  3:16 Phil Blundell
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Blundell @ 2002-01-16  3:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR target/5399; it has been noted by GNATS.

From: Phil Blundell <pb@nexus.co.uk>
To: Adrian von Bidder <avbidder@atlas.acter.ch>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: target/5399: arm/thumb: pointer indirections when using -fpic
Date: 16 Jan 2002 11:11:54 +0000

 On Wed, 2002-01-16 at 10:22, Adrian von Bidder wrote:
 > 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...
 
 Try something like this.  The problem isn't so much the GOTOFF itself
 (although the handling of that is fairly broken) as that the indirection
 through .LC1 shouldn't be happening in the first place.
 
 p.
 
 Index: arm.h
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.h,v
 retrieving revision 1.98.4.3
 diff -u -r1.98.4.3 arm.h
 --- arm.h	2001/12/07 09:49:23	1.98.4.3
 +++ arm.h	2002/01/16 11:08:13
 @@ -1899,7 +1899,8 @@
  #define THUMB_LEGITIMATE_CONSTANT_P(X)	\
   (   GET_CODE (X) == CONST_INT		\
    || GET_CODE (X) == CONST_DOUBLE	\
 -  || CONSTANT_ADDRESS_P (X))
 +  || CONSTANT_ADDRESS_P (X)		\
 +  || flag_pic)
  
  #define LEGITIMATE_CONSTANT_P(X)	\
    (TARGET_ARM ? ARM_LEGITIMATE_CONSTANT_P (X) : THUMB_LEGITIMATE_CONSTANT_P (X))
 


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

* target/5399: arm/thumb: pointer indirections when using -fpic
@ 2002-01-16  2:26 Adrian von Bidder
  0 siblings, 0 replies; 3+ messages in thread
From: Adrian von Bidder @ 2002-01-16  2:26 UTC (permalink / raw)
  To: gcc-gnats

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


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

end of thread, other threads:[~2002-01-18 17:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-18  9:35 target/5399: arm/thumb: pointer indirections when using -fpic pb
  -- strict thread matches above, loose matches on Subject: below --
2002-01-16  3:16 Phil Blundell
2002-01-16  2:26 Adrian von Bidder

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