I do not understand why my linker script is not working as expected, I am compiling my assembly code using
nasm -f elf64 file.asm
and later I link it using my custom linker script
ld -o file.elf64 -T linker_script.lds file.o
without linker script I can execute it, but with the linker script not, I just wanna place the text and code section on different locations and mark text as RWX and the data as RW.
MEMORY
{
cod (RWX) : ORIGIN = 0x0041000 , LENGTH = 0x1000
mem (RW) : ORIGIN = 0x0040000 , LENGTH = 0x1000
}
SECTIONS
{
.data : { *(.data) } >mem
.text : { *(.text) } >cod
}
If I view the Sections in r2 I get
r2 -c 'iS' -A file.elf64
[Sections]
Nm Paddr Size Vaddr Memsz Perms Name
00 0x00000000 0 0x00000000 0 ----
01 0x00001000 69 0x00041000 69 -r-- .TEXT
02 0x00001045 13 0x00041045 13 -r-- .DATA
03 0x00001058 168 0x00000000 168 ---- .symtab
04 0x00001100 33 0x00000000 33 ---- .strtab
05 0x00001121 39 0x00000000 39 ---- .shstrtab
which I do not understand
(For completness the asm-Code)
SECTION .TEXT
GLOBAL _start
_start:
mov rax, 0 ; read syscall
mov rdi, 0
mov rsi, hello
mov rdx, 10
syscall
mov rax, 1 ; write syscall
mov rdi, 1
mov rsi, hello
mov rdx, 10
syscall
mov rax, 1
syscall
SECTION .DATA
hello: db 'Hello world!',10
helloLen: equ $-hello
.datais not the same thing as.DATA. - fuz