diff options
| author | leo60228 <leo@60228.dev> | 2021-09-15 15:26:59 -0400 |
|---|---|---|
| committer | leo60228 <leo@60228.dev> | 2022-07-14 15:57:19 -0400 |
| commit | 4bc8549cb3ea8bafd93c185cd99353e391967390 (patch) | |
| tree | a6c8ab9ac6a8aff7b5ce2a8f9eafd967753776dd /compiler/rustc_target/src | |
| parent | f688a56ef68ae5e726314e5a554e0057fdcb5b27 (diff) | |
| download | rust-4bc8549cb3ea8bafd93c185cd99353e391967390.tar.gz rust-4bc8549cb3ea8bafd93c185cd99353e391967390.zip | |
Add linker script for switch
Diffstat (limited to 'compiler/rustc_target/src')
| -rw-r--r-- | compiler/rustc_target/src/spec/aarch64_nintendo_switch.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/aarch64_nintendo_switch_linker_script.ld | 83 |
2 files changed, 86 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/aarch64_nintendo_switch.rs b/compiler/rustc_target/src/spec/aarch64_nintendo_switch.rs index b6863d509f2..4e4cabe9bbf 100644 --- a/compiler/rustc_target/src/spec/aarch64_nintendo_switch.rs +++ b/compiler/rustc_target/src/spec/aarch64_nintendo_switch.rs @@ -1,10 +1,13 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelroLevel, Target, TargetOptions}; +const LINKER_SCRIPT: &str = include_str!("./aarch64_nintendo_switch_linker_script.ld"); + /// A base target for Nintendo Switch devices using a pure LLVM toolchain. pub fn target() -> Target { let mut opts = TargetOptions { linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), linker: Some("rust-lld".into()), + link_script: Some(LINKER_SCRIPT.into()), os: "horizon".into(), max_atomic_width: Some(128), panic_strategy: PanicStrategy::Abort, diff --git a/compiler/rustc_target/src/spec/aarch64_nintendo_switch_linker_script.ld b/compiler/rustc_target/src/spec/aarch64_nintendo_switch_linker_script.ld new file mode 100644 index 00000000000..7938f75e139 --- /dev/null +++ b/compiler/rustc_target/src/spec/aarch64_nintendo_switch_linker_script.ld @@ -0,0 +1,83 @@ +OUTPUT_FORMAT(elf64-littleaarch64) +OUTPUT_ARCH(aarch64) +ENTRY(_start) + +PHDRS +{ + text PT_LOAD FLAGS(5); + rodata PT_LOAD FLAGS(4); + data PT_LOAD FLAGS(6); + bss PT_LOAD FLAGS(6); + dynamic PT_DYNAMIC; +} + +SECTIONS +{ + . = 0; + + .text : ALIGN(0x1000) { + HIDDEN(__text_start = .); + KEEP(*(.text.jmp)) + + . = 0x80; + + *(.text .text.*) + *(.plt .plt.*) + } + + /* Read-only sections */ + + . = ALIGN(0x1000); + + .module_name : { *(.module_name) } :rodata + + .rodata : { *(.rodata .rodata.*) } :rodata + .mod0 : { + KEEP(crt0.nso.o(.data.mod0)) + KEEP(crt0.nro.o(.data.mod0)) + KEEP(crt0.lib.nro.o(.data.mod0)) + } + .hash : { *(.hash) } + .dynsym : { *(.dynsym .dynsym.*) } + .dynstr : { *(.dynstr .dynstr.*) } + .rela.dyn : { *(.rela.dyn) } + + .eh_frame : { + HIDDEN(__eh_frame_start = .); + *(.eh_frame .eh_frame.*) + HIDDEN(__eh_frame_end = .); + } + + .eh_frame_hdr : { + HIDDEN(__eh_frame_hdr_start = .); + *(.eh_frame_hdr .eh_frame_hdr.*) + HIDDEN(__eh_frame_hdr_end = .); + } + + /* Read-write sections */ + + . = ALIGN(0x1000); + + .data : { + *(.data .data.*) + *(.got .got.*) + *(.got.plt .got.plt.*) + } :data + + .dynamic : { + HIDDEN(__dynamic_start = .); + *(.dynamic) + } + + /* BSS section */ + + . = ALIGN(0x1000); + + .bss : { + HIDDEN(__bss_start = .); + *(.bss .bss.*) + *(COMMON) + . = ALIGN(8); + HIDDEN(__bss_end = .); + } :bss +} |
