-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Land #19518, Add support for RISC-V 32-bit / 64-bit Little Endian pay…
…loads
- Loading branch information
Showing
16 changed files
with
831 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
; build with: | ||
; nasm elf_dll_riscv32le_template.s -f bin -o template_riscv32le_linux_dll.bin | ||
|
||
BITS 32 | ||
|
||
org 0 | ||
|
||
ehdr: | ||
db 0x7f, "ELF", 1, 1, 1, 0 ; e_ident | ||
db 0, 0, 0, 0, 0, 0, 0, 0 | ||
dw 3 ; e_type = ET_DYN | ||
dw 0xF3 ; e_machine = EM_RISCV | ||
dd 1 ; e_version = EV_CURRENT | ||
dd _start ; e_entry = _start | ||
dd phdr - $$ ; e_phoff | ||
dd shdr - $$ ; e_shoff | ||
dd 0 ; e_flags | ||
dw ehdrsize ; e_ehsize | ||
dw phdrsize ; e_phentsize | ||
dw 2 ; e_phnum | ||
dw shentsize ; e_shentsize | ||
dw 2 ; e_shnum | ||
dw 1 ; e_shstrndx | ||
|
||
ehdrsize equ $ - ehdr | ||
|
||
phdr: | ||
dd 1 ; p_type = PT_LOAD | ||
dd 0 ; p_offset | ||
dd $$ ; p_vaddr | ||
dd $$ ; p_paddr | ||
dd 0xDEADBEEF ; p_filesz | ||
dd 0xDEADBEEF ; p_memsz | ||
dd 7 ; p_flags = rwx | ||
dd 0x1000 ; p_align | ||
|
||
phdrsize equ $ - phdr | ||
|
||
dd 2 ; p_type = PT_DYNAMIC | ||
dd 7 ; p_flags = rwx | ||
dd dynsection ; p_offset | ||
dd dynsection ; p_vaddr | ||
dd dynsection ; p_vaddr | ||
dd dynsz ; p_filesz | ||
dd dynsz ; p_memsz | ||
dd 0x1000 ; p_align | ||
|
||
shdr: | ||
dd 1 ; sh_name | ||
dd 6 ; sh_type = SHT_DYNAMIC | ||
dd 0 ; sh_flags | ||
dd dynsection ; sh_addr | ||
dd dynsection ; sh_offset | ||
dd dynsz ; sh_size | ||
dd 0 ; sh_link | ||
dd 0 ; sh_info | ||
dd 8 ; sh_addralign | ||
dd 7 ; sh_entsize | ||
shentsize equ $ - shdr | ||
dd 0 ; sh_name | ||
dd 3 ; sh_type = SHT_STRTAB | ||
dd 0 ; sh_flags | ||
dd strtab ; sh_addr | ||
dd strtab ; sh_offset | ||
dd strtabsz ; sh_size | ||
dd 0 ; sh_link | ||
dd 0 ; sh_info | ||
dd 0 ; sh_addralign | ||
dd 0 ; sh_entsize | ||
|
||
dynsection: | ||
; DT_INIT | ||
dd 0x0c | ||
dd _start | ||
; DT_STRTAB | ||
dd 0x05 | ||
dd strtab | ||
; DT_SYMTAB | ||
dd 0x06 | ||
dd strtab | ||
; DT_STRSZ | ||
dd 0x0a | ||
dd 0 | ||
; DT_SYMENT | ||
dd 0x0b | ||
dd 0 | ||
; DT_NULL | ||
dd 0x00 | ||
dd 0 | ||
dynsz equ $ - dynsection | ||
|
||
strtab: | ||
db 0 | ||
db 0 | ||
strtabsz equ $ - strtab | ||
|
||
global _start | ||
_start: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
; build with: | ||
; nasm elf_dll_riscv64le_template.s -f bin -o template_riscv64le_linux_dll.bin | ||
|
||
BITS 64 | ||
|
||
org 0 | ||
|
||
ehdr: ; Elf64_Ehdr | ||
db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident | ||
db 0, 0, 0, 0, 0, 0, 0, 0 ; | ||
dw 3 ; e_type = ET_DYN | ||
dw 0xF3 ; e_machine = RISCV | ||
dd 1 ; e_version | ||
dq _start ; e_entry | ||
dq phdr - $$ ; e_phoff | ||
dq shdr - $$ ; e_shoff | ||
dd 0 ; e_flags | ||
dw ehdrsize ; e_ehsize | ||
dw phdrsize ; e_phentsize | ||
dw 2 ; e_phnum | ||
dw shentsize ; e_shentsize | ||
dw 2 ; e_shnum | ||
dw 1 ; e_shstrndx | ||
|
||
ehdrsize equ $ - ehdr | ||
|
||
phdr: ; Elf32_Phdr | ||
dd 1 ; p_type = PT_LOAD | ||
dd 7 ; p_flags = rwx | ||
dq 0 ; p_offset | ||
dq $$ ; p_vaddr | ||
dq $$ ; p_paddr | ||
dq 0xDEADBEEF ; p_filesz | ||
dq 0xDEADBEEF ; p_memsz | ||
dq 0x1000 ; p_align | ||
|
||
phdrsize equ $ - phdr | ||
dd 2 ; p_type = PT_DYNAMIC | ||
dd 7 ; p_flags = rwx | ||
dq dynsection ; p_offset | ||
dq dynsection ; p_vaddr | ||
dq dynsection ; p_vaddr | ||
dq dynsz ; p_filesz | ||
dq dynsz ; p_memsz | ||
dq 0x1000 ; p_align | ||
|
||
shdr: | ||
dd 1 ; sh_name | ||
dd 6 ; sh_type = SHT_DYNAMIC | ||
dq 0 ; sh_flags | ||
dq dynsection ; sh_addr | ||
dq dynsection ; sh_offset | ||
dq dynsz ; sh_size | ||
dd 0 ; sh_link | ||
dd 0 ; sh_info | ||
dq 8 ; sh_addralign | ||
dq 7 ; sh_entsize | ||
shentsize equ $ - shdr | ||
dd 0 ; sh_name | ||
dd 3 ; sh_type = SHT_STRTAB | ||
dq 0 ; sh_flags | ||
dq strtab ; sh_addr | ||
dq strtab ; sh_offset | ||
dq strtabsz ; sh_size | ||
dd 0 ; sh_link | ||
dd 0 ; sh_info | ||
dq 0 ; sh_addralign | ||
dq 0 ; sh_entsize | ||
|
||
dynsection: | ||
; DT_INIT | ||
dq 0x0c | ||
dq _start | ||
; DT_STRTAB | ||
dq 0x05 | ||
dq strtab | ||
; DT_SYMTAB | ||
dq 0x06 | ||
dq strtab | ||
; DT_STRSZ | ||
dq 0x0a | ||
dq 0 | ||
; DT_SYMENT | ||
dq 0x0b | ||
dq 0 | ||
; DT_NULL | ||
dq 0x00 | ||
dq 0 | ||
|
||
dynsz equ $ - dynsection | ||
|
||
strtab: | ||
db 0 | ||
db 0 | ||
strtabsz equ $ - strtab | ||
|
||
align 16 | ||
global _start | ||
_start: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
; build with: | ||
; nasm elf_riscv32le_template.s -f bin -o template_riscv32le_linux.bin | ||
|
||
BITS 32 | ||
|
||
org 0x00010000 | ||
|
||
ehdr: ; Elf32_Ehdr | ||
db 0x7F, "ELF", 1, 1, 1, 0 ; e_ident | ||
db 0, 0, 0, 0, 0, 0, 0, 0 ; | ||
dw 2 ; e_type = ET_EXEC for an executable | ||
dw 0xF3 ; e_machine = RISCV | ||
dd 1 ; e_version | ||
dd _start ; e_entry | ||
dd phdr - $$ ; e_phoff | ||
dd 0 ; e_shoff | ||
dd 0 ; e_flags | ||
dw ehdrsize ; e_ehsize | ||
dw phdrsize ; e_phentsize | ||
dw 1 ; e_phnum | ||
dw 0 ; e_shentsize | ||
dw 0 ; e_shnum | ||
dw 0 ; e_shstrndx | ||
|
||
ehdrsize equ $ - ehdr | ||
|
||
phdr: ; Elf32_Phdr | ||
dd 1 ; p_type = PT_LOAD | ||
dd 0 ; p_offset | ||
dd $$ ; p_vaddr | ||
dd $$ ; p_paddr | ||
dd 0xDEADBEEF ; p_filesz | ||
dd 0xDEADBEEF ; p_memsz | ||
dd 7 ; p_flags = rwx | ||
dd 0x1000 ; p_align | ||
|
||
phdrsize equ $ - phdr | ||
|
||
global _start | ||
|
||
_start: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
; build with: | ||
; nasm elf_riscv64le_template.s -f bin -o template_riscv64le_linux.bin | ||
|
||
BITS 64 | ||
|
||
org 0x00400000 | ||
|
||
ehdr: ; Elf32_Ehdr | ||
db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident | ||
db 0, 0, 0, 0, 0, 0, 0, 0 ; | ||
dw 2 ; e_type = ET_EXEC for an executable | ||
dw 0xF3 ; e_machine = RISCV | ||
dd 1 ; e_version | ||
dq _start ; e_entry | ||
dq phdr - $$ ; e_phoff | ||
dq 0 ; e_shoff | ||
dd 0 ; e_flags | ||
dw ehdrsize ; e_ehsize | ||
dw phdrsize ; e_phentsize | ||
dw 1 ; e_phnum | ||
dw 0 ; e_shentsize | ||
dw 0 ; e_shnum | ||
dw 0 ; e_shstrndx | ||
|
||
ehdrsize equ $ - ehdr | ||
|
||
phdr: ; Elf32_Phdr | ||
dd 1 ; p_type = PT_LOAD | ||
dd 7 ; p_flags = rwx | ||
dq 0 ; p_offset | ||
dq $$ ; p_vaddr | ||
dq $$ ; p_paddr | ||
dq 0xDEADBEEF ; p_filesz | ||
dq 0xDEADBEEF ; p_memsz | ||
dq 0x1000 ; p_align | ||
|
||
phdrsize equ $ - phdr | ||
|
||
global _start | ||
|
||
_start: | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.