From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Douglas RAILLARD <douglas.raillard@arm.com>
Cc: acme@redhat.com, dwarves@vger.kernel.org
Subject: Re: [PATCH v2 3/3] btf_loader.c: Infer alignment info
Date: Mon, 25 Oct 2021 14:06:02 -0300 [thread overview]
Message-ID: <YXbj+gukL1fZx/Gb@kernel.org> (raw)
In-Reply-To: <YXIGaA1SYSx37EEV@kernel.org>
Em Thu, Oct 21, 2021 at 09:31:36PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Oct 18, 2021 at 02:16:21PM +0100, Douglas RAILLARD escreveu:
> > From: Douglas Raillard <douglas.raillard@arm.com>
> >
> > BTF does not carry alignment information, but it carries the offset in
> > structs. This allows inferring the original alignment, yielding a C
> > header dump that is not identical to the original C code, but is
> > guaranteed to lead to the same memory layout.
> >
> > This allows using the output of pahole in another program to poke at
> > memory, with the assurance that we will not read garbage.
> >
> > Note: Since the alignment is inferred from the offset, it sometimes
> > happens that the offset was already correctly aligned, which means the
> > inferred alignment will be smaller than in the original source. This
> > does not impact the ability to read existing structs, but it could
> > impact creating such struct if other client code expects higher
> > alignment than the one exposed in the generated header.
>
> this one makes btfdiff fail, example:
>
>
> @@ -125578,7 +125640,7 @@ struct xt_entry_match {
> struct xt_match * match; /* 8 8 */
> } kernel; /* 0 16 */
> __u16 match_size; /* 0 2 */
> - } u; /* 0 32 */
> + } u; /* 0 32 */
> unsigned char data[]; /* 32 0 */
>
> /* size: 32, cachelines: 1, members: 2 */
>
> Why the change in the generated source code comment alignment?
Since this is inferred and DWARF has the alignment info explicitely, we
can't really compare, so I'll stick this to btfdiff.
diff --git a/btfdiff b/btfdiff
index 77543630d1965b5e..cbdf65285cd90f62 100755
--- a/btfdiff
+++ b/btfdiff
@@ -33,6 +33,7 @@ ${pahole_bin} -F dwarf \
--show_private_classes $dwarf_input > $dwarf_output
${pahole_bin} -F btf \
--sort \
+ --suppress_aligned_attribute \
--suppress_packed \
$btf_input > $btf_output
> There are some other differences, I'll check tomorrow.
I got sidetracked, will try to reduce the differences somehow, but
probably as patches on top of yours, to test this the best is to use
fullcircle from BTF info, which I'll also look into as I think you
reported issues with pfunct's --compile option.
- Arnaldo
next prev parent reply other threads:[~2021-10-25 17:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 13:16 [PATCH v2 0/3] Infer BTF alignment Douglas RAILLARD
2021-10-18 13:16 ` [PATCH v2 1/3] fprintf: Fix nested struct printing Douglas RAILLARD
2021-10-18 13:16 ` [PATCH v2 2/3] btf_loader.c: Refactor class__fixup_btf_bitfields Douglas RAILLARD
2021-10-21 20:49 ` Arnaldo Carvalho de Melo
2021-10-18 13:16 ` [PATCH v2 3/3] btf_loader.c: Infer alignment info Douglas RAILLARD
2021-10-22 0:31 ` Arnaldo Carvalho de Melo
2021-10-25 17:06 ` Arnaldo Carvalho de Melo [this message]
2021-10-26 15:03 ` Douglas Raillard
2021-10-27 20:47 ` Arnaldo Carvalho de Melo
2021-10-28 9:31 ` Douglas Raillard
2021-10-28 11:38 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YXbj+gukL1fZx/Gb@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=douglas.raillard@arm.com \
--cc=dwarves@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox