@@ -47,6 +47,7 @@ use crate::{
47
47
diff:: { calc_diff_ranges, print_diff, process_code} ,
48
48
dol:: process_dol,
49
49
elf:: { process_elf, write_elf} ,
50
+ extab:: clean_extab,
50
51
file:: {
51
52
buf_copy_with_hash, buf_writer, check_hash_str, touch, verify_hash, FileIterator ,
52
53
FileReadInfo ,
@@ -293,6 +294,9 @@ pub struct ModuleConfig {
293
294
pub block_relocations : Vec < BlockRelocationConfig > ,
294
295
#[ serde( default , skip_serializing_if = "Vec::is_empty" ) ]
295
296
pub add_relocations : Vec < AddRelocationConfig > ,
297
+ /// Process exception tables and zero out uninitialized data.
298
+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
299
+ pub clean_extab : Option < bool > ,
296
300
}
297
301
298
302
#[ derive( Serialize , Deserialize , Debug , Clone , PartialEq ) ]
@@ -818,17 +822,29 @@ struct AnalyzeResult {
818
822
splits_cache : Option < FileReadInfo > ,
819
823
}
820
824
821
- fn load_analyze_dol ( config : & ProjectConfig , object_base : & ObjectBase ) -> Result < AnalyzeResult > {
822
- let object_path = object_base. join ( & config. base . object ) ;
825
+ fn load_dol_module (
826
+ config : & ModuleConfig ,
827
+ object_base : & ObjectBase ,
828
+ ) -> Result < ( ObjInfo , Utf8NativePathBuf ) > {
829
+ let object_path = object_base. join ( & config. object ) ;
823
830
log:: debug!( "Loading {}" , object_path) ;
824
831
let mut obj = {
825
- let mut file = object_base. open ( & config. base . object ) ?;
832
+ let mut file = object_base. open ( & config. object ) ?;
826
833
let data = file. map ( ) ?;
827
- if let Some ( hash_str) = & config. base . hash {
834
+ if let Some ( hash_str) = & config. hash {
828
835
verify_hash ( data, hash_str) ?;
829
836
}
830
- process_dol ( data, config. base . name ( ) ) ?
837
+ process_dol ( data, config. name ( ) ) ?
831
838
} ;
839
+ if config. clean_extab . unwrap_or ( false ) {
840
+ log:: debug!( "Cleaning extab for {}" , config. name( ) ) ;
841
+ clean_extab ( & mut obj) ?;
842
+ }
843
+ Ok ( ( obj, object_path) )
844
+ }
845
+
846
+ fn load_analyze_dol ( config : & ProjectConfig , object_base : & ObjectBase ) -> Result < AnalyzeResult > {
847
+ let ( mut obj, object_path) = load_dol_module ( & config. base , object_base) ?;
832
848
let mut dep = vec ! [ object_path] ;
833
849
834
850
if let Some ( comment_version) = config. mw_comment_version {
@@ -1658,15 +1674,7 @@ fn diff(args: DiffArgs) -> Result<()> {
1658
1674
let config: ProjectConfig = serde_yaml:: from_reader ( config_file. as_mut ( ) ) ?;
1659
1675
let object_base = find_object_base ( & config) ?;
1660
1676
1661
- log:: info!( "Loading {}" , object_base. join( & config. base. object) ) ;
1662
- let mut obj = {
1663
- let mut file = object_base. open ( & config. base . object ) ?;
1664
- let data = file. map ( ) ?;
1665
- if let Some ( hash_str) = & config. base . hash {
1666
- verify_hash ( data, hash_str) ?;
1667
- }
1668
- process_dol ( data, config. base . name ( ) ) ?
1669
- } ;
1677
+ let ( mut obj, _object_path) = load_dol_module ( & config. base , & object_base) ?;
1670
1678
1671
1679
if let Some ( symbols_path) = & config. base . symbols {
1672
1680
apply_symbols_file ( & symbols_path. with_encoding ( ) , & mut obj) ?;
@@ -1882,15 +1890,7 @@ fn apply(args: ApplyArgs) -> Result<()> {
1882
1890
let config: ProjectConfig = serde_yaml:: from_reader ( config_file. as_mut ( ) ) ?;
1883
1891
let object_base = find_object_base ( & config) ?;
1884
1892
1885
- log:: info!( "Loading {}" , object_base. join( & config. base. object) ) ;
1886
- let mut obj = {
1887
- let mut file = object_base. open ( & config. base . object ) ?;
1888
- let data = file. map ( ) ?;
1889
- if let Some ( hash_str) = & config. base . hash {
1890
- verify_hash ( data, hash_str) ?;
1891
- }
1892
- process_dol ( data, config. base . name ( ) ) ?
1893
- } ;
1893
+ let ( mut obj, _object_path) = load_dol_module ( & config. base , & object_base) ?;
1894
1894
1895
1895
let Some ( symbols_path) = & config. base . symbols else {
1896
1896
bail ! ( "No symbols file specified in config" ) ;
0 commit comments