Skip to content

Commit 968f50e

Browse files
committed
Add auto_force_active option (disable to support -code_merging)
Fixes #13
1 parent 5a3256b commit 968f50e

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "decomp-toolkit"
33
description = "Yet another GameCube/Wii decompilation toolkit."
44
authors = ["Luke Street <[email protected]>"]
55
license = "MIT OR Apache-2.0"
6-
version = "0.7.0"
6+
version = "0.7.1"
77
edition = "2021"
88
publish = false
99
repository = "https://github.com/encounter/decomp-toolkit"

src/cmd/dol.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,12 @@ pub struct ProjectConfig {
225225
/// and instead assumes that all symbols are known.
226226
#[serde(default, skip_serializing_if = "is_default")]
227227
pub symbols_known: bool,
228-
/// Fills gaps between symbols with
228+
/// Fills gaps between symbols to avoid linker realignment.
229229
#[serde(default = "bool_true", skip_serializing_if = "is_true")]
230230
pub fill_gaps: bool,
231+
/// Marks all emitted symbols as "force active" to prevent the linker from removing them.
232+
#[serde(default = "bool_true", skip_serializing_if = "is_true")]
233+
pub auto_force_active: bool,
231234
}
232235

233236
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
@@ -859,7 +862,7 @@ fn split_write_obj(
859862
entry,
860863
};
861864
for (unit, split_obj) in module.obj.link_order.iter().zip(&split_objs) {
862-
let out_obj = write_elf(split_obj)?;
865+
let out_obj = write_elf(split_obj, config.auto_force_active)?;
863866
let out_path = obj_dir.join(obj_path_for_unit(&unit.name));
864867
out_config.units.push(OutputUnit {
865868
object: out_path.clone(),
@@ -1763,6 +1766,7 @@ fn config(args: ConfigArgs) -> Result<()> {
17631766
common_start: None,
17641767
symbols_known: false,
17651768
fill_gaps: true,
1769+
auto_force_active: true,
17661770
};
17671771

17681772
let mut modules = Vec::<(u32, ModuleConfig)>::new();

src/cmd/elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn split(args: SplitArgs) -> Result<()> {
185185

186186
let split_objs = split_obj(&obj)?;
187187
for (unit, split_obj) in obj.link_order.iter().zip(&split_objs) {
188-
let out_obj = write_elf(split_obj)?;
188+
let out_obj = write_elf(split_obj, false)?;
189189
match file_map.entry(unit.name.clone()) {
190190
hash_map::Entry::Vacant(e) => e.insert(out_obj),
191191
hash_map::Entry::Occupied(_) => bail!("Duplicate file {}", unit.name),

src/cmd/rel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ fn merge(args: MergeArgs) -> Result<()> {
579579

580580
// Write ELF
581581
log::info!("Writing {}", args.out_file.display());
582-
fs::write(&args.out_file, write_elf(&obj)?)?;
582+
fs::write(&args.out_file, write_elf(&obj, false)?)?;
583583
Ok(())
584584
}
585585

src/util/elf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ where P: AsRef<Path> {
346346
Ok(obj)
347347
}
348348

349-
pub fn write_elf(obj: &ObjInfo) -> Result<Vec<u8>> {
349+
pub fn write_elf(obj: &ObjInfo, force_active: bool) -> Result<Vec<u8>> {
350350
let mut out_data = Vec::new();
351351
let mut writer = object::write::elf::Writer::new(Endianness::Big, false, &mut out_data);
352352

@@ -540,7 +540,7 @@ pub fn write_elf(obj: &ObjInfo) -> Result<Vec<u8>> {
540540
out_symbols.push(OutSymbol { index, sym });
541541
symbol_map[symbol_index] = Some(index.0);
542542
if let Some(comment_data) = &mut comment_data {
543-
CommentSym::from(symbol, true).to_writer_static(comment_data, Endian::Big)?;
543+
CommentSym::from(symbol, force_active).to_writer_static(comment_data, Endian::Big)?;
544544
}
545545
}
546546

0 commit comments

Comments
 (0)