Skip to content

Commit

Permalink
Add native support for writing ELF R_AARCH64_CALL26 relocations (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 authored Jun 11, 2021
1 parent d1b9429 commit d26bc89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
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)
}
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
}
(RelocationKind::Elf(x), _, _) => x,
_ => {
return Err(Error(format!("unimplemented relocation {:?}", reloc)));
Expand Down

0 comments on commit d26bc89

Please sign in to comment.