From mboxrd@z Thu Jan 1 00:00:00 1970 From: hjl@lucon.org (H.J. Lu) To: robertl@dgii.com (Robert Lipe) Cc: gas2@cygnus.com Subject: Re: pushl computed immediate address on 2.8.1 Date: Fri, 09 Jan 1998 20:42:00 -0000 Message-id: References: <19980102144041.15293@dgii.com> X-SW-Source: 1998/msg00005.html > > > I was thinking this was a bug in the SCO x86 assembler becuase it worked > under GAS for Linux. However, after some prodding form the egcs folks > that really know PIC, I'm wondering if this is actually a construct that > GAS should produce an error for becuase GCC shouldn't emit it. > > The problem is that > > pushl $.LC0@GOTOFF(%ebx) > > seems to assemble just like > > pushl $LC0 > > so it ends up generating an push of an absolute address once the > linker gets done with it. > > Does this sound right at all? Should GAS error on this? > > > Here's a short "hello, world" in PIC to exercise the issue. > > > Thanx, > > RJL > > .file "test.c" > .section .rodata > .LC0: > .string "Hello, World\n" > > .text > .align 4 > .globl main > .type main,@function > main: > pushl %ebp > movl %esp,%ebp > pushl %ebx > call .L2 > .L2: > popl %ebx > addl $_GLOBAL_OFFSET_TABLE_+[.-.L2],%ebx > > // This is the aproach that works, and is what GCC should emit. > // registers > leal .LC0@GOTOFF(%ebx),%eax > pushl %eax > call printf@PLT > > // This what GCC does emit, but seems to be nonsensical. > // assembler. > pushl $.LC0@GOTOFF(%ebx) > call printf@PLT > Which gcc are you using? How did you get gcc to emit that? I only can get my gcc to generate leal .LC0@GOTOFF(%ebx),%eax pushl %eax call printf@PLT I tried egcs 971215, egcs 1.0.1 and gcc 2.8.0 971225. They are all the same. H.J.