Некоторые дополнительные информации ...
Один из НКУ-х builtins является
void __builtin_trap (void)
Эта функция заставляет программу выйти из строя. GCC реализует эту функцию, используя механизм, зависящий от цели (, например, преднамеренное выполнение незаконной инструкции) или путем вызова функции прерывания. Используемый механизм может отличаться от выпуска к выпуску, поэтому вам не следует полагаться на какую-либо конкретную реализацию.
Его implementation for ARMv7 is:
(define_insn "trap"
[(trap_if (const_int 1) (const_int 0))]
""
"*
if (TARGET_ARM)
return \".inst\\t0xe7f000f0\";
else
return \".inst\\t0xdeff\";
"
[(set (attr "length")
(if_then_else (eq_attr "is_thumb" "yes")
(const_int 2)
(const_int 4)))
(set_attr "type" "trap")
(set_attr "conds" "unconditional")]
)
Так что для ARM режима GCC будет генерировать 0x7f000f0 (f0 00 f0 07)
и для других режимов 0xdeff (ff de)
(удобна при разборке/отладки).
Also note that:
these encodings match the UDF instruction that is defined in the most
recent edition of the ARM architecture reference manual.
Thumb: 0xde00 | imm8 (we chose 0xff for the imm8)
ARM: 0xe7f000f0 | (imm12 << 8) | imm4 (we chose to use 0 for both imms)
Для LLVM__builtin_trap
значений генерироваться является 0xe7ffdefe
и 0xdefe
:
case ARM::TRAP: {
// Non-Darwin binutils don't yet support the "trap" mnemonic.
// FIXME: Remove this special case when they do.
if (!Subtarget->isTargetDarwin()) {
//.long 0xe7ffdefe @ trap
uint32_t Val = 0xe7ffdefeUL;
OutStreamer.AddComment("trap");
OutStreamer.EmitIntValue(Val, 4);
return;
}
break;
}
case ARM::tTRAP: {
// Non-Darwin binutils don't yet support the "trap" mnemonic.
// FIXME: Remove this special case when they do.
if (!Subtarget->isTargetDarwin()) {
//.short 57086 @ trap
uint16_t Val = 0xdefe;
OutStreamer.AddComment("trap");
OutStreamer.EmitIntValue(Val, 2);
return;
}
break;
}
Согласно http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337e/I1010015.html BLX от thumb16 не поддерживается M3 и «всегда неисправности». –