Add `auto_force_active` option (disable to support `-code_merging`)
Fixes #13
This commit is contained in:
parent
5a3256b2b6
commit
968f50ebed
|
@ -295,7 +295,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "decomp-toolkit"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ar",
|
||||
|
|
|
@ -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.0"
|
||||
version = "0.7.1"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
repository = "https://github.com/encounter/decomp-toolkit"
|
||||
|
|
|
@ -225,9 +225,12 @@ pub struct ProjectConfig {
|
|||
/// and instead assumes that all symbols are known.
|
||||
#[serde(default, skip_serializing_if = "is_default")]
|
||||
pub symbols_known: bool,
|
||||
/// Fills gaps between symbols with
|
||||
/// Fills gaps between symbols to avoid linker realignment.
|
||||
#[serde(default = "bool_true", skip_serializing_if = "is_true")]
|
||||
pub fill_gaps: bool,
|
||||
/// Marks all emitted symbols as "force active" to prevent the linker from removing them.
|
||||
#[serde(default = "bool_true", skip_serializing_if = "is_true")]
|
||||
pub auto_force_active: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||
|
@ -859,7 +862,7 @@ fn split_write_obj(
|
|||
entry,
|
||||
};
|
||||
for (unit, split_obj) in module.obj.link_order.iter().zip(&split_objs) {
|
||||
let out_obj = write_elf(split_obj)?;
|
||||
let out_obj = write_elf(split_obj, config.auto_force_active)?;
|
||||
let out_path = obj_dir.join(obj_path_for_unit(&unit.name));
|
||||
out_config.units.push(OutputUnit {
|
||||
object: out_path.clone(),
|
||||
|
@ -1763,6 +1766,7 @@ fn config(args: ConfigArgs) -> Result<()> {
|
|||
common_start: None,
|
||||
symbols_known: false,
|
||||
fill_gaps: true,
|
||||
auto_force_active: true,
|
||||
};
|
||||
|
||||
let mut modules = Vec::<(u32, ModuleConfig)>::new();
|
||||
|
|
|
@ -185,7 +185,7 @@ fn split(args: SplitArgs) -> Result<()> {
|
|||
|
||||
let split_objs = split_obj(&obj)?;
|
||||
for (unit, split_obj) in obj.link_order.iter().zip(&split_objs) {
|
||||
let out_obj = write_elf(split_obj)?;
|
||||
let out_obj = write_elf(split_obj, false)?;
|
||||
match file_map.entry(unit.name.clone()) {
|
||||
hash_map::Entry::Vacant(e) => e.insert(out_obj),
|
||||
hash_map::Entry::Occupied(_) => bail!("Duplicate file {}", unit.name),
|
||||
|
|
|
@ -579,7 +579,7 @@ fn merge(args: MergeArgs) -> Result<()> {
|
|||
|
||||
// Write ELF
|
||||
log::info!("Writing {}", args.out_file.display());
|
||||
fs::write(&args.out_file, write_elf(&obj)?)?;
|
||||
fs::write(&args.out_file, write_elf(&obj, false)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ where P: AsRef<Path> {
|
|||
Ok(obj)
|
||||
}
|
||||
|
||||
pub fn write_elf(obj: &ObjInfo) -> Result<Vec<u8>> {
|
||||
pub fn write_elf(obj: &ObjInfo, force_active: bool) -> Result<Vec<u8>> {
|
||||
let mut out_data = Vec::new();
|
||||
let mut writer = object::write::elf::Writer::new(Endianness::Big, false, &mut out_data);
|
||||
|
||||
|
@ -540,7 +540,7 @@ pub fn write_elf(obj: &ObjInfo) -> Result<Vec<u8>> {
|
|||
out_symbols.push(OutSymbol { index, sym });
|
||||
symbol_map[symbol_index] = Some(index.0);
|
||||
if let Some(comment_data) = &mut comment_data {
|
||||
CommentSym::from(symbol, true).to_writer_static(comment_data, Endian::Big)?;
|
||||
CommentSym::from(symbol, force_active).to_writer_static(comment_data, Endian::Big)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue