diff --git a/src/ELF/Parser.tcc b/src/ELF/Parser.tcc index e4fe2c193..1e816f7e7 100644 --- a/src/ELF/Parser.tcc +++ b/src/ELF/Parser.tcc @@ -126,10 +126,13 @@ ok_error_t Parser::parse_binary() { int64_t rel_offset = seg_dyn->virtual_address() - load_seg.virtual_address(); assert(rel_offset >= 0); - span dynamic_content = load_seg.content().subspan(rel_offset); - SpanStream stream(dynamic_content); - stream.set_endian_swap(stream_->should_swap()); - parse_dynamic_entries(stream); + span seg_content = load_seg.content(); + if (!seg_content.empty()) { + span dynamic_content = seg_content.subspan(rel_offset); + SpanStream stream(dynamic_content); + stream.set_endian_swap(stream_->should_swap()); + parse_dynamic_entries(stream); + } } else /* No PT_LOAD segment wrapping up the PT_DYNAMIC table */ { const Elf_Off offset = seg_dyn->file_offset(); ScopedStream scoped(*stream_, offset);