如何在c ++函数中重新定位prolog?

时间:2018-04-29 10:36:22

标签: c++ assembly

命令行

  

g ++ -g -Og -m64 -c -mabi = ms -mno-red-zone -mno-mmx -mno-sse -nostartfiles -nostdlib -nostdinc -nostdinc ++ -undef -finline-functions -falign-functions = 16 -falign-labels = 1 -falign-loops = 1 -falign-jumps = 1 -fno-builtin -ffreestanding -fno-use-cxa-atexit -fpermissive -fno-rtti -fno-exceptions -fno-stack-protector -fshort -wchar -free -fno-toplevel-reorder -fsigned-char -funsigned-bitfields

来源

#define INT_PROLOG \
  asm volatile ("push %rsp\n\
  push %rax\n\
  ... save registers
  push %r15\n\
  ");

#define INT_EPILOG \
  asm volatile ("pop %r15\n\
  pop %r14\n\
  ... restore registers
  pop %rax\n\
  pop %rsp\n\
  ");

#define ERRINT_BEGIN(name, err) VOID DALIGNED name(size_t err) {\
  asm volatile ("pop %rcx");\
  INT_PROLOG;

#define INT_BEGIN(name) VOID DALIGNED name (size_t) {\
  INT_PROLOG

#define INT_END \
  asm volatile ("\n\
    movq    huEOI(%rip), %rax\n\
    movl    $0, (%rax)");\
  INT_EPILOG;\
  asm volatile ("iretq");\
  }

INT_BEGIN(int_de)
  uart_send("DE\n");
  hung();
INT_END

生成下一个代码

INT_BEGIN(int_de)
  40:   48 83 ec 28             sub    $0x28,%rsp
  44:   54                      push   %rsp
  45:   50                      push   %rax
  ...
  5a:   41 57                   push   %r15

我想要的是什么:

INT_BEGIN(int_de)
  40:   54                      push   %rsp
  41:   50                      push   %rax
  ...
  52:   41 57                   push   %r15
  54:   48 83 ec 28             sub    $0x28,%rsp

1 个答案:

答案 0 :(得分:0)

需要属性((中断)) 这不适用于Windows上的Ubuntu上的Bash!'!