diff options
Diffstat (limited to 'vendor/object/src/write/elf')
-rw-r--r-- | vendor/object/src/write/elf/object.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/object/src/write/elf/object.rs b/vendor/object/src/write/elf/object.rs index 8c1fa4717..068ada6bd 100644 --- a/vendor/object/src/write/elf/object.rs +++ b/vendor/object/src/write/elf/object.rs @@ -67,6 +67,7 @@ impl<'a> Object<'a> { fn elf_has_relocation_addend(&self) -> Result<bool> { Ok(match self.architecture { Architecture::Aarch64 => true, + Architecture::Aarch64_Ilp32 => true, Architecture::Arm => false, Architecture::Avr => true, Architecture::Bpf => false, @@ -83,7 +84,9 @@ impl<'a> Object<'a> { Architecture::Riscv64 => true, Architecture::Riscv32 => true, Architecture::S390x => true, + Architecture::Sbf => false, Architecture::Sparc64 => true, + Architecture::Xtensa => true, _ => { return Err(Error(format!( "unimplemented architecture {:?}", @@ -264,6 +267,7 @@ impl<'a> Object<'a> { let e_type = elf::ET_REL; let e_machine = match self.architecture { Architecture::Aarch64 => elf::EM_AARCH64, + Architecture::Aarch64_Ilp32 => elf::EM_AARCH64, Architecture::Arm => elf::EM_ARM, Architecture::Avr => elf::EM_AVR, Architecture::Bpf => elf::EM_BPF, @@ -280,7 +284,9 @@ impl<'a> Object<'a> { Architecture::Riscv32 => elf::EM_RISCV, Architecture::Riscv64 => elf::EM_RISCV, Architecture::S390x => elf::EM_S390, + Architecture::Sbf => elf::EM_SBF, Architecture::Sparc64 => elf::EM_SPARCV9, + Architecture::Xtensa => elf::EM_XTENSA, _ => { return Err(Error(format!( "unimplemented architecture {:?}", @@ -450,6 +456,20 @@ impl<'a> Object<'a> { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, + Architecture::Aarch64_Ilp32 => { + match (reloc.kind, reloc.encoding, reloc.size) { + (RelocationKind::Absolute, RelocationEncoding::Generic, 32) => { + elf::R_AARCH64_P32_ABS32 + } + (RelocationKind::Elf(x), _, _) => x, + _ => { + return Err(Error(format!( + "unimplemented relocation {:?}", + reloc + ))); + } + } + } Architecture::Arm => match (reloc.kind, reloc.encoding, reloc.size) { (RelocationKind::Absolute, _, 32) => elf::R_ARM_ABS32, (RelocationKind::Elf(x), _, _) => x, @@ -528,6 +548,25 @@ 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, RelocationEncoding::LoongArchBranch, 16) + | ( + RelocationKind::PltRelative, + RelocationEncoding::LoongArchBranch, + 16, + ) => elf::R_LARCH_B16, + (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 21) + | ( + RelocationKind::PltRelative, + RelocationEncoding::LoongArchBranch, + 21, + ) => elf::R_LARCH_B21, + (RelocationKind::Relative, RelocationEncoding::LoongArchBranch, 26) + | ( + RelocationKind::PltRelative, + RelocationEncoding::LoongArchBranch, + 26, + ) => elf::R_LARCH_B26, (RelocationKind::Elf(x), _, _) => x, _ => { return Err(Error(format!("unimplemented relocation {:?}", reloc))); @@ -574,6 +613,9 @@ impl<'a> Object<'a> { match (reloc.kind, reloc.encoding, reloc.size) { (RelocationKind::Absolute, _, 32) => elf::R_RISCV_32, (RelocationKind::Absolute, _, 64) => elf::R_RISCV_64, + (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { + elf::R_RISCV_32_PCREL + } (RelocationKind::Elf(x), _, _) => x, _ => { return Err(Error(format!( @@ -649,6 +691,14 @@ impl<'a> Object<'a> { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, + Architecture::Sbf => match (reloc.kind, reloc.encoding, reloc.size) { + (RelocationKind::Absolute, _, 64) => elf::R_SBF_64_64, + (RelocationKind::Absolute, _, 32) => elf::R_SBF_64_32, + (RelocationKind::Elf(x), _, _) => x, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, Architecture::Sparc64 => match (reloc.kind, reloc.encoding, reloc.size) { // TODO: use R_SPARC_32/R_SPARC_64 if aligned. (RelocationKind::Absolute, _, 32) => elf::R_SPARC_UA32, @@ -658,6 +708,16 @@ impl<'a> Object<'a> { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, + Architecture::Xtensa => match (reloc.kind, reloc.encoding, reloc.size) { + (RelocationKind::Absolute, _, 32) => elf::R_XTENSA_32, + (RelocationKind::Relative, RelocationEncoding::Generic, 32) => { + elf::R_XTENSA_32_PCREL + } + (RelocationKind::Elf(x), _, _) => x, + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, _ => { if let RelocationKind::Elf(x) = reloc.kind { x |