LOGBOOK

HELP

Quiz Entry - updated: 2026.07.06

What is %rip-relative addressing and why is it used?

It addresses data as an offset from the current instruction pointer (sym(%rip)), so the code works no matter where it's loaded — the basis of Position-Independent Code.

# Load string address relative to current instruction
lea  msg(%rip), %rsi

# Access global variable relative to current instruction
mov  counter(%rip), %eax

Why it matters:

  • In shared libraries and PIE (Position Independent Executables), code can be loaded at any address
  • Absolute addresses (mov $0x402490, %esi) only work at fixed addresses
  • RIP-relative works regardless of where the code is loaded

How to read it in GDB: The disassembler resolves the actual address:

lea  0x2008(%rip), %rsi    # 0x402490 <msg>

GDB shows both the offset and the resolved address.

Forensic relevance: Modern binaries (compiled with -fPIC or -pie) use RIP-relative addressing everywhere. If you see absolute addresses, it's either an older binary or a statically linked one.

Go deeper:

From Quiz: REVE1 / Assembly Patterns & GDB | Updated: Jul 06, 2026