compiler: bump object to 0.36.7

Update all callsites using `write::Relocation` to the new API.
This commit is contained in:
Jakub Konka 2024-12-31 16:17:34 +01:00
parent 275b2afb55
commit 3a3556a74c
No known key found for this signature in database
GPG key ID: 3AEF55DD984C8344
3 changed files with 100 additions and 73 deletions

42
Cargo.lock generated
View file

@ -216,7 +216,7 @@ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object", "object 0.32.2",
"rustc-demangle", "rustc-demangle",
] ]
@ -724,7 +724,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"hashbrown", "hashbrown 0.14.3",
"lock_api", "lock_api",
"once_cell", "once_cell",
"parking_lot_core", "parking_lot_core",
@ -932,6 +932,12 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.2.0" version = "1.2.0"
@ -1117,6 +1123,15 @@ dependencies = [
"allocator-api2", "allocator-api2",
] ]
[[package]]
name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"foldhash",
]
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.4.1" version = "0.4.1"
@ -1302,7 +1317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown", "hashbrown 0.14.3",
] ]
[[package]] [[package]]
@ -1719,9 +1734,18 @@ name = "object"
version = "0.32.2" version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [
"memchr",
]
[[package]]
name = "object"
version = "0.36.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"hashbrown", "hashbrown 0.15.2",
"indexmap", "indexmap",
"memchr", "memchr",
] ]
@ -2466,7 +2490,7 @@ dependencies = [
"bitvec", "bitvec",
"bumpalo", "bumpalo",
"fnv", "fnv",
"hashbrown", "hashbrown 0.14.3",
"im", "im",
"im-rc", "im-rc",
"smallvec", "smallvec",
@ -2596,7 +2620,7 @@ version = "0.0.1"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"capstone", "capstone",
"object", "object 0.36.7",
"packed_struct", "packed_struct",
"roc_builtins", "roc_builtins",
"roc_can", "roc_can",
@ -2756,7 +2780,7 @@ dependencies = [
"libc", "libc",
"mach_object", "mach_object",
"memmap2 0.5.10", "memmap2 0.5.10",
"object", "object 0.36.7",
"roc_collections", "roc_collections",
"roc_error_macros", "roc_error_macros",
"roc_load", "roc_load",
@ -2874,7 +2898,7 @@ dependencies = [
"arrayvec 0.7.4", "arrayvec 0.7.4",
"bitvec", "bitvec",
"bumpalo", "bumpalo",
"hashbrown", "hashbrown 0.14.3",
"indoc", "indoc",
"parking_lot", "parking_lot",
"roc_builtins", "roc_builtins",
@ -3176,7 +3200,7 @@ dependencies = [
"arrayvec 0.7.4", "arrayvec 0.7.4",
"bitvec", "bitvec",
"bumpalo", "bumpalo",
"hashbrown", "hashbrown 0.14.3",
"indoc", "indoc",
"parking_lot", "parking_lot",
"pretty_assertions", "pretty_assertions",

View file

@ -56,7 +56,7 @@ repository = "https://github.com/roc-lang/roc"
version = "0.0.1" version = "0.0.1"
[workspace.dependencies] [workspace.dependencies]
object = { version = "0.32.2", default-features = false, features = [ object = { version = "0.36.7", default-features = false, features = [
"read", "read",
"write", "write",
] } ] }

View file

@ -4,8 +4,8 @@ use bumpalo::collections::Vec;
use object::write::{self, SectionId, SymbolId}; use object::write::{self, SectionId, SymbolId};
use object::write::{Object, StandardSection, StandardSegment, Symbol, SymbolSection}; use object::write::{Object, StandardSection, StandardSegment, Symbol, SymbolSection};
use object::{ use object::{
Architecture, BinaryFormat, Endianness, RelocationEncoding, RelocationKind, SectionKind, Architecture, BinaryFormat, Endianness, RelocationEncoding, RelocationFlags, RelocationKind,
SymbolFlags, SymbolKind, SymbolScope, SectionKind, SymbolFlags, SymbolKind, SymbolScope,
}; };
use roc_collections::all::MutMap; use roc_collections::all::MutMap;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
@ -245,11 +245,11 @@ fn generate_roc_panic<'a, B: Backend<'a>>(backend: &mut B, output: &mut Object)
// 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650 // 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650
let relocation = write::Relocation { let relocation = write::Relocation {
offset: offset + proc_offset, offset: offset + proc_offset,
size: 21,
kind: RelocationKind::Elf(object::elf::R_AARCH64_ADR_PREL_PG_HI21),
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: 0, addend: 0,
flags: write::RelocationFlags::Elf {
r_type: object::elf::R_AARCH64_ADR_PREL_PG_HI21,
},
}; };
output.add_relocation(text_section, relocation).unwrap(); output.add_relocation(text_section, relocation).unwrap();
@ -258,25 +258,24 @@ fn generate_roc_panic<'a, B: Backend<'a>>(backend: &mut B, output: &mut Object)
// 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650 // 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650
write::Relocation { write::Relocation {
offset: offset + proc_offset + 4, offset: offset + proc_offset + 4,
size: 12,
kind: RelocationKind::Elf(object::elf::R_AARCH64_ADD_ABS_LO12_NC),
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: 0, addend: 0,
flags: write::RelocationFlags::Elf {
r_type: object::elf::R_AARCH64_ADD_ABS_LO12_NC,
},
} }
} else if cfg!(all(target_arch = "aarch64", target_os = "macos")) { } else if cfg!(all(target_arch = "aarch64", target_os = "macos")) {
// 4dc: 90000001 adrp x1, 0x0 <ltmp0> // 4dc: 90000001 adrp x1, 0x0 <ltmp0>
// 00000000000004dc: ARM64_RELOC_PAGE21 ___unnamed_6 // 00000000000004dc: ARM64_RELOC_PAGE21 ___unnamed_6
let relocation = write::Relocation { let relocation = write::Relocation {
offset: offset + proc_offset, offset: offset + proc_offset,
size: 32,
kind: RelocationKind::MachO {
value: object::macho::ARM64_RELOC_PAGE21,
relative: true,
},
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: 0, addend: 0,
flags: write::RelocationFlags::MachO {
r_type: object::macho::ARM64_RELOC_PAGE21,
r_pcrel: true,
r_length: 2,
},
}; };
output.add_relocation(text_section, relocation).unwrap(); output.add_relocation(text_section, relocation).unwrap();
@ -285,23 +284,24 @@ fn generate_roc_panic<'a, B: Backend<'a>>(backend: &mut B, output: &mut Object)
// 00000000000004e0: ARM64_RELOC_PAGEOFF12 ___unnamed_6 // 00000000000004e0: ARM64_RELOC_PAGEOFF12 ___unnamed_6
write::Relocation { write::Relocation {
offset: offset + proc_offset + 4, offset: offset + proc_offset + 4,
size: 32,
kind: RelocationKind::MachO {
value: object::macho::ARM64_RELOC_PAGEOFF12,
relative: false,
},
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: 0, addend: 0,
flags: write::RelocationFlags::MachO {
r_type: object::macho::ARM64_RELOC_PAGEOFF12,
r_pcrel: false,
r_length: 2,
},
} }
} else { } else {
write::Relocation { write::Relocation {
offset: offset + proc_offset, offset: offset + proc_offset,
size: 32,
kind: RelocationKind::GotRelative,
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: -4, addend: -4,
flags: write::RelocationFlags::Generic {
kind: RelocationKind::GotRelative,
encoding: RelocationEncoding::Generic,
size: 32,
},
} }
} }
} else { } else {
@ -383,45 +383,46 @@ fn generate_wrapper<'a, B: Backend<'a>>(
} }
fn create_relocation(target: Target, symbol: SymbolId, offset: u64) -> write::Relocation { fn create_relocation(target: Target, symbol: SymbolId, offset: u64) -> write::Relocation {
let (encoding, size, addend, kind) = match target.architecture() { let (flags, addend) = match target.architecture() {
roc_target::Architecture::Aarch32 => todo!(), roc_target::Architecture::Aarch32 => todo!(),
roc_target::Architecture::Aarch64 => { roc_target::Architecture::Aarch64 => {
if cfg!(target_os = "macos") { if cfg!(target_os = "macos") {
( (
RelocationEncoding::Generic, RelocationFlags::MachO {
26, r_type: object::macho::ARM64_RELOC_BRANCH26,
0, r_pcrel: true,
RelocationKind::MachO { r_length: 2,
value: 2,
relative: true,
}, },
0,
) )
} else { } else {
( (
RelocationEncoding::AArch64Call, RelocationFlags::Generic {
26, kind: RelocationKind::PltRelative,
encoding: RelocationEncoding::AArch64Call,
size: 26,
},
0, 0,
RelocationKind::PltRelative,
) )
} }
} }
roc_target::Architecture::Wasm32 => todo!(), roc_target::Architecture::Wasm32 => todo!(),
roc_target::Architecture::X86_32 => todo!(), roc_target::Architecture::X86_32 => todo!(),
roc_target::Architecture::X86_64 => ( roc_target::Architecture::X86_64 => (
RelocationEncoding::X86Branch, RelocationFlags::Generic {
32, kind: RelocationKind::PltRelative,
encoding: RelocationEncoding::X86Branch,
size: 32,
},
-4, -4,
RelocationKind::PltRelative,
), ),
}; };
write::Relocation { write::Relocation {
offset, offset,
size,
kind,
encoding,
symbol, symbol,
addend, addend,
flags,
} }
} }
@ -957,11 +958,13 @@ fn build_proc<'a, B: Backend<'a>>(
output.add_symbol_data(data_id, data_section, data, 4); output.add_symbol_data(data_id, data_section, data, 4);
write::Relocation { write::Relocation {
offset: offset + proc_offset, offset: offset + proc_offset,
size: 32,
kind: RelocationKind::Relative,
encoding: RelocationEncoding::Generic,
symbol: data_id, symbol: data_id,
addend: -4, addend: -4,
flags: RelocationFlags::Generic {
kind: RelocationKind::Relative,
encoding: RelocationEncoding::Generic,
size: 32,
},
} }
} }
Relocation::LinkedData { offset, name } => { Relocation::LinkedData { offset, name } => {
@ -973,11 +976,11 @@ fn build_proc<'a, B: Backend<'a>>(
// 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650 // 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650
let r = write::Relocation { let r = write::Relocation {
offset: proc_offset + offset, offset: proc_offset + offset,
size: 21,
kind: RelocationKind::Elf(object::elf::R_AARCH64_ADR_PREL_PG_HI21),
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: -4, addend: -4,
flags: RelocationFlags::Elf {
r_type: object::elf::R_AARCH64_ADR_PREL_PG_HI21,
},
}; };
relocations.push((section_id, r)); relocations.push((section_id, r));
@ -986,25 +989,24 @@ fn build_proc<'a, B: Backend<'a>>(
// 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650 // 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650
write::Relocation { write::Relocation {
offset: proc_offset + offset + 4, offset: proc_offset + offset + 4,
size: 12,
kind: RelocationKind::Elf(object::elf::R_AARCH64_ADD_ABS_LO12_NC),
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: 0, addend: 0,
flags: RelocationFlags::Elf {
r_type: object::elf::R_AARCH64_ADD_ABS_LO12_NC,
},
} }
} else if cfg!(all(target_arch = "aarch64", target_os = "macos")) { } else if cfg!(all(target_arch = "aarch64", target_os = "macos")) {
// 4ed0: 90000000 adrp x0, 0x4000 <_std.unicode.utf8Decode4+0x16c> // 4ed0: 90000000 adrp x0, 0x4000 <_std.unicode.utf8Decode4+0x16c>
// 0000000000004ed0: ARM64_RELOC_PAGE21 ___unnamed_11 // 0000000000004ed0: ARM64_RELOC_PAGE21 ___unnamed_11
let r = write::Relocation { let r = write::Relocation {
offset: proc_offset + offset, offset: proc_offset + offset,
size: 21,
kind: RelocationKind::MachO {
value: object::macho::ARM64_RELOC_PAGE21,
relative: true,
},
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: 0, addend: 0,
flags: RelocationFlags::MachO {
r_type: object::macho::ARM64_RELOC_PAGE21,
r_pcrel: true,
r_length: 2,
},
}; };
relocations.push((section_id, r)); relocations.push((section_id, r));
@ -1013,23 +1015,24 @@ fn build_proc<'a, B: Backend<'a>>(
// 0000000000004ed4: ARM64_RELOC_PAGEOFF12 ___unnamed_11 // 0000000000004ed4: ARM64_RELOC_PAGEOFF12 ___unnamed_11
write::Relocation { write::Relocation {
offset: proc_offset + offset + 4, offset: proc_offset + offset + 4,
size: 12,
kind: RelocationKind::MachO {
value: object::macho::ARM64_RELOC_PAGEOFF12,
relative: false,
},
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: 0, addend: 0,
flags: RelocationFlags::MachO {
r_type: object::macho::ARM64_RELOC_PAGEOFF12,
r_pcrel: false,
r_length: 2,
},
} }
} else { } else {
write::Relocation { write::Relocation {
offset: offset + proc_offset, offset: offset + proc_offset,
size: 32,
kind: RelocationKind::GotRelative,
encoding: RelocationEncoding::Generic,
symbol: sym_id, symbol: sym_id,
addend: -4, addend: -4,
flags: RelocationFlags::Generic {
kind: RelocationKind::GotRelative,
encoding: RelocationEncoding::Generic,
size: 32,
},
} }
} }
} else { } else {