bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH dwarves v3 0/3] permit merging all dwarf cu's for clang lto built binary
@ 2021-03-28 20:14 Yonghong Song
  2021-03-28 20:14 ` [PATCH dwarves v3 1/3] dwarf_loader: permits flexible HASHTAGS__BITS Yonghong Song
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Yonghong Song @ 2021-03-28 20:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, dwarves
  Cc: Alexei Starovoitov, Andrii Nakryiko, Bill Wendling, bpf, kernel-team

For vmlinux built with clang thin-lto or lto for latest bpf-next,
there exist cross cu debuginfo type references. For example,
      compile unit 1:
         tag 10:  type A
      compile unit 2:
         ...
           refer to type A (tag 10 in compile unit 1)
I only checked a few but have seen type A may be a simple type
like "unsigned char" or a complex type like an array of base types.
I am using latest llvm trunk and bpf-next. I suspect llvm12 or
linus tree >= 5.12 rc2 should be able to exhibit the issue as well.
Both thin-lto and lto have the same issues.

Current pahole cannot handle this. It will report types cannot
be found error. Bill Wendling has attempted to fix the issue
with [1] by permitting all tags/types are hashed to the same
hash table and then process cu's one by one. This does not
really work. The reason is that each cu resolves types locally
so for the above example we may have
  compile unit 1:
    type A : type_id = 10
  compile unit 2:
    refer to type A : type A will be resolved as type id = 10
But id 10 refers to compile unit 1, we will get either out
of bound type id or incorrect one.

This patch set is a continuation of Bill's work. We still
increase the hashtable size and traverse all cu's before
recoding and finalization. But instead of creating one-to-one
mapping between debuginfo cu and pahole cu, we just create
one pahole cu, which should solve the above incorrect type
id issue.

This patch set depends on kernel patch [2]
to emit compilation flags for clang lto build so pahole
can properly discover whether to merge cu's or not.

Patch #1 and #2 are refactoring the existing code and
Patch #3 added logic to premit merging all debuginfo cu's
into one pahole cu. The detection for whether merging is
desirable is done by checking the existence of
"clang" compiler and its "lto" option in dwarf producer tag.

[1] https://lore.kernel.org/bpf/20210212211607.2890660-1-morbo@google.com/
[2] https://lore.kernel.org/bpf/20210328064121.2062927-1-yhs@fb.com/

Changelogs:
  v2 -> v3:
    . change "return 1" to "return DWARF_CB_ABORT" in
      cus__merge_and_process_cu().
    . add kbuild/bpf link (above [2]) for kernel patch reference.
  v1 -> v2:
    . removed "--merge_cus" option, relied on detections on
      clang compiler and its lto flags.

Yonghong Song (3):
  dwarf_loader: permits flexible HASHTAGS__BITS
  dwarf_loader: factor out common code to initialize a cu
  dwarf_loader: permit merging all dwarf cu's for clang lto built binary

 dwarf_loader.c | 209 +++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 175 insertions(+), 34 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-03-31 15:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-28 20:14 [PATCH dwarves v3 0/3] permit merging all dwarf cu's for clang lto built binary Yonghong Song
2021-03-28 20:14 ` [PATCH dwarves v3 1/3] dwarf_loader: permits flexible HASHTAGS__BITS Yonghong Song
2021-03-28 20:14 ` [PATCH dwarves v3 2/3] dwarf_loader: factor out common code to initialize a cu Yonghong Song
2021-03-28 20:14 ` [PATCH dwarves v3 3/3] dwarf_loader: permit merging all dwarf cu's for clang lto built binary Yonghong Song
2021-03-30 20:08   ` Bill Wendling
2021-03-30 20:15     ` Yonghong Song
2021-03-30 21:44       ` Bill Wendling
2021-03-30 22:28         ` Yonghong Song
2021-03-30 23:25           ` Bill Wendling
2021-03-29 17:40 ` [PATCH dwarves v3 0/3] " Arnaldo Carvalho de Melo
2021-03-30 15:10   ` Arnaldo Carvalho de Melo
2021-03-30 18:08     ` Arnaldo Carvalho de Melo
2021-03-30 18:24       ` Arnaldo Carvalho de Melo
2021-03-31  3:20         ` Yonghong Song
2021-03-31 13:54           ` Arnaldo Carvalho de Melo
2021-03-31 15:08             ` Yonghong Song
2021-03-31  0:29     ` Yonghong Song
2021-03-29 23:14 ` Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).