Hi, gatekeeper and Gautam:
Could you please help review the fix for bug967?
bug case:
static unsigned long *anon1;
int x86_this_cpu_constant_test_bit(unsigned int nr)
{
return ((1UL << (nr % 64)) & ({ typeof(*anon1) pfo_ret__; switch
(sizeof(*anon1)) { case 1: asm("mov" "b ""%%""gs"":" "%P" "1"",%0" : "=q"
(p\
fo_ret__) : "m" (*anon1)); break; case 2: asm("mov" "w ""%%""gs"":" "%P"
"1"",%0" : "=r" (pfo_ret__) : "m" (*anon1)); break; case 4: asm("mov"\
"l ""%%""gs"":" "%P" "1"",%0" : "=r" (pfo_ret__) : "m" (*anon1)); break;
case
8: asm("mov" "q ""%%""gs"":" "%P" "1"",%0" : "=r" (pfo_ret__) :\
"m" (*anon1)); break; default: __bad_percpu_size(); } pfo_ret__; })) != 0;
}
opencc -c anon2.c
/tmp/ccspin#.GLUadD.s: Assembler messages:
/tmp/ccspin#.GLUadD.s:35: Error: symbol `anon1' is already defined
as previously discussed, the trouble is raised by wgen_spin_symbol.cxx :
1609 else {
1610 sprintf(tempname, "anon%d", ++anon_count);
1611 name = tempname;
1612 }
Suggested fix:
As Sun suggested, we use ".anon_" prefix instead of "anon", for isolation
of compiler generated symbols from those user variables and we also define
a macro for good coding practice.
patch below:
osprey/wgen/wgen_misc.h -- 1d2e1d4..d8e4b1b 100644
--- a/osprey/wgen/wgen_misc.h
+++ b/osprey/wgen/wgen_misc.h
@@ -170,6 +170,9 @@ Get_Srcpos (void)
return s;
}
+#define TVAR_PREFIX ".anon_"
+#define TVAR_PREFIX_LEN (sizeof(TVAR_PREFIX) - 1)
+
#endif
#endif
osprey/wgen/wgen_spin_symbol.cxx -- ff56fe0..2453b28 100644
--- a/osprey/wgen/wgen_spin_symbol.cxx
+++ b/osprey/wgen/wgen_spin_symbol.cxx
@@ -1607,7 +1607,7 @@ Create_ST_For_Tree (gs_t decl_node)
else if (gs_decl_name (decl_node))
name = (char *) gs_identifier_pointer (gs_decl_name (decl_node));
else {
- sprintf(tempname, "anon%d", ++anon_count);
+ sprintf(tempname, TVAR_PREFIX "%d", ++anon_count);
name = tempname;
}
thanks in advance for the review.
Regards
Gang
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel