RFC pahole: Save header guard names when --header_guards_db is passed
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest1 patch 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | pahole: Save header guard names when --header_guards_db is passedbtf_encoder.c btf_encoder.h dutil.c +3 more | +210 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC dwarves 0/1] pahole: Save header guard names when --header_guards_db is passed
This is a supporting change for a kernel RFC that should allow using uapi headers with vmlinux.h. For this it is necessary to add #ifndef GUARD ... #ifdef brackets around some types if those types originate from uapi kernel headers.
For example:
include/uapi/linux/tcp.h:
#ifndef _UAPI_LINUX_TCP_H
#define _UAPI_LINUX_TCP_H
...
union tcp_word_hdr {
struct tcphdr hdr;
__be32 words[5]; };
...
#endif /* _UAPI_LINUX_TCP_H */
vmlinux.h:
... #ifndef _UAPI_LINUX_TCP_H
union tcp_word_hdr {
struct tcphdr hdr;
__be32 words[5];};
#endif ...
The information about the GUARD names has to be encoded in BTF to allow bpftool to generate it for a specific kernel binary.
This is achieved by adding a parameter --header_guards_db to pahole. This parameter should point to a file that associates header file names with names of a C pre-processor variables used as a double include guards (dubbed as "header guard"s).
For each emitted type the DWARF attribute DW_AT_decl_file is checked, when the file name is present in the header guards DB a fake BTF_KIND_DECL_TAG record of the following form is emitted:
- type: the id of the emitted type;
- name_off: a string "header_guard:<guard>".
I'd like to cover this thing with a few unit tests but I don't see any tests in the dwarves repository ([1]), could you please suggest the right location?
I'm going to use a lore link to this thread in the kernel RFC email. I will post a link to the kernel RFC as a reply in this thread as soon as I have one. The change is not useful on it's own, so if kernel RFC will not be accepted this one should not be accepted either.
Thanks,
Eduard
[1] https://github.com/acmel/dwarves
Eduard Zingerman (1):
pahole: Save header guard names when --header_guards_db is passed
btf_encoder.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++---- btf_encoder.h | 3 +- dutil.c | 20 +++++++--- dutil.h | 1 + dwarves.h | 1 + pahole.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 210 insertions(+), 17 deletions(-)
Signature · 1 line
2.34.1