Could someone explain to me what leaq str(%rip), %rsi
does and why there isn't a simple mov operation to move the value of the string in a register? This is a hello world script for macOS x86-64.
I understand that it's setting the rsi register with the address of the string + the address of rip register. But why have to offset from the address of the rip register?
.section __DATA,__data
str:
.ascii "Hello world!\n"
len = . - str
.section __TEXT,__text
.globl start
start:
movl $0x2000004, %eax
movl $1, %edi
leaq str(%rip), %rsi
movq $len, %rdx
syscall
movl $0x2000001, %eax
movl $0, %ebx
syscall