Skip to content

Commit ce9a02e

Browse files
author
Kai Luo
committed
Address comment
1 parent 14e6f3f commit ce9a02e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/rustc_codegen_ssa/src/back/metadata.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub(super) fn get_metadata_xcoff<'a>(path: &Path, data: &'a [u8]) -> Result<&'a
159159
{
160160
let offset = metadata_symbol.address() as usize;
161161
// The offset specifies the location of rustc metadata in the .info section of XCOFF.
162-
// Each string stored in .info section of XCOFF is preceded by a 4-byte lenght field.
162+
// Each string stored in .info section of XCOFF is preceded by a 4-byte length field.
163163
if offset < 4 {
164164
return Err(format!("Invalid metadata symbol offset: {offset}"));
165165
}
@@ -480,7 +480,10 @@ pub fn create_wrapper_file(
480480
file.section_mut(section).flags =
481481
SectionFlags::Xcoff { s_flags: xcoff::STYP_INFO as u32 };
482482
// Encode string stored in .info section of XCOFF.
483-
let len = data.len() as u32;
483+
// FIXME: The length of data here is not guaranteed to fit in a u32.
484+
// We may have to split the data into multiple pieces in order to
485+
// store in .info section.
486+
let len: u32 = data.len().try_into().unwrap();
484487
let offset = file.append_section_data(section, &len.to_be_bytes(), 1);
485488
// Add a symbol referring to the data in .info section.
486489
file.add_symbol(Symbol {

0 commit comments

Comments
 (0)