forked from qmonnet/rbpf
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite of C ELF tests to Rust or ASM.
- Loading branch information
Showing
57 changed files
with
370 additions
and
555 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
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
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
static mut VAL: u64 = 0; | ||
|
||
#[no_mangle] | ||
pub fn entrypoint() -> u64 { | ||
unsafe { core::ptr::write_volatile(&mut VAL, 42); } | ||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
static mut VAL: u64 = 42; | ||
|
||
#[no_mangle] | ||
pub fn entrypoint() -> u64 { | ||
unsafe { core::ptr::write_volatile(&mut VAL, 0); } | ||
return 0; | ||
} |
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
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 |
---|---|---|
@@ -1,102 +1,59 @@ | ||
#!/bin/bash -ex | ||
|
||
# Requires Latest release of Solana's custom LLVM | ||
#https://github.com/solana-labs/llvm-builder/releases | ||
|
||
LLVM_DIR=../../../solana/sdk/sbf/dependencies/sbf-tools/llvm/bin/ | ||
CC_FLAGS_COMMON="-Werror -target sbf -O2 -fno-builtin -fPIC" | ||
CC_FLAGS="$CC_FLAGS_COMMON -mcpu=sbfv2" | ||
CC_FLAGS_V1="$CC_FLAGS_COMMON -mcpu=generic" | ||
LD_FLAGS_COMMON="-z notext -shared --Bdynamic -entry entrypoint --script elf.ld" | ||
LD_FLAGS="$LD_FLAGS_COMMON --section-start=.text=0x100000000" | ||
LD_FLAGS_V1=$LD_FLAGS_COMMON | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o noop.o -c noop.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o noop.so noop.o | ||
rm noop.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o noro.o -c noro.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o noro.so noro.o | ||
rm noro.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o empty_rodata.o -c empty_rodata.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o empty_rodata.so empty_rodata.o | ||
rm empty_rodata.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o unresolved_syscall.o -c unresolved_syscall.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o unresolved_syscall.so unresolved_syscall.o | ||
rm unresolved_syscall.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o entrypoint.o -c entrypoint.c | ||
"$LLVM_DIR"clang $CC_FLAGS -o multiple_file.o -c multiple_file.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o multiple_file.so entrypoint.o multiple_file.o | ||
rm entrypoint.o | ||
rm multiple_file.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS_V1 -o reloc_64_64.o -c reloc_64_64.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS_V1 -o reloc_64_64_sbpfv1.so reloc_64_64.o | ||
rm reloc_64_64.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o reloc_64_64.o -c reloc_64_64.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o reloc_64_64.so reloc_64_64.o | ||
rm reloc_64_64.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o reloc_64_relative.o -c reloc_64_relative.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o reloc_64_relative.so reloc_64_relative.o | ||
rm reloc_64_relative.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS_V1 -o reloc_64_relative.o -c reloc_64_relative.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS_V1 -o reloc_64_relative_sbpfv1.so reloc_64_relative.o | ||
rm reloc_64_relative.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS_V1 -o reloc_64_relative_data.o -c reloc_64_relative_data.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS_V1 -o reloc_64_relative_data_sbpfv1.so reloc_64_relative_data.o | ||
rm reloc_64_relative_data.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o reloc_64_relative_data.o -c reloc_64_relative_data.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o reloc_64_relative_data.so reloc_64_relative_data.o | ||
rm reloc_64_relative_data.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o scratch_registers.o -c scratch_registers.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o scratch_registers.so scratch_registers.o | ||
rm scratch_registers.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o pass_stack_reference.o -c pass_stack_reference.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o pass_stack_reference.so pass_stack_reference.o | ||
rm pass_stack_reference.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o writable_data_section.o -c writable_data_section.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o writable_data_section.so writable_data_section.o | ||
rm writable_data_section.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o bss_section.o -c bss_section.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o bss_section.so bss_section.o | ||
rm bss_section.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o rodata.o -c rodata.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o rodata.so rodata.o | ||
rm rodata.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS_V1 -mcpu=generic -o rodata.o -c rodata.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS_V1 -o rodata_sbpfv1.so rodata.o | ||
rm rodata.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o syscall_static_unknown.o -c syscall_static_unknown.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o syscall_static_unknown.so syscall_static_unknown.o | ||
rm syscall_static_unknown.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o syscall_static.o -c syscall_static.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o syscall_static.so syscall_static.o | ||
rm syscall_static.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o program_headers_overflow.o -c rodata.c | ||
"$LLVM_DIR"ld.lld -z notext -shared --Bdynamic -entry entrypoint --script program_headers_overflow.ld --noinhibit-exec -o program_headers_overflow.so program_headers_overflow.o | ||
rm program_headers_overflow.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -fdebug-prefix-map=$(pwd)=. -o scratch_registers_debug.o -c scratch_registers.c | ||
"$LLVM_DIR"ld.lld -z notext -shared --Bdynamic -entry entrypoint --section-start=.text=0x1000 -o scratch_registers_debug.so scratch_registers_debug.o | ||
rm scratch_registers_debug.o | ||
|
||
"$LLVM_DIR"clang $CC_FLAGS -o struct_func_pointer.o -c struct_func_pointer.c | ||
"$LLVM_DIR"ld.lld $LD_FLAGS -o struct_func_pointer.so struct_func_pointer.o | ||
rm struct_func_pointer.o | ||
# https://github.com/solana-labs/platform-tools/releases | ||
|
||
TOOLCHAIN=../../../solana/sdk/sbf/dependencies/sbf-tools | ||
RC_COMMON="$TOOLCHAIN/rust/bin/rustc --target sbf-solana-solana --crate-type lib -C panic=abort -C opt-level=2" | ||
RC="$RC_COMMON -C target_cpu=sbfv2" | ||
RC_V1="$RC_COMMON -C target_cpu=generic" | ||
LD_COMMON="$TOOLCHAIN/llvm/bin/ld.lld -z notext -shared --Bdynamic -entry entrypoint --script elf.ld" | ||
LD="$LD_COMMON --section-start=.text=0x100000000" | ||
LD_V1=$LD_COMMON | ||
|
||
$RC -o relative_call.o relative_call.rs | ||
$LD -o relative_call.so relative_call.o | ||
|
||
$RC_V1 -o syscall_reloc_64_32.o syscall_reloc_64_32.rs | ||
$LD_V1 -o syscall_reloc_64_32.so syscall_reloc_64_32.o | ||
|
||
$RC -o syscall_static.o syscall_static.rs | ||
$LD -o syscall_static.so syscall_static.o | ||
|
||
$RC -o bss_section.o bss_section.rs | ||
$LD -o bss_section.so bss_section.o | ||
|
||
$RC -o data_section.o data_section.rs | ||
$LD -o data_section.so data_section.o | ||
|
||
$RC_V1 -o rodata_section.o rodata_section.rs | ||
$LD_V1 -o rodata_section_sbpfv1.so rodata_section.o | ||
|
||
$RC -o rodata_section.o rodata_section.rs | ||
$LD -o rodata_section.so rodata_section.o | ||
|
||
$RC -o program_headers_overflow.o rodata_section.rs | ||
"$TOOLCHAIN"/llvm/bin/ld.lld -z notext -shared --Bdynamic -entry entrypoint --script program_headers_overflow.ld --noinhibit-exec -o program_headers_overflow.so program_headers_overflow.o | ||
|
||
$RC -o struct_func_pointer.o struct_func_pointer.rs | ||
$LD -o struct_func_pointer.so struct_func_pointer.o | ||
|
||
$RC -o reloc_64_64.o reloc_64_64.rs | ||
$LD -o reloc_64_64.so reloc_64_64.o | ||
|
||
$RC_V1 -o reloc_64_64.o reloc_64_64.rs | ||
$LD_V1 -o reloc_64_64_sbpfv1.so reloc_64_64.o | ||
|
||
$RC -o reloc_64_relative.o reloc_64_relative.rs | ||
$LD -o reloc_64_relative.so reloc_64_relative.o | ||
|
||
$RC_V1 -o reloc_64_relative.o reloc_64_relative.rs | ||
$LD_V1 -o reloc_64_relative_sbpfv1.so reloc_64_relative.o | ||
|
||
# $RC -o reloc_64_relative_data.o reloc_64_relative_data.rs | ||
# $LD -o reloc_64_relative_data.so reloc_64_relative_data.o# | ||
|
||
# $RC_V1 -o reloc_64_relative_data.o reloc_64_relative_data.rs | ||
# $LD_V1 -o reloc_64_relative_data_sbpfv1.so reloc_64_relative_data.o | ||
|
||
rm *.o |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.