From: Vegard Nossum <vegard.nossum@oracle.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-um@lists.infradead.org, bpf@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH] kbuild: use objcopy to generate asm-offsets
Date: Wed, 28 Aug 2024 12:07:44 +0200 [thread overview]
Message-ID: <894fc485-0a0f-479e-88e0-eddb9ccf065c@oracle.com> (raw)
In-Reply-To: <20240828083605.3093701-1-vegard.nossum@oracle.com>
On 28/08/2024 10:36, Vegard Nossum wrote:
> In order to give assembly code access to C structs without having to
> hardcore member offsets, the kernel compiles a C source file listing all
> the structs and offsets that are needed in assembly code. Using some
> C preprocessor trickery and a sed script, the compiled assembly code is
> turned back into C preprocessor code that in turn can be used by the
> asssembly code.
>
> This sed script is very hard to read and understand.
>
> Remove the sed script and compile the C source listing structs and
> offsets to an object file (instead of assembly code) that embeds C source
> directly. Then extract the C source using objcopy.
>
> The resulting code is more readable, less fragile, and sligthly shorter.
>
> Note to reviewers: The 'objcopy ... /dev/stdout | cat' bit is needed to
> force the correct ordering of the objcopy lines vs. the surrounding echo
> commands; without it, objcopy will open /dev/stdout (which refers to a
> temporary file created by kbuild) and reset the file offset to 0. In
> other words, the pipe ensures that objcopy doesn't overwrite the lines
> that already exist in /dev/stdout.
Turns out LLVM's objcopy doesn't support writing to /dev/stdout, so we
might have to use a temporary file. I'll look into it and send a v2.
Vegard
next prev parent reply other threads:[~2024-08-28 10:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 8:36 [PATCH] kbuild: use objcopy to generate asm-offsets Vegard Nossum
2024-08-28 10:07 ` Vegard Nossum [this message]
2024-08-29 14:58 ` kernel test robot
2024-08-29 15:50 ` kernel test robot
2024-08-29 20:37 ` kernel test robot
2024-09-02 23:45 ` Michael Ellerman
2024-09-03 7:20 ` Vegard Nossum
2024-09-03 9:28 ` Masahiro Yamada
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=894fc485-0a0f-479e-88e0-eddb9ccf065c@oracle.com \
--to=vegard.nossum@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@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