fix issue of jumping to address 0
This commit is contained in:
@ -16,8 +16,8 @@ LDFLAGS = -T test.ld
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
|
||||
%.elf: %.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
%.elf: %.o %.ld
|
||||
$(LD) $(LDFLAGS) $< -o $@
|
||||
|
||||
text.hex: test.elf
|
||||
riscv64-linux-gnu-objdump -s $^ | sed -n '/.text/,$$p' | tail -n+2 | sed -n '/.data/,$$!p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
||||
|
Binary file not shown.
46
test/test.S
46
test/test.S
@ -27,7 +27,7 @@ _start:
|
||||
# or
|
||||
or x9, x1, x2 # x9 = 0xffffffff
|
||||
or x10, x1, x0 # x10 = 0xfedcb789
|
||||
or x11, x4, x3 # x11 = 0x0xfedcb79a
|
||||
or x11, x4, x3 # x11 = 0xfedcb79a
|
||||
|
||||
# xor
|
||||
xor x12, x1, x2 # x12 = 0x01234876
|
||||
@ -209,27 +209,29 @@ test9:
|
||||
j fail
|
||||
|
||||
test10:
|
||||
# now for some memory stuff
|
||||
# # sw
|
||||
# la x9, someint # x9 = start of .bss
|
||||
# li x10, 0x12345678 # x10 = 0x12345678
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# sw x10, 0(x9) # someint = 0x12345678
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# lw x11, 0(x9) # x11 = 0x12345678
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
addi x30, x0, 10 # x30 = 10
|
||||
# # now for some memory stuff
|
||||
# # sw
|
||||
# la x9, someint # x9 = start of .bss
|
||||
# lui x10, 0x12345 # x10 = 0x12345000
|
||||
# addi x10, x10, 0x678 # x10 = 0x12345678
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# sw x10, 0(x9) # someint = 0x12345678
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# # lw x11, 0(x9) # x11 = 0x12345678
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
# nop
|
||||
|
||||
|
||||
done:
|
||||
|
10
test/test.ld
10
test/test.ld
@ -3,7 +3,7 @@ ENTRY(_start)
|
||||
MEMORY
|
||||
{
|
||||
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 1024
|
||||
RAM (rwx) : ORIGIN = 0x10000000, LENGTH = 512
|
||||
RAM (rwx) : ORIGIN = 0x00100000, LENGTH = 1024
|
||||
/* FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 512 */
|
||||
}
|
||||
|
||||
@ -11,20 +11,20 @@ SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
/* . = ALIGN(4); */
|
||||
_text = .;
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
_etext = .;
|
||||
. = ALIGN(4);
|
||||
/* . = ALIGN(4); */
|
||||
} > ROM
|
||||
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
/* . = ALIGN(4); */
|
||||
_data = .;
|
||||
*(.data*)
|
||||
_edata = .;
|
||||
. = ALIGN(4);
|
||||
/* . = ALIGN(4); */
|
||||
} > RAM /*AT> FLASH*/
|
||||
}
|
Reference in New Issue
Block a user