重新编码malloc:代码签名被阻止了mmap()

时间:2018-06-26 08:25:34

标签: c memory malloc shared-libraries

我实际上是在使用avl来重新编码malloc,并且当我使用以下脚本进行测试时:

#!/bin/sh
export DYLD_LIBRARY_PATH=.
export DYLD_INSERT_LIBRARIES="libft_malloc.so"
export DYLD_FORCE_FLAT_NAMESPACE=1`
$@

,然后是./script ls或./script vim,效果很好。但是当我在外壳程序中手动导出变量时,出现此错误:

dyld: warning: could not load inserted library 'libft_malloc.so' into 
library validated process because no suitable image found.  Did find:
    libft_malloc.so: code signing blocked mmap() of 'libft_malloc.so'

这是mmap的用法:

pges_ctrl.header_pge = mmap(NULL, getpagesize() * NB_PAGES, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (pges_ctrl.header_pge == MAP_FAILED)
    return (0);

tmp = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (tmp == MAP_FAILED)
{
    pges_ctrl.errors |= MMAP_BAD_ALLOC;
    return NULL;
}

如果您知道可能是什么原因,或者我如何调试它,那将会很有帮助! 我正在使用Mac OSX Sierra 10.12.6

使用gcc -Wall -Wextra -Werror编译 感谢您的帮助!

0 个答案:

没有答案