aarch64: Support GOT Relative relocations in PIC mode (#5550)

* cranelift: Add `adrp` encoding to AArch64 backend

* cranelift: Support GOT Symbol References in AArch64

* cranelift: Add MachO GOT relocations

* cranelift: Do not mark the GOT PageOffset12 MachO relocation as relative
This commit is contained in:
Afonso Bordado
2023-02-15 23:19:18 +00:00
committed by GitHub
parent aba239e9b8
commit eabd43a178
13 changed files with 197 additions and 57 deletions

View File

@@ -678,6 +678,38 @@ impl ObjectModule {
12,
)
}
Reloc::Aarch64AdrGotPage21 => match self.object.format() {
object::BinaryFormat::Elf => (
RelocationKind::Elf(object::elf::R_AARCH64_ADR_GOT_PAGE),
RelocationEncoding::Generic,
21,
),
object::BinaryFormat::MachO => (
RelocationKind::MachO {
value: object::macho::ARM64_RELOC_GOT_LOAD_PAGE21,
relative: true,
},
RelocationEncoding::Generic,
21,
),
_ => unimplemented!("Aarch64AdrGotPage21 is not supported for this file format"),
},
Reloc::Aarch64Ld64GotLo12Nc => match self.object.format() {
object::BinaryFormat::Elf => (
RelocationKind::Elf(object::elf::R_AARCH64_LD64_GOT_LO12_NC),
RelocationEncoding::Generic,
12,
),
object::BinaryFormat::MachO => (
RelocationKind::MachO {
value: object::macho::ARM64_RELOC_GOT_LOAD_PAGEOFF12,
relative: false,
},
RelocationEncoding::Generic,
12,
),
_ => unimplemented!("Aarch64Ld64GotLo12Nc is not supported for this file format"),
},
Reloc::S390xPCRel32Dbl => (RelocationKind::Relative, RelocationEncoding::S390xDbl, 32),
Reloc::S390xPLTRel32Dbl => (
RelocationKind::PltRelative,