大会编译错误(gcc4.2.4 =胜利,gcc4.3.3 =失败) [英] Assembly compilation error (gcc4.2.4=win, gcc4.3.3=fail)
问题描述
我们最近从 gcc4.2.4
升级code到 gcc4.3.3
。
We recently upgraded the code to gcc4.3.3
from gcc4.2.4
.
void testAndSet( volatile int* s, int* val )
{
__asm__ __volatile__ ( "btsl $0, %0\n "
"jc bitSet\n "
"movl $0, %1\n "
"jmp returnVector\n"
"bitSet:\n "
"movl $1, %1\n"
"returnVector: " : "=m"(*s), "=m"(*val) );
}
我们的code现在失败,出现以下错误,
Our code now fails with the following errors,
lock.cxx: Assembler messages:
lock.cxx:59: Error: symbol `bitSet' is already defined
lock.cxx:61: Error: symbol `returnVector' is already defined
lock.cxx:59: Error: symbol `bitSet' is already defined
lock.cxx:61: Error: symbol `returnVector' is already defined
均未发现这些符号其他地方。 (重命名它们会导致新的名称相同的错误)。
Those symbols weren't found anywhere else. (Renaming them causes the same error with the new name).
这个是怎么回事?为什么会出现错误两次?
What's up with this? why do I get the errors twice?
推荐答案
大概优化已经改变,现在你的内联检查并设置()函数转换成2位。由于您使用的是全局名称为您的标签,这是行不通的。您应该改用本地名称。例如:
Probably the optimizer has changed and is now inlining your testAndSet() function into 2 places. Because you are using global names for your labels, this does not work. You should use local names instead. E.g:
__asm__ __volatile__ ( "btsl $0, %0\n "
"jc 0f\n "
"movl $0, %1\n "
"jmp 1f\n"
"0:\n "
"movl $1, %1\n"
"1: " : "=m"(*s), "=m"(*val) );
局部标签只是数字;为消除歧义,那里有许多标签所谓的0,你需要使用 JMP 0F
向前跳跃和 JMP 0B $ C案例$ C>为向后跳跃。
Local labels are just numbers; to disambiguate cases where there are many labels called "0" you need to use "jmp 0f
" for forward jumps and "jmp 0b
" for backward jumps.
这篇关于大会编译错误(gcc4.2.4 =胜利,gcc4.3.3 =失败)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!