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; +}