From 9c5210184dda97f5035b5c20b4de23d833e5f14c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 13 Sep 2025 02:14:37 -0600 Subject: [PATCH] Remove globalize_symbols test (#116) --- src/cmd/dol.rs | 6 +++++- src/cmd/elf.rs | 2 +- src/util/split.rs | 32 +++++++++++++++++++------------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/cmd/dol.rs b/src/cmd/dol.rs index 5966404..544f236 100644 --- a/src/cmd/dol.rs +++ b/src/cmd/dol.rs @@ -234,6 +234,9 @@ pub struct ProjectConfig { /// Marks all emitted symbols as "exported" to prevent the linker from removing them. #[serde(default = "bool_true", skip_serializing_if = "is_true")] pub export_all: bool, + /// Promotes local symbols referenced by other units to global. + #[serde(default = "bool_true", skip_serializing_if = "is_true")] + pub globalize_symbols: bool, /// Optional base path for all object files. #[serde(with = "unix_path_serde_option", default, skip_serializing_if = "is_default")] pub object_base: Option, @@ -259,6 +262,7 @@ impl Default for ProjectConfig { symbols_known: false, fill_gaps: true, export_all: true, + globalize_symbols: true, object_base: None, extract_objects: true, } @@ -967,7 +971,7 @@ fn split_write_obj( debug!("Splitting {} objects", module.obj.link_order.len()); let module_name = module.config.name().to_string(); - let split_objs = split_obj(&module.obj, Some(module_name.as_str()))?; + let split_objs = split_obj(&module.obj, Some(module_name.as_str()), config.globalize_symbols)?; debug!("Writing object files"); DirBuilder::new() diff --git a/src/cmd/elf.rs b/src/cmd/elf.rs index 65ed99e..ead5cd4 100644 --- a/src/cmd/elf.rs +++ b/src/cmd/elf.rs @@ -136,7 +136,7 @@ fn disasm(args: DisasmArgs) -> Result<()> { match obj.kind { ObjKind::Executable => { log::info!("Splitting {} objects", obj.link_order.len()); - let split_objs = split_obj(&obj, None)?; + let split_objs = split_obj(&obj, None, false)?; let asm_dir = args.out.join("asm"); let include_dir = args.out.join("include"); diff --git a/src/util/split.rs b/src/util/split.rs index e3ea084..a161acb 100644 --- a/src/util/split.rs +++ b/src/util/split.rs @@ -992,7 +992,11 @@ fn resolve_link_order(obj: &ObjInfo) -> Result> { /// Split an object into multiple relocatable objects. #[instrument(level = "debug", skip(obj))] -pub fn split_obj(obj: &ObjInfo, module_name: Option<&str>) -> Result> { +pub fn split_obj( + obj: &ObjInfo, + module_name: Option<&str>, + globalize_symbols: bool, +) -> Result> { let mut objects: Vec = vec![]; let mut object_symbols: Vec>> = vec![]; let mut name_to_obj: HashMap = HashMap::new(); @@ -1215,7 +1219,7 @@ pub fn split_obj(obj: &ObjInfo, module_name: Option<&str>) -> Result) -> Result) -> Result) -> Result