From: Peter Zijlstra <peterz@infradead.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] objtool: fix objtool regression on x32 systems
Date: Mon, 16 May 2022 17:41:40 +0200 [thread overview]
Message-ID: <YoJwtCeVzYUm6Uhg@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <alpine.LRH.2.02.2205161041260.11556@file01.intranet.prod.int.rdu2.redhat.com>
On Mon, May 16, 2022 at 11:06:36AM -0400, Mikulas Patocka wrote:
> The patch 4abff6d48dbc ("objtool: Fix code relocs vs weak symbols") makes
> the kernel unbootable. The patch c087c6e7b551 ("objtool: Fix type of
> reloc::addend") attempts to fix it by replacing 'int' with 'long'.
>
> However, we may be running on a system with x32 ABI and 'long' on x32 is
> 32-bit, thus the patch c087c6e7b551 doesn't really change anything and we
> still end up with miscompiled kernel. This patch replaces 'long' with
> 'long long', so that the 64-bit kernel is correctly compiled on a x32
> system.
Hurmph.. you're building a 64bit kernel on a x32 hosted machine? And
this is the *only* thing that goes sideways?
I suspect quite a bit of objtool assumes LP64 and won't quite work right
on ILP32 and we've just been lucky so far.
> Index: linux-2.6/tools/objtool/elf.c
> ===================================================================
> --- linux-2.6.orig/tools/objtool/elf.c 2022-05-16 16:20:49.000000000 +0200
> +++ linux-2.6/tools/objtool/elf.c 2022-05-16 16:22:21.000000000 +0200
> @@ -546,7 +546,7 @@ static struct section *elf_create_reloc_
> int reltype);
>
> int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
> - unsigned int type, struct symbol *sym, long addend)
> + unsigned int type, struct symbol *sym, long long addend)
> {
> struct reloc *reloc;
>
> Index: linux-2.6/tools/objtool/include/objtool/elf.h
> ===================================================================
> --- linux-2.6.orig/tools/objtool/include/objtool/elf.h 2022-05-16 16:07:54.000000000 +0200
> +++ linux-2.6/tools/objtool/include/objtool/elf.h 2022-05-16 16:22:45.000000000 +0200
> @@ -73,7 +73,7 @@ struct reloc {
> struct symbol *sym;
> unsigned long offset;
> unsigned int type;
> - long addend;
> + long long addend;
> int idx;
> bool jump_table_start;
> };
> @@ -135,7 +135,7 @@ struct elf *elf_open_read(const char *na
> struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
>
> int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
> - unsigned int type, struct symbol *sym, long addend);
> + unsigned int type, struct symbol *sym, long long addend);
> int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
> unsigned long offset, unsigned int type,
> struct section *insn_sec, unsigned long insn_off);
>
I think I much prefer s64 there instead of 'long long'. But really I
think all of objtool needs a bit of an audit to see what types need be
used.
next prev parent reply other threads:[~2022-05-16 15:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 15:06 [PATCH] objtool: fix objtool regression on x32 systems Mikulas Patocka
2022-05-16 15:41 ` Peter Zijlstra [this message]
2022-05-16 15:56 ` Mikulas Patocka
2022-05-16 21:25 ` Peter Zijlstra
2022-05-17 8:26 ` David Laight
2022-05-17 9:42 ` Peter Zijlstra
2022-05-18 13:28 ` [PATCH v2] " Mikulas Patocka
2022-05-18 18:08 ` 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=YoJwtCeVzYUm6Uhg@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=torvalds@linux-foundation.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