IA-32 gas _GLOBAL_OFFSET_TABLE_ handling bugs
Thu Aug 1 03:06:00 GMT 2002
On Thu, Aug 01, 2002 at 12:08:18PM +0930, Alan Modra wrote:
> On Wed, Jul 31, 2002 at 06:31:15PM -0700, Roland McGrath wrote:
> > Actually, the case generated by GCC that bit me does not use `.' at all.
> > It looks like this:
> > movl $.L30, %eax
> > .L30:
> > addl $_GLOBAL_OFFSET_TABLE_, %eax
> Eep. We really have dug a pit for ourselves with this syntax. Does
> this work on other assemblers? Can gcc be fixed to not emit the
No. gcc has been doing this in 2.95.x already:
.ident "GCC: (GNU) 2.95.4 20010319 (prerelease)"
addl $_GLOBAL_OFFSET_TABLE_+[.-XXX], %ebx
addl $_GLOBAL_OFFSET_TABLE_, %ebx
must do what it was doing until now unless we want to screw up all gcc's
since 2.95.x era, ie. R_386_GOTPC relocation with 2+[.-XXX] resp. 2 in
gcc 3.3 and any TLS enabled GCCs will also use
addl $_GLOBAL_OFFSET_TABLE_+[.-XXX], %reg
addl $_GLOBAL_OFFSET_TABLE_, %reg
forms where reg can be any 32-bit general register.
With %eax this means the addend should be 1+[.-XXX] resp. 1.
In this case we can IMHO decide whether we want to use this braindamaged
syntax or some other (addl $_GLOBAL_OFFSET_TABLE_+[.-XXX]@GOTPC, %eax?),
as GCC will need 2.13+ gas for it to work properly anyway, unless
we decide to keep status quo and require GCC to use
addl $_GLOBAL_OFFSET_TABLE_+[.-XXX-1], %eax
addl $_GLOBAL_OFFSET_TABLE_-1, %eax.
The rest depends on
a) what Solaris and other proprietary assemblers do
b) whether anyone is already using those constructs
Certainly, .long _GLOBAL_OFFSET_TABLE_ resulting in R_386_GOTPC reloc
is very weird.
Anyone has access to Solaris/x86 as?
> This is really taking "do what I mean rather than what I say" to new
> heights. Presumably, the magic _GLOBAL_OFFSET_TABLE_ transformations
> should only happen on "add" or "lea" type instructions, so that
> mov $_GLOBAL_OFFSET_TABLE_, %eax
> does the right thing.
More information about the Binutils