Unexpected exec permission from mmap when assembly files included in the project

后端 未结 2 1290
甜味超标
甜味超标 2020-11-28 07:36

I am banging my head into the wall with this.

In my project, when I\'m allocating memory with mmap the mapping (/proc/self/maps) shows that

2条回答
  •  日久生厌
    2020-11-28 08:26

    As an alternative to modifying your assembly files with GNU-specific section directive variants, you can add -Wa,--noexecstack to your command line for building assembly files. For example, see how I do it in musl's configure:

    https://git.musl-libc.org/cgit/musl/commit/configure?id=adefe830dd376be386df5650a09c313c483adf1a

    I believe at least some versions of clang with integrated-assembler may require it to be passed as --noexecstack (without the -Wa), so your configure script should probably check both and see which is accepted.

    You can also use -Wl,-z,noexecstack at link time (in LDFLAGS) to get the same result. The disadvantage of this is that it doesn't help if your project produces static (.a) library files for use by other software, since you then don't control the link-time options when it's used by other programs.

提交回复
热议问题