OnlyWick
OnlyWick

Reputation: 464

Why can `%rip + displacement` access data section?

The usage of this is that I saw after used gcc -S.

I know ary represents the first address of the sequence, then I also know leaq ary(, %rdi, 4) has the same effect(assume %rdi equals 0).

But I don't understand, why can ary(%rip) access data section. Maybe I lack the memory layout for program running, or I misunderstand the addressing modes?

Below is my example.

.section .data
ary:
    .int 1, 2, 3, 4, 5, 6

.section .text
.globl  _start

_start:
    leaq ary, %rax
    leaq ary(%rip), %rbx   # ???

    movq $60, %rax
    syscall

Upvotes: 1

Views: 85

Answers (0)

Related Questions