fix build on BE and 32bit

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
epel9
Igor Gnatenko 7 years ago
parent 8f088f054f
commit ba395e1647

@ -0,0 +1,25 @@
From 391beaee2397b86480b2e855571a00b4af58b2d2 Mon Sep 17 00:00:00 2001
From: Philip Craig <philipjcraig@gmail.com>
Date: Tue, 2 Jan 2018 12:57:50 +1000
Subject: [PATCH] Fix BigEndian build
---
src/parser.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/parser.rs b/src/parser.rs
index 0df4d94..ed717bb 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -633,7 +633,7 @@ mod tests {
let input = [expected.0, 1, 2, 3, 4];
let input = &mut EndianBuf::new(&input, NativeEndian);
assert_eq!(parse_pointer_encoding(input), Ok(expected));
- assert_eq!(*input, EndianBuf::new(&[1, 2, 3, 4], LittleEndian));
+ assert_eq!(*input, EndianBuf::new(&[1, 2, 3, 4], NativeEndian));
}
#[test]
--
2.15.1

@ -0,0 +1,151 @@
From 31c8914bb530bc89ec8cda045b2e4d6537d6b750 Mon Sep 17 00:00:00 2001
From: Philip Craig <philipjcraig@gmail.com>
Date: Tue, 2 Jan 2018 12:02:46 +1000
Subject: [PATCH] Fix tests for 32 bit builds
---
src/abbrev.rs | 3 ++-
src/cfi.rs | 2 ++
src/op.rs | 7 ++++---
src/parser.rs | 1 +
src/unit.rs | 31 ++++++++++++++++++++++++++++++-
5 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/abbrev.rs b/src/abbrev.rs
index 6ecc30d..da493a1 100644
--- a/src/abbrev.rs
+++ b/src/abbrev.rs
@@ -393,7 +393,8 @@ pub mod tests {
use endianity::{EndianBuf, LittleEndian};
use parser::Error;
use self::test_assembler::Section;
- use std::u64;
+ #[cfg(target_pointer_width = "32")]
+ use std::u32;
use test_util::GimliSectionMethods;
pub trait AbbrevSectionMethods {
diff --git a/src/cfi.rs b/src/cfi.rs
index ec2d0b7..4320646 100644
--- a/src/cfi.rs
+++ b/src/cfi.rs
@@ -6048,6 +6048,7 @@ mod tests {
}
#[test]
+ #[cfg(target_pointer_width = "64")]
fn size_of_unwind_ctx() {
use std::mem;
assert_eq!(
@@ -6059,6 +6060,7 @@ mod tests {
}
#[test]
+ #[cfg(target_pointer_width = "64")]
fn size_of_register_rule_map() {
use std::mem;
assert_eq!(
diff --git a/src/op.rs b/src/op.rs
index ab0f711..0eb30ea 100644
--- a/src/op.rs
+++ b/src/op.rs
@@ -1788,8 +1788,9 @@ mod tests {
use leb128;
use parser::{Error, Format, Result};
use self::test_assembler::{Endian, Section};
- use unit::{DebugInfoOffset, UnitOffset};
+ use std::usize;
use test_util::GimliSectionMethods;
+ use unit::{DebugInfoOffset, UnitOffset};
#[test]
fn test_compute_pc() {
@@ -1801,7 +1802,7 @@ mod tests {
assert_eq!(compute_pc(ebuf, ebuf, 0), Ok(*ebuf));
assert_eq!(
compute_pc(ebuf, ebuf, -1),
- Err(Error::BadBranchTarget(-1i64 as u64))
+ Err(Error::BadBranchTarget(usize::MAX as u64))
);
assert_eq!(compute_pc(ebuf, ebuf, 5), Ok(ebuf.range_from(5..)));
assert_eq!(
@@ -2119,7 +2120,7 @@ mod tests {
let input = [opcode.0, 0xfc, 0xff];
check_op_parse_failure(
&input[..],
- Error::BadBranchTarget(!0u64),
+ Error::BadBranchTarget(usize::MAX as u64),
ADDRESS_SIZE,
FORMAT,
);
diff --git a/src/parser.rs b/src/parser.rs
index 2512d1f..0df4d94 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -618,6 +618,7 @@ mod tests {
let section = Section::with_endian(Endian::Little).L64(0x0123456789abcdef);
let buf = section.get_contents().unwrap();
+ let input = &mut EndianBuf::new(&buf, LittleEndian);
match input.read_offset(Format::Dwarf64) {
Err(Error::UnsupportedOffset) => assert!(true),
otherwise => panic!("Unexpected result: {:?}", otherwise),
diff --git a/src/unit.rs b/src/unit.rs
index 50f9bab..6167188 100644
--- a/src/unit.rs
+++ b/src/unit.rs
@@ -3244,6 +3244,35 @@ mod tests {
};
}
+ #[test]
+ fn test_parse_type_unit_header_32_ok() {
+ let expected_rest = &[1, 2, 3, 4, 5, 6, 7, 8, 9];
+ let mut expected_unit = TypeUnitHeader {
+ header: UnitHeader {
+ unit_length: 0,
+ version: 4,
+ debug_abbrev_offset: DebugAbbrevOffset(0x08070605),
+ address_size: 8,
+ format: Format::Dwarf32,
+ entries_buf: EndianBuf::new(expected_rest, LittleEndian),
+ },
+ offset: DebugTypesOffset(0),
+ type_signature: DebugTypeSignature(0xdeadbeefdeadbeef),
+ type_offset: UnitOffset(0x78563412),
+ };
+ let section = Section::with_endian(Endian::Little)
+ .type_unit(&mut expected_unit)
+ .append_bytes(expected_rest);
+ let buf = section.get_contents().unwrap();
+ let rest = &mut EndianBuf::new(&buf, LittleEndian);
+
+ assert_eq!(
+ parse_type_unit_header(rest, DebugTypesOffset(0)),
+ Ok(expected_unit)
+ );
+ assert_eq!(*rest, EndianBuf::new(expected_rest, LittleEndian));
+ }
+
#[test]
#[cfg(target_pointer_width = "64")]
fn test_parse_type_unit_header_64_ok() {
@@ -3284,7 +3313,6 @@ mod tests {
}
#[test]
- #[cfg(target_pointer_width = "64")]
fn test_attribute_value() {
let mut unit = test_parse_attribute_unit_default();
let endian = unit.entries_buf.endian();
@@ -3324,6 +3352,7 @@ mod tests {
AttributeValue::Data4(([4, 3, 2, 1], endian)),
AttributeValue::Udata(0x01020304),
),
+ #[cfg(target_pointer_width = "64")]
(
2,
constants::DW_AT_data_member_location,
--
2.15.1

@ -17,6 +17,10 @@ Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{
Patch0: gimli-0.15.0-fix-metadata.diff
# Make it work with object-v0.6, https://github.com/gimli-rs/gimli/pull/265
Patch1: 0001-bump-object-to-0.6.patch
# https://github.com/gimli-rs/gimli/commit/31c8914bb530bc89ec8cda045b2e4d6537d6b750
Patch2: 0001-Fix-tests-for-32-bit-builds.patch
# https://github.com/gimli-rs/gimli/commit/391beaee2397b86480b2e855571a00b4af58b2d2
Patch3: 0001-Fix-BigEndian-build.patch
ExclusiveArch: %{rust_arches}

Loading…
Cancel
Save