Trying to redirect GCC to a specific asm goto in Clang

I tried to turn some GNU extensions into actual standard C, so it will work on clang, knowing standard C, not GNU extensions, I lost a little.

__asm__ (goto("1:" STATIC_KEY_INITIAL_NOP ".pushsection __jump_table, \"aw\" \n\t" _ASM_ALIGN "\n\t" _ASM_PTR "1b, %l[l_yes], %c0 \n\t" ".popsection \n\t" : : "i" (key) : : l_yes);); 

I tried to include this in the actual asm, but have not yet succeeded.

If you're interested, this is part of the kernel that I just compiled on clang, except that there is one section.

+6
source share
1 answer

You are having trouble compiling arch / x86 / include / asm / jump_label.h . The entire code snippet should include support for "correcting transition marks." A new feature that is very useful for debugging resolution (printing logs, etc.) With almost zero overhead when debugging is disabled.

The implementation you come across depends on gcc (v4.5), which adds a new asm goto that allows you to jump to the label.

It appears that Clang / LLVM <9.0.0 does NOT support asm goto .

As a quick fix for compiling the Linux kernel correctly, you can disable CONFIG_JUMP_LABEL in your kernel configuration. This configuration parameter is used to disable optimization when the compiler does NOT support asm goto properly.


Update : Initial support for asm goto was added to Clang in version 9.0.0 .

Initial support for asm goto (GNU C extension) added flow control from built-in assembly to labels. The main consumers of this design are the Linux kernel (CONFIG_JUMP_LABEL = y) and glib. There are some more unsupported angular cases in the integrated assembler Clang and IfConverter. Please report bugs for any problems you encounter.

+7
source

Source: https://habr.com/ru/post/1502719/


All Articles