gerge branch 'main' into experimental

This commit is contained in:
Luke Street 2023-01-19 12:54:52 -05:00
commit 827e0806be
5 changed files with 13 additions and 15 deletions

View File

@ -3,7 +3,7 @@ name = "decomp-toolkit"
description = "GameCube/Wii decompilation project tools."
authors = ["Luke Street <luke@street.dev>"]
license = "MIT OR Apache-2.0"
version = "0.2.2"
version = "0.2.3"
edition = "2021"
publish = false
build = "build.rs"

View File

@ -45,9 +45,8 @@ fn create(args: CreateArgs) -> Result<()> {
// Process response files (starting with '@')
let mut files = Vec::with_capacity(args.files.len());
for path in args.files {
let path_str = path
.to_str()
.ok_or_else(|| anyhow!("'{}' is not valid UTF-8", path.display()))?;
let path_str =
path.to_str().ok_or_else(|| anyhow!("'{}' is not valid UTF-8", path.display()))?;
match path_str.strip_prefix('@') {
Some(rsp_file) => {
let reader = BufReader::new(
@ -71,18 +70,14 @@ fn create(args: CreateArgs) -> Result<()> {
let mut identifiers = Vec::with_capacity(files.len());
let mut symbol_table = BTreeMap::new();
for path in &files {
let file_name = path
.file_name()
.ok_or_else(|| anyhow!("'{}' is not a file path", path.display()))?;
let file_name = file_name
.to_str()
.ok_or_else(|| anyhow!("'{}' is not valid UTF-8", file_name.to_string_lossy()))?;
let identifier = file_name.as_bytes().to_vec();
let path_str =
path.to_str().ok_or_else(|| anyhow!("'{}' is not valid UTF-8", path.display()))?;
let identifier = path_str.as_bytes().to_vec();
identifiers.push(identifier.clone());
let entries = match symbol_table.entry(identifier) {
Entry::Vacant(e) => e.insert(Vec::new()),
Entry::Occupied(_) => bail!("Duplicate file name '{file_name}'"),
Entry::Occupied(_) => bail!("Duplicate file name '{path_str}'"),
};
let object_file = File::open(path)
.with_context(|| format!("Failed to open object file '{}'", path.display()))?;
@ -101,7 +96,10 @@ fn create(args: CreateArgs) -> Result<()> {
let mut builder =
ar::GnuBuilder::new(out, identifiers, ar::GnuSymbolTableFormat::Size32, symbol_table)?;
for path in files {
builder.append_path(path)?;
let path_str =
path.to_str().ok_or_else(|| anyhow!("'{}' is not valid UTF-8", path.display()))?;
let mut file = File::open(&path)?;
builder.append_file(path_str.as_bytes(), &mut file)?;
}
builder.into_inner()?.flush()?;
Ok(())

View File

@ -144,7 +144,7 @@ fn disasm(args: DisasmArgs) -> Result<()> {
let asm_dir = args.out.join("asm");
let include_dir = args.out.join("include");
DirBuilder::new().recursive(true).create(&include_dir)?;
fs::write(&include_dir.join("macros.inc"), include_bytes!("../../assets/macros.inc"))?;
fs::write(include_dir.join("macros.inc"), include_bytes!("../../assets/macros.inc"))?;
let mut files_out = File::create(args.out.join("link_order.txt"))?;
for (unit, split_obj) in obj.link_order.iter().zip(&split_objs) {

View File

@ -378,6 +378,7 @@ fn write_symbol_entry<W: Write>(
Ok(())
}
#[allow(clippy::too_many_arguments)]
fn write_data<W: Write>(
w: &mut W,
symbols: &[ObjSymbol],

View File

@ -105,7 +105,6 @@ pub fn process_elf<P: AsRef<Path>>(path: P) -> Result<ObjInfo> {
relocations: vec![],
original_address: 0, // TODO load from abs symbol
file_offset: section.file_range().map(|(v, _)| v).unwrap_or_default(),
section_known: true,
});
}