Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.
Open
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
6 changes: 6 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ rustflags = [
"-C", "relocation-model=pic",
"-C", "link-args=-Wl,--sort-section=alignment -nostartfiles",
"-C", "link-self-contained=no",
"-C", "link-arg=-Tlink.script",

# Using GNU ld on Fedora 34 produces this assertion:
# = note: /usr/bin/ld: BFD version 2.35.2-3.fc34 assertion fail elf.c:6278
# collect2: error: ld returned 1 exit status
"-C", "link-arg=-fuse-ld=lld",
]
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
override: true
- name: Install lld
run: sudo apt install lld
- uses: actions-rs/cargo@v1
with:
command: test
command: build
args: ${{ matrix.profile.flag }}
strategy:
fail-fast: false
Expand Down
58 changes: 58 additions & 0 deletions link.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
ENTRY(_start)

PHDRS {
preamble PT_LOAD FILEHDR PHDRS;
text PT_LOAD;
rodata PT_LOAD;
data PT_LOAD;

dynamic PT_DYNAMIC;
note PT_NOTE;

frame 0x6474e550; /* GNU_EH_FRAME */
stack 0x6474e551 FLAGS(6); /* GNU_STACK */
relro 0x6474e552 FLAGS(4); /* GNU_RELRO */
}

SECTIONS {
. = SIZEOF_HEADERS;

. = ALIGN(CONSTANT(MAXPAGESIZE));
.interp : { *(.interp) } :preamble
.note.gnu.build-id : { *(.note.gnu.build-id) } :preamble :note
.hash : { *(.hash) } :preamble
.gnu.hash : { *(.gnu.hash) } :preamble
.dynsym : { *(.dynsym) } :preamble
.dynstr : { *(.dynstr) } :preamble
.gnu.version : { *(.gnu.version) } :preamble
.gnu.version_d : { *(.gnu.version_d) } :preamble
.gnu.version_r : { *(.gnu.version_r) } :preamble
.rela.dyn : { *(.rela.*) } :preamble
.rela.plt : { *(.rela.plt) *(.rela.iplt) } :preamble

. = ALIGN(CONSTANT(MAXPAGESIZE));
.init : { KEEP (*(SORT_NONE(.init))) } :text
.fini : { KEEP (*(SORT_NONE(.fini))) } :text
.text : { *(.text .text.*) } :text
.plt : { *(.plt) *(.iplt) } :text
.plt.got : { *(.plt.got) } :text
.plt.sec : { *(.plt.sec) } :text

. = ALIGN(CONSTANT(MAXPAGESIZE));
.rodata : { *(.rodata .rodata.*) } :rodata
.rodata1 : { *(.rodata1) } :rodata
.eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } :rodata :frame
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } :rodata

. = ALIGN(CONSTANT(MAXPAGESIZE));
.data.rel.ro : { *(.data.rel.ro .data.rel.ro.*) } :data :relro
.dynamic : { *(.dynamic) } :data :relro :dynamic
.got : { *(.got) } :data :relro
.got.plt : { *(.got.plt) } :data :relro

. = ALIGN(CONSTANT(MAXPAGESIZE)); /* Align here? New section? */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } :data
.data : { *(.data .data.*) } :data
.data1 : { *(.data1) } :data
.bss : { *(.bss .bss.*) } :data
}