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.reloc: added new constants for 32-bit PowerPC #439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
elf.reloc: added new constants for 32-bit PowerPC
  • Loading branch information
andrew committed Dec 10, 2024
commit 1675cb18c3524cd26bade8a15c5cd87e75288b85
164 changes: 164 additions & 0 deletions src/elf/constants_relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,89 @@ pub const R_RISCV_SET16: u32 = 55;
/// Local label subtraction
pub const R_RISCV_SET32: u32 = 56;

/////////////////////
// PowerPC
// See: https://www.nxp.com/docs/en/reference-manual/E500ABIUG.pdf
/////////////////////
pub const R_PPC_NONE: u32 = 0;
pub const R_PPC_ADDR32: u32 = 1;
pub const R_PPC_ADDR24: u32 = 2;
pub const R_PPC_ADDR16: u32 = 3;
pub const R_PPC_ADDR16_LO: u32 = 4;
pub const R_PPC_ADDR16_HI: u32 = 5;
pub const R_PPC_ADDR16_HA: u32 = 6;
pub const R_PPC_ADDR14: u32 = 7;
pub const R_PPC_ADDR14_BRTAKEN: u32 = 8;
pub const R_PPC_ADDR14_BRNTAKEN: u32 = 9;
pub const R_PPC_REL24: u32 = 10;
pub const R_PPC_REL14: u32 = 11;
pub const R_PPC_REL14_BRTAKEN: u32 = 12;
pub const R_PPC_REL14_BRNTAKEN: u32 = 13;
pub const R_PPC_GOT16: u32 = 14;
pub const R_PPC_GOT16_LO: u32 = 15;
pub const R_PPC_GOT16_HI: u32 = 16;
pub const R_PPC_GOT16_HA: u32 = 17;
pub const R_PPC_PLTREL24: u32 = 18;
pub const R_PPC_COPY: u32 = 19;
pub const R_PPC_GLOB_DAT: u32 = 20;
pub const R_PPC_JMP_SLOT: u32 = 21;
pub const R_PPC_RELATIVE: u32 = 22;
pub const R_PPC_LOCAL24PC: u32 = 23;
pub const R_PPC_UADDR32: u32 = 24;
pub const R_PPC_UADDR16: u32 = 25;
pub const R_PPC_REL32: u32 = 26;
pub const R_PPC_PLT32: u32 = 27;
pub const R_PPC_PLTREL32: u32 = 28;
pub const R_PPC_PLT16_LO: u32 = 29;
pub const R_PPC_PLT16_HI: u32 = 30;
pub const R_PPC_PLT16_HA: u32 = 31;
pub const R_PPC_SDAREL16: u32 = 32;
pub const R_PPC_SECTOFF: u32 = 33;
pub const R_PPC_SECTOFF_LO: u32 = 34;
pub const R_PPC_SECTOFF_HI: u32 = 35;
pub const R_PPC_SECTOFF_HA: u32 = 36;
pub const R_PPC_ADDR30: u32 = 37;
pub const R_PPC_EMB_NADDR32: u32 = 101;
pub const R_PPC_EMB_NADDR16: u32 = 102;
pub const R_PPC_EMB_NADDR16_LO: u32 = 103;
pub const R_PPC_EMB_NADDR16_HI: u32 = 104;
pub const R_PPC_EMB_NADDR16_HA: u32 = 105;
pub const R_PPC_EMB_SDA_I16: u32 = 106;
pub const R_PPC_EMB_SDA2_I16: u32 = 107;
pub const R_PPC_EMB_SDA2REL: u32 = 108;
pub const R_PPC_EMB_SDA21: u32 = 109;
pub const R_PPC_EMB_MRKREF: u32 = 110;
pub const R_PPC_EMB_RELSEC16: u32 = 111;
pub const R_PPC_EMB_RELST_LO: u32 = 112;
pub const R_PPC_EMB_RELST_HI: u32 = 113;
pub const R_PPC_EMB_RELST_HA: u32 = 114;
pub const R_PPC_EMB_BIT_FLD: u32 = 115;
pub const R_PPC_EMB_RELSDA: u32 = 116;
pub const R_PPC_EMB_RELOC_120: u32 = 120;
pub const R_PPC_EMB_RELOC_121: u32 = 121;
pub const R_PPC_DIAB_SDA21_LO: u32 = 180;
pub const R_PPC_DIAB_SDA21_HI: u32 = 181;
pub const R_PPC_DIAB_SDA21_HA: u32 = 182;
pub const R_PPC_DIAB_RELSDA_LO: u32 = 183;
pub const R_PPC_DIAB_RELSDA_HI: u32 = 184;
pub const R_PPC_DIAB_RELSDA_HA: u32 = 185;
pub const R_PPC_EMB_SPE_DOUBLE: u32 = 201;
pub const R_PPC_EMB_SPE_WORD: u32 = 202;
pub const R_PPC_EMB_SPE_HALF: u32 = 203;
pub const R_PPC_EMB_SPE_DOUBLE_SDAREL: u32 = 204;
pub const R_PPC_EMB_SPE_WORD_SDAREL: u32 = 205;
pub const R_PPC_EMB_SPE_HALF_SDAREL: u32 = 206;
pub const R_PPC_EMB_SPE_DOUBLE_SDA2REL: u32 = 207;
pub const R_PPC_EMB_SPE_WORD_SDA2REL: u32 = 208;
pub const R_PPC_EMB_SPE_HALF_SDA2REL: u32 = 209;
pub const R_PPC_EMB_SPE_DOUBLE_SDA0REL: u32 = 210;
pub const R_PPC_EMB_SPE_WORD_SDA0REL: u32 = 211;
pub const R_PPC_EMB_SPE_HALF_SDA0REL: u32 = 212;
pub const R_PPC_EMB_SPE_DOUBLE_SDA: u32 = 213;
pub const R_PPC_EMB_SPE_WORD_SDA: u32 = 214;
pub const R_PPC_EMB_SPE_HALF_SDA: u32 = 215;


#[inline]
pub fn r_to_str(typ: u32, machine: u16) -> &'static str {
use crate::elf::header::*;
Expand Down Expand Up @@ -1412,6 +1495,87 @@ pub fn r_to_str(typ: u32, machine: u16) -> &'static str {
R_RISCV_SET32 => "R_RISCV_SET32",
_ => "R_UNKNOWN_RISCV",
}},
// Power-PC
EM_PPC => { match typ {
R_PPC_NONE => "R_PPC_NONE",
R_PPC_ADDR32 => "R_PPC_ADDR32",
R_PPC_ADDR24 => "R_PPC_ADDR24",
R_PPC_ADDR16 => "R_PPC_ADDR16",
R_PPC_ADDR16_LO => "R_PPC_ADDR16_LO",
R_PPC_ADDR16_HI => "R_PPC_ADDR16_HI",
R_PPC_ADDR16_HA => "R_PPC_ADDR16_HA",
R_PPC_ADDR14 => "R_PPC_ADDR14",
R_PPC_ADDR14_BRTAKEN => "R_PPC_ADDR14_BRTAKEN",
R_PPC_ADDR14_BRNTAKEN => "R_PPC_ADDR14_BRNTAKEN",
R_PPC_REL24 => "R_PPC_REL24",
R_PPC_REL14 => "R_PPC_REL14",
R_PPC_REL14_BRTAKEN => "R_PPC_REL14_BRTAKEN",
R_PPC_REL14_BRNTAKEN => "R_PPC_REL14_BRNTAKEN",
R_PPC_GOT16 => "R_PPC_GOT16",
R_PPC_GOT16_LO => "R_PPC_GOT16_LO",
R_PPC_GOT16_HI => "R_PPC_GOT16_HI",
R_PPC_GOT16_HA => "R_PPC_GOT16_HA",
R_PPC_PLTREL24 => "R_PPC_PLTREL24",
R_PPC_COPY => "R_PPC_COPY",
R_PPC_GLOB_DAT => "R_PPC_GLOB_DAT",
R_PPC_JMP_SLOT => "R_PPC_JMP_SLOT",
R_PPC_RELATIVE => "R_PPC_RELATIVE",
R_PPC_LOCAL24PC => "R_PPC_LOCAL24PC",
R_PPC_UADDR32 => "R_PPC_UADDR32",
R_PPC_UADDR16 => "R_PPC_UADDR16",
R_PPC_REL32 => "R_PPC_REL32",
R_PPC_PLT32 => "R_PPC_PLT32",
R_PPC_PLTREL32 => "R_PPC_PLTREL32",
R_PPC_PLT16_LO => "R_PPC_PLT16_LO",
R_PPC_PLT16_HI => "R_PPC_PLT16_HI",
R_PPC_PLT16_HA => "R_PPC_PLT16_HA",
R_PPC_SDAREL16 => "R_PPC_SDAREL16",
R_PPC_SECTOFF => "R_PPC_SECTOFF",
R_PPC_SECTOFF_LO => "R_PPC_SECTOFF_LO",
R_PPC_SECTOFF_HI => "R_PPC_SECTOFF_HI",
R_PPC_SECTOFF_HA => "R_PPC_SECTOFF_HA",
R_PPC_ADDR30 => "R_PPC_ADDR30",
R_PPC_EMB_NADDR32 => "R_PPC_EMB_NADDR32",
R_PPC_EMB_NADDR16 => "R_PPC_EMB_NADDR16",
R_PPC_EMB_NADDR16_LO => "R_PPC_EMB_NADDR16_LO",
R_PPC_EMB_NADDR16_HI => "R_PPC_EMB_NADDR16_HI",
R_PPC_EMB_NADDR16_HA => "R_PPC_EMB_NADDR16_HA",
R_PPC_EMB_SDA_I16 => "R_PPC_EMB_SDA_I16",
R_PPC_EMB_SDA2_I16 => "R_PPC_EMB_SDA2_I16",
R_PPC_EMB_SDA2REL => "R_PPC_EMB_SDA2REL",
R_PPC_EMB_SDA21 => "R_PPC_EMB_SDA21",
R_PPC_EMB_MRKREF => "R_PPC_EMB_MRKREF",
R_PPC_EMB_RELSEC16 => "R_PPC_EMB_RELSEC16",
R_PPC_EMB_RELST_LO => "R_PPC_EMB_RELST_LO",
R_PPC_EMB_RELST_HI => "R_PPC_EMB_RELST_HI",
R_PPC_EMB_RELST_HA => "R_PPC_EMB_RELST_HA",
R_PPC_EMB_BIT_FLD => "R_PPC_EMB_BIT_FLD",
R_PPC_EMB_RELSDA => "R_PPC_EMB_RELSDA",
R_PPC_EMB_RELOC_120 => "R_PPC_EMB_RELOC_120",
R_PPC_EMB_RELOC_121 => "R_PPC_EMB_RELOC_121",
R_PPC_DIAB_SDA21_LO => "R_PPC_DIAB_SDA21_LO",
R_PPC_DIAB_SDA21_HI => "R_PPC_DIAB_SDA21_HI",
R_PPC_DIAB_SDA21_HA => "R_PPC_DIAB_SDA21_HA",
R_PPC_DIAB_RELSDA_LO => "R_PPC_DIAB_RELSDA_LO",
R_PPC_DIAB_RELSDA_HI => "R_PPC_DIAB_RELSDA_HI",
R_PPC_DIAB_RELSDA_HA => "R_PPC_DIAB_RELSDA_HA",
R_PPC_EMB_SPE_DOUBLE => "R_PPC_EMB_SPE_DOUBLE",
R_PPC_EMB_SPE_WORD => "R_PPC_EMB_SPE_WORD",
R_PPC_EMB_SPE_HALF => "R_PPC_EMB_SPE_HALF",
R_PPC_EMB_SPE_DOUBLE_SDAREL => "R_PPC_EMB_SPE_DOUBLE_SDAREL",
R_PPC_EMB_SPE_WORD_SDAREL => "R_PPC_EMB_SPE_WORD_SDAREL",
R_PPC_EMB_SPE_HALF_SDAREL => "R_PPC_EMB_SPE_HALF_SDAREL",
R_PPC_EMB_SPE_DOUBLE_SDA2REL => "R_PPC_EMB_SPE_DOUBLE_SDA2REL",
R_PPC_EMB_SPE_WORD_SDA2REL => "R_PPC_EMB_SPE_WORD_SDA2REL",
R_PPC_EMB_SPE_HALF_SDA2REL => "R_PPC_EMB_SPE_HALF_SDA2REL",
R_PPC_EMB_SPE_DOUBLE_SDA0REL => "R_PPC_EMB_SPE_DOUBLE_SDA0REL",
R_PPC_EMB_SPE_WORD_SDA0REL => "R_PPC_EMB_SPE_WORD_SDA0REL",
R_PPC_EMB_SPE_HALF_SDA0REL => "R_PPC_EMB_SPE_HALF_SDA0REL",
R_PPC_EMB_SPE_DOUBLE_SDA => "R_PPC_EMB_SPE_DOUBLE_SDA",
R_PPC_EMB_SPE_WORD_SDA => "R_PPC_EMB_SPE_WORD_SDA",
R_PPC_EMB_SPE_HALF_SDA => "R_PPC_EMB_SPE_HALF_SDA",
_ => "R_UNKNOWN_PPC",
}},
_ => "R_UNKNOWN",
}
}
Loading