fix missing data ptr relocation for aarch64

This commit is contained in:
Folkert 2023-10-07 16:05:26 +02:00
parent 82b96395e2
commit e1f173fb95
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -218,8 +218,8 @@ fn generate_roc_panic<'a, B: Backend<'a>>(backend: &mut B, output: &mut Object)
Relocation::LinkedData { offset, name } => {
if let Some(sym_id) = output.symbol_id(name.as_bytes()) {
if cfg!(all(target_arch = "aarch64", target_os = "linux")) {
// 700: 90000001 adrp x1, 0x0 <std.builtin.default_panic>
// 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650
// 700: 90000001 adrp x1, 0x0 <std.builtin.default_panic>
// 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650
let relocation = write::Relocation {
offset: offset + proc_offset,
size: 21,
@ -231,8 +231,8 @@ fn generate_roc_panic<'a, B: Backend<'a>>(backend: &mut B, output: &mut Object)
output.add_relocation(text_section, relocation).unwrap();
// 704: 91000021 add x1, x1, #0x0
// 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650
// 704: 91000021 add x1, x1, #0x0
// 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650
write::Relocation {
offset: offset + proc_offset + 4,
size: 12,
@ -242,8 +242,8 @@ fn generate_roc_panic<'a, B: Backend<'a>>(backend: &mut B, output: &mut Object)
addend: 0,
}
} else if cfg!(all(target_arch = "aarch64", target_os = "macos")) {
// 4dc: 90000001 adrp x1, 0x0 <ltmp0>
// 00000000000004dc: ARM64_RELOC_PAGE21 ___unnamed_6
// 4dc: 90000001 adrp x1, 0x0 <ltmp0>
// 00000000000004dc: ARM64_RELOC_PAGE21 ___unnamed_6
let relocation = write::Relocation {
offset: offset + proc_offset,
size: 32,
@ -258,8 +258,8 @@ fn generate_roc_panic<'a, B: Backend<'a>>(backend: &mut B, output: &mut Object)
output.add_relocation(text_section, relocation).unwrap();
// 4e0: 91000021 add x1, x1, #0x0
// 00000000000004e0: ARM64_RELOC_PAGEOFF12 ___unnamed_6
// 4e0: 91000021 add x1, x1, #0x0
// 00000000000004e0: ARM64_RELOC_PAGEOFF12 ___unnamed_6
write::Relocation {
offset: offset + proc_offset + 4,
size: 32,
@ -922,8 +922,8 @@ fn build_proc<'a, B: Backend<'a>>(
Relocation::LinkedData { offset, name } => {
if let Some(sym_id) = output.symbol_id(name.as_bytes()) {
if cfg!(all(target_arch = "aarch64", target_os = "linux")) {
// 700: 90000001 adrp x1, 0x0 <std.builtin.default_panic>
// 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650
// 700: 90000001 adrp x1, 0x0 <std.builtin.default_panic>
// 0000000000000700: R_AARCH64_ADR_PREL_PG_HI21 .rodata+0x650
let r = write::Relocation {
offset: offset + proc_offset,
size: 21,
@ -935,8 +935,8 @@ fn build_proc<'a, B: Backend<'a>>(
relocations.push((section_id, r));
// 704: 91000021 add x1, x1, #0x0
// 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650
// 704: 91000021 add x1, x1, #0x0
// 0000000000000704: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x650
write::Relocation {
offset: offset + proc_offset,
size: 12,
@ -946,7 +946,35 @@ fn build_proc<'a, B: Backend<'a>>(
addend: 0,
}
} else if cfg!(all(target_arch = "aarch64", target_os = "macos")) {
todo!()
// 4ed0: 90000000 adrp x0, 0x4000 <_std.unicode.utf8Decode4+0x16c>
// 0000000000004ed0: ARM64_RELOC_PAGE21 ___unnamed_11
let r = write::Relocation {
offset: offset + proc_offset,
size: 21,
kind: RelocationKind::MachO {
value: object::macho::ARM64_RELOC_PAGE21,
relative: true,
},
encoding: RelocationEncoding::Generic,
symbol: sym_id,
addend: -4,
};
relocations.push((section_id, r));
// 4ed4: 91000000 add x0, x0, #0x0
// 0000000000004ed4: ARM64_RELOC_PAGEOFF12 ___unnamed_11
write::Relocation {
offset: offset + proc_offset,
size: 12,
kind: RelocationKind::MachO {
value: object::macho::ARM64_RELOC_PAGEOFF12,
relative: true,
},
encoding: RelocationEncoding::Generic,
symbol: sym_id,
addend: 0,
}
} else {
write::Relocation {
offset: offset + proc_offset,