Page MenuHomePhabricator

[BPF] Fix bpf llvm-objdump issues

Authored by yonghong-song on Aug 16 2019, 4:37 PM.



Commit ("[DWARF] Refactor
RelocVisitor and fix computation of SHT_RELA-typed relocation entries)
made a change for relocation resolution when operating
on an object file.

The change unfortunately broke BPF as given SymbolValue (S) and
Addent (A), previously relocation is resolved to

S + A

and after the change, it is resolved to


This patch fixed the issue by resolving relocation correctly.

It looks not all relocation resolution reaches here and I did not
trace down exactly when. But I do find if the object file includes
codes in two different ELF sections than default ".text",
the above bug will be triggered.

This patch included a trivial two function source code to
demonstrate this issue. The relocation for .debug_loc is resolved
incorrectly due to this and llvm-objdump cannot display source
annotated assembly.

Diff Detail


Event Timeline

yonghong-song created this revision.Aug 16 2019, 4:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2019, 4:37 PM
ast accepted this revision.Aug 17 2019, 8:13 AM
This revision is now accepted and ready to land.Aug 17 2019, 8:13 AM
MaskRay added inline comments.
48 ↗(On Diff #215715)

Can you clean up these metadata tags? A lot of attributes, e.g directory, checksum, source, clang version, DILocation, etc, are not needed.

yonghong-song marked an inline comment as done.Aug 17 2019, 8:26 AM
yonghong-song added inline comments.
48 ↗(On Diff #215715)

I need this to have reliable source in llvm-objdump -S.

Closed by commit rL369199: [BPF] Fix bpf llvm-objdump issues. (authored by yhs, committed by ). · Explain WhyAug 17 2019, 3:12 PM
This revision was automatically updated to reflect the committed changes.