diff options
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/dbxout.c | 62 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20041216-1.c | 23 |
4 files changed, 63 insertions, 31 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f21d9d2ff35..ca995ccadfe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-01-26 Ulrich Weigand <uweigand@de.ibm.com> + + * dbxout.c (dbxout_symbol_location): Resolve constant pool references + even for variables with NULL DECL_INITIAL. + 2005-01-26 Stuart Hastings <stuart@apple.com> * gcc/gimplify.c (shortcut_cond_expr): Re-compute side-effects. diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 8c2d6eac5e4..d4c78e99c9f 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -2733,6 +2733,37 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home) letter = decl_function_context (decl) ? 'V' : 'S'; + /* Some ports can transform a symbol ref into a label ref, + because the symbol ref is too far away and has to be + dumped into a constant pool. Alternatively, the symbol + in the constant pool might be referenced by a different + symbol. */ + if (GET_CODE (addr) == SYMBOL_REF + && CONSTANT_POOL_ADDRESS_P (addr)) + { + bool marked; + rtx tmp = get_pool_constant_mark (addr, &marked); + + if (GET_CODE (tmp) == SYMBOL_REF) + { + addr = tmp; + if (CONSTANT_POOL_ADDRESS_P (addr)) + get_pool_constant_mark (addr, &marked); + else + marked = true; + } + else if (GET_CODE (tmp) == LABEL_REF) + { + addr = tmp; + marked = true; + } + + /* If all references to the constant pool were optimized + out, we just ignore the symbol. */ + if (!marked) + return 0; + } + /* This should be the same condition as in assemble_variable, but we don't have access to dont_output_data here. So, instead, we rely on the fact that error_mark_node initializers always @@ -2747,37 +2778,6 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home) code = DBX_STATIC_CONST_VAR_CODE; else { - /* Some ports can transform a symbol ref into a label ref, - because the symbol ref is too far away and has to be - dumped into a constant pool. Alternatively, the symbol - in the constant pool might be referenced by a different - symbol. */ - if (GET_CODE (addr) == SYMBOL_REF - && CONSTANT_POOL_ADDRESS_P (addr)) - { - bool marked; - rtx tmp = get_pool_constant_mark (addr, &marked); - - if (GET_CODE (tmp) == SYMBOL_REF) - { - addr = tmp; - if (CONSTANT_POOL_ADDRESS_P (addr)) - get_pool_constant_mark (addr, &marked); - else - marked = true; - } - else if (GET_CODE (tmp) == LABEL_REF) - { - addr = tmp; - marked = true; - } - - /* If all references to the constant pool were optimized - out, we just ignore the symbol. */ - if (!marked) - return 0; - } - /* Ultrix `as' seems to need this. */ #ifdef DBX_STATIC_STAB_DATA_SECTION data_section (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7cdaf99f162..0140e9aa7e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-01-26 Ulrich Weigand <uweigand@de.ibm.com> + + * gcc.dg/20041216-1.c: New test. + 2005-01-26 Alexander Malmberg <alexander@malmberg.org> PR objc/18862 diff --git a/gcc/testsuite/gcc.dg/20041216-1.c b/gcc/testsuite/gcc.dg/20041216-1.c new file mode 100644 index 00000000000..3f892a2e375 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20041216-1.c @@ -0,0 +1,23 @@ +/* This test case would get an unresolved symbol during link + because stabs referred to an optimized-away literal pool + entry. */ + +/* { dg-do run { target s390*-*-* } } */ +/* { dg-options "-O2 -fno-omit-frame-pointer -gstabs" } */ + +int main (void) +{ + static char buf[4096]; + char *p; + + do + { + p = buf; + asm volatile ("" : : : "memory", "0", "1", "2", "3", "4", "5", "6", + "7", "8", "9", "10", "12"); + } + while (*p); + + return 0; +} + |