-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #72062 - overdrivenpotato:psp, r=jonas-schievink
Add built in PSP target This adds a new target, `mipsel-sony-psp`, corresponding to the Sony PSP. The linker script is necessary to handle special sections, which are required by the target. This has been tested with my [rust-psp] crate and I can confirm it works as intended. The linker script is taken from [here]. It has been slightly adapted to work with rust and LLD. The `stdarch` submodule was also updated in order for `libcore` to build successfully. [rust-psp]: https://github.com/overdrivenpotato/rust-psp [here]: https://github.com/pspdev/pspsdk/blob/master/src/base/linkfile.prx.in
- Loading branch information
Showing
5 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, RelocModel}; | ||
use crate::spec::{Target, TargetOptions, TargetResult}; | ||
|
||
// The PSP has custom linker requirements. | ||
const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); | ||
|
||
pub fn target() -> TargetResult { | ||
let mut pre_link_args = LinkArgs::new(); | ||
pre_link_args.insert( | ||
LinkerFlavor::Lld(LldFlavor::Ld), | ||
vec!["--eh-frame-hdr".to_string(), "--emit-relocs".to_string()], | ||
); | ||
|
||
Ok(Target { | ||
llvm_target: "mipsel-sony-psp".to_string(), | ||
target_endian: "little".to_string(), | ||
target_pointer_width: "32".to_string(), | ||
target_c_int_width: "32".to_string(), | ||
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), | ||
arch: "mips".to_string(), | ||
target_os: "psp".to_string(), | ||
target_env: "".to_string(), | ||
target_vendor: "sony".to_string(), | ||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), | ||
|
||
options: TargetOptions { | ||
cpu: "mips2".to_string(), | ||
executables: true, | ||
linker: Some("rust-lld".to_owned()), | ||
linker_is_gnu: true, | ||
relocation_model: RelocModel::Static, | ||
|
||
// PSP FPU only supports single precision floats. | ||
features: "+single-float".to_string(), | ||
|
||
// PSP does not support trap-on-condition instructions. | ||
llvm_args: vec!["-mno-check-zero-division".to_string()], | ||
pre_link_args, | ||
link_script: Some(LINKER_SCRIPT.to_string()), | ||
..Default::default() | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
ENTRY(module_start) | ||
SECTIONS | ||
{ | ||
/* PRX format requires text to begin at 0 */ | ||
.text 0 : { *(.text .text.*) } | ||
|
||
/* Sort stubs for convenient ordering */ | ||
.sceStub.text : { *(.sceStub.text) *(SORT(.sceStub.text.*)) } | ||
|
||
/* Keep these sections around, even though they may appear unused to the linker */ | ||
.lib.ent.top : { KEEP(*(.lib.ent.top)) } | ||
.lib.ent : { KEEP(*(.lib.ent)) } | ||
.lib.ent.btm : { KEEP(*(.lib.ent.btm)) } | ||
.lib.stub.top : { KEEP(*(.lib.stub.top)) } | ||
.lib.stub : { KEEP(*(.lib.stub)) } | ||
.lib.stub.btm : { KEEP(*(.lib.stub.btm)) } | ||
.eh_frame_hdr : { KEEP(*(.eh_frame_hdr)) } | ||
|
||
/* Add symbols for LLVM's libunwind */ | ||
__eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0; | ||
__eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0; | ||
.eh_frame : | ||
{ | ||
__eh_frame_start = .; | ||
KEEP(*(.eh_frame)) | ||
__eh_frame_end = .; | ||
} | ||
|
||
/* These are explicitly listed to avoid being merged into .rodata */ | ||
.rodata.sceResident : { *(.rodata.sceResident) } | ||
.rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) } | ||
/* Sort NIDs for convenient ordering */ | ||
.rodata.sceNid : { *(.rodata.sceNid) *(SORT(.rodata.sceNid.*)) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule stdarch
updated
3 files
+1 −1 | ci/docker/wasm32-unknown-unknown/wasm-entrypoint.sh | |
+4 −0 | crates/core_arch/src/mips/mod.rs | |
+9 −3 | crates/core_arch/src/x86/cpuid.rs |