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

elf: Update LoongArch relocation types per LoongArch ABI v2.20 #589

Merged
merged 2 commits into from
Nov 7, 2023
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
1 change: 1 addition & 0 deletions crates/examples/src/readobj/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3170,6 +3170,7 @@ const FLAGS_R_LOONGARCH: &[Flag<u32>] = &flags!(
R_LARCH_ADD_ULEB128,
R_LARCH_SUB_ULEB128,
R_LARCH_64_PCREL,
R_LARCH_CALL36,
);
const FLAGS_NT_CORE: &[Flag<u32>] = &flags!(
NT_PRSTATUS,
Expand Down
5 changes: 4 additions & 1 deletion src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6055,7 +6055,7 @@ pub const R_LARCH_32_PCREL: u32 = 99;
/// Paired with a normal relocation at the same address to indicate the
/// instruction can be relaxed
pub const R_LARCH_RELAX: u32 = 100;
/// Delete an instruction, should be only used internally by the linker
/// Reserved
pub const R_LARCH_DELETE: u32 = 101;
/// Delete some bytes to ensure the instruction at PC + A aligned to
/// `A.next_power_of_two()`-byte boundary
Expand All @@ -6074,6 +6074,9 @@ pub const R_LARCH_ADD_ULEB128: u32 = 107;
pub const R_LARCH_SUB_ULEB128: u32 = 108;
/// 64-bit PC relative
pub const R_LARCH_64_PCREL: u32 = 109;
/// 18..=37 bits of `S + A - PC` into the `pcaddu18i` instruction at `PC`,
/// and 2..=17 bits of `S + A - PC` into the `jirl` instruction at `PC + 4`
pub const R_LARCH_CALL36: u32 = 110;

// Xtensa values Rel*::r_type`.
pub const R_XTENSA_NONE: u32 = 0;
Expand Down
1 change: 1 addition & 0 deletions src/write/elf/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ impl<'a> Object<'a> {
(RelocationKind::Absolute, _, 32) => elf::R_LARCH_32,
(RelocationKind::Absolute, _, 64) => elf::R_LARCH_64,
(RelocationKind::Relative, _, 32) => elf::R_LARCH_32_PCREL,
(RelocationKind::Relative, _, 64) => elf::R_LARCH_64_PCREL,
(RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 16)
| (
RelocationKind::PltRelative,
Expand Down