This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
OpenBSD _GLOBAL_OFFSET_TABLE_ fix
- To: Richard Henderson <rth at redhat dot com>
- Subject: OpenBSD _GLOBAL_OFFSET_TABLE_ fix
- From: Marc Espie <espie at schutzenberger dot liafa dot jussieu dot fr>
- Date: Fri, 14 Sep 2001 14:52:28 +0200
- Cc: gcc-patches at gcc dot gnu dot org
- References: <877kv7dp67.fsf@kaka.blahonga.org> <Pine.LNX.4.33.0109101655330.16107-100000@host140.cambridge.redhat.com> <20010910184528.A10185@schutzenberger.liafa.jussieu.fr> <20010910181833.A11350@redhat.com>
- Reply-To: Marc dot Espie at liafa dot jussieu dot fr
config/i386/unix.h incorrectly generates refs to _GLOBAL_OFFSET_TABLE_
directly. On YES_UNDERSCORES systems, this should be __GLOBAL_OFFSET_TABLE_
The following patch uses the same strategy as the rest of the code to
handle this problem.
This is a patch for both -current and the 3.0 branch, as OpenBSD won't
bootstrap pic code without this patch now (this was found when
we removed the atrocious hack that `recognized' _GLOBAL_OFFSET_TABLE_
as __GLOBAL_OFFSET_TABLE_)
Okay ?
2001-09-14 Marc Espie <espie@openbsd.org>
* config/i386/unix.h (ASM_OUTPUT_MI_THUNK): Generate reference to GOT
correctly.
*** unix.h.orig Fri Sep 14 14:47:19 2001
--- unix.h Fri Sep 14 14:48:12 2001
***************
*** 87,93 ****
#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
do { \
tree parm; \
! rtx xops[2]; \
\
if (ix86_regparm > 0) \
parm = TYPE_ARG_TYPES (TREE_TYPE (function)); \
--- 87,93 ----
#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
do { \
tree parm; \
! rtx xops[3]; \
\
if (ix86_regparm > 0) \
parm = TYPE_ARG_TYPES (TREE_TYPE (function)); \
***************
*** 110,115 ****
--- 110,116 ----
{ \
xops[0] = pic_offset_table_rtx; \
xops[1] = gen_label_rtx (); \
+ xops[2] = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_"); \
\
if (ix86_regparm > 2) \
abort (); \
***************
*** 117,123 ****
output_asm_insn ("call\t%P1", xops); \
ASM_OUTPUT_INTERNAL_LABEL (FILE, "L", CODE_LABEL_NUMBER (xops[1])); \
output_asm_insn ("pop{l}\t%0", xops); \
! output_asm_insn ("add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-%P1], %0|%0, OFFSET FLAT: _GLOBAL_OFFSET_TABLE_+[.-%P1]}", xops); \
xops[0] = gen_rtx_MEM (SImode, XEXP (DECL_RTL (FUNCTION), 0)); \
output_asm_insn ("mov{l}\t{%0@GOT(%%ebx), %%ecx|%%ecx, %0@GOT[%%ebx]}",\
xops); \
--- 118,124 ----
output_asm_insn ("call\t%P1", xops); \
ASM_OUTPUT_INTERNAL_LABEL (FILE, "L", CODE_LABEL_NUMBER (xops[1])); \
output_asm_insn ("pop{l}\t%0", xops); \
! output_asm_insn ("add{l}\t{%2+[.-%P1], %0|%0, OFFSET FLAT: %2+[.-%P1]}", xops); \
xops[0] = gen_rtx_MEM (SImode, XEXP (DECL_RTL (FUNCTION), 0)); \
output_asm_insn ("mov{l}\t{%0@GOT(%%ebx), %%ecx|%%ecx, %0@GOT[%%ebx]}",\
xops); \