This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/10877: [3.3/3.4 regression] miscompilation with -O3 -fPIC on x86
- From: "Christian Ehrhardt" <ehrhardt at mathematik dot uni-ulm dot de>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 21 May 2003 12:46:01 -0000
- Subject: Re: optimization/10877: [3.3/3.4 regression] miscompilation with -O3 -fPIC on x86
- Reply-to: "Christian Ehrhardt" <ehrhardt at mathematik dot uni-ulm dot de>
The following reply was made to PR optimization/10877; it has been noted by GNATS.
From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de>
To: Wolfgang Bangerth <bangerth@ices.utexas.edu>, ebotcazou@libertysurf.fr
Cc: Andrew Pinski <pinskia@physics.uc.edu>, gcc-bugs@gcc.gnu.org,
lloyd@acm.jhu.edu, gcc-gnats@gcc.gnu.org
Subject: Re: optimization/10877: [3.3/3.4 regression] miscompilation with -O3 -fPIC on x86
Date: Wed, 21 May 2003 14:39:38 +0200
[ Added Eric to cc because his patch might have triggered this gas bug. ]
On Tue, May 20, 2003 at 12:05:35PM -0500, Wolfgang Bangerth wrote:
> > Feeding this assembler file into gcc 3.2 on an Intel box works for me
> > and the program doesn't crash! This might mean that we have an
> > assembler/binutils problem here.
>
> Whereas if I do the same, it crashes. So you seem to have a point :-)
This is definitely a gas Bug! The problem is the following instruction:
addl $_GLOBAL_OFFSET_TABLE_, %eax
This tells the assembler that we want the difference between the adress
of this addl instruction and the start of the global offset table to be
added to %eax. When translating this request into relocation records an
R_386_GOTPC relocation is used.
However, this relocation calculates the difference between the place where
the relocation takes place and the start of the global offset table.
Hence the assembler must add an addend to fix up the difference between
the address of the addl instruction and the address of its immediate
operand (the latter is the place of the relocation).
Now in the %eax case gas emmits the 0x05 opcode for addl imm32,%eax
with a length of 1 byte. If the register isn't %eax the assembler
has to use the longer 0x81 0xc3 opcode. Both opcodes are followed by
the immediate 32bit Operand.
I.e. if %eax is used the addend for the R_386_GOTPC relocation must be 1
but for all other registers it must be 2 due to the different length of
the opcode. This is what some gas versions seem to get wrong.
So what should we do with this report? Do we want to work around
this bug in gcc or should we close it and tell people to upgrade
binutils. The bug is fixed at least since 2.12.90.0.15 20020717 (SuSE).
regards Christian
--
THAT'S ALL FOLKS!