This is an archive of the discontinued LLVM Phabricator instance.

[BPF] Fix bpf llvm-objdump issues
ClosedPublic

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

Details

Summary

Commit https://reviews.llvm.org/D57939 ("[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

S

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

Repository
rL LLVM

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.
llvm/test/CodeGen/BPF/objdump_two_funcs.ll
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.
llvm/test/CodeGen/BPF/objdump_two_funcs.ll
48 ↗(On Diff #215715)

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

This revision was automatically updated to reflect the committed changes.