Skip to content

Commit b4dece0

Browse files
nagisaDavid Wood
authored andcommitted
Do not assert all sections in object are UTF-8
We are iterating over all of the sections of an input file, and while all section names we care about are UTF-8, we don't necessarily care that the other sections are valid UTF-8. This commit would allow us to handle those files correctly, still.
1 parent 5ccab70 commit b4dece0

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

thorin/src/error.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ pub enum Error {
6060
NoDie,
6161
/// Top-level debugging information entry is not a compilation/type unit.
6262
TopLevelDieNotUnit,
63-
/// Section name isn't UTF-8.
64-
NonUtf8SectionName(object::Error),
6563
/// Section required of input DWARF objects was missing.
6664
MissingRequiredSection(&'static str),
6765
/// Failed to parse unit abbreviations.
@@ -137,7 +135,6 @@ impl StdError for Error {
137135
Error::NoCompilationUnits => None,
138136
Error::NoDie => None,
139137
Error::TopLevelDieNotUnit => None,
140-
Error::NonUtf8SectionName(source) => Some(source.as_dyn_error()),
141138
Error::MissingRequiredSection(_) => None,
142139
Error::ParseUnitAbbreviations(source) => Some(source.as_dyn_error()),
143140
Error::ParseUnitAttribute(source) => Some(source.as_dyn_error()),
@@ -207,9 +204,6 @@ impl fmt::Display for Error {
207204
Error::TopLevelDieNotUnit => {
208205
write!(f, "Top-level debugging information entry is not a compilation/type unit")
209206
}
210-
Error::NonUtf8SectionName(_) => {
211-
write!(f, "Section name is not valid UTF-8")
212-
}
213207
Error::MissingRequiredSection(section) => {
214208
write!(f, "Input object missing required section `{}`", section)
215209
}

thorin/src/package.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -461,36 +461,36 @@ impl<'file> InProgressDwarfPackage<'file> {
461461
// Iterate over sections rather than using `section_by_name` because sections can be
462462
// repeated.
463463
for section in input.sections() {
464-
match section.name().map_err(Error::NonUtf8SectionName)? {
465-
".debug_abbrev.dwo" | ".zdebug_abbrev.dwo" => {
464+
match section.name() {
465+
Ok(".debug_abbrev.dwo" | ".zdebug_abbrev.dwo") => {
466466
let data = section.compressed_data()?.decompress()?;
467467
update!(debug_abbrev += self.obj.append_to_debug_abbrev(&data));
468468
}
469-
".debug_line.dwo" | ".zdebug_line.dwo" => {
469+
Ok(".debug_line.dwo" | ".zdebug_line.dwo") => {
470470
let data = section.compressed_data()?.decompress()?;
471471
update!(debug_line += self.obj.append_to_debug_line(&data));
472472
}
473-
".debug_loc.dwo" | ".zdebug_loc.dwo" => {
473+
Ok(".debug_loc.dwo" | ".zdebug_loc.dwo") => {
474474
let data = section.compressed_data()?.decompress()?;
475475
update!(debug_loc += self.obj.append_to_debug_loc(&data));
476476
}
477-
".debug_loclists.dwo" | ".zdebug_loclists.dwo" => {
477+
Ok(".debug_loclists.dwo" | ".zdebug_loclists.dwo") => {
478478
let data = section.compressed_data()?.decompress()?;
479479
update!(debug_loclists += self.obj.append_to_debug_loclists(&data));
480480
}
481-
".debug_macinfo.dwo" | ".zdebug_macinfo.dwo" => {
481+
Ok(".debug_macinfo.dwo" | ".zdebug_macinfo.dwo") => {
482482
let data = section.compressed_data()?.decompress()?;
483483
update!(debug_macinfo += self.obj.append_to_debug_macinfo(&data));
484484
}
485-
".debug_macro.dwo" | ".zdebug_macro.dwo" => {
485+
Ok(".debug_macro.dwo" | ".zdebug_macro.dwo") => {
486486
let data = section.compressed_data()?.decompress()?;
487487
update!(debug_macro += self.obj.append_to_debug_macro(&data));
488488
}
489-
".debug_rnglists.dwo" | ".zdebug_rnglists.dwo" => {
489+
Ok(".debug_rnglists.dwo" | ".zdebug_rnglists.dwo") => {
490490
let data = section.compressed_data()?.decompress()?;
491491
update!(debug_rnglists += self.obj.append_to_debug_rnglists(&data));
492492
}
493-
".debug_str_offsets.dwo" | ".zdebug_str_offsets.dwo" => {
493+
Ok(".debug_str_offsets.dwo" | ".zdebug_str_offsets.dwo") => {
494494
let debug_str_offsets_section = {
495495
let data = section.compressed_data()?.decompress()?;
496496
let data_ref = sess.alloc_owned_cow(data);
@@ -580,15 +580,15 @@ impl<'file> InProgressDwarfPackage<'file> {
580580

581581
for section in input.sections() {
582582
let data = section.compressed_data()?.decompress()?;
583-
let (is_debug_types, mut iter) = match section.name().map_err(Error::NonUtf8SectionName)? {
584-
".debug_info.dwo" | ".zdebug_info.dwo"
583+
let (is_debug_types, mut iter) = match section.name() {
584+
Ok(".debug_info.dwo" | ".zdebug_info.dwo")
585585
// Report an error if a input DWARF package has multiple `.debug_info`
586586
// sections.
587587
if seen_debug_info && cu_index.is_some() =>
588588
{
589589
return Err(Error::MultipleDebugInfoSection);
590590
}
591-
".debug_info.dwo" | ".zdebug_info.dwo" => {
591+
Ok(".debug_info.dwo" | ".zdebug_info.dwo") => {
592592
seen_debug_info = true;
593593
(
594594
false,
@@ -597,14 +597,14 @@ impl<'file> InProgressDwarfPackage<'file> {
597597
),
598598
)
599599
}
600-
".debug_types.dwo" | ".zdebug_types.dwo"
600+
Ok(".debug_types.dwo" | ".zdebug_types.dwo")
601601
// Report an error if a input DWARF package has multiple `.debug_types`
602602
// sections.
603603
if seen_debug_types && tu_index.is_some() =>
604604
{
605605
return Err(Error::MultipleDebugTypesSection);
606606
}
607-
".debug_types.dwo" | ".zdebug_types.dwo" => {
607+
Ok(".debug_types.dwo" | ".zdebug_types.dwo") => {
608608
seen_debug_types = true;
609609
(
610610
true,

0 commit comments

Comments
 (0)