Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building for big-endian systems #18

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
- name: Test
run: |
cargo test
- name: Check (big-endian)
run: |
rustup target add powerpc64-unknown-linux-gnu
cargo check --target powerpc64-unknown-linux-gnu

fmt:
name: rustfmt
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ar_archive_writer"
version = "0.3.2"
version = "0.3.3"
edition = "2021"
license = "Apache-2.0 WITH LLVM-exception"
description = "A writer for object file ar archives"
Expand Down
8 changes: 4 additions & 4 deletions src/coff_import_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub(crate) const NULL_THUNK_DATA_SUFFIX: &[u8] = b"_NULL_THUNK_DATA";

macro_rules! u16 {
($val:expr) => {
object::U16::new(object::NativeEndian, $val)
object::U16::new(object::LittleEndian, $val)
};
}

macro_rules! u32 {
($val:expr) => {
object::U32::new(object::NativeEndian, $val)
object::U32::new(object::LittleEndian, $val)
};
}

Expand All @@ -49,7 +49,7 @@ pub(crate) fn get_short_import_symbol(
let mut offset = 0;
let header = ImportObjectHeader::parse(buf, &mut offset).map_err(Error::other)?;
let data = header.parse_data(buf, &mut offset).map_err(Error::other)?;
let is_ec = header.machine.get(object::NativeEndian) == object::pe::IMAGE_FILE_MACHINE_ARM64EC;
let is_ec = header.machine.get(object::LittleEndian) == object::pe::IMAGE_FILE_MACHINE_ARM64EC;

let name = data.symbol();
let demangled_name = is_ec
Expand Down Expand Up @@ -77,7 +77,7 @@ pub(crate) fn get_short_import_symbol(
f(demangled_name.as_ref())?;

// For Arm64EC, also the EC import symbol and thunk.
if header.machine.get(object::NativeEndian) == object::pe::IMAGE_FILE_MACHINE_ARM64EC {
if header.machine.get(object::LittleEndian) == object::pe::IMAGE_FILE_MACHINE_ARM64EC {
const IMP_PREFIX: &[u8] = b"__imp_aux_";
f(&IMP_PREFIX
.iter()
Expand Down
Loading