Bug 12521

Summary: RISCV RV32IA selected, RV64GC output
Product: buildroot Reporter: lelassal
Component: OtherAssignee: unassigned
Status: RESOLVED INVALID    
Severity: major CC: buildroot
Priority: P5    
Version: 2019.11   
Target Milestone: ---   
Hardware: Other   
OS: All   
Host: Target:
Build:

Description lelassal 2020-02-03 00:18:27 UTC
Hi,

I selected RV32IA (no option without A) and ILP32 as target. Output is ELF format using VMLinux which has been disassembled using riscv64-unknown-elf-objdump. I get this:


ffffffe000000000 <_start>:
ffffffe000000000:	10401073          	csrw	sie,zero
ffffffe000000004:	007a6197          	auipc	gp,0x7a6
ffffffe000000008:	d9418193          	addi	gp,gp,-620 # ffffffe0007a5d98 <__global_pointer$>
ffffffe00000000c:	6299                	lui	t0,0x6
ffffffe00000000e:	1002b073          	csrc	sstatus,t0
ffffffe000000012:	21018693          	addi	a3,gp,528 # ffffffe0007a5fa8 <hart_lottery>
ffffffe000000016:	4605                	li	a2,1
ffffffe000000018:	00c6a6af          	amoadd.w	a3,a2,(a3)
ffffffe00000001c:	e2e9                	bnez	a3,ffffffe0000000de <relocate+0x64>
ffffffe00000001e:	007a8697          	auipc	a3,0x7a8
ffffffe000000022:	fe268693          	addi	a3,a3,-30 # ffffffe0007a8000 <swapper_pmd>
ffffffe000000026:	00872717          	auipc	a4,0x872
ffffffe00000002a:	e3a70713          	addi	a4,a4,-454 # ffffffe000871e60 <__bss_stop>
ffffffe00000002e:	00e6d763          	bge	a3,a4,ffffffe00000003c <clear_bss_done>

ffffffe000000032 <clear_bss>:
ffffffe000000032:	0006b023          	sd	zero,0(a3)
ffffffe000000036:	06a1                	addi	a3,a3,8
ffffffe000000038:	fee6cde3          	blt	a3,a4,ffffffe000000032 <clear_bss>

...

ffffffe00000079c:	6314                	ld	a3,0(a4)
ffffffe00000079e:	0074b617          	auipc	a2,0x74b
ffffffe0000007a2:	53260613          	addi	a2,a2,1330 # ffffffe00074bcd0 <__start___param>
ffffffe0000007a6:	0074e797          	auipc	a5,0x74e
ffffffe0000007aa:	d0278793          	addi	a5,a5,-766 # ffffffe00074e4a8 <__stop___param>
ffffffe0000007ae:	8f91                	sub	a5,a5,a2
ffffffe0000007b0:	878d                	srai	a5,a5,0x3
ffffffe0000007b2:	02d786bb          	mulw	a3,a5,a3
ffffffe0000007b6:	19018793          	addi	a5,gp,400 # ffffffe0007a5f28 <static_command_line>
ffffffe0000007ba:	638c                	ld	a1,0(a5)
ffffffe0000007bc:	00000897          	auipc	a7,0x0



As you can see, it uses compressed instructions, is 64 bit and more (like multiplication).

Thank you.
Comment 1 Thomas Petazzoni 2020-02-03 09:35:35 UTC
Thanks for your report. Instead of looking at the kernel code, could you instead look at some user-space application or library ?

Indeed, the kernel build system very often overrides the toolchain architecture/ABI flags, depending on the kernel configuration.

Also, could you share a Buildroot .config file that allows to reproduce the issue ?
Comment 2 Thomas Petazzoni 2020-02-28 15:58:17 UTC
I'm closing due to the lack of feedback, and missing information to properly debug this.
Comment 3 lelassal 2020-02-28 16:33:14 UTC
So sorry I didn't get a notification about your previous message!

> Thanks for your report. Instead of looking at the kernel code, could you instead look at some user-space application or library ?

I don't know how I can get you this...

> Also, could you share a Buildroot .config file that allows to reproduce the issue ?

Here you go: https://pastebin.com/VAri9WdE

Thank you and again apologies for the delay as I hadn't seen that you replied.
Comment 4 Mark Corbin 2020-03-04 14:10:14 UTC
Hello

The configuration that you posted won't build due to a missing entry for the location of your kernel configuration file (BR2_LINUX_KERNEL_DEFCONFIG).

The default RISC-V configuration for the 5.0.13 kernel is for a 64-bit build, so you would need to provide an appropriate kernel config fragment to change this to 32-bit. Note that there is now an 'rv32_defconfig' in the kernel tree (since the 5.1 release).

However, the minimum ISA requirement for the 5.0.13 kernel is RV32im and later kernels require RV32ima (see arch/riscv/Makefile), so it seems that you wouldn't actually be able to build an RV32ia (or RV32i) kernel anyway.

Regards

Mark
Comment 5 Thomas Petazzoni 2020-05-18 07:37:15 UTC
We still don't have any way of reproducing the issue, and both Mark and I believe there is in fact no issue: whether the kernel is 64 bit or 32 bit is not directly Buildroot's fault: it is up to having a correct Linux kernel configuration.