-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip(panic): replace libunwind with unwinding
- Loading branch information
Showing
7 changed files
with
122 additions
and
298 deletions.
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 |
---|---|---|
@@ -1,31 +1,19 @@ | ||
use std::{env, path::Path}; | ||
use std::env; | ||
use std::path::Path; | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-changed=psp.ld"); | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=libunwind.a"); | ||
println!("cargo:rerun-if-env-changed=RUSTFLAGS"); | ||
|
||
if env::var("CARGO_FEATURE_STUB_ONLY").is_ok() { | ||
return; | ||
} | ||
|
||
// Figure out whether to use the LTO libunwind, or the regular one. | ||
let libunwind = if env::var("CARGO_ENCODED_RUSTFLAGS") | ||
.unwrap() | ||
.split('\x1f') | ||
.any(|flags| flags.starts_with("-Clinker-plugin-lto")) | ||
{ | ||
"./libunwind_lto.a" | ||
} else { | ||
"./libunwind.a" | ||
}; | ||
|
||
// TODO: Do we even need to copy the library over? Maybe we can just link | ||
// directly from the current directory. | ||
let out_dir = env::var("OUT_DIR").unwrap(); | ||
let out_file = Path::new(&out_dir).join("libunwind.a"); | ||
std::fs::copy(libunwind, out_file).unwrap(); | ||
let out_file = Path::new(&out_dir).join("psp.ld"); | ||
std::fs::copy("psp.ld", out_file).unwrap(); | ||
|
||
println!("cargo:rustc-link-lib=static=unwind"); | ||
println!("cargo:rustc-link-search=native={}", out_dir); | ||
println!("cargo:rustc-link-arg=-Tpsp.ld"); | ||
println!("cargo:rustc-link-search={}", out_dir); | ||
} |
Binary file not shown.
Binary file not shown.
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,37 @@ | ||
ENTRY(module_start) | ||
SECTIONS | ||
{ | ||
/* PRX format requires text to begin at 0 */ | ||
.text 0 : { KEEP(*(.text .text.*)) } | ||
PROVIDE(__text = ADDR(.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)) } | ||
|
||
/* Exception support */ | ||
.eh_frame_hdr : { KEEP(*(.eh_frame_hdr .eh_frame_hdr.*)) } | ||
PROVIDE(__eh_frame_hdr = ADDR(.eh_frame_hdr)); | ||
.eh_frame : { KEEP(*(.eh_frame .eh_frame.*)) } | ||
PROVIDE(__eh_frame = ADDR(.eh_frame)); | ||
|
||
/* These are explicitly listed to avoid being merged into .rodata */ | ||
.rodata.sceResident : { *(.rodata.sceResident) *(.rodata.sceResident.*) } | ||
.rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) } | ||
/* Sort NIDs for convenient ordering */ | ||
.rodata.sceNid : { *(.rodata.sceNid) *(SORT(.rodata.sceNid.*)) } | ||
|
||
.rodata : { *(.rodata .rodata.*) } | ||
.data : { *(.data .data.*) } | ||
.gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } | ||
.bss : { *(.bss .bss.*) } | ||
|
||
/DISCARD/ : { *(.rel.sceStub.text .MIPS.abiflags .reginfo) } | ||
} |
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
Oops, something went wrong.