This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix i386 @NTPOFF and @DTPOFF with addend
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Roland McGrath <roland at redhat dot com>
- Cc: binutils at sources dot redhat dot com, rth at redhat dot com, drepper at redhat dot com
- Date: Tue, 10 Sep 2002 18:26:36 -0400
- Subject: Re: [PATCH] Fix i386 @NTPOFF and @DTPOFF with addend
- References: <20020910235526.K1013@sunsite.ms.mff.cuni.cz> <20020910150706.H2823@dhcp187.sf.frob.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Sep 10, 2002 at 03:07:06PM -0700, Roland McGrath wrote:
> If there are remaining types where it ignores the addend, I think it should
> give an error when an addend is specified rather than silently ignoring it.
Well, addend is ignored with all the GOT style relocs (@GOT, @TLSGD,
@TLSLDM, @GOTTPOFF), say:
movl x@GOT(%ebx), %eax
movl 8+x@GOT(%ebx), %ecx
will generate identical instructions/relocs in both cases.
We should probably add a warning for all of these with non-zero addend,
but I'm pretty sure nobody is using it intentionally - it makes no sense
at all to request a got slot for one variable and load from a slot 8 bytes
later in .got (that's about the same as int i; int j = *(&i + 2);).
> Also, having as do the negation seems a little questionable.
> Shouldn't the assembly writer (and compiler) know that it is using
> a negative operand in this case and write it that way?
Don't know. The reloc in question is the Sun style one:
movl %gs:0, %eax
subl foo@TPOFF, %eax
If foo is a 16 byte struct and I want to access its second word,
I can either write:
movl %gs:0, %eax
subl foo@TPOFF, %eax
addl $4, %eax
or if I want a shorter sequence, either:
movl %gs:0, %eax
subl 4+foo@TPOFF, %eax
(with meaning (foo+4)@TPOFF, with value = -value), or
movl %gs:0, %eax
subl -4+foo@TPOFF, %eax
(with meaning eax -= foo@TPOFF; eax -= -4; with value = -value
line deleted).
I don't have access to Sun IA-32 as supporting TLS, so I cannot tell
which of these it accepts (if any).
Jakub