Re: Possible bug - GAS for RSIC-V

2023-07-04 Thread Andreas Schwab
You haven't set up gp, or disable relaxation.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



Possible bug - GAS for RSIC-V

2023-07-03 Thread David
Greetings,

Assembly code below prints a Hello message on stdout under Linux. It is a
simple call to Write system call while the address of my_str is loaded and
passed via ABI conventions.

*However, if you uncomment the second line, we will face an issue and no
prints happen. Can we review this:*

cat > main.s
.data
*#my_var1: .int 1 #*
my_str: .asciz "Hello\n"

.text
.global _start

print:
addi sp, sp, -40
sd ra, 0(sp)
sd a0, 8(sp)
sd a1, 16(sp)
sd a2, 24(sp)
sd a7, 32(sp)
li a0, 1
la a1, my_str
li a2, 6
li a7, 64
ecall
ld ra, 0(sp)
ld a0, 8(sp)
ld a1, 16(sp)
ld a2, 24(sp)
ld a7, 32(sp)
addi sp, sp, 40
ret

_start:
call print
li a0, 0
li a7, 93
ecall

[root@fedora-riscv ~]# as -o main.o main.s; ld -o main main.o; ./main
Hello

*If you uncomment the second line (my_var1: .int 1), the program will no
longer print anything!!!*:
[root@fedora-riscv ~]# rm -f main.o main
[root@fedora-riscv ~]# as -o main.o main.s; ld -o main main.o; ./main
[root@fedora-riscv ~]#

##
Please note, all we did was just to use .int directive in the data section
and very oddly we no longer can access my_str ... I tried to use .align 3
to make sure we have 64 bit alignment with no luck ...
##

[root@fedora-riscv ~]# as --version
GNU assembler version 2.39-4.fc37
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `riscv64-redhat-linux'.

[root@fedora-riscv ~]# cat /proc/cpuinfo
processor : 0
hart : 5
isa : rv64imafdch_sstc_zicbom_zihintpause
mmu : sv57

processor : 1
hart : 0
isa : rv64imafdch_sstc_zicbom_zihintpause
mmu : sv57

processor : 2
hart : 1
isa : rv64imafdch_sstc_zicbom_zihintpause
mmu : sv57

processor : 3
hart : 2
isa : rv64imafdch_sstc_zicbom_zihintpause
mmu : sv57

processor : 4
hart : 3
isa : rv64imafdch_sstc_zicbom_zihintpause
mmu : sv57

processor : 5
hart : 4
isa : rv64imafdch_sstc_zicbom_zihintpause
mmu : sv57

[root@fedora-riscv ~]# uname -a
Linux fedora-riscv 6.0.10-300.0.riscv64.fc37.riscv64 #1 SMP Sun Nov 27
19:08:44 GMT 2022 riscv64 riscv64 riscv64 GNU/Linux

System is vanilla Fedora 37 running under the QEMU emulator version 8.0.2
for RISC-V 64.

Thank you,
David