Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update link scripts and elf build script #27

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions tests/elfs/elf.ld
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
SECTIONS
{
.text 0x000000000 : { *(.text*) } :text
.rodata 0x100000000 : { *(.rodata*) } :rodata
.bss.stack 0x200000000 : { *(.bss.stack*) } :stack
.bss.heap 0x300000000 : { *(.bss.heap*) } :heap
.dynsym 0xFFFFFFFF00000000 : { *(.dynsym) } :dynsym
.dynstr : { *(.dynstr) } :other
.dynamic : { *(.dynamic) } :other
.symtab : { *(.symtab) } :other
.shstrtab : { *(.shstrtab) } :other
.strtab : { *(.strtab) } :other
.text 0x000000000 : {
*(.text*)
} :text
.rodata 0x100000000 : {
*(.rodata*)
*(.data.rel.ro*)
BYTE(0);
. = ALIGN(8);
} :rodata
.bss.stack 0x200000000 (NOLOAD) : {
_stack_start = .;
. = . + 0x1000;
_stack_end = .;
. = ALIGN(8);
} :stack
.bss.heap 0x300000000 (NOLOAD) : {
_heap_start = .;
. = . + 0x1000;
_heap_end = .;
. = ALIGN(8);
} :heap
.dynsym 0xFFFFFFFF00000000 : {
*(.dynsym)
. = ALIGN(8);
} :dynsym
.strtab : { *(.strtab) } :other
.dynstr : { *(.dynstr) } :other
/DISCARD/ : {
*(.comment*)
*(.eh_frame*)
*(*hash*)
*(.bss*)
*(.data*)
*(.rel.dyn*)
*(.dynamic)
}
}

Expand Down
File renamed without changes.
82 changes: 55 additions & 27 deletions tests/elfs/elfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,74 @@
# Requires Latest release of Solana's custom LLVM
# https://github.com/anza-xyz/platform-tools/releases

TOOLCHAIN=../../../agave/sdk/sbf/dependencies/platform-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"
TOOLCHAIN="$HOME"/.cache/solana/v1.44/platform-tools/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where cargo-build-sbf installs the platform tools locally.


CC_V0="$TOOLCHAIN/llvm/bin/clang -Werror -target sbf -O2 -fno-builtin -fPIC"
CC_V3="$CC_V0 -mcpu=v3"

RC_V0="$TOOLCHAIN/rust/bin/rustc --target sbf-solana-solana --crate-type lib -C panic=abort -C opt-level=2"
RC_V3="$RC_V0 -C target_cpu=v3 -C target_feature=+static-syscalls"

LD_COMMON="$TOOLCHAIN/llvm/bin/ld.lld -z notext -shared --Bdynamic -entry entrypoint"
LD="$LD_COMMON --script elf.ld"
LD_V1="$LD_COMMON --script elf_sbpfv0.ld"
LD_V3="$LD_COMMON -Bsymbolic --script elf.ld"
LD_V0="$LD_COMMON --script elf_sbpfv0.ld"

$RC -o strict_header.o strict_header.rs
$LD -o strict_header.so strict_header.o
$RC_V3 -o strict_header.o strict_header.rs
$LD_V3 -o strict_header.so strict_header.o

$RC_V1 -o relative_call.o relative_call.rs
$LD_V1 -o relative_call_sbpfv0.so relative_call.o
$RC_V0 -o relative_call.o relative_call.rs
$LD_V0 -o relative_call_sbpfv0.so relative_call.o

$RC_V1 -o syscall_reloc_64_32.o syscall_reloc_64_32.rs
$LD_V1 -o syscall_reloc_64_32_sbpfv0.so syscall_reloc_64_32.o
$RC_V3 -o relative_call.o relative_call.rs
$LD_V3 -o relative_call.so relative_call.o

$RC_V1 -o bss_section.o bss_section.rs
$LD_V1 -o bss_section_sbpfv0.so bss_section.o
$RC_V0 -o syscall_reloc_64_32.o syscall_reloc_64_32.rs
$LD_V0 -o syscall_reloc_64_32_sbpfv0.so syscall_reloc_64_32.o

$RC_V1 -o data_section.o data_section.rs
$LD_V1 -o data_section_sbpfv0.so data_section.o
$RC_V0 -o bss_section.o bss_section.rs
$LD_V0 -o bss_section_sbpfv0.so bss_section.o

$RC_V1 -o rodata_section.o rodata_section.rs
$LD_V1 -o rodata_section_sbpfv0.so rodata_section.o
$RC_V0 -o data_section.o data_section.rs
$LD_V0 -o data_section_sbpfv0.so data_section.o

$RC -o program_headers_overflow.o rodata_section.rs
$RC_V0 -o rodata_section.o rodata_section.rs
$LD_V0 -o rodata_section_sbpfv0.so rodata_section.o

$RC_V3 -o rodata_section.o rodata_section.rs
$LD_V3 -o rodata_section.so rodata_section.o

$RC_V0 -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_V1 -o struct_func_pointer.o struct_func_pointer.rs
$LD_V1 -o struct_func_pointer_sbpfv0.so struct_func_pointer.o
$RC_V0 -o struct_func_pointer.o struct_func_pointer.rs
$LD_V0 -o struct_func_pointer_sbpfv0.so struct_func_pointer.o

$RC_V3 -o struct_func_pointer.o struct_func_pointer.rs
$LD_V3 -o struct_func_pointer.so struct_func_pointer.o

$RC_V0 -o reloc_64_64.o reloc_64_64.rs
$LD_V0 -o reloc_64_64_sbpfv0.so reloc_64_64.o

$RC_V3 -o reloc_64_64.o reloc_64_64.rs
$LD_V3 -o reloc_64_64.so reloc_64_64.o

$RC_V3 -o reloc_64_64.o reloc_64_64.rs
$LD_V3 -o reloc_64_64.so reloc_64_64.o

$RC_V0 -o reloc_64_relative.o reloc_64_relative.rs
$LD_V0 -o reloc_64_relative_sbpfv0.so reloc_64_relative.o

$RC_V3 -o reloc_64_relative.o reloc_64_relative.rs
$LD_V3 -o reloc_64_relative.so reloc_64_relative.o

$RC_V1 -o reloc_64_64.o reloc_64_64.rs
$LD_V1 -o reloc_64_64_sbpfv0.so reloc_64_64.o
$CC_V0 -o reloc_64_relative_data.o -c reloc_64_relative_data.c
$LD_V0 -o reloc_64_relative_data_sbpfv0.so reloc_64_relative_data.o

$RC_V1 -o reloc_64_relative.o reloc_64_relative.rs
$LD_V1 -o reloc_64_relative_sbpfv0.so reloc_64_relative.o
$CC_V3 -o reloc_64_relative_data.o -c reloc_64_relative_data.c
$LD_V3 -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_sbpfv0.so reloc_64_relative_data.o
$RC_V3 -o syscall_static.o syscall_static.rs
$LD_V3 -o syscall_static.so syscall_static.o

# $RC_V1 -o callx_unaligned.o callx_unaligned.rs
# $LD_V1 -o callx_unaligned.so callx_unaligned.o
Expand Down