gpt4 book ai didi

elf - ELF 文件中的重定位加数 - Elf64_Rel 与 Elf64_Rela?

转载 作者:行者123 更新时间:2023-12-03 09:58:35 44 4
gpt4 key购买 nike

ELF 文件包含两个结构来处理重定位:

Elf64_Rel:

typedef struct {
Elf64_Addr r_offset;
Uint64_t
r_info;
} Elf64_Rel;

Elf64_Rela:

typedef struct {
Elf64_Addr r_offset;
uint64_t
r_info;
int64_t
r_addend;
} Elf64_Rela;

我想查看重定位条目,但不确定使用哪一个。手册页对此非常含糊。每个都有特定的用法吗?

最佳答案

这取决于目标。大多数目标仅使用两种形式中的一种。 Relocation中的章节 System V Application Binary Interface (ELF 规范)是这样说的:

As specified previously, only Elf32_Rela and Elf64_Rela entries contain an explicit addend. Entries of type Elf32_Rel and Elf64_Rel store an implicit addend in the location to be modified. Depending on the processor architecture, one form or the other might be necessary or more convenient. Consequently, an implementation for a particular machine may use one form exclusively or either form depending on context.

ELF 格式是自描述的,因为它显示是否使用 REL 或 RELA 重定位(SHT_RELSHT_RELA 用于节类型;DT_RELDT_RELSZDT_RELENTDT_RELADT_RELASZDT_RELAENT动态部分)。但是重定位处理本身是非常特定于目标的。

关于elf - ELF 文件中的重定位加数 - Elf64_Rel 与 Elf64_Rela?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60462386/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com