Fix a bug that caused incorrect PIC code to be generated for exceptions.

The symptom was an assembler warning

    "GOT relocation burb: `___EXCEPTION_TABLE__' should be global"

followed (sometimes) by a core dump.  The fix makes the compiler
generate the correct GOTOFF addressing for that symbol, rather than the
GOT addressing it was emitting before.

Warning:  There is still at least one serious bug in the i386 exception
code for PIC.  The exception code that is generated clobbers the GOT
register (%ebx) and then tries to use it later.  That leads to core
dumps at program execution time.  I know where the problem is, but I do
not have a fix for it at this time.  Until it is fixed, exceptions will
not work in PIC code.  This is a general problem for all i386 platforms;
it is not specific to FreeBSD.
This commit is contained in:
John Polstra 1996-10-03 17:49:35 +00:00
parent 8d1005c8c4
commit 87f11ab41b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=18659
2 changed files with 23 additions and 1 deletions

View File

@ -1286,6 +1286,22 @@ do \
} \
while (0)
/* Define this macro if a SYMBOL_REF representing a non-global
address must be marked specially. This is called for
compiler-generated local symbols, such as "__EXCEPTION_TABLE__".
On i386, if using PIC, we use this to set the rtx's
SYMBOL_REF_FLAG, so that we may access it directly as
an offset from the GOT register. */
#define MARK_LOCAL_ADDRESS(X) \
do \
{ \
if (flag_pic && GET_CODE (X) == SYMBOL_REF) \
SYMBOL_REF_FLAG (X) = 1; \
} \
while (0)
/* Initialize data used by insn expanders. This is called from
init_emit, once for each function, before code is generated.
For 386, clear stack slot assignments remembered from previous

View File

@ -1614,9 +1614,15 @@ emit_exception_table ()
void
register_exception_table ()
{
rtx addr = gen_rtx (SYMBOL_REF, Pmode, "__EXCEPTION_TABLE__");
#ifdef MARK_LOCAL_ADDRESS
MARK_LOCAL_ADDRESS(addr);
#endif
emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__register_exceptions"), 0,
VOIDmode, 1,
gen_rtx (SYMBOL_REF, Pmode, "__EXCEPTION_TABLE__"),
addr,
Pmode);
}