fix relocation format macos aarch64 dev backend

This commit is contained in:
Luke Boswell 2023-09-16 19:33:44 +10:00
parent 04906c1b58
commit 0259c11565
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
2 changed files with 31 additions and 4 deletions

View file

@ -41,6 +41,9 @@ jobs:
- name: check that the platform`s produced dylib is loadable
run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked
- name: test aarch64 dev backend
run: nix develop -c cargo test-gen-dev bitwise_and --locked --release
# we run the llvm wasm tests only on this machine because it is fast and wasm should be cross-target
- name: execute llvm wasm tests with --release
run: nix develop -c cargo test-gen-llvm-wasm --locked --release

View file

@ -287,18 +287,42 @@ fn generate_wrapper<'a, B: Backend<'a>>(
}
fn create_relocation(target_info: TargetInfo, symbol: SymbolId, offset: u64) -> write::Relocation {
let (encoding, size, addend) = match target_info.architecture {
let (encoding, size, addend, kind) = match target_info.architecture {
roc_target::Architecture::Aarch32 => todo!(),
roc_target::Architecture::Aarch64 => (RelocationEncoding::AArch64Call, 26, 0),
roc_target::Architecture::Aarch64 => {
if cfg!(target_os = "macos") {
(
RelocationEncoding::Generic,
26,
0,
RelocationKind::MachO {
value: 2,
relative: true,
},
)
} else {
(
RelocationEncoding::AArch64Call,
26,
0,
RelocationKind::PltRelative,
)
}
}
roc_target::Architecture::Wasm32 => todo!(),
roc_target::Architecture::X86_32 => todo!(),
roc_target::Architecture::X86_64 => (RelocationEncoding::X86Branch, 32, -4),
roc_target::Architecture::X86_64 => (
RelocationEncoding::X86Branch,
32,
-4,
RelocationKind::PltRelative,
),
};
write::Relocation {
offset,
size,
kind: RelocationKind::PltRelative,
kind,
encoding,
symbol,
addend,