@@ -482,61 +482,7 @@ impl<'a, 'b> PEWriter<'a, 'b> {
482482 // if cert table exist, it should be the last element
483483 // if debug table exist, it should be the last element
484484 // This is important because they are not mapped in memory.
485- debug_assert ! (
486- self . pe
487- . header
488- . optional_header
489- . map( |opt_header| {
490- // This test is incorrect
491- // We need to find the section enclosing the debug data directory
492- // and verify if it's a .debug section, if it is, it must be at the end
493- // if it's not enclosed by a section (which apparently can happen??)…
494- // and finally if it's in .data (which happens sometimes), let's ignore the debug
495- // table ordering.
496- let dd_end = opt_header. data_directories. data_directories[ 6 ]
497- . and_then( |( offset, debug_table) | Some ( offset as u32 + debug_table. size) ) ;
498- let cert_attr_end = opt_header
499- . data_directories
500- . get_certificate_table( )
501- . and_then( |cert_table| {
502- enumerate_certificates(
503- & buffer,
504- cert_table. virtual_address,
505- cert_table. size,
506- )
507- . ok( )
508- } )
509- . and_then( |certificates| {
510- certificates
511- . last( )
512- . map( |( last_offset, cert) | * last_offset as u32 + cert. length)
513- } ) ;
514-
515- debug!( "debug table end: {:?}" , dd_end) ;
516- debug!( "cert attribute end: {:?}" , cert_attr_end) ;
517- debug!( "file size: {}" , self . file_size) ;
518-
519- // it is sufficient to prove:
520- // cert attributes end <= debug table end <= align(debug table or cert attributes
521- // end, file alignment)
522- // where any end can be None.
523- match ( cert_attr_end, dd_end) {
524- ( Some ( cert_end) , Some ( dd_end) ) => {
525- cert_end <= dd_end
526- && align_to( dd_end, self . file_alignment) == self . file_size
527- }
528- ( None , Some ( dd_end) ) => {
529- align_to( dd_end, self . file_alignment) == self . file_size
530- }
531- ( Some ( cert_end) , None ) => {
532- align_to( cert_end, self . file_alignment) == self . file_size
533- }
534- ( None , None ) => true ,
535- }
536- } )
537- . unwrap_or( true ) ,
538- "certificate attributes and debug information are incorrectly placed"
539- ) ;
485+ // TODO: reintroduce it.
540486
541487 // We cannot guarantee that written == self.file_size
542488 // as PE cannot be perfectly efficient vs. how we do write them.
0 commit comments