This is because you use pointers to an unsigned int
or some other type (for _start
and _key
) that is four bytes wide. You will notice that even with pointer arithmetics in C/C++ you get the same results.
Write this into foo.cpp
:
#include <cstdio>
int main(int argc, char** argv)
{
unsigned int* _start = (unsigned int*)0x08049054, * _key = (unsigned int*)0x0804916d;
printf("start(%p), key(%p) -> [key - start](%li)\n", _start, _key, _key - _start);
}
Now the make file (GNUmakefile
):
CXXFLAGS=-ggdb -g3 -O0
foo: foo.cpp
Build it by invoking make
(GNU make, to be precise).
The output will be:
start(0x8049054), key(0x804916d) -> [key - start](70)
... and 70 == 0x46
.