附加向量

本文介绍了ELF binary loader使用的辅助向量(Auxiliary vector),详细解析了其在X86和X64架构中的位置,以及如何利用AT_SYSINFO_EHDR、AT_SYSINFO、AT_RANDOM和AT_PLATFORM等字段传递信息,特别是如何通过AT_RANDOM来计算栈数据地址。辅助向量位于环境指针数组之后,环境字符串之前,对于理解和利用这些信息至关重要。
摘要由CSDN通过智能技术生成

附加向量

1.1 附加向量

Auxiliary vector是一种机制,内核的ELF binary loader使用附加向量在程序执行时传递某些信息到用户空间。

 #include <sys/auxv.h>

unsigned long getauxval(unsigned long type);

 

sys/auxv.h

#define AT_NULL         0               /* End of vector */

#define AT_IGNORE       1               /* Entry should be ignored */

#define AT_EXECFD       2               /* File descriptor of program */

#define AT_PHDR         3               /* Program headers for program */

#define AT_PHENT        4               /* Size of program header entry */

#define AT_PHNUM        5               /* Number of program headers */

#define AT_PAGESZ       6               /* System page size */

#define AT_BASE         7               /* Base address of interpreter */

#define AT_FLAGS        8               /* Flags */

#define AT_ENTRY        9               /* Entry point of program */

#define AT_NOTELF       10              /* Program is not ELF */

#define AT_UID          11              /* Real uid */

#define AT_EUID         12              /* Effective uid */

#define AT_GID          13              /* Real gid */

#define AT_EGID         14              /* Effective gid */

#define AT_CLKTCK       17              /* Frequency of times() */

 

/* Some more special a_type values describing the hardware.  */

#define AT_PLATFORM     15              /* String identifying platform.  */

#define AT_HWCAP        16              /* Machine-dependent hints about

                                           processor capabilities.  */

 

/* This entry gives some information about the FPU initialization

   performed by the kernel.  */

#define AT_FPUCW        18              /* Used FPU control word.  */

 

/* Cache block sizes.  */

#define AT_DCACHEBSIZE  19              /* Data cache block size.  */

#define AT_ICACHEBSIZE  20              /* Instruction cache block size.  */

#define AT_UCACHEBSIZE  21              /* Unified cache block size.  */

 

/* A special ignored value for PPC, used by the kernel to control the

   interpretation of the AUXV. Must be > 16.  */

#define AT_IGNOREPPC    22              /* Entry should be ignored.  */

 

#define AT_SECURE       23              /* Boolean, was exec setuid-like?  */

 

#define AT_BASE_PLATFORM 24             /* String identifying real platforms.*/

 

#define AT_RANDOM       25              /* Address of 16 random bytes.  */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值