Skip to content

Commit

Permalink
build/elf: handle .annobin.notes string section
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Oct 5, 2024
1 parent 5527f23 commit 9d6ac9d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/build/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl<'data> Builder<'data> {
builder.gnu_hash_bloom_count = hash.bloom_count.get(endian);
builder.gnu_hash_bucket_count = hash.bucket_count.get(endian);
}
let name = sections.section_name(endian, section)?;
let data = match section.sh_type(endian) {
elf::SHT_NOBITS => SectionData::UninitializedData(section.sh_size(endian).into()),
elf::SHT_PROGBITS
Expand Down Expand Up @@ -261,6 +262,10 @@ impl<'data> Builder<'data> {
SectionData::DynamicString
} else if index == section_strings_index {
SectionData::SectionString
} else if name == b".annobin.notes" {
// Not actually a string table because nothing references the strings.
// We simply need to preserve the data (similar to a .comment section).
SectionData::Data(section.data(endian, data)?.into())
} else {
return Err(Error(format!(
"Unsupported SHT_STRTAB section at index {}",
Expand Down Expand Up @@ -341,7 +346,7 @@ impl<'data> Builder<'data> {
builder.sections.push(Section {
id,
delete: false,
name: sections.section_name(endian, section)?.into(),
name: name.into(),
sh_type: section.sh_type(endian),
sh_flags,
sh_addr,
Expand Down

0 comments on commit 9d6ac9d

Please sign in to comment.