This is the mail archive of the binutils@sourceware.org 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]

[PATCH] change the condition preventing symbol replacement in snapshot_symbol()


As the new ltoff22x-6 test shows, using the defined-ness of a symbol to
decide whether to replace it is not correct - whether the symbol gets
defined before or after the use shouldn't matter. What does matter is
whether the symbol is global (and hence can, e.g. with ELF, be
overridden) - it's that case where replacement should be avoided in
order to not screw up the resulting relocations.

ltoff22x-7 exposes another issue (mailed about yesterday) in that for
equates of undefined global symbols resolve_symbol_value() will still
cause the referenced symbol to be used rather than the original one,
regardless of whether the original symbol is externally visible. The
test therefore is an xfail for the time being, until I hear back on
that issue.

gas/
2009-07-24  Jan Beulich  <jbeulich@novell.com>

	* symbols.c (snapshot_symbol): Check whether the to be replaced
	symbol is global, rather than whether the replacement symbol is
	defined.

gas/testsuite/
2009-07-24  Jan Beulich  <jbeulich@novell.com>

	ia64/ltoff22x-[67].[ds]: New.
	* ia64/ia64.exp: Run new tests. Mark ltoff22x-7 as xfail for
	now.

--- 2009-07-24/gas/symbols.c	2009-07-03 10:05:26.000000000 +0200
+++ 2009-07-24/gas/symbols.c	2009-07-24 10:26:00.000000000 +0200
@@ -1482,6 +1482,7 @@ snapshot_symbol (symbolS **symbolPP, val
     }
   else
     {
+      int global = S_IS_EXTERNAL(symbolP) || S_IS_WEAK(symbolP);
       expressionS expr = symbolP->sy_value;
 
       if (!symbolP->sy_resolved && expr.X_op != O_illegal)
@@ -1512,9 +1513,8 @@ snapshot_symbol (symbolS **symbolPP, val
 	    }
 	}
 
-      /* Never change a defined symbol.  */
-      if (symbolP->bsym->section == undefined_section
-	  || symbolP->bsym->section == expr_section)
+      /* Never replace a global symbol.  */
+      if (!global)
 	*symbolPP = symbolP;
       *valueP = expr.X_add_number;
       *segP = symbolP->bsym->section;
--- 2009-07-24/gas/testsuite/gas/ia64/ia64.exp	2007-06-18 09:23:35.000000000 +0200
+++ 2009-07-24/gas/testsuite/gas/ia64/ia64.exp	2009-07-24 10:26:00.000000000 +0200
@@ -37,6 +37,9 @@ if [istarget "ia64-*"] then {
     run_dump_test "ltoff22x-3"
     run_dump_test "ltoff22x-4"
     run_dump_test "ltoff22x-5"
+    run_dump_test "ltoff22x-6"
+    setup_xfail *-*
+    run_dump_test "ltoff22x-7"
 
     run_dump_test "nostkreg"
     run_list_test "invalid-ar" ""
--- 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-6.d	1970-01-01 01:00:00.000000000 +0100
+++ 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-6.d	2009-07-24 08:36:35.000000000 +0200
@@ -0,0 +1,11 @@
+# objdump: -r
+# name: ia64 ltoff22x-6
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[\.text\]:
+OFFSET[ 	]+TYPE[ 	]+VALUE 
+0+000 LTOFF22X          foo
+0+010 LDXMOV            foo
+
+
--- 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-6.s	1970-01-01 01:00:00.000000000 +0100
+++ 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-6.s	2009-07-24 08:36:53.000000000 +0200
@@ -0,0 +1,15 @@
+	.global foo#
+	foo# = bar#
+	.global bar#
+
+	.text
+	addl	r3 = @ltoffx(foo#), gp
+	nop.i	0
+	nop.i	0
+	ld8.mov r3 = [r3], foo#
+	nop.i	0
+	nop.i	0
+
+	.data
+bar:
+	data4 0
--- 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-7.d	1970-01-01 01:00:00.000000000 +0100
+++ 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-7.d	2009-07-24 08:38:15.000000000 +0200
@@ -0,0 +1,11 @@
+# objdump: -r
+# name: ia64 ltoff22x-7
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[\.text\]:
+OFFSET[ 	]+TYPE[ 	]+VALUE 
+0+000 LTOFF22X          foo
+0+010 LDXMOV            foo
+
+
--- 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-7.s	1970-01-01 01:00:00.000000000 +0100
+++ 2009-07-24/gas/testsuite/gas/ia64/ltoff22x-7.s	2009-07-24 08:37:11.000000000 +0200
@@ -0,0 +1,11 @@
+	.global foo#
+	foo# = bar#
+	.global bar#
+
+	.text
+	addl	r3 = @ltoffx(foo#), gp
+	nop.i	0
+	nop.i	0
+	ld8.mov r3 = [r3], foo#
+	nop.i	0
+	nop.i	0




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