From dc0db358abe19481e475e10c32149b53370f1a1c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:31 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/object/src/read/elf/file.rs | 1 + vendor/object/src/read/elf/note.rs | 23 +++++++++++++---------- vendor/object/src/read/elf/relocation.rs | 5 +++++ vendor/object/src/read/elf/symbol.rs | 8 ++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) (limited to 'vendor/object/src/read/elf') diff --git a/vendor/object/src/read/elf/file.rs b/vendor/object/src/read/elf/file.rs index aac66e7cc..67be37e21 100644 --- a/vendor/object/src/read/elf/file.rs +++ b/vendor/object/src/read/elf/file.rs @@ -161,6 +161,7 @@ where (elf::EM_ARM, _) => Architecture::Arm, (elf::EM_AVR, _) => Architecture::Avr, (elf::EM_BPF, _) => Architecture::Bpf, + (elf::EM_CSKY, _) => Architecture::Csky, (elf::EM_386, _) => Architecture::I386, (elf::EM_X86_64, false) => Architecture::X86_64_X32, (elf::EM_X86_64, true) => Architecture::X86_64, diff --git a/vendor/object/src/read/elf/note.rs b/vendor/object/src/read/elf/note.rs index fc5aa7753..84d4179de 100644 --- a/vendor/object/src/read/elf/note.rs +++ b/vendor/object/src/read/elf/note.rs @@ -113,21 +113,24 @@ impl<'data, Elf: FileHeader> Note<'data, Elf> { self.header.n_descsz(endian) } - /// Return the bytes for the name field following the `NoteHeader`, - /// excluding any null terminator. + /// Return the bytes for the name field following the `NoteHeader`. /// - /// This field is usually a string including a null terminator + /// This field is usually a string including one or more trailing null bytes /// (but it is not required to be). /// - /// The length of this field (including any null terminator) is given by - /// `n_namesz`. + /// The length of this field is given by `n_namesz`. + pub fn name_bytes(&self) -> &'data [u8] { + self.name + } + + /// Return the bytes for the name field following the `NoteHeader`, + /// excluding all trailing null bytes. pub fn name(&self) -> &'data [u8] { - if let Some((last, name)) = self.name.split_last() { - if *last == 0 { - return name; - } + let mut name = self.name; + while let [rest @ .., 0] = name { + name = rest; } - self.name + name } /// Return the bytes for the desc field following the `NoteHeader`. diff --git a/vendor/object/src/read/elf/relocation.rs b/vendor/object/src/read/elf/relocation.rs index 8443dbc75..78032dfdb 100644 --- a/vendor/object/src/read/elf/relocation.rs +++ b/vendor/object/src/read/elf/relocation.rs @@ -276,6 +276,11 @@ fn parse_relocation( elf::R_BPF_64_32 => (RelocationKind::Absolute, 32), r_type => (RelocationKind::Elf(r_type), 0), }, + elf::EM_CSKY => match reloc.r_type(endian, false) { + elf::R_CKCORE_ADDR32 => (RelocationKind::Absolute, 32), + elf::R_CKCORE_PCREL32 => (RelocationKind::Relative, 32), + r_type => (RelocationKind::Elf(r_type), 0), + }, elf::EM_386 => match reloc.r_type(endian, false) { elf::R_386_32 => (RelocationKind::Absolute, 32), elf::R_386_PC32 => (RelocationKind::Relative, 32), diff --git a/vendor/object/src/read/elf/symbol.rs b/vendor/object/src/read/elf/symbol.rs index ac1095705..ee5aa37f1 100644 --- a/vendor/object/src/read/elf/symbol.rs +++ b/vendor/object/src/read/elf/symbol.rs @@ -309,6 +309,14 @@ where pub(super) symbol: &'data Elf::Sym, } +impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> ElfSymbol<'data, 'file, Elf, R> { + /// Return a reference to the raw symbol structure. + #[inline] + pub fn raw_symbol(&self) -> &'data Elf::Sym { + self.symbol + } +} + impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> read::private::Sealed for ElfSymbol<'data, 'file, Elf, R> { -- cgit v1.2.3