b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

otool_otoole_对mac的终端写otool(3)

电脑杂谈  发布时间:2017-04-21 10:10:19  来源:网络整理

cmdsize是加载命令的字节数。

当加载命令的类型为LC_SEGMENT时(segment load command),意味着这部分文件需要映射到进程的地址空间中去。其对应的结构体如下:

[codesyntax lang="c" lines="fancy"]

struct segment_command {
	/* for 32-bit architectures */
        uint32_t   cmd;
        /* LC_SEGMENT */
        uint32_t   cmdsize;
        /* includes sizeof section structs */
        char          segname[16];
        /* segment name */
        uint32_t   vmaddr;
        /* memory address of this segment */
        uint32_t   vmsize;
        /* memory size of this segment */
        uint32_t   fileoff;
        /* file offset of this segment */
        uint32_t   filesize;
        /* amount to map from the file */
        vm_prot_t        maxprot;
        /* maximum VM protection */
        vm_prot_t        initprot;
        /* initial VM protection */
        uint32_t   nsects;
        /* number of sections in segment */
        uint32_t   flags;
        /* flags */
};

[/codesyntax]cmd字段 类型为LC_SEGMENT;

cmdsize字段 当前段(segment)所包含的sections的字节数。

flag字段 SG_HIGHVM,SG_FVMLIB,SG_NORELOC,SG_PROTECTED_VERSION_1;具体解释参照/usr/include/mach-o/loader.h

文件映射的起始位置是由fileoff给出,映射到地址空间的vmaddr处。otool

vmsize等于或者大于filesize。

看到上面两个定义,我们在回头看截取的load command 0,发现:

类型为LC_SEGMENT,故完全符合segment_command的定义

在截取信息中,我们可以清晰的看到命令字节数,虚拟地址起始位置,所占空间等信息。

如果当前段(segment)包含section,那么section structure紧跟在segment command之后,section所占的字节数由当前段的cmdsize字段给出。

Section的定义如下:

[codesyntax lang="c" lines="fancy"]

struct section {
	/* for 32-bit architectures */
        char          sectname[16];
        /* name of this section */
        char          segname[16];
        /* segment this section goes in */
        uint32_t   addr;
        /* memory address of this section */
        uint32_t   size;
        /* size in bytes of this section */
        uint32_t   offset;
        /* file offset of this section */
        uint32_t   align;
        /* section alignment (power of 2) */
        uint32_t   reloff;
        /* file offset of relocation entries */
        uint32_t   nreloc;
        /* number of relocation entries */
        uint32_t   flags;
        /* flags (section type and attributes)*/
        uint32_t   reserved1;
        /* reserved (for offset or index) */
        uint32_t   reserved2;
        /* reserved (for count or sizeof) */
};


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-42605-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...