6l: call dwarfaddfrag when registering D_FILE symbols#142
Merged
Conversation
ftab (the file fragment table used by dwarf.c's decodez()) was never populated, causing every z entry lookup to fail with "corrupt z entry". Register each new SFILE symbol's fragment string into ftab via dwarfaddfrag() at the same point histgen is assigned. https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
There was a problem hiding this comment.
Code Review
This pull request introduces DWARF debugging support to the 6l linker by including the dwarf.h header and invoking dwarfaddfrag during SFILE symbol processing. A potential out-of-bounds read was identified when accessing the symbol name, and a check was suggested to ensure the string is not empty before offsetting the pointer.
| histgen++; | ||
| s->type = SFILE; | ||
| s->value = histgen; | ||
| dwarfaddfrag(s->value, s->name+1); |
There was a problem hiding this comment.
The call to dwarfaddfrag uses s->name+1 to skip the type prefix (typically 'z' or 'f'). While SFILE symbols in this context are expected to have such a prefix, if s->name were an empty string, this would result in an out-of-bounds read. Adding a check for the string length ensures robustness against malformed object files.
if(s->name[0] != '\0')
dwarfaddfrag(s->value, s->name+1);
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.
ftab (the file fragment table used by dwarf.c's decodez()) was never populated, causing every z entry lookup to fail with "corrupt z entry". Register each new SFILE symbol's fragment string into ftab via dwarfaddfrag() at the same point histgen is assigned.
https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs