Rework .splitmeta, now .note.split
Uses actual ELF .note format, which is more standard and handled better by mwld.
This commit is contained in:
parent
96b13be11d
commit
b829e15438
|
@ -305,7 +305,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "decomp-toolkit"
|
||||
version = "0.7.4"
|
||||
version = "0.7.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ar",
|
||||
|
@ -700,7 +700,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "objdiff-core"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/encounter/objdiff?rev=5b9ac93c084bd0a9ae710e8c8195c4b0db939b8a#5b9ac93c084bd0a9ae710e8c8195c4b0db939b8a"
|
||||
source = "git+https://github.com/encounter/objdiff?rev=20e42a499a7af4bda4f8010c76bdf312df9bcd4c#20e42a499a7af4bda4f8010c76bdf312df9bcd4c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"byteorder",
|
||||
|
|
|
@ -3,7 +3,7 @@ name = "decomp-toolkit"
|
|||
description = "Yet another GameCube/Wii decompilation toolkit."
|
||||
authors = ["Luke Street <luke@street.dev>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
version = "0.7.4"
|
||||
version = "0.7.5"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
repository = "https://github.com/encounter/decomp-toolkit"
|
||||
|
@ -47,7 +47,8 @@ memmap2 = "0.9.0"
|
|||
multimap = "0.9.1"
|
||||
nintendo-lz = "0.1.3"
|
||||
num_enum = "0.7.1"
|
||||
objdiff-core = { git = "https://github.com/encounter/objdiff", rev = "5b9ac93c084bd0a9ae710e8c8195c4b0db939b8a", features = ["ppc"] }
|
||||
objdiff-core = { git = "https://github.com/encounter/objdiff", rev = "20e42a499a7af4bda4f8010c76bdf312df9bcd4c", features = ["ppc"] }
|
||||
#objdiff-core = { path = "../objdiff/objdiff-core", features = ["ppc"] }
|
||||
object = { version = "0.32.1", features = ["read_core", "std", "elf", "write_std"], default-features = false }
|
||||
once_cell = "1.18.0"
|
||||
owo-colors = { version = "3.5.0", features = ["supports-colors"] }
|
||||
|
|
|
@ -601,12 +601,18 @@ fn info(args: InfoArgs) -> Result<()> {
|
|||
let data = split_meta_section.uncompressed_data()?;
|
||||
if !data.is_empty() {
|
||||
let meta =
|
||||
SplitMeta::from_reader(&mut data.as_ref(), in_file.endianness(), in_file.is_64())
|
||||
.context("While reading .splitmeta section")?;
|
||||
println!("\nSplit metadata (.splitmeta):");
|
||||
SplitMeta::from_section(split_meta_section, in_file.endianness(), in_file.is_64())
|
||||
.context("While reading .note.split section")?;
|
||||
println!("\nSplit metadata (.note.split):");
|
||||
if let Some(generator) = &meta.generator {
|
||||
println!("\tGenerator: {}", generator);
|
||||
}
|
||||
if let Some(module_name) = &meta.module_name {
|
||||
println!("\tModule name: {}", module_name);
|
||||
}
|
||||
if let Some(module_id) = meta.module_id {
|
||||
println!("\tModule ID: {}", module_id);
|
||||
}
|
||||
if let Some(virtual_addresses) = &meta.virtual_addresses {
|
||||
println!("\tVirtual addresses:");
|
||||
println!("\t{: >10} | {: <10}", "Addr", "Symbol");
|
||||
|
|
|
@ -133,15 +133,13 @@ where P: AsRef<Path> {
|
|||
if data.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let mut reader = Cursor::new(&*data);
|
||||
let metadata =
|
||||
SplitMeta::from_reader(&mut reader, obj_file.endianness(), obj_file.is_64())
|
||||
.context("While reading .splitmeta section")?;
|
||||
log::debug!("Loaded .splitmeta section");
|
||||
ensure!(
|
||||
data.len() - reader.position() as usize == 0,
|
||||
".splitmeta section data not fully read"
|
||||
);
|
||||
let metadata = SplitMeta::from_section(
|
||||
split_meta_section,
|
||||
obj_file.endianness(),
|
||||
obj_file.is_64(),
|
||||
)
|
||||
.context("While reading .note.split section")?;
|
||||
log::debug!("Loaded .note.split section");
|
||||
Some(metadata)
|
||||
}
|
||||
} else {
|
||||
|
@ -456,7 +454,7 @@ pub fn write_elf(obj: &ObjInfo, export_all: bool) -> Result<Vec<u8>> {
|
|||
None
|
||||
};
|
||||
|
||||
// Generate .splitmeta section
|
||||
// Generate .note.split section
|
||||
let mut split_meta = if let Some(metadata) = &obj.split_meta {
|
||||
// Reserve section
|
||||
let name = writer.add_section_name(SPLITMETA_SECTION.as_bytes());
|
||||
|
@ -472,7 +470,7 @@ pub fn write_elf(obj: &ObjInfo, export_all: bool) -> Result<Vec<u8>> {
|
|||
virtual_address: None,
|
||||
});
|
||||
|
||||
// Generate .splitmeta data
|
||||
// Generate .note.split data
|
||||
let mut out = metadata.clone();
|
||||
out.virtual_addresses = Some(vec![
|
||||
0, // Null symbol
|
||||
|
@ -667,7 +665,7 @@ pub fn write_elf(obj: &ObjInfo, export_all: bool) -> Result<Vec<u8>> {
|
|||
out_section.offset = writer.reserve(comment_data.len(), 32);
|
||||
}
|
||||
|
||||
// Reserve .splitmeta section
|
||||
// Reserve .note.split section
|
||||
if let Some((metadata, idx)) = &split_meta {
|
||||
let out_section = &mut out_sections[*idx];
|
||||
out_section.offset = writer.reserve(metadata.write_size(false), 32);
|
||||
|
@ -786,7 +784,7 @@ pub fn write_elf(obj: &ObjInfo, export_all: bool) -> Result<Vec<u8>> {
|
|||
writer.write(comment_data);
|
||||
}
|
||||
|
||||
// Write .splitmeta section
|
||||
// Write .note.split section
|
||||
if let Some((metadata, idx)) = &split_meta {
|
||||
let out_section = &out_sections[*idx];
|
||||
writer.write_align(32);
|
||||
|
@ -856,7 +854,7 @@ pub fn write_elf(obj: &ObjInfo, export_all: bool) -> Result<Vec<u8>> {
|
|||
});
|
||||
}
|
||||
|
||||
// Write .splitmeta section header
|
||||
// Write .note.split section header
|
||||
if let Some((metadata, idx)) = &split_meta {
|
||||
let out_section = &out_sections[*idx];
|
||||
writer.write_section_header(&SectionHeader {
|
||||
|
@ -868,8 +866,8 @@ pub fn write_elf(obj: &ObjInfo, export_all: bool) -> Result<Vec<u8>> {
|
|||
sh_size: metadata.write_size(false) as u64,
|
||||
sh_link: 0,
|
||||
sh_info: 0,
|
||||
sh_addralign: 1,
|
||||
sh_entsize: 1,
|
||||
sh_addralign: 4,
|
||||
sh_entsize: 0,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue