小编Ask*_*ons的帖子

apple的main参数中的ptr_munge是什么?

我最近在研究main的其他参数,发现除了macOS上的argc,argv和envp外,还有一个额外的char ** apple选项。

显然,我要做的第一件事就是快速遍历它:

int main(int argc, char ** argv, char ** envp, char ** apple)
{
    puts("-----------------Apple-----------------");
    for(char **a = apple; *a != 0; a++)
    {
        printf("%s\n", *a);
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

看看里面是什么:

-----------------Apple-----------------
executable_path=bin/apple



ptr_munge=
main_stack=
executable_file=0x1901000004,0x2ea3d0
dyld_file=0x1901000004,0xab575
Run Code Online (Sandbox Code Playgroud)

假设它们不是完全误导的名称,我可以猜出它们的其余部分是什么,但我有些困惑ptr_munge-那是什么,可以用它做什么?(还有所有额外的空白吗?)

编辑:

好的,我找到了这个文件:kern_exec.c,其中包含以下文件:

/*
 * libplatform needs a random pointer-obfuscation value when it is initialized.
 */
#define PTR_MUNGE_VALUES 1
#define PTR_MUNGE_KEY "ptr_munge="
...
/*
* Supply libpthread & libplatform with a random value to use for …
Run Code Online (Sandbox Code Playgroud)

c macos

6
推荐指数
1
解决办法
138
查看次数

mach-o标题中的标志是指什么?

我正在尝试这个,我注意到mach-o标题的标志部分,我想知道它做了什么.我试着谷歌搜索它,发现很多引用它,但没有解释标志是什么.

如果我在编译的基本hello世界中使用otool,clang hello.c那么运行otool它会给我这些标志:

$ otool a.out -h
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x80           2    14        664 0x00200085
Run Code Online (Sandbox Code Playgroud)

对于Chess.app

Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x80           2    32       4576 0x00210085
Run Code Online (Sandbox Code Playgroud)

这里有什么标志?我在哪里可以找到这样的答案?

macos mach-o otool

2
推荐指数
1
解决办法
205
查看次数

标签 统计

macos ×2

c ×1

mach-o ×1

otool ×1