Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) use debuginfo for undefined references #543

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

llunak
Copy link
Contributor

@llunak llunak commented Jun 17, 2022

This is an unfinished work that tries to use debuginfo to report source locations of places that cause undefined references, rather than just the object file. The reason I'm submitting this unfinished version is that debuginfo requires relocating to be usable, otherwise references between sections do not work (relocations include also offsets within the section, and without relocations those values are 0, pointing to incorrect places in the debuginfo data in the .o file).

The debuginfo relocations need to be done somewhere, and currently it's done while writing the entire output file, so for now the patch delays reporting the undefined symbols until after that, since currently molds always processes the entire file even if there are errors. But you reverted the delayed processing of undefined references, and I don't know if it's possible to process debuginfo and its relocations before non-delayed undefined references handling. This changeset reverts the revert for simplicity, but I don't want to change the code back to delayed if you'd change it back yet again, so I wanted to ask for feedback on this.

Signed-off-by: Luboš Luňák <l.lunak@centrum.cz>
Signed-off-by: Luboš Luňák <l.lunak@centrum.cz>
When reporting undefined references, first try to search debuginfo
for the actual source location of where the reference comes from,
i.e. the line/column and possibly header file. DWARFv5 filenames
are not supported yet. Since debuginfo needs to be relocated to
be usable (otherwise various references between different debug
sections do not work), so the reporting now needs to be done
later (to be improved).

Signed-off-by: Luboš Luňák <l.lunak@centrum.cz>
@rui314
Copy link
Owner

rui314 commented Jun 17, 2022

I honestly feel that this is a bit too much code and complexity just to show the line number for an undefined symbol reference. After all, we just want to know the line number, but unfortunately DWARF is too complicated that that doesn't allow us to do that easily. It is usually easy for me to identify a location of an undefined reference without a line number, so I didn't personally find it that useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants