[NSWI004] Problem with PIE

Petr Tůma petr.tuma at d3s.mff.cuni.cz
Thu Oct 8 08:27:17 CEST 2020


Hi Ondrej,

you will note that the example in Q2 actually prints its own address (the address of the main function, and the address of the i variable) when run. So do not (obj)dump the executable, run it :-) ...

(You have also discovered an important piece of the puzzle that is memory layout randomization - it does not happen at compile time, but early at runtime.)

Best, Petr


On 07/10/2020 23:04, Ondřej Roztočil wrote:
> Hi,
> 
> I must be missing something, but I have a problem with Q2 in 02-code-stack-before.md which deals with memory layout randomization.
> 
> First, I compile the provided code with the all the specified compiler parameters:
> 
> gcc -pie -fpie -o main main.c
> 
> Then I find addresses of main and the i variable in the output of:
> 
> objdump -d main
> 
> However, when I repeat the process I always get the same addresses. I tried it on the lab computer and on my pc (with Ubuntu in WSL). Is objdump -d not the right tool to solve this question?
> 
> Thanks
> 
> OR
> _______________________________________________
> NSWI004 mailing list
> NSWI004 at d3s.mff.cuni.cz
> https://d3s.mff.cuni.cz/mailman/listinfo/nswi004
> 


More information about the NSWI004 mailing list