Codebase list rust-libslirp / 103d155
object - add upstream endian fixes. Peter Michael Green 1 year, 6 months ago
5 changed file(s) with 164 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 rust-object (0.29.0-2) UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; urgency=medium
1
2 * Team upload.
3 * Package object 0.29.0 from crates.io using debcargo 2.5.0
4 * Add upstream patches to fix endian issues (Closes: 1021678)
5
6 -- Peter Michael Green <plugwash@debian.org> Sat, 15 Oct 2022 15:56:07 +0000
7
08 rust-object (0.29.0-1) unstable; urgency=medium
19
210 * Team upload.
0 Bump old dependencies so it is possible to run tests with -Z minimal-versions
1
2 compiler_builtins bumped due to build failure in compiler_builtins.
3
4
5 Index: object/Cargo.toml
6 ===================================================================
7 --- object.orig/Cargo.toml
8 +++ object/Cargo.toml
9 @@ -33,7 +33,7 @@ features = ["doc"]
10
11
12 [dependencies.compiler_builtins]
13 -version = "0.1.2"
14 +version = "0.1.70"
15 optional = true
16
17 [dependencies.crc32fast]
11 remove-wasm-feature.patch
22 remove-rustc-dep-of-std.patch
33 disable-tests-missing-testdata.patch
4 use-endianness-for-extended-section-indexes.patch
5 use-endianness-for-resource-names.patch
6 bump-old-deps.patch
0 This patch is based on the upstream commit described below, with changes
1 to files not included in the crates.io release removed.
2
3 commit 21b49c36e9cf746e86c2f06e7e1599d82f12a075
4 Author: Philip Craig <philipjcraig@gmail.com>
5 Date: Mon Aug 22 15:43:43 2022 +1000
6
7 read/elf: use endianness for extended section indices
8
9 diff --git a/src/read/elf/symbol.rs b/src/read/elf/symbol.rs
10 index f52eff20e..390aa466f 100644
11 --- a/src/read/elf/symbol.rs
12 +++ b/src/read/elf/symbol.rs
13 @@ -4,7 +4,6 @@ use core::fmt::Debug;
14 use core::slice;
15 use core::str;
16
17 -use crate::elf;
18 use crate::endian::{self, Endianness};
19 use crate::pod::Pod;
20 use crate::read::util::StringTable;
21 @@ -12,6 +11,7 @@ use crate::read::{
22 self, ObjectSymbol, ObjectSymbolTable, ReadError, ReadRef, SectionIndex, SymbolFlags,
23 SymbolIndex, SymbolKind, SymbolMap, SymbolMapEntry, SymbolScope, SymbolSection,
24 };
25 +use crate::{elf, U32};
26
27 use super::{FileHeader, SectionHeader, SectionTable};
28
29 @@ -28,7 +28,7 @@ where
30 shndx_section: SectionIndex,
31 symbols: &'data [Elf::Sym],
32 strings: StringTable<'data, R>,
33 - shndx: &'data [u32],
34 + shndx: &'data [U32<Elf::Endian>],
35 }
36
37 impl<'data, Elf: FileHeader, R: ReadRef<'data>> Default for SymbolTable<'data, Elf, R> {
38 @@ -145,8 +145,8 @@ impl<'data, Elf: FileHeader, R: ReadRef<'data>> SymbolTable<'data, Elf, R> {
39
40 /// Return the extended section index for the given symbol if present.
41 #[inline]
42 - pub fn shndx(&self, index: usize) -> Option<u32> {
43 - self.shndx.get(index).copied()
44 + pub fn shndx(&self, endian: Elf::Endian, index: usize) -> Option<u32> {
45 + self.shndx.get(index).map(|x| x.get(endian))
46 }
47
48 /// Return the section index for the given symbol.
49 @@ -161,7 +161,7 @@ impl<'data, Elf: FileHeader, R: ReadRef<'data>> SymbolTable<'data, Elf, R> {
50 match symbol.st_shndx(endian) {
51 elf::SHN_UNDEF => Ok(None),
52 elf::SHN_XINDEX => self
53 - .shndx(index)
54 + .shndx(endian, index)
55 .read_error("Missing ELF symbol extended index")
56 .map(|index| Some(SectionIndex(index as usize))),
57 shndx if shndx < elf::SHN_LORESERVE => Ok(Some(SectionIndex(shndx.into()))),
58 @@ -369,7 +369,7 @@ impl<'data, 'file, Elf: FileHeader, R: ReadRef<'data>> ObjectSymbol<'data>
59 }
60 }
61 elf::SHN_COMMON => SymbolSection::Common,
62 - elf::SHN_XINDEX => match self.symbols.shndx(self.index.0) {
63 + elf::SHN_XINDEX => match self.symbols.shndx(self.endian, self.index.0) {
64 Some(index) => SymbolSection::Section(SectionIndex(index as usize)),
65 None => SymbolSection::Unknown,
66 },
0 This patch is based on the upstream commit described below, with changes to
1 files that are not included in the crates.io release removed.
2
3 commit 7521d394a4c4b111a815a9270b6a5a44669e4486
4 Author: Philip Craig <philipjcraig@gmail.com>
5 Date: Mon Aug 22 16:18:55 2022 +1000
6
7 read/pe: use endianness for resource names
8
9 diff --git a/README.md b/README.md
10 index 19268a953..193a5a7c1 100644
11 --- a/README.md
12 +++ b/README.md
13 @@ -39,7 +39,7 @@ See [`crates/examples`](crates/examples) for more examples.
14 Changes to MSRV are considered breaking changes. We are conservative about changing the MSRV,
15 but sometimes are required to due to dependencies. The MSRV is:
16
17 - * 1.42.0 for the `read` feature and its dependencies.
18 + * 1.52.0 for the `read` feature and its dependencies.
19 * 1.56.1 for the `write` feature and its dependencies.
20
21 ## License
22 diff --git a/src/read/pe/resource.rs b/src/read/pe/resource.rs
23 index bfbb609f5..cb5d5a5e8 100644
24 --- a/src/read/pe/resource.rs
25 +++ b/src/read/pe/resource.rs
26 @@ -1,7 +1,8 @@
27 use alloc::string::String;
28 +use core::char;
29
30 use crate::read::{ReadError, ReadRef, Result};
31 -use crate::{pe, LittleEndian as LE, U16};
32 +use crate::{pe, LittleEndian as LE, U16Bytes};
33
34 /// The `.rsrc` section of a PE file.
35 #[derive(Debug, Clone, Copy)]
36 @@ -143,20 +144,26 @@ pub struct ResourceName {
37 impl ResourceName {
38 /// Converts to a `String`.
39 pub fn to_string_lossy(&self, directory: ResourceDirectory) -> Result<String> {
40 - let d = self.data(directory)?;
41 - Ok(String::from_utf16_lossy(d))
42 + let d = self.data(directory)?.iter().map(|c| c.get(LE));
43 +
44 + Ok(char::decode_utf16(d)
45 + .map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER))
46 + .collect::<String>())
47 }
48
49 /// Returns the string unicode buffer.
50 - pub fn data<'data>(&self, directory: ResourceDirectory<'data>) -> Result<&'data [u16]> {
51 + pub fn data<'data>(
52 + &self,
53 + directory: ResourceDirectory<'data>,
54 + ) -> Result<&'data [U16Bytes<LE>]> {
55 let mut offset = u64::from(self.offset);
56 let len = directory
57 .data
58 - .read::<U16<LE>>(&mut offset)
59 + .read::<U16Bytes<LE>>(&mut offset)
60 .read_error("Invalid resource name offset")?;
61 directory
62 .data
63 - .read_slice::<u16>(&mut offset, len.get(LE).into())
64 + .read_slice::<U16Bytes<LE>>(&mut offset, len.get(LE).into())
65 .read_error("Invalid resource name length")
66 }
67 }