File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed
rustc_codegen_ssa/src/back Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,7 @@ pub fn create_compressed_metadata_file(
305
305
symbol_name : & str ,
306
306
) -> Vec < u8 > {
307
307
let mut compressed = rustc_metadata:: METADATA_HEADER . to_vec ( ) ;
308
+ compressed. write_all ( & ( metadata. raw_data ( ) . len ( ) as u32 ) . to_be_bytes ( ) ) . unwrap ( ) ;
308
309
FrameEncoder :: new ( & mut compressed) . write_all ( metadata. raw_data ( ) ) . unwrap ( ) ;
309
310
let Some ( mut file) = create_object_file ( sess) else {
310
311
return compressed. to_vec ( ) ;
Original file line number Diff line number Diff line change @@ -798,8 +798,15 @@ fn get_metadata_section<'p>(
798
798
) ) ) ;
799
799
}
800
800
801
+ // Length of the compressed stream - this allows linkers to pad the section if they want
802
+ let usize_len = core:: mem:: size_of :: < u32 > ( ) ;
803
+ let Ok ( len_bytes) = <[ u8 ; 4 ] >:: try_from ( & buf[ header_len..cmp:: min ( header_len + usize_len, buf. len ( ) ) ] ) else {
804
+ return Err ( MetadataError :: LoadFailure ( "invalid metadata length found" . to_string ( ) ) ) ;
805
+ } ;
806
+ let compressed_len = u32:: from_be_bytes ( len_bytes) as usize ;
807
+
801
808
// Header is okay -> inflate the actual metadata
802
- let compressed_bytes = & buf[ header_len..] ;
809
+ let compressed_bytes = & buf[ header_len..compressed_len + header_len ] ;
803
810
debug ! ( "inflating {} bytes of compressed metadata" , compressed_bytes. len( ) ) ;
804
811
// Assume the decompressed data will be at least the size of the compressed data, so we
805
812
// don't have to grow the buffer as much.
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ pub(crate) fn rustc_version() -> String {
55
55
/// Metadata encoding version.
56
56
/// N.B., increment this if you change the format of metadata such that
57
57
/// the rustc version can't be found to compare with `rustc_version()`.
58
- const METADATA_VERSION : u8 = 6 ;
58
+ const METADATA_VERSION : u8 = 7 ;
59
59
60
60
/// Metadata header which includes `METADATA_VERSION`.
61
61
///
You can’t perform that action at this time.
0 commit comments