When I use gcc to compile a C++ program to a 32 bit and I run it through gdb. When I disassemble the main function the gdb reads out the memory addresses EXAMPLE: 0x585583d0 and in other peoples examples of 32 bit it reads out 0x080483d0. Im using Kali linux and am wondering if its just because its a different distribution or am I missing some C libraries?
-
1What is the real problem you are facing? Why do you believe the address should be different? – SergeyA Jun 20 '18 at 21:56
-
No just curious – x7309wh Jun 20 '18 at 21:58
-
Why do you say "instead"? Why don't you think the address should be `0xDEADBEEF`? – MPops Jun 20 '18 at 22:07
-
No I've seen examples that have address starting with 0x08 and mine are 0x56 and I was just wondering why, thats it. Its just question. Its not getting in the way of anything for me. – x7309wh Jun 20 '18 at 22:19
1 Answers
am wondering if its just because its a different distribution or am I missing some C libraries?
This is because you built a position independent executable, while other people didn't.
The default load address for non-PIE binaries on 32-bit x86 systems is 0x08048000
. The default load address for PIE binaries under GDB is somewhere in the 0x5855....
region (it can be very random outside of GDB; if you set disable-randomization off
, you'll observe that the executable starts "jumping around" to different addresses).
Some newer distributions default to building PIE binaries. You can avoid this with:
gcc -no-pie main.c
The resulting binary should now start around 0x08048xxx
.
You can check whether you have a PIE binary or not with file a.out
-- it will say executable
for non-PIE binary, and shared library
for a PIE binary. See also this answer.

- 199,314
- 34
- 295
- 362