This is the mail archive of the 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]

IA-32 gas _GLOBAL_OFFSET_TABLE_ handling bugs


Roland noticed that gas doesn't handle
  addl $_GLOBAL_OFFSET_TABLE_+[.-test], %eax
correctly (unlike with any other register), which is very bad, as either
with TLS, or gcc 3.3+ gcc can use any register for PIC pointer if no PLT
calls are made, including %eax (in which case the insn is one byte shorter).

The problem is that . here is computed from start of instruction (and thus
_GLOBAL_OFFSET_TABLE_ is considered relative to start of the instruction
too), but gas hardcodes this difference as 2 (well, another question is why
it first does += 3 and later on in another routine subtracts one).
The following patch tries to deal with this, unfortunately I'm not sure
what should actually happen when _GLOBAL_OFFSET_TABLE_ is present in the
displacement, not immediate and also what should happen if
_GLOBAL_OFFSET_TABLE_ is mentioned outside of the instruction (ie. in .long
Current gas behaviour is that for
  movl $1234, _GLOBAL_OFFSET_TABLE_
it creates R_386_GOTPC relocation without any adjustement, ie.
  addl $_GLOBAL_OFFSET_TABLE_+[.-test], %ebx
does a different thing than
  leal _GLOBAL_OFFSET_TABLE_+[.-test](%ebx), %ebx
(in the latter case %ebx will be %ebx in the former - 2).
Should it match the immediate behaviour (ie. does output_disp need to be
modified)? Or should it forget about special meaning
of _GLOBAL_OFFSET_TABLE_ in that case?

What's your preference?
I'd like to build a dejagnu testcase from this, but need to know what
should be expected...


Attachment: P
Description: Text document

Attachment: R.s
Description: Text document

Attachment: R.old
Description: Text document

Description: Text document

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