[NSWI004] Problem with PIE

Ondřej Roztočil roztocil at outlook.com
Thu Oct 8 08:54:00 CEST 2020


Hi,

so I made a fool of myself :-) I was going through the exercise late at night and actually didn't look at the code, I just copied it and skimmed through the instructions (just hoping "it will be over soon"). Then I got stressed that I have to have some answer before tomorrow and went to the mailing list. So, sorry about writing too soon.

(To my defense, I knew how relocation works - at least theoretically - I just didn't know what objdump with all those options does and got confused.)

Best regards

OR

From: Petr Tůma <petr.tuma at d3s.mff.cuni.cz>
Sent: Thursday, October 8, 2020 8:27 AM
To: Operating Systems Course <nswi004 at d3s.mff.cuni.cz>; Ondřej Roztočil <roztocil at outlook.com>
Subject: Re: [NSWI004] Problem with PIE 
 
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