From 087d837e042af03a607f1974d32929a129eef806 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 8 Dec 2009 03:14:29 +0000 Subject: [PATCH] Call symbol_same_p to check to if 2 symbols are the same. gas/ 2009-12-07 H.J. Lu PR gas/11037 * expr.c (resolve_expression): Call symbol_same_p to check if 2 symbols are the same. * symbols.c (symbol_same_p): New. * symbols.h (symbol_same_p): Likewise. gas/testsuite/ 2009-12-07 H.J. Lu PR gas/11037 * gas/i386/intelpic.s: Add testcases. * gas/i386/intelpic.d: Updated. --- gas/ChangeLog | 9 +++++++++ gas/expr.c | 3 +-- gas/symbols.c | 14 ++++++++++++++ gas/symbols.h | 1 + gas/testsuite/ChangeLog | 6 ++++++ gas/testsuite/gas/i386/intelpic.d | 10 ++++++++++ gas/testsuite/gas/i386/intelpic.s | 9 +++++++++ 7 files changed, 50 insertions(+), 2 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index f941c9f7a93..f7d9c083706 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2009-12-07 H.J. Lu + + PR gas/11037 + * expr.c (resolve_expression): Call symbol_same_p to check + if 2 symbols are the same. + + * symbols.c (symbol_same_p): New. + * symbols.h (symbol_same_p): Likewise. + 2009-12-02 Nick Clifton Richard Earnshaw diff --git a/gas/expr.c b/gas/expr.c index 094141f6e3b..fbfdffc6758 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -2237,8 +2237,7 @@ resolve_expression (expressionS *expressionP) op = O_constant; else if (seg_left == reg_section && final_val == 0) op = O_register; - else if (seg_left == undefined_section - && add_symbol != orig_add_symbol) + else if (!symbol_same_p (add_symbol, orig_add_symbol)) final_val += left; expressionP->X_add_symbol = add_symbol; } diff --git a/gas/symbols.c b/gas/symbols.c index 4cfa85b103b..5eda2cbbd21 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -2385,6 +2385,20 @@ symbol_set_value_expression (symbolS *s, const expressionS *exp) S_CLEAR_WEAKREFR (s); } +/* Return whether 2 symbols are the same. */ + +int +symbol_same_p (symbolS *s1, symbolS *s2) +{ + if (s1->bsym == NULL + && local_symbol_converted_p ((struct local_symbol *) s1)) + s1 = local_symbol_get_real_symbol ((struct local_symbol *) s1); + if (s2->bsym == NULL + && local_symbol_converted_p ((struct local_symbol *) s2)) + s2 = local_symbol_get_real_symbol ((struct local_symbol *) s2); + return s1 == s2; +} + /* Return a pointer to the X_add_number component of a symbol. */ offsetT * diff --git a/gas/symbols.h b/gas/symbols.h index 19f58c6f8f6..377a130074b 100644 --- a/gas/symbols.h +++ b/gas/symbols.h @@ -198,6 +198,7 @@ extern int symbol_constant_p (symbolS *); extern int symbol_shadow_p (symbolS *); extern asymbol *symbol_get_bfdsym (symbolS *); extern void symbol_set_bfdsym (symbolS *, asymbol *); +extern int symbol_same_p (symbolS *, symbolS *); #ifdef OBJ_SYMFIELD_TYPE OBJ_SYMFIELD_TYPE *symbol_get_obj (symbolS *); diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 449a1834a2d..ea8c2b52573 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-12-07 H.J. Lu + + PR gas/11037 + * gas/i386/intelpic.s: Add testcases. + * gas/i386/intelpic.d: Updated. + 2009-12-03 H.J. Lu * gas/i386/i386.exp: Run x86-64-fxsave and x86-64-fxsave-intel. diff --git a/gas/testsuite/gas/i386/intelpic.d b/gas/testsuite/gas/i386/intelpic.d index 5af73894d90..d78894a8815 100644 --- a/gas/testsuite/gas/i386/intelpic.d +++ b/gas/testsuite/gas/i386/intelpic.d @@ -14,4 +14,14 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 8b 83 00 00 00 00 mov 0x0\(%ebx\),%eax [ ]*[a-f0-9]+: ff 24 85 0d 00 00 00 jmp \*0xd\(,%eax,4\) [ ]*[a-f0-9]+: 8d 83 14 00 00 00 lea 0x14\(%ebx\),%eax +[ ]*[a-f0-9]+: ff 24 85 0d 10 00 00 jmp \*0x100d\(,%eax,4\) +[ ]*[a-f0-9]+: ff 24 85 28 10 00 00 jmp \*0x1028\(,%eax,4\) +[ ]*[a-f0-9]+: 90 nop + +0+29 : +[ ]*[a-f0-9]+: ff 24 85 29 10 00 00 jmp \*0x1029\(,%eax,4\) +[ ]*[a-f0-9]+: ff 24 85 37 10 00 00 jmp \*0x1037\(,%eax,4\) + +0+37 : +[ ]*[a-f0-9]+: 90 nop #pass diff --git a/gas/testsuite/gas/i386/intelpic.s b/gas/testsuite/gas/i386/intelpic.s index 9bca76fc931..b8db43db200 100644 --- a/gas/testsuite/gas/i386/intelpic.s +++ b/gas/testsuite/gas/i386/intelpic.s @@ -12,3 +12,12 @@ bar: jmp DWORD PTR[ .L11 + eax * 4 ] .LC0: lea eax, DWORD PTR[ .LC0@GOTOFF + ebx ] + jmp DWORD PTR[ .L11 + eax * 4 + 0x1000 ] + jmp DWORD PTR[ .L12 + eax * 4 + 0x1000 ] +.L12: + nop +L11: + jmp DWORD PTR[ L11 + eax * 4 + 0x1000 ] + jmp DWORD PTR[ L12 + eax * 4 + 0x1000 ] +L12: + nop -- 2.30.2