Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native support for writing ELF R_AARCH64_CALL26 relocations #322

Merged
merged 3 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ pub enum RelocationEncoding {
///
/// The `RelocationKind` must be PC relative.
S390xDbl,

/// AArch64 call target.
///
/// The `RelocationKind` must be PC relative.
AArch64Call,
}

/// File flags that are specific to each file format.
Expand Down
4 changes: 4 additions & 0 deletions src/read/elf/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ fn parse_relocation<Elf: FileHeader>(
elf::R_AARCH64_PREL64 => (RelocationKind::Relative, 64),
elf::R_AARCH64_PREL32 => (RelocationKind::Relative, 32),
elf::R_AARCH64_PREL16 => (RelocationKind::Relative, 16),
elf::R_AARCH64_CALL26 => {
encoding = RelocationEncoding::AArch64Call;
(RelocationKind::PltRelative, 26)
}
bjorn3 marked this conversation as resolved.
Show resolved Hide resolved
r_type => (RelocationKind::Elf(r_type), 0),
},
elf::EM_ARM => match reloc.r_type(endian, false) {
Expand Down
4 changes: 4 additions & 0 deletions src/write/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@ impl Object {
(RelocationKind::Relative, RelocationEncoding::Generic, 16) => {
elf::R_AARCH64_PREL16
}
(RelocationKind::Relative, RelocationEncoding::AArch64Call, 26)
| (RelocationKind::PltRelative, RelocationEncoding::AArch64Call, 26) => {
elf::R_AARCH64_CALL26
}
bjorn3 marked this conversation as resolved.
Show resolved Hide resolved
(RelocationKind::Elf(x), _, _) => x,
_ => {
return Err(Error(format!("unimplemented relocation {:?}", reloc)));
Expand Down