decompiled __set_debug_bba and __get_debug_bba
This commit is contained in:
parent
d7bf3e394d
commit
dd05a3392e
10 changed files with 85 additions and 28 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,4 +3,5 @@
|
|||
/build.ninja
|
||||
/build
|
||||
.ninja_log
|
||||
.ninja_deps
|
||||
.ninja_deps
|
||||
.~lock.*#
|
|
@ -1,15 +1,4 @@
|
|||
build/obj/init_80004000_80006310.o
|
||||
build/obj/0.o
|
||||
build/obj/sdk/rvl/os/__start.o
|
||||
build/obj/init_8000661c_80006684.o
|
||||
build/obj/extab_80006740_800068cc.o
|
||||
build/obj/extabindex_800068e0_800069e4.o
|
||||
build/obj/text_80006a00_80406244.o
|
||||
build/obj/ctors_80406260_8040652c.o
|
||||
build/obj/dtors_80406544_80406548.o
|
||||
build/obj/rodata_80406560_80421030.o
|
||||
build/obj/data_80421040_804966fc.o
|
||||
build/obj/bss_80496700_8055640c.o
|
||||
build/obj/sdata_80556420_8055c6d0.o
|
||||
build/obj/sbss_8055c6e0_8055df74.o
|
||||
build/obj/sdata2_8055df80_805643b0.o
|
||||
build/obj/sbss2_805643c0_805643fc.o
|
||||
build/obj/2.o
|
||||
build/obj/3.o
|
|
@ -1,6 +1,5 @@
|
|||
StartAddress,EndAddress,Section,File,function
|
||||
80006310,8000661c,.init,__start.o,__start
|
||||
80006684,80006728,.init,linker generated,Symbol is generated by the linker automatically
|
||||
8040652c,80406530,.ctors,linker generated,Symbol is generated by the linker automatically
|
||||
80406540,80406544,.dtors,linker generated,Symbol is generated by the linker automatically
|
||||
80406548,8040654c,.dtors,linker generated,Symbol is generated by the linker automatically
|
||||
.init start,.init end,extab start,extab end,extabindex start,extabindex end,.text start,.text end,.ctors start,.ctors end,.dtors start,.dtors end,.rodata start,.rodata end,.data start,.data end,.bss start,.bss end,.sdata start,.sdata end,.sbss start,.sbss end,.sdata2 start,.sdata2 end,.sbss2 start,.sbss2 end,File
|
||||
800062f0,8000661c,,,,,,,,,,,,,,,,,,,8055c878,8055c879,,,,,sdk/rvl/os/__start.o
|
||||
,,,,,,,,80406540,80406544,,,,,,,,,,,,,,,,,Linker generated symbol file
|
||||
80006684,80006728,,,,,,,8040652c,80406530,80406548,8040654c,,,,,,,,,,,,,,,Linker generated symbol file
|
||||
80006728,80006728,800068cc,800068cc,800069e4,800069e4,80406244,80406244,80406530,80406530,8040654c,8040654c,80421030,80421030,804966fc,804966fc,8055640c,8055640c,8055c6d0,8055c6d0,8055df74,8055df74,805643b0,805643b0,805643fc,805643fc,End of File
|
||||
|
|
|
|
@ -19,3 +19,4 @@ Address,SymbolName
|
|||
80028530,__init_user
|
||||
800285a0,exit
|
||||
80174ad8,main
|
||||
8055c878,Debug_BBA
|
||||
|
|
|
|
@ -17,3 +17,6 @@ rule cc
|
|||
|
||||
rule elf2dol
|
||||
command = cargo run --quiet --release --bin elf2dol -- $in $out
|
||||
|
||||
rule mergeobj
|
||||
command = ld.lld -relocatable $in -o $out
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
void __init_registers(void);
|
||||
void __init_data(void);
|
||||
void __init_hardware(void);
|
||||
void __set_debug_bba(void);
|
||||
void InitMetroTRK(void);
|
||||
void OSInit(void);
|
||||
void __check_pad3(void);
|
||||
void __get_debug_bba(void);
|
||||
void InitMetroTRK_BBA(void);
|
||||
void __init_user(void);
|
||||
int main(int argc, char **argv);
|
||||
|
@ -20,6 +18,12 @@ extern int _SDA_BASE_;
|
|||
extern int _rom_copy_info;
|
||||
extern int _bss_init_info;
|
||||
|
||||
static char Debug_BBA;
|
||||
|
||||
__declspec(section ".init") void __set_debug_bba() { Debug_BBA = 1; }
|
||||
|
||||
__declspec(section ".init") char __get_debug_bba() { return Debug_BBA; }
|
||||
|
||||
__declspec(section ".init") asm void start() {
|
||||
// clang-format off
|
||||
nofralloc;
|
||||
|
|
|
@ -36,15 +36,18 @@ fn main() -> Result<()> {
|
|||
|
||||
for result in rdr.records() {
|
||||
let result = result?;
|
||||
ranges.remove_range(
|
||||
parse_hex(result.get(0).unwrap())?,
|
||||
parse_hex(result.get(1).unwrap())?,
|
||||
);
|
||||
for i in 0..13 {
|
||||
if &result[2 * i] == "" {
|
||||
continue;
|
||||
}
|
||||
ranges.remove_range(parse_hex(&result[2 * i])?, parse_hex(&result[2 * i + 1])?);
|
||||
}
|
||||
}
|
||||
|
||||
ranges.merge_ranges();
|
||||
|
||||
for (start, end) in ranges.into_iter() {
|
||||
for (start, end) in ranges.iter() {
|
||||
let (start, end) = (*start, *end);
|
||||
let objfile = format!(
|
||||
"build/obj/{}_{:08x}_{:08x}.o",
|
||||
dolfile.get_section_name(start),
|
||||
|
@ -54,6 +57,36 @@ fn main() -> Result<()> {
|
|||
ninja.emit_extract("bin/donut/donut.dol", &objfile, start, end)?;
|
||||
}
|
||||
|
||||
let mut rdr = csv::Reader::from_reader(BufReader::new(File::open("data/ranges.csv")?));
|
||||
|
||||
for (i, result) in rdr.records().enumerate() {
|
||||
let result = result?;
|
||||
let mut start_addrs = Vec::new();
|
||||
for i in 0..13 {
|
||||
if &result[2 * i] == "" {
|
||||
continue;
|
||||
}
|
||||
start_addrs.push(parse_hex(&result[2 * i])?);
|
||||
}
|
||||
let mut to_merge = Vec::new();
|
||||
for (start, end) in ranges.iter() {
|
||||
let (start, end) = (*start, *end);
|
||||
for start_addr in start_addrs.iter() {
|
||||
if *start_addr == end {
|
||||
to_merge.push(format!(
|
||||
"build/obj/{}_{:08x}_{:08x}.o",
|
||||
dolfile.get_section_name(start),
|
||||
start,
|
||||
end
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if !to_merge.is_empty() {
|
||||
ninja.emit_merge(format!("build/obj/{}.o", i), &to_merge)?;
|
||||
}
|
||||
}
|
||||
|
||||
for source in SOURCES.iter() {
|
||||
ninja.emit_cc(source.0, source.1)?;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ pub struct Dol<R: Read + Seek + ?Sized> {
|
|||
section_sizes: [u32; 18],
|
||||
bss_address: u32,
|
||||
bss_size: u32,
|
||||
#[allow(dead_code)]
|
||||
entry_point: u32,
|
||||
reader: R,
|
||||
}
|
||||
|
|
|
@ -85,6 +85,29 @@ impl NinjaFile {
|
|||
self.emit_mkdir(parent)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn emit_merge(
|
||||
&mut self,
|
||||
outfile: impl AsRef<Path>,
|
||||
objs: &[impl AsRef<Path>],
|
||||
) -> Result<()> {
|
||||
let outfile = outfile.as_ref();
|
||||
if self.emitted_targets.contains(outfile) {
|
||||
return Ok(());
|
||||
}
|
||||
self.emitted_targets.insert(outfile.to_owned());
|
||||
let parent = outfile.parent().unwrap();
|
||||
self.writer
|
||||
.write_all(format!("build {}: mergeobj ", outfile.display()).as_bytes())?;
|
||||
for object in objs.iter() {
|
||||
self.writer
|
||||
.write_all(format!("{} ", object.as_ref().display()).as_bytes())?;
|
||||
}
|
||||
self.writer.write_all(b"\n")?;
|
||||
self.emit_mkdir(parent)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn emit_genlcf(&mut self, outfile: impl AsRef<Path>) -> Result<()> {
|
||||
let outfile = outfile.as_ref();
|
||||
if self.emitted_targets.contains(outfile) {
|
||||
|
|
|
@ -66,4 +66,7 @@ impl Ranges {
|
|||
pub fn into_iter(self) -> impl Iterator<Item = (u32, u32)> {
|
||||
self.range_list.into_iter()
|
||||
}
|
||||
pub fn iter(&self) -> impl Iterator<Item = (&u32, &u32)> {
|
||||
self.range_list.iter()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue