libdyld: add arm relocation types

This commit is contained in:
Astro 2020-04-17 23:10:53 +02:00 committed by Sebastien Bourdeauducq
parent 102d553b5c
commit e1190ec76c
2 changed files with 134 additions and 132 deletions

View File

@ -1462,133 +1462,132 @@ pub const R_AARCH64_TLS_DTPREL64: usize = 1029;
pub const R_AARCH64_TLS_TPREL64: usize = 1030;
pub const R_AARCH64_TLSDESC: usize = 1031;
pub const R_AARCH64_IRELATIVE: usize = 1032;
pub const R_ARM_NONE: usize = 0;
pub const R_ARM_PC24: usize = 1;
pub const R_ARM_ABS32: usize = 2;
pub const R_ARM_REL32: usize = 3;
pub const R_ARM_PC13: usize = 4;
pub const R_ARM_ABS16: usize = 5;
pub const R_ARM_ABS12: usize = 6;
pub const R_ARM_THM_ABS5: usize = 7;
pub const R_ARM_ABS8: usize = 8;
pub const R_ARM_SBREL32: usize = 9;
pub const R_ARM_THM_PC22: usize = 10;
pub const R_ARM_THM_PC8: usize = 11;
pub const R_ARM_AMP_VCALL9: usize = 12;
pub const R_ARM_SWI24: usize = 13;
pub const R_ARM_TLS_DESC: usize = 13;
pub const R_ARM_THM_SWI8: usize = 14;
pub const R_ARM_XPC25: usize = 15;
pub const R_ARM_THM_XPC22: usize = 16;
pub const R_ARM_TLS_DTPMOD32: usize = 17;
pub const R_ARM_TLS_DTPOFF32: usize = 18;
pub const R_ARM_TLS_TPOFF32: usize = 19;
pub const R_ARM_COPY: usize = 20;
pub const R_ARM_GLOB_DAT: usize = 21;
pub const R_ARM_JUMP_SLOT: usize = 22;
pub const R_ARM_RELATIVE: usize = 23;
pub const R_ARM_GOTOFF: usize = 24;
pub const R_ARM_GOTPC: usize = 25;
pub const R_ARM_GOT32: usize = 26;
pub const R_ARM_PLT32: usize = 27;
pub const R_ARM_CALL: usize = 28;
pub const R_ARM_JUMP24: usize = 29;
pub const R_ARM_THM_JUMP24: usize = 30;
pub const R_ARM_BASE_ABS: usize = 31;
pub const R_ARM_ALU_PCREL_7_0: usize = 32;
pub const R_ARM_ALU_PCREL_15_8: usize = 33;
pub const R_ARM_ALU_PCREL_23_15: usize = 34;
pub const R_ARM_LDR_SBREL_11_0: usize = 35;
pub const R_ARM_ALU_SBREL_19_12: usize = 36;
pub const R_ARM_ALU_SBREL_27_20: usize = 37;
pub const R_ARM_TARGET1: usize = 38;
pub const R_ARM_SBREL31: usize = 39;
pub const R_ARM_V4BX: usize = 40;
pub const R_ARM_TARGET2: usize = 41;
pub const R_ARM_PREL31: usize = 42;
pub const R_ARM_MOVW_ABS_NC: usize = 43;
pub const R_ARM_MOVT_ABS: usize = 44;
pub const R_ARM_MOVW_PREL_NC: usize = 45;
pub const R_ARM_MOVT_PREL: usize = 46;
pub const R_ARM_THM_MOVW_ABS_NC: usize = 47;
pub const R_ARM_THM_MOVT_ABS: usize = 48;
pub const R_ARM_THM_MOVW_PREL_NC: usize = 49;
pub const R_ARM_THM_MOVT_PREL: usize = 50;
pub const R_ARM_THM_JUMP19: usize = 51;
pub const R_ARM_THM_JUMP6: usize = 52;
pub const R_ARM_THM_ALU_PREL_11_0: usize = 53;
pub const R_ARM_THM_PC12: usize = 54;
pub const R_ARM_ABS32_NOI: usize = 55;
pub const R_ARM_REL32_NOI: usize = 56;
pub const R_ARM_ALU_PC_G0_NC: usize = 57;
pub const R_ARM_ALU_PC_G0: usize = 58;
pub const R_ARM_ALU_PC_G1_NC: usize = 59;
pub const R_ARM_ALU_PC_G1: usize = 60;
pub const R_ARM_ALU_PC_G2: usize = 61;
pub const R_ARM_LDR_PC_G1: usize = 62;
pub const R_ARM_LDR_PC_G2: usize = 63;
pub const R_ARM_LDRS_PC_G0: usize = 64;
pub const R_ARM_LDRS_PC_G1: usize = 65;
pub const R_ARM_LDRS_PC_G2: usize = 66;
pub const R_ARM_LDC_PC_G0: usize = 67;
pub const R_ARM_LDC_PC_G1: usize = 68;
pub const R_ARM_LDC_PC_G2: usize = 69;
pub const R_ARM_ALU_SB_G0_NC: usize = 70;
pub const R_ARM_ALU_SB_G0: usize = 71;
pub const R_ARM_ALU_SB_G1_NC: usize = 72;
pub const R_ARM_ALU_SB_G1: usize = 73;
pub const R_ARM_ALU_SB_G2: usize = 74;
pub const R_ARM_LDR_SB_G0: usize = 75;
pub const R_ARM_LDR_SB_G1: usize = 76;
pub const R_ARM_LDR_SB_G2: usize = 77;
pub const R_ARM_LDRS_SB_G0: usize = 78;
pub const R_ARM_LDRS_SB_G1: usize = 79;
pub const R_ARM_LDRS_SB_G2: usize = 80;
pub const R_ARM_LDC_SB_G0: usize = 81;
pub const R_ARM_LDC_SB_G1: usize = 82;
pub const R_ARM_LDC_SB_G2: usize = 83;
pub const R_ARM_MOVW_BREL_NC: usize = 84;
pub const R_ARM_MOVT_BREL: usize = 85;
pub const R_ARM_MOVW_BREL: usize = 86;
pub const R_ARM_THM_MOVW_BREL_NC: usize = 87;
pub const R_ARM_THM_MOVT_BREL: usize = 88;
pub const R_ARM_THM_MOVW_BREL: usize = 89;
pub const R_ARM_TLS_GOTDESC: usize = 90;
pub const R_ARM_TLS_CALL: usize = 91;
pub const R_ARM_TLS_DESCSEQ: usize = 92;
pub const R_ARM_THM_TLS_CALL: usize = 93;
pub const R_ARM_PLT32_ABS: usize = 94;
pub const R_ARM_GOT_ABS: usize = 95;
pub const R_ARM_GOT_PREL: usize = 96;
pub const R_ARM_GOT_BREL12: usize = 97;
pub const R_ARM_GOTOFF12: usize = 98;
pub const R_ARM_GOTRELAX: usize = 99;
pub const R_ARM_GNU_VTENTRY: usize = 100;
pub const R_ARM_GNU_VTINHERIT: usize = 101;
pub const R_ARM_THM_PC11: usize = 102;
pub const R_ARM_THM_PC9: usize = 103;
pub const R_ARM_TLS_GD32: usize = 104;
pub const R_ARM_TLS_LDM32: usize = 105;
pub const R_ARM_TLS_LDO32: usize = 106;
pub const R_ARM_TLS_IE32: usize = 107;
pub const R_ARM_TLS_LE32: usize = 108;
pub const R_ARM_TLS_LDO12: usize = 109;
pub const R_ARM_TLS_LE12: usize = 110;
pub const R_ARM_TLS_IE12GP: usize = 111;
pub const R_ARM_ME_TOO: usize = 128;
pub const R_ARM_THM_TLS_DESCSEQ: usize = 129;
pub const R_ARM_THM_TLS_DESCSEQ16: usize = 129;
pub const R_ARM_THM_TLS_DESCSEQ32: usize = 130;
pub const R_ARM_THM_GOT_BREL12: usize = 131;
pub const R_ARM_IRELATIVE: usize = 160;
pub const R_ARM_RXPC25: usize = 249;
pub const R_ARM_RSBREL32: usize = 250;
pub const R_ARM_THM_RPC22: usize = 251;
pub const R_ARM_RREL32: usize = 252;
pub const R_ARM_RABS22: usize = 253;
pub const R_ARM_RPC24: usize = 254;
pub const R_ARM_RBASE: usize = 255;
pub const R_ARM_NUM: usize = 256;
pub const R_ARM_NONE: u8 = 0;
pub const R_ARM_PC24: u8 = 1;
pub const R_ARM_ABS32: u8 = 2;
pub const R_ARM_REL32: u8 = 3;
pub const R_ARM_PC13: u8 = 4;
pub const R_ARM_ABS16: u8 = 5;
pub const R_ARM_ABS12: u8 = 6;
pub const R_ARM_THM_ABS5: u8 = 7;
pub const R_ARM_ABS8: u8 = 8;
pub const R_ARM_SBREL32: u8 = 9;
pub const R_ARM_THM_PC22: u8 = 10;
pub const R_ARM_THM_PC8: u8 = 11;
pub const R_ARM_AMP_VCALL9: u8 = 12;
pub const R_ARM_SWI24: u8 = 13;
pub const R_ARM_TLS_DESC: u8 = 13;
pub const R_ARM_THM_SWI8: u8 = 14;
pub const R_ARM_XPC25: u8 = 15;
pub const R_ARM_THM_XPC22: u8 = 16;
pub const R_ARM_TLS_DTPMOD32: u8 = 17;
pub const R_ARM_TLS_DTPOFF32: u8 = 18;
pub const R_ARM_TLS_TPOFF32: u8 = 19;
pub const R_ARM_COPY: u8 = 20;
pub const R_ARM_GLOB_DAT: u8 = 21;
pub const R_ARM_JUMP_SLOT: u8 = 22;
pub const R_ARM_RELATIVE: u8 = 23;
pub const R_ARM_GOTOFF: u8 = 24;
pub const R_ARM_GOTPC: u8 = 25;
pub const R_ARM_GOT32: u8 = 26;
pub const R_ARM_PLT32: u8 = 27;
pub const R_ARM_CALL: u8 = 28;
pub const R_ARM_JUMP24: u8 = 29;
pub const R_ARM_THM_JUMP24: u8 = 30;
pub const R_ARM_BASE_ABS: u8 = 31;
pub const R_ARM_ALU_PCREL_7_0: u8 = 32;
pub const R_ARM_ALU_PCREL_15_8: u8 = 33;
pub const R_ARM_ALU_PCREL_23_15: u8 = 34;
pub const R_ARM_LDR_SBREL_11_0: u8 = 35;
pub const R_ARM_ALU_SBREL_19_12: u8 = 36;
pub const R_ARM_ALU_SBREL_27_20: u8 = 37;
pub const R_ARM_TARGET1: u8 = 38;
pub const R_ARM_SBREL31: u8 = 39;
pub const R_ARM_V4BX: u8 = 40;
pub const R_ARM_TARGET2: u8 = 41;
pub const R_ARM_PREL31: u8 = 42;
pub const R_ARM_MOVW_ABS_NC: u8 = 43;
pub const R_ARM_MOVT_ABS: u8 = 44;
pub const R_ARM_MOVW_PREL_NC: u8 = 45;
pub const R_ARM_MOVT_PREL: u8 = 46;
pub const R_ARM_THM_MOVW_ABS_NC: u8 = 47;
pub const R_ARM_THM_MOVT_ABS: u8 = 48;
pub const R_ARM_THM_MOVW_PREL_NC: u8 = 49;
pub const R_ARM_THM_MOVT_PREL: u8 = 50;
pub const R_ARM_THM_JUMP19: u8 = 51;
pub const R_ARM_THM_JUMP6: u8 = 52;
pub const R_ARM_THM_ALU_PREL_11_0: u8 = 53;
pub const R_ARM_THM_PC12: u8 = 54;
pub const R_ARM_ABS32_NOI: u8 = 55;
pub const R_ARM_REL32_NOI: u8 = 56;
pub const R_ARM_ALU_PC_G0_NC: u8 = 57;
pub const R_ARM_ALU_PC_G0: u8 = 58;
pub const R_ARM_ALU_PC_G1_NC: u8 = 59;
pub const R_ARM_ALU_PC_G1: u8 = 60;
pub const R_ARM_ALU_PC_G2: u8 = 61;
pub const R_ARM_LDR_PC_G1: u8 = 62;
pub const R_ARM_LDR_PC_G2: u8 = 63;
pub const R_ARM_LDRS_PC_G0: u8 = 64;
pub const R_ARM_LDRS_PC_G1: u8 = 65;
pub const R_ARM_LDRS_PC_G2: u8 = 66;
pub const R_ARM_LDC_PC_G0: u8 = 67;
pub const R_ARM_LDC_PC_G1: u8 = 68;
pub const R_ARM_LDC_PC_G2: u8 = 69;
pub const R_ARM_ALU_SB_G0_NC: u8 = 70;
pub const R_ARM_ALU_SB_G0: u8 = 71;
pub const R_ARM_ALU_SB_G1_NC: u8 = 72;
pub const R_ARM_ALU_SB_G1: u8 = 73;
pub const R_ARM_ALU_SB_G2: u8 = 74;
pub const R_ARM_LDR_SB_G0: u8 = 75;
pub const R_ARM_LDR_SB_G1: u8 = 76;
pub const R_ARM_LDR_SB_G2: u8 = 77;
pub const R_ARM_LDRS_SB_G0: u8 = 78;
pub const R_ARM_LDRS_SB_G1: u8 = 79;
pub const R_ARM_LDRS_SB_G2: u8 = 80;
pub const R_ARM_LDC_SB_G0: u8 = 81;
pub const R_ARM_LDC_SB_G1: u8 = 82;
pub const R_ARM_LDC_SB_G2: u8 = 83;
pub const R_ARM_MOVW_BREL_NC: u8 = 84;
pub const R_ARM_MOVT_BREL: u8 = 85;
pub const R_ARM_MOVW_BREL: u8 = 86;
pub const R_ARM_THM_MOVW_BREL_NC: u8 = 87;
pub const R_ARM_THM_MOVT_BREL: u8 = 88;
pub const R_ARM_THM_MOVW_BREL: u8 = 89;
pub const R_ARM_TLS_GOTDESC: u8 = 90;
pub const R_ARM_TLS_CALL: u8 = 91;
pub const R_ARM_TLS_DESCSEQ: u8 = 92;
pub const R_ARM_THM_TLS_CALL: u8 = 93;
pub const R_ARM_PLT32_ABS: u8 = 94;
pub const R_ARM_GOT_ABS: u8 = 95;
pub const R_ARM_GOT_PREL: u8 = 96;
pub const R_ARM_GOT_BREL12: u8 = 97;
pub const R_ARM_GOTOFF12: u8 = 98;
pub const R_ARM_GOTRELAX: u8 = 99;
pub const R_ARM_GNU_VTENTRY: u8 = 100;
pub const R_ARM_GNU_VTINHERIT: u8 = 101;
pub const R_ARM_THM_PC11: u8 = 102;
pub const R_ARM_THM_PC9: u8 = 103;
pub const R_ARM_TLS_GD32: u8 = 104;
pub const R_ARM_TLS_LDM32: u8 = 105;
pub const R_ARM_TLS_LDO32: u8 = 106;
pub const R_ARM_TLS_IE32: u8 = 107;
pub const R_ARM_TLS_LE32: u8 = 108;
pub const R_ARM_TLS_LDO12: u8 = 109;
pub const R_ARM_TLS_LE12: u8 = 110;
pub const R_ARM_TLS_IE12GP: u8 = 111;
pub const R_ARM_ME_TOO: u8 = 128;
pub const R_ARM_THM_TLS_DESCSEQ: u8 = 129;
pub const R_ARM_THM_TLS_DESCSEQ16: u8 = 129;
pub const R_ARM_THM_TLS_DESCSEQ32: u8 = 130;
pub const R_ARM_THM_GOT_BREL12: u8 = 131;
pub const R_ARM_IRELATIVE: u8 = 160;
pub const R_ARM_RXPC25: u8 = 249;
pub const R_ARM_RSBREL32: u8 = 250;
pub const R_ARM_THM_RPC22: u8 = 251;
pub const R_ARM_RREL32: u8 = 252;
pub const R_ARM_RABS22: u8 = 253;
pub const R_ARM_RPC24: u8 = 254;
pub const R_ARM_RBASE: u8 = 255;
pub const EF_IA_64_MASKOS: usize = 15;
pub const EF_IA_64_ABI64: usize = 16;
pub const EF_IA_64_ARCH: usize = 4278190080;

View File

@ -134,7 +134,8 @@ impl<'a> Library<'a> {
pub unsafe fn rebind(&self, name: &[u8], addr: Elf32_Word) -> Result<(), Error<'a>> {
for rela in self.pltrel.iter() {
match ELF32_R_TYPE(rela.r_info) {
R_OR1K_32 | R_OR1K_GLOB_DAT | R_OR1K_JMP_SLOT => {
R_OR1K_32 | R_OR1K_GLOB_DAT | R_OR1K_JMP_SLOT |
R_ARM_GLOB_DAT | R_ARM_JUMP_SLOT => {
let sym = self.symtab.get(ELF32_R_SYM(rela.r_info) as usize)
.ok_or("symbol out of bounds of symbol table")?;
let sym_name = self.name_starting_at(sym.st_name as usize)?;
@ -163,13 +164,14 @@ impl<'a> Library<'a> {
let value;
match ELF32_R_TYPE(rela.r_info) {
R_OR1K_NONE =>
R_OR1K_NONE | R_ARM_NONE =>
return Ok(()),
R_OR1K_RELATIVE =>
R_OR1K_RELATIVE | R_ARM_RELATIVE =>
value = self.image_off + rela.r_addend as Elf32_Word,
R_OR1K_32 | R_OR1K_GLOB_DAT | R_OR1K_JMP_SLOT => {
R_OR1K_32 | R_OR1K_GLOB_DAT | R_OR1K_JMP_SLOT |
R_ARM_GLOB_DAT | R_ARM_JUMP_SLOT => {
let sym = sym.ok_or("relocation requires an associated symbol")?;
let sym_name = self.name_starting_at(sym.st_name as usize)?;
@ -189,7 +191,8 @@ impl<'a> Library<'a> {
}
}
_ => return Err("unsupported relocation type")?
_ =>
return Err("unsupported relocation type")?,
}
self.update_rela(rela, value)