1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use cretonne_codegen::binemit::Reloc;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Format {
ELF,
MachO,
}
pub fn raw_relocation(reloc: Reloc, format: Format) -> u32 {
match format {
Format::ELF => {
use goblin::elf;
match reloc {
Reloc::Abs4 => elf::reloc::R_X86_64_32,
Reloc::Abs8 => elf::reloc::R_X86_64_64,
Reloc::X86PCRel4 => elf::reloc::R_X86_64_PC32,
Reloc::X86GOTPCRel4 => elf::reloc::R_X86_64_GOTPCREL,
Reloc::X86PLTRel4 => elf::reloc::R_X86_64_PLT32,
_ => unimplemented!(),
}
}
Format::MachO => unimplemented!(),
}
}