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]

symbol cloning


PR 6848 has a couple of testcases:

	.data
        .globl x
	.long x
        x=y
y:
        .long 1
z:
        .long 1
        x=z

The above assembles, with .long x being evaluated as y's address,
.data + 4.  The second testcase doesn't currently assemble.

	.data
        .globl x
	.long x
y:
        .long 1
        x=y
z:
        .long 1
        x=z

The difference is just that x is assigned an undefined y in the first
instance, and a defined y in the second.  I think it is a little weird
that the assembler treats these cases differently.  The following
patch allows the second testcase to assemble (at least on targets that
reduce relocs against local symbols to relocs against section syms).

	* symbols.c (symbol_clone): Ensure clones are not external.

Index: gas/symbols.c
===================================================================
RCS file: /cvs/src/src/gas/symbols.c,v
retrieving revision 1.90
diff -u -p -r1.90 symbols.c
--- gas/symbols.c	12 Aug 2008 23:39:30 -0000	1.90
+++ gas/symbols.c	20 Aug 2008 12:49:34 -0000
@@ -596,13 +596,20 @@ symbol_clone (symbolS *orgsymP, int repl
 	symbol_lastP = newsymP;
       else if (orgsymP->sy_next)
 	orgsymP->sy_next->sy_previous = newsymP;
+
+      /* Symbols that won't be output can't be external.  */
+      S_CLEAR_EXTERNAL (orgsymP);
       orgsymP->sy_previous = orgsymP->sy_next = orgsymP;
       debug_verify_symchain (symbol_rootP, symbol_lastP);
 
       symbol_table_insert (newsymP);
     }
   else
-    newsymP->sy_previous = newsymP->sy_next = newsymP;
+    {
+      /* Symbols that won't be output can't be external.  */
+      S_CLEAR_EXTERNAL (newsymP);
+      newsymP->sy_previous = newsymP->sy_next = newsymP;
+    }
 
   return newsymP;
 }

-- 
Alan Modra
Australia Development Lab, IBM


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