@@ -13,7 +13,7 @@ use crate::{
1313 code:: { diff_code, no_diff_code} ,
1414 data:: {
1515 diff_bss_section, diff_bss_symbol, diff_data_section, diff_data_symbol,
16- diff_generic_section,
16+ diff_generic_section, no_diff_bss_section , no_diff_data_section ,
1717 } ,
1818 } ,
1919 obj:: { InstructionRef , Object , Relocation , SectionKind , Symbol , SymbolFlag } ,
@@ -288,52 +288,84 @@ pub fn diff_objs(
288288 }
289289
290290 for section_match in section_matches {
291- if let SectionMatch {
292- left : Some ( left_section_idx) ,
293- right : Some ( right_section_idx) ,
294- section_kind,
295- } = section_match
296- {
297- let ( left_obj, left_out) = left. as_mut ( ) . unwrap ( ) ;
298- let ( right_obj, right_out) = right. as_mut ( ) . unwrap ( ) ;
299- match section_kind {
300- SectionKind :: Code => {
301- let ( left_diff, right_diff) = diff_generic_section (
302- left_obj,
303- right_obj,
304- left_out,
305- right_out,
306- left_section_idx,
307- right_section_idx,
308- ) ?;
309- left_out. sections [ left_section_idx] = left_diff;
310- right_out. sections [ right_section_idx] = right_diff;
291+ match section_match {
292+ SectionMatch {
293+ left : Some ( left_section_idx) ,
294+ right : Some ( right_section_idx) ,
295+ section_kind,
296+ } => {
297+ let ( left_obj, left_out) = left. as_mut ( ) . unwrap ( ) ;
298+ let ( right_obj, right_out) = right. as_mut ( ) . unwrap ( ) ;
299+ match section_kind {
300+ SectionKind :: Code => {
301+ let ( left_diff, right_diff) = diff_generic_section (
302+ left_obj,
303+ right_obj,
304+ left_out,
305+ right_out,
306+ left_section_idx,
307+ right_section_idx,
308+ ) ?;
309+ left_out. sections [ left_section_idx] = left_diff;
310+ right_out. sections [ right_section_idx] = right_diff;
311+ }
312+ SectionKind :: Data => {
313+ let ( left_diff, right_diff) = diff_data_section (
314+ left_obj,
315+ right_obj,
316+ left_out,
317+ right_out,
318+ left_section_idx,
319+ right_section_idx,
320+ ) ?;
321+ left_out. sections [ left_section_idx] = left_diff;
322+ right_out. sections [ right_section_idx] = right_diff;
323+ }
324+ SectionKind :: Bss | SectionKind :: Common => {
325+ let ( left_diff, right_diff) = diff_bss_section (
326+ left_obj,
327+ right_obj,
328+ left_out,
329+ right_out,
330+ left_section_idx,
331+ right_section_idx,
332+ ) ?;
333+ left_out. sections [ left_section_idx] = left_diff;
334+ right_out. sections [ right_section_idx] = right_diff;
335+ }
336+ SectionKind :: Unknown => unreachable ! ( ) ,
311337 }
312- SectionKind :: Data => {
313- let ( left_diff, right_diff) = diff_data_section (
314- left_obj,
315- right_obj,
316- left_out,
317- right_out,
318- left_section_idx,
319- right_section_idx,
320- ) ?;
321- left_out. sections [ left_section_idx] = left_diff;
322- right_out. sections [ right_section_idx] = right_diff;
338+ }
339+ SectionMatch { left : Some ( left_section_idx) , right : None , section_kind } => {
340+ let ( left_obj, left_out) = left. as_mut ( ) . unwrap ( ) ;
341+ match section_kind {
342+ SectionKind :: Code => { }
343+ SectionKind :: Data => {
344+ left_out. sections [ left_section_idx] =
345+ no_diff_data_section ( left_obj, left_section_idx) ?;
346+ }
347+ SectionKind :: Bss | SectionKind :: Common => {
348+ left_out. sections [ left_section_idx] = no_diff_bss_section ( ) ?;
349+ }
350+ SectionKind :: Unknown => unreachable ! ( ) ,
323351 }
324- SectionKind :: Bss | SectionKind :: Common => {
325- let ( left_diff, right_diff) = diff_bss_section (
326- left_obj,
327- right_obj,
328- left_out,
329- right_out,
330- left_section_idx,
331- right_section_idx,
332- ) ?;
333- left_out. sections [ left_section_idx] = left_diff;
334- right_out. sections [ right_section_idx] = right_diff;
352+ }
353+ SectionMatch { left : None , right : Some ( right_section_idx) , section_kind } => {
354+ let ( right_obj, right_out) = right. as_mut ( ) . unwrap ( ) ;
355+ match section_kind {
356+ SectionKind :: Code => { }
357+ SectionKind :: Data => {
358+ right_out. sections [ right_section_idx] =
359+ no_diff_data_section ( right_obj, right_section_idx) ?;
360+ }
361+ SectionKind :: Bss | SectionKind :: Common => {
362+ right_out. sections [ right_section_idx] = no_diff_bss_section ( ) ?;
363+ }
364+ SectionKind :: Unknown => unreachable ! ( ) ,
335365 }
336- SectionKind :: Unknown => unreachable ! ( ) ,
366+ }
367+ SectionMatch { left : None , right : None , .. } => {
368+ // Should not happen
337369 }
338370 }
339371 }
0 commit comments