<div dir="ltr">Hi All,<div><br></div><div>Thank you so much for all your answers.</div><div><br></div><div>Regards,</div><div>Madhu</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 2, 2016 at 8:22 AM, Arshad Hussain <span dir="ltr"><<a href="mailto:arshad.super@gmail.com" target="_blank">arshad.super@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On 30-Sep-2016, at 10:10 pm, Román Martínez <<a href="mailto:rgmf@riseup.net">rgmf@riseup.net</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> I compile main.s and it generates main.o. With objdump I can see:<br>
><br>
> 0000000000000000 <_start>:<br>
> 0: b8 01 00 00 00 mov $0x1,%eax<br>
> 5: bb 00 00 00 00 mov $0x0,%ebx<br>
> a: cd 80 int $0x80<br>
><br>
> After link main.o it generates main. With objdump I now can see:<br>
><br>
> 0000000000400078 <_start>:<br>
> 400078: b8 01 00 00 00 mov $0x1,%eax<br>
> 40007d: bb 00 00 00 00 mov $0x0,%ebx<br>
> 400082: cd 80 int $0x80<br>
><br>
> So, linker generates virtual address, doesn't it? But why it starts at 400078 and not in other any location? Is there any logic here? A virtual address can start at 0?<br>
><br>
</span>The linker script would normally leave out some area and _not_ start from 0. (although this is not<br>
an absolute necessity ). It will pick up and valid virtual address and assign start of .text,.bss and<br>
.stack. This is possible because we now have virtual memory. And every program thinks that it<br>
has _all_ the memory for itself. So, 400078 is perfectly valid virtual address space and linker<br>
has chosen this for this executable.<br>
<br>
Also note that if the address space is getting shifted by little , this is because of the KASLR<br>
(layout randomisation) - If this is disabled then the linker would generate the same virtual<br>
address for all the executable every time.<br>
<br>
<br>
<br>
<snip><br>
<br>
<br>
</blockquote></div><br></div>