Message ID | 20231227070317.1936234-1-kernel@xen0n.name (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | modpost: Ignore relaxation and alignment marker relocs on LoongArch | expand |
On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: > And even though the kernel is built with relaxation disabled, so > far a small number of R_LARCH_RELAX marker relocs are still emitted as > part of la.* pseudo instructions in assembly. I'd consider it a toolchain bug... Is there a reproducer?
On Wed, Dec 27, 2023 at 7:06 PM Xi Ruoyao <xry111@xry111.site> wrote: > > On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: > > And even though the kernel is built with relaxation disabled, so > > far a small number of R_LARCH_RELAX marker relocs are still emitted as > > part of la.* pseudo instructions in assembly. > > I'd consider it a toolchain bug... Is there a reproducer? Any updates? Should I apply this patch for loongarch-next? Huacai > > -- > Xi Ruoyao <xry111@xry111.site> > School of Aerospace Science and Technology, Xidian University >
On Thu, Jan 4, 2024 at 5:58 PM Huacai Chen <chenhuacai@kernel.org> wrote: > > On Wed, Dec 27, 2023 at 7:06 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: > > > And even though the kernel is built with relaxation disabled, so > > > far a small number of R_LARCH_RELAX marker relocs are still emitted as > > > part of la.* pseudo instructions in assembly. > > > > I'd consider it a toolchain bug... Is there a reproducer? > Any updates? Should I apply this patch for loongarch-next? This is odd. At least, Fixes: 3d36f4298ba9 is unrelated. The instruction to reproduce it was requested. I did not see any error for defconfig with loongarch64-linux-gcc 13.2 provided by 0day bot. -- Best Regards Masahiro Yamada
On Thu, 2024-01-04 at 16:57 +0800, Huacai Chen wrote: > On Wed, Dec 27, 2023 at 7:06 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: > > > And even though the kernel is built with relaxation disabled, so > > > far a small number of R_LARCH_RELAX marker relocs are still emitted as > > > part of la.* pseudo instructions in assembly. > > > > I'd consider it a toolchain bug... Is there a reproducer? > Any updates? Should I apply this patch for loongarch-next? Tiezhu told me this should be reproducible with GCC 14 and Binutils-2.42 development snapshots and defconfig. I'm trying...
On Fri, 2024-01-05 at 00:26 +0800, Xi Ruoyao wrote: > On Thu, 2024-01-04 at 16:57 +0800, Huacai Chen wrote: > > On Wed, Dec 27, 2023 at 7:06 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > > > On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: > > > > And even though the kernel is built with relaxation disabled, so > > > > far a small number of R_LARCH_RELAX marker relocs are still emitted as > > > > part of la.* pseudo instructions in assembly. > > > > > > I'd consider it a toolchain bug... Is there a reproducer? > > Any updates? Should I apply this patch for loongarch-next? > > Tiezhu told me this should be reproducible with GCC 14 and Binutils-2.42 > development snapshots and defconfig. I'm trying... Unfortunately I still cannot reproduce the issue (with GCC 14.0.0 20231208, binutils 2.41.50.20240104, and defconfig). One possibility is this was already fixed somehow, another is the issue was triggered with a GCC snapshot > 20231208 but I think this very unlikely. Xuerui: can you find the guilty .o file containing R_LARCH_RELAX and/or R_LARCH_ALIGN? Then you can just run "make path/to/something.s" (replace ".o" with ".s") to produce the assembly file and send it to me for further investigation.
On 01/05/2024 12:26 AM, Xi Ruoyao wrote: > On Thu, 2024-01-04 at 16:57 +0800, Huacai Chen wrote: >> On Wed, Dec 27, 2023 at 7:06 PM Xi Ruoyao <xry111@xry111.site> wrote: >>> >>> On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: >>>> And even though the kernel is built with relaxation disabled, so >>>> far a small number of R_LARCH_RELAX marker relocs are still emitted as >>>> part of la.* pseudo instructions in assembly. >>> >>> I'd consider it a toolchain bug... Is there a reproducer? >> Any updates? Should I apply this patch for loongarch-next? > > Tiezhu told me this should be reproducible with GCC 14 and Binutils-2.42 > development snapshots and defconfig. I'm trying... 1. How to reproduce I update the latest upstream toolchains (20240105): [fedora@linux 6.7.test]$ gcc --version gcc (GCC) 14.0.0 20240105 (experimental) [fedora@linux 6.7.test]$ as --version GNU assembler (GNU Binutils) 2.41.50.20240105 [fedora@linux 6.7.test]$ ld --version GNU ld (GNU Binutils) 2.41.50.20240105 and then test it again, here is the failure info: [fedora@linux 6.7.test]$ git log --oneline | head -1 610a9b8f49fb Linux 6.7-rc8 [fedora@linux 6.7.test]$ make loongson3_defconfig [fedora@linux 6.7.test]$ make ... AR built-in.a AR vmlinux.a LD vmlinux.o OBJCOPY modules.builtin.modinfo GEN modules.builtin GEN .vmlinux.objs MODPOST Module.symvers make[2]: *** [scripts/Makefile.modpost:145: Module.symvers] Error 139 make[1]: *** [/home/fedora/6.7.test/Makefile:1863: modpost] Error 2 make: *** [Makefile:234: __sub-make] Error 2 2. Additional info I can confirm that the slightly older version of toolchains (20231127) have no the above failure, so I guess this is related with toolchains. 3. How to fix (1) One way is to modify the kernel code, with this kernel patch, there is no building failure with the latest upstream toolchains. (2) The other way is to analysis and fix the binutils code, it need more work to do. Thanks, Tiezhu
On 2024-01-05 16:09, Tiezhu Yang wrote: > > > On 01/05/2024 12:26 AM, Xi Ruoyao wrote: >> On Thu, 2024-01-04 at 16:57 +0800, Huacai Chen wrote: >>> On Wed, Dec 27, 2023 at 7:06 PM Xi Ruoyao <xry111@xry111.site> wrote: >>>> >>>> On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: >>>>> And even though the kernel is built with relaxation disabled, so >>>>> far a small number of R_LARCH_RELAX marker relocs are still >>>>> emitted as >>>>> part of la.* pseudo instructions in assembly. >>>> >>>> I'd consider it a toolchain bug... Is there a reproducer? >>> Any updates? Should I apply this patch for loongarch-next? >> >> Tiezhu told me this should be reproducible with GCC 14 and Binutils-2.42 >> development snapshots and defconfig. I'm trying... > > 1. How to reproduce > > I update the latest upstream toolchains (20240105): > > [fedora@linux 6.7.test]$ gcc --version > gcc (GCC) 14.0.0 20240105 (experimental) > [fedora@linux 6.7.test]$ as --version > GNU assembler (GNU Binutils) 2.41.50.20240105 > [fedora@linux 6.7.test]$ ld --version > GNU ld (GNU Binutils) 2.41.50.20240105 > > and then test it again, here is the failure info: > > [fedora@linux 6.7.test]$ git log --oneline | head -1 > 610a9b8f49fb Linux 6.7-rc8 > [fedora@linux 6.7.test]$ make loongson3_defconfig > [fedora@linux 6.7.test]$ make > ... > AR built-in.a > AR vmlinux.a > LD vmlinux.o > OBJCOPY modules.builtin.modinfo > GEN modules.builtin > GEN .vmlinux.objs > MODPOST Module.symvers > make[2]: *** [scripts/Makefile.modpost:145: Module.symvers] Error 139 > make[1]: *** [/home/fedora/6.7.test/Makefile:1863: modpost] Error 2 > make: *** [Makefile:234: __sub-make] Error 2 > > 2. Additional info > > I can confirm that the slightly older version of toolchains (20231127) > have no the above failure, so I guess this is related with toolchains. > > 3. How to fix > > (1) One way is to modify the kernel code, with this kernel patch, > there is no building failure with the latest upstream toolchains. > (2) The other way is to analysis and fix the binutils code, > it need more work to do. Hi, I have an idea about that, but I didn't really get into it. The improved R_LARCH_ALIGN (psABI v2.30) requires a symbol index. The symbol is only created at the first time to handle alignment directive. This means that all other sections may use this symbol. If the section of this symbol is discarded, there may be problems. Thanks, Jinyang > > Thanks, > Tiezhu >
Hi, Xuerui, Could you please update a V2 to just modify the commit message? Huacai On Fri, Jan 5, 2024 at 6:11 PM Jinyang He <hejinyang@loongson.cn> wrote: > > > On 2024-01-05 16:09, Tiezhu Yang wrote: > > > > > > On 01/05/2024 12:26 AM, Xi Ruoyao wrote: > >> On Thu, 2024-01-04 at 16:57 +0800, Huacai Chen wrote: > >>> On Wed, Dec 27, 2023 at 7:06 PM Xi Ruoyao <xry111@xry111.site> wrote: > >>>> > >>>> On Wed, 2023-12-27 at 15:03 +0800, WANG Xuerui wrote: > >>>>> And even though the kernel is built with relaxation disabled, so > >>>>> far a small number of R_LARCH_RELAX marker relocs are still > >>>>> emitted as > >>>>> part of la.* pseudo instructions in assembly. > >>>> > >>>> I'd consider it a toolchain bug... Is there a reproducer? > >>> Any updates? Should I apply this patch for loongarch-next? > >> > >> Tiezhu told me this should be reproducible with GCC 14 and Binutils-2.42 > >> development snapshots and defconfig. I'm trying... > > > > 1. How to reproduce > > > > I update the latest upstream toolchains (20240105): > > > > [fedora@linux 6.7.test]$ gcc --version > > gcc (GCC) 14.0.0 20240105 (experimental) > > [fedora@linux 6.7.test]$ as --version > > GNU assembler (GNU Binutils) 2.41.50.20240105 > > [fedora@linux 6.7.test]$ ld --version > > GNU ld (GNU Binutils) 2.41.50.20240105 > > > > and then test it again, here is the failure info: > > > > [fedora@linux 6.7.test]$ git log --oneline | head -1 > > 610a9b8f49fb Linux 6.7-rc8 > > [fedora@linux 6.7.test]$ make loongson3_defconfig > > [fedora@linux 6.7.test]$ make > > ... > > AR built-in.a > > AR vmlinux.a > > LD vmlinux.o > > OBJCOPY modules.builtin.modinfo > > GEN modules.builtin > > GEN .vmlinux.objs > > MODPOST Module.symvers > > make[2]: *** [scripts/Makefile.modpost:145: Module.symvers] Error 139 > > make[1]: *** [/home/fedora/6.7.test/Makefile:1863: modpost] Error 2 > > make: *** [Makefile:234: __sub-make] Error 2 > > > > 2. Additional info > > > > I can confirm that the slightly older version of toolchains (20231127) > > have no the above failure, so I guess this is related with toolchains. > > > > 3. How to fix > > > > (1) One way is to modify the kernel code, with this kernel patch, > > there is no building failure with the latest upstream toolchains. > > (2) The other way is to analysis and fix the binutils code, > > it need more work to do. > > Hi, > > I have an idea about that, but I didn't really get into it. The improved > R_LARCH_ALIGN (psABI v2.30) requires a symbol index. The symbol is only > created at the first time to handle alignment directive. This means that > all other sections may use this symbol. If the section of this symbol is > discarded, there may be problems. > > Thanks, > > Jinyang > > > > > > Thanks, > > Tiezhu > > >
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index cb6406f485a9..a4df47372b95 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1346,6 +1346,14 @@ static Elf_Addr addend_mips_rel(uint32_t *location, unsigned int r_type) #define R_LARCH_SUB32 55 #endif +#ifndef R_LARCH_RELAX +#define R_LARCH_RELAX 100 +#endif + +#ifndef R_LARCH_ALIGN +#define R_LARCH_ALIGN 102 +#endif + static void get_rel_type_and_sym(struct elf_info *elf, uint64_t r_info, unsigned int *r_type, unsigned int *r_sym) { @@ -1400,9 +1408,16 @@ static void section_rela(struct module *mod, struct elf_info *elf, continue; break; case EM_LOONGARCH: - if (!strcmp("__ex_table", fromsec) && - r_type == R_LARCH_SUB32) + switch (r_type) { + case R_LARCH_SUB32: + if (!strcmp("__ex_table", fromsec)) + continue; + break; + case R_LARCH_RELAX: + case R_LARCH_ALIGN: + /* these relocs do not refer to symbols */ continue; + } break; }