0

Consider this code:

int arr[4];
void foo(void)
{
    arr[0] = arr[1];
}

compiled and objdumped as:

gcc t57.c -O3 -c && objdump -Dr t57.o

leading to:

0000000000000000 <foo>:
   0:   f3 0f 1e fa             endbr64
   4:   8b 05 00 00 00 00       mov    0x0(%rip),%eax        # a <foo+0xa>
                        6: R_X86_64_PC32        arr
   a:   89 05 00 00 00 00       mov    %eax,0x0(%rip)        # 10 <foo+0x10>
                        c: R_X86_64_PC32        arr-0x4
  10:   c3                      retq

Here we see arr and arr-0x4.

Question: why not arr+0x4 and arr? Where this -0x4 comes from?

pmor
  • 5,392
  • 4
  • 17
  • 36

0 Answers0