clang would duplicate the loop body and end up with a double definition of the symbol: ``` /tmp/test_x86_emulator-0f3576.s:27823: Error: symbol `vmovsh_to_mem' is already defined /tmp/test_x86_emulator-0f3576.s:27825: Error: symbol `.Lvmovsh_to_mem_end' is already defined ```
Avoid this by only emitting the symbols surrounding the instructions if they are not already defined. (We know that the definitions would be identical, and we only need one of them as input to the emulator) Signed-off-by: Edwin Török <[email protected]> --- Changed since v1: * use .ifndef directive instead of volatile workaround --- tools/tests/x86_emulator/test_x86_emulator.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c index ea507f9c3a..8f93a8bbcd 100644 --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -1882,8 +1882,13 @@ int main(int argc, char **argv) #define decl_insn(which) extern const unsigned char which[], \ which##_end[] asm ( ".L" #which "_end" ) #define put_insn(which, insn) ".pushsection .test\n" \ - #which ": " insn "\n" \ + ".ifndef "#which"\n" \ + #which ": \n" \ + ".endif\n" \ + insn "\n" \ + ".ifndef .L"#which"_end\n" \ ".L" #which "_end:\n" \ + ".endif\n" \ ".popsection" #define set_insn(which) (regs.eip = (unsigned long)(which)) #define valid_eip(which) (regs.eip >= (unsigned long)(which) && \ @@ -5248,7 +5253,7 @@ int main(int argc, char **argv) memset(res + 3, ~0, 8); regs.eax = (unsigned long)res; regs.ecx = ~0; - for ( i = 0; i < 2; ++i ) + for (i = 0; i < 2; ++i ) { decl_insn(vmovsh_to_mem); -- 2.47.3
