• 已解决 73482 个问题
  • 已帮助 5993 位优秀工程师

X86_64架构,ICC编译选项 mon-red-zon是啥

沃尔夫斯堡的羊 2020-01-23 浏览量:847
如题,在X86_64架构中,ICC工具链编译选项 mon-red-zo​ne是什么意思?有哪位大神指点一下?好像是和X86_64架构中函数调用堆栈的使用有关?在使用makefile编译过程中,不加此选项时,elf文件加载运行起来一会儿就会死在某个地方,加了之后就不会出现此种状况,可以正常跑起来。。。
0 0 收起

我来回答

上传资料:
选择文件 文件大小不超过15M(格式支持:doc、ppt、xls、pdf、zip、rar、txt)
所有亮答 数量:1
  • 你给的信息有误,是mno-red-zone!

    英语的介绍是:

    What is the 'red-zone'?

    The red-zone is a feature described in the x86-64 ABI.

    It is a 128 byte long region located directly below the stack pointer. This region is free-for-use for the compiler without the requirement to notify the application / the os or any running interrupt handler.

    For user applications there is no issue as interrupts and other kernel related code won't interfere with the user stack. In your kernel however things can get ugly especially so if you have nested interrupts and no red-zone support. Imagine running inside your interrupt handler gcc puts some data inside the red zone a nested interrupt occurs and clobbers the red-zone or vice versa.

    To get around this the red-zone can be disabled by passing -mno-red-zone to GCC.

    x86_64-elf-gcc $CFLAGS -mno-red-zone ...
    就是为了保护一个128byte区域的编译特性,防止各种原因破坏其中的数据,一般在编译内核时都需要打开,编译一般的用户程序可以不打开。

相关问题

问题达人换一批

X86_64架构,ICC编译选项 mon-red-zon是啥