What's the purpose of the UD2 opcode in the Linux kernel?

后端 未结 1 634
误落风尘
误落风尘 2021-01-07 17:02

I have found the following fragment in the Linux kernel (not the corresponding C code though), somewhere during the start up phase. You can clearly see the 0F 0B

相关标签:
1条回答
  • 2021-01-07 17:38

    It's the BUG() macro from include/asm-i386/bug.h.

    /*
     * Tell the user there is some problem.
     * The offending file and line are encoded after the "officially
     * undefined" opcode for parsing in the trap handler.
     */
    
    #ifdef CONFIG_DEBUG_BUGVERBOSE
    #define BUG()                           \
     __asm__ __volatile__(  "ud2\n"         \
                            "\t.word %c0\n" \
                            "\t.long %c1\n" \
                             : : "i" (__LINE__), "i" (__FILE__))
    

    For example, the one at 0C05AF is for file with name at 0xC0274A86 and line number 117 (0x75).

    0 讨论(0)
提交回复
热议问题