From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
Peter Zijlstra <peterz@infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"aik@ozlabs.ru" <aik@ozlabs.ru>,
Sathvika Vasireddy <sv@linux.ibm.com>,
"naveen.n.rao@linux.vnet.ibm.com"
<naveen.n.rao@linux.vnet.ibm.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [RFC PATCH 3/3] objtool/mcount: Add powerpc specific functions
Date: Tue, 29 Mar 2022 21:26:49 -0700 [thread overview]
Message-ID: <20220330042649.fj43vxtpxmyxtbnd@treble> (raw)
In-Reply-To: <af262c28-0d73-7ae6-3dd5-2977c9a41f7d@csgroup.eu>
On Tue, Mar 29, 2022 at 05:32:18PM +0000, Christophe Leroy wrote:
>
>
> Le 29/03/2022 à 14:01, Michael Ellerman a écrit :
> > Josh Poimboeuf <jpoimboe@redhat.com> writes:
> >> On Sun, Mar 27, 2022 at 09:09:20AM +0000, Christophe Leroy wrote:
> >>> Second point is the endianess and 32/64 selection, especially when
> >>> crossbuilding. There is already some stuff regarding endianess based on
> >>> bswap_if_needed() but that's based on constant selection at build time
> >>> and I couldn't find an easy way to set it conditionaly based on the
> >>> target being built.
> >>>
> >>> Regarding 32/64 selection, there is almost nothing, it's based on using
> >>> type 'long' which means that at the time being the target and the build
> >>> platform must both be 32 bits or 64 bits.
> >>>
> >>> For both cases (endianess and 32/64) I think the solution should
> >>> probably be to start with the fileformat of the object file being
> >>> reworked by objtool.
> >>
> >> Do we really need to detect the endianness/bitness at runtime? Objtool
> >> is built with the kernel, why not just build-in the same target
> >> assumptions as the kernel itself?
> >
> > I don't think we need runtime detection. But it will need to support
> > basically most combinations of objtool running as 32-bit/64-bit LE/BE
> > while the kernel it's analysing is 32-bit/64-bit LE/BE.
>
> Exactly, the way it is done today with a constant in
> objtool/endianness.h is too simple, we need to be able to select it
> based on kernel's config. Is there a way to get the CONFIG_ macros from
> the kernel ? If yes then we could use CONFIG_64BIT and
> CONFIG_CPU_LITTLE_ENDIAN to select the correct options in objtool.
As of now, there's no good way to get CONFIG options from the kernel.
That's pretty much by design, since objtool is meant to be a standalone
tool. In fact there are people who've used objtool for other projects.
The objtool Makefile does at least have access to HOSTARCH/SRCARCH, but
I guess that doesn't help here. We could maybe export the endian/bit
details in env variables to the objtool build somehow.
But, I managed to forget that objtool can already be cross-compiled for
a x86-64 target, from a 32-bit x86 LE host or a 64-bit powerpc BE host.
There are some people out there doing x86 kernel builds on such systems
who reported bugs, which were since fixed. And the fixes were pretty
trivial, IIRC.
Libelf actually does a decent job of abstracting those details from
objtool. So, forget what I said, it might be ok to just detect
endian/bit (and possibly even arch) at runtime like you originally
suggested.
For example bswap_if_needed() could be reworked to be a runtime check.
--
Josh
next prev parent reply other threads:[~2022-03-30 4:27 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 10:51 [RFC PATCH 0/3] objtool: Add mcount sub-command Sathvika Vasireddy
2022-03-18 10:51 ` [RFC PATCH 1/3] objtool: Move common code to utils.c Sathvika Vasireddy
2022-03-23 18:02 ` Miroslav Benes
2022-03-18 10:51 ` [RFC PATCH 2/3] objtool: Enable and implement 'mcount' subcommand Sathvika Vasireddy
2022-03-21 7:06 ` Christophe Leroy
2022-03-21 8:19 ` Naveen N. Rao
2022-03-21 8:26 ` Christophe Leroy
2022-03-21 9:48 ` Naveen N. Rao
2022-03-18 10:51 ` [RFC PATCH 3/3] objtool/mcount: Add powerpc specific functions Sathvika Vasireddy
2022-03-18 12:26 ` Peter Zijlstra
2022-03-18 13:59 ` Christophe Leroy
2022-03-21 2:27 ` Michael Ellerman
2022-03-21 6:47 ` Christophe Leroy
2022-03-21 7:46 ` Christophe Leroy
2022-03-21 7:56 ` Christophe Leroy
2022-03-21 8:30 ` Christophe Leroy
2022-03-21 8:59 ` Christophe Leroy
2022-03-26 7:58 ` Christophe Leroy
2022-03-21 6:25 ` Naveen N. Rao
2022-03-27 9:09 ` Christophe Leroy
2022-03-28 19:59 ` Josh Poimboeuf
2022-03-28 20:14 ` Peter Zijlstra
2022-03-28 20:15 ` Peter Zijlstra
2022-03-28 20:21 ` Josh Poimboeuf
2022-03-29 12:01 ` Michael Ellerman
2022-03-29 17:32 ` Christophe Leroy
2022-03-30 4:26 ` Josh Poimboeuf [this message]
2022-03-30 18:40 ` Naveen N. Rao
2022-05-12 14:52 ` Christophe Leroy
2022-05-12 15:12 ` Josh Poimboeuf
2022-05-21 9:38 ` Christophe Leroy
2022-05-21 10:57 ` Peter Zijlstra
2022-05-23 5:39 ` Naveen N. Rao
2022-03-19 1:35 ` [RFC PATCH 0/3] objtool: Add mcount sub-command Josh Poimboeuf
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=20220330042649.fj43vxtpxmyxtbnd@treble \
--to=jpoimboe@redhat.com \
--cc=aik@ozlabs.ru \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sv@linux.ibm.com \
/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