Fix file/directory table count in pre-DWARF5 line table parsing#802
Open
portbuster1337 wants to merge 1 commit into
Open
Fix file/directory table count in pre-DWARF5 line table parsing#802portbuster1337 wants to merge 1 commit into
portbuster1337 wants to merge 1 commit into
Conversation
Bug: ctx->unit_dir and ctx->unit_file are never populated by the caller (rdi_from_dwarf_2.c), but dw2_read_line_table_header unconditionally pushed them as the first directory/file entries. This created an empty leading entry, making dirs.count and files.count one greater than the actual data. All subsequent directory indices and file indices were off by one. Fix: 1. Guard the first-entry pushes behind non-empty size checks in dw2_read_line_table_header (dwarf_parse_2.c). 2. Fix the file_index mapping in the line VM (rdi_from_dwarf_2.c): - Initialize file_index to 0 for DWARF 5, 1 for pre-DWARF5 - Convert 1-based file indices to 0-based array indices for pre-DWARF5 - Fix the bounds check to be correct for each version's indexing scheme
|
both changed files got deleted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
ctx->unit_dirandctx->unit_fileinDW2_ParseCtxare never populated by the caller (rdi_from_dwarf_2.c), butdw2_read_line_table_headerunconditionally pushed them as the first directory and file entries for pre-DWARF5 line tables. This created an empty leading entry, makingdirs.countandfiles.countone greater than the actual data.Additionally,
DW_StdOpcode_Filein the line VM setsfile_indexto 1-based values for pre-DWARF5 and 0-based for DWARF 5, but the array lookup used the raw 1-based index directly on a 0-based array, and the initialfile_indexwas unconditionally set to 1 (wrong for DWARF 5 where it should be 0).Changes
src/dwarf/dwarf_parse_2.c: Guard the first-entry pushes behindsize != 0checks so the DWARF data's own entries stand on their own when the context fields are unpopulated.src/rdi_from_dwarf/rdi_from_dwarf_2.c:file_indexto 0 for DWARF 5, 1 for pre-DWARF5