diff options
| author | bors <bors@rust-lang.org> | 2023-12-11 17:21:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-11 17:21:14 +0000 |
| commit | 57010939ed1d00076b4af0ed06a81ec69ea5e4a8 (patch) | |
| tree | 76646b8959916e3fcd3a6566dcaaf7ac7dcde9bf /compiler/rustc_codegen_ssa/src | |
| parent | 8a3765582cb83733f8c344062729df0175409488 (diff) | |
| parent | 79bdd24d6ee1022e4a02fd00a490279c7f0a4f98 (diff) | |
| download | rust-57010939ed1d00076b4af0ed06a81ec69ea5e4a8.tar.gz rust-57010939ed1d00076b4af0ed06a81ec69ea5e4a8.zip | |
Auto merge of #118344 - saethlin:rmeta-header-pos, r=WaffleLapkin
Use a u64 for the rmeta root position Waffle noticed this in https://github.com/rust-lang/rust/pull/117301#discussion_r1405410174 We've upgraded the other file offsets to u64, and this one only costs 4 bytes per file. Also the way the truncation was being done before was extremely easy to miss, I sure missed it! It's not clear to me if not having this change effectively made the other upgrades from u32 to u64 ineffective, but we can have it now. r? `@WaffleLapkin`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/metadata.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 3e26e3653ea..bc0e3a82806 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -158,12 +158,12 @@ pub(super) fn get_metadata_xcoff<'a>(path: &Path, data: &'a [u8]) -> Result<&'a file.symbols().find(|sym| sym.name() == Ok(AIX_METADATA_SYMBOL_NAME)) { let offset = metadata_symbol.address() as usize; - if offset < 4 { + if offset < 8 { return Err(format!("Invalid metadata symbol offset: {offset}")); } // The offset specifies the location of rustc metadata in the comment section. - // The metadata is preceded by a 4-byte length field. - let len = u32::from_be_bytes(info_data[(offset - 4)..offset].try_into().unwrap()) as usize; + // The metadata is preceded by a 8-byte length field. + let len = u64::from_le_bytes(info_data[(offset - 8)..offset].try_into().unwrap()) as usize; if offset + len > (info_data.len() as usize) { return Err(format!( "Metadata at offset {offset} with size {len} is beyond .info section" @@ -479,8 +479,8 @@ pub fn create_wrapper_file( file.section_mut(section).flags = SectionFlags::Xcoff { s_flags: xcoff::STYP_INFO as u32 }; - let len = data.len() as u32; - let offset = file.append_section_data(section, &len.to_be_bytes(), 1); + let len = data.len() as u64; + let offset = file.append_section_data(section, &len.to_le_bytes(), 1); // Add a symbol referring to the data in .info section. file.add_symbol(Symbol { name: AIX_METADATA_SYMBOL_NAME.into(), @@ -524,7 +524,7 @@ pub fn create_compressed_metadata_file( symbol_name: &str, ) -> Vec<u8> { let mut packed_metadata = rustc_metadata::METADATA_HEADER.to_vec(); - packed_metadata.write_all(&(metadata.raw_data().len() as u32).to_be_bytes()).unwrap(); + packed_metadata.write_all(&(metadata.raw_data().len() as u64).to_le_bytes()).unwrap(); packed_metadata.extend(metadata.raw_data()); let Some(mut file) = create_object_file(sess) else { @@ -599,12 +599,12 @@ pub fn create_compressed_metadata_file_for_xcoff( section: SymbolSection::Section(data_section), flags: SymbolFlags::None, }); - let len = data.len() as u32; - let offset = file.append_section_data(section, &len.to_be_bytes(), 1); + let len = data.len() as u64; + let offset = file.append_section_data(section, &len.to_le_bytes(), 1); // Add a symbol referring to the rustc metadata. file.add_symbol(Symbol { name: AIX_METADATA_SYMBOL_NAME.into(), - value: offset + 4, // The metadata is preceded by a 4-byte length field. + value: offset + 8, // The metadata is preceded by a 8-byte length field. size: 0, kind: SymbolKind::Unknown, scope: SymbolScope::Dynamic, |
