From ae54bb7b92fa3224ca15dfb8a6aebc3172762a2b Mon Sep 17 00:00:00 2001 From: numzero Date: Mon, 12 Aug 2024 00:16:09 +0300 Subject: [PATCH] All in the name of size! --- Makefile | 4 ++-- link.ld | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 link.ld diff --git a/Makefile b/Makefile index 4ad5dfc..ef7b2d3 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -server: main.o func.o - gcc main.o func.o -o server -nostdlib -static +server: link.ld main.o func.o + gcc -T link.ld main.o func.o -o server -nostdlib -static main.o: main.S gcc -c main.S diff --git a/link.ld b/link.ld new file mode 100644 index 0000000..492dc3f --- /dev/null +++ b/link.ld @@ -0,0 +1,15 @@ +ENTRY(_start) + +SECTIONS { + . = 4M; + . = . + SIZEOF_HEADERS; + .text : { *(.text) } :text + .rodata : { *(.rodata) } + . = ALIGN(4K); + .bss : { *(COMMON) *(.bss) } :bss +} + +PHDRS { + text PT_LOAD FILEHDR PHDRS FLAGS(5); + bss PT_LOAD; +}