This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix i386 @NTPOFF and @DTPOFF with addend


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]