[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 25/28] x86: Use PIE codegen for the core kernel
- To: Uros Bizjak <ubizjak@xxxxxxxxx>
- From: "H. Peter Anvin" <hpa@xxxxxxxxx>
- Date: Sat, 5 Oct 2024 16:36:48 -0700
- Cc: Ard Biesheuvel <ardb@xxxxxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Ard Biesheuvel <ardb+git@xxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx, Andy Lutomirski <luto@xxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Dennis Zhou <dennis@xxxxxxxxxx>, Tejun Heo <tj@xxxxxxxxxx>, Christoph Lameter <cl@xxxxxxxxx>, Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Masahiro Yamada <masahiroy@xxxxxxxxxx>, Kees Cook <kees@xxxxxxxxxx>, Nathan Chancellor <nathan@xxxxxxxxxx>, Keith Packard <keithp@xxxxxxxxxx>, Justin Stitt <justinstitt@xxxxxxxxxx>, Josh Poimboeuf <jpoimboe@xxxxxxxxxx>, Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>, Namhyung Kim <namhyung@xxxxxxxxxx>, Jiri Olsa <jolsa@xxxxxxxxxx>, Ian Rogers <irogers@xxxxxxxxxx>, Adrian Hunter <adrian.hunter@xxxxxxxxx>, Kan Liang <kan.liang@xxxxxxxxxxxxxxx>, linux-doc@xxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-efi@xxxxxxxxxxxxxxx, linux-arch@xxxxxxxxxxxxxxx, linux-sparse@xxxxxxxxxxxxxxx, linux-kbuild@xxxxxxxxxxxxxxx, linux-perf-users@xxxxxxxxxxxxxxx, rust-for-linux@xxxxxxxxxxxxxxx, llvm@xxxxxxxxxxxxxxx
- Delivery-date: Sat, 05 Oct 2024 23:38:05 +0000
- Dkim-filter: OpenDKIM Filter v2.11.0 mail.zytor.com 495NapwS1593555
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 10/5/24 01:31, Uros Bizjak wrote:
movq $sym to leaq sym(%rip) which you said ought to be smaller (and in
reality appears to be the same size, 7 bytes) seems like a no-brainer
and can be treated as a code quality issue -- in other words, file bug
reports against gcc and clang.
It is the kernel assembly source that should be converted to
rip-relative form, gcc (and probably clang) have nothing with it.
Sadly, that is not correct; neither gcc nor clang uses lea:
-hpa
gcc version 14.2.1 20240912 (Red Hat 14.2.1-3) (GCC)
hpa@tazenda:/tmp$ cat foo.c
int foobar;
int *where_is_foobar(void)
{
return &foobar;
}
hpa@tazenda:/tmp$ gcc -mcmodel=kernel -O2 -c -o foo.o foo.c
hpa@tazenda:/tmp$ objdump -dr foo.o
foo.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <where_is_foobar>:
0: 48 c7 c0 00 00 00 00 mov $0x0,%rax
3: R_X86_64_32S foobar
7: c3 ret
clang version 18.1.8 (Fedora 18.1.8-1.fc40)
hpa@tazenda:/tmp$ clang -mcmodel=kernel -O2 -c -o foo.o foo.c
hpa@tazenda:/tmp$ objdump -dr foo.o
foo.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <where_is_foobar>:
0: 48 c7 c0 00 00 00 00 mov $0x0,%rax
3: R_X86_64_32S foobar
7: c3 ret
|