kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: rgmf@riseup.net (Román Martínez)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Virtual Address Space
Date: Fri, 30 Sep 2016 18:40:18 +0200	[thread overview]
Message-ID: <1475253618.1158.6.camel@riseup.net> (raw)
In-Reply-To: <CAKJ7aR5moNU56te4fF_xaoPopdtH++W95=wZJkWkR9VHCLo3ow@mail.gmail.com>

Hi,

I compile main.s and it generates main.o. With objdump I can see:

0000000000000000 <_start>:
???0:	b8 01 00 00 00???????	mov????$0x1,%eax
???5:	bb 00 00 00 00???????	mov????$0x0,%ebx
???a:	cd 80????????????????	? ? ? ? int????$0x80

After link main.o it generates main. With objdump I now can see:

0000000000400078 <_start>:
? 400078:	b8 01 00 00 00???????	mov????$0x1,%eax
? 40007d:	bb 00 00 00 00???????	mov????$0x0,%ebx
? 400082:	cd 80????????????????	? ? ? ? int????$0x80

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?

Regards.

El mi?, 28-09-2016 a las 19:02 +0530, Gadre Nayan escribi?:
> > > Virtual addresses will be used only in case MMU is enabled, otherwise
for a processor an address is something it can put on the bus,
irrespective of physical or virtual.
> > So when your PC increments virtual address for a MMU enabled system,
they will get translated to physical.
> > > On 28 Sep 2016 4:29 p.m., "Prabhunath G" <gprabhunath@gmail.com>
wrote:
> > > > > > > > > > > > > > > > > > The virtual addresses what you see in the output of objdump is
given/associated by Linker to every instruction and data symbol in
the data/bss section except for symbols in the stack section. It is
wrong to use generated in the context of Linker.?When you initiate
$./a.out for execution, the kernel will take your start address
from the ELF header of a.out and place it on the PC (program
counter) or IP (instruction pointer) of the CPU, thereafter CPU
will start incrementing or generating virtual address for every
subsequent instructions.?
> > Regards,
> > Prabhu
> > 
> > 
> > > > > > On Wed, Sep 28, 2016 at 3:41 PM, Madhu K <madhu.sk89@gmail.com>
wrote:
> > > Hi Arun,
> > > Thanks for your response.
> > > 
> > > > > > > > > > > > > > > I will elaborate my question.Assume I have test.c file, I
compiled test.c and generated the a.out ( Executable for linux ),
when I do objdump of a.out, we can see addresses( virtual address
) associated with each instruction, these instructions are
generated by whom?
> > > 
> > > Thanks
> > > 
> > > 
> > > > > > On Wed, Sep 28, 2016 at 11:35 AM, Arun Sudhilal <getarunks@gmail.
com> wrote:
> > > > Hello Madhu,
> > > > 
> > > > 
> > > > > > > > On Wed, Sep 28, 2016 at 10:36 AM, Madhu K <madhu.sk89@gmail.com
> wrote:
> > > > 
> > > > > Hi All,
> > > > 
> > > > >
> > > > 
> > > > > > > > > This is to understand the Virtual address space.Basically who
generates the
> > > > 
> > > > > virtual addresses CPU or GNU compiler?
> > > > 
> > > > 
> > > > 
> > > > I didn't really get your question.
> > > > 
> > > > 
> > > > 
> > > > > > > > Linux kernel starts at a fixed location in virtual space. This
is
> > > > 
> > > > > > > > called PAGE_OFFSET. On a kernel split of 3GB/1GB, 32 system,
its is
> > > > 
> > > > > > > > 0xC000_0000. You can have a look at system.map file after
compiling
> > > > 
> > > > your kernel.
> > > > 
> > > > When cpu runs with MMU on, your cpu generates virtual address.
> > > > 
> > > > 
> > > > 
> > > > Regards,
> > > > 
> > > > Arun
> > > > 
> > > > 
> > > > 
> > > > >
> > > > 
> > > > > Thanks
> > > > 
> > > > > Madhu
> > > > 
> > > > >
> > > > 
> > > > > _______________________________________________
> > > > 
> > > > > Kernelnewbies mailing list
> > > > 
> > > > > Kernelnewbies at kernelnewbies.org
> > > > 
> > > > > > > > > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbie
s
> > > > 
> > > > >
> > > > 
> > > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > 
> > > Kernelnewbies mailing list
> > > 
> > > Kernelnewbies at kernelnewbies.org
> > > 
> > > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> > > 
> > > 
> > 
> > 
> > 
> > --?
> > Regards,
> > Prabhunath G
> > Linux Trainer
> > Bangalore
> > 
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > 
> > Kernelnewbies mailing list
> > 
> > Kernelnewbies at kernelnewbies.org
> > 
> > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> > 
> > 
> 
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160930/a0338ba2/attachment.html 

  reply	other threads:[~2016-09-30 16:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28  5:06 Virtual Address Space Madhu K
2016-09-28  6:05 ` Arun Sudhilal
2016-09-28 10:11   ` Madhu K
2016-09-28 10:59     ` Prabhunath G
2016-09-28 13:32       ` Gadre Nayan
2016-09-30 16:40         ` Román Martínez [this message]
2016-10-02  2:52           ` Arshad Hussain
2016-10-03  5:12             ` Madhu K
2016-09-28  6:09 ` Greg KH
2016-09-28 10:14   ` Madhu K
2016-09-28 10:29     ` Greg KH
2016-09-28  9:14 ` Augusto Mecking Caringi
2016-09-28 10:21   ` Madhu K
2016-09-28 10:37 ` Alexander Kapshuk
2016-09-29  7:25 ` arshad hussain
2016-09-30 17:09   ` roman at mailoo.org
2016-10-01 18:02     ` piyush moghe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475253618.1158.6.camel@riseup.net \
    --to=rgmf@riseup.net \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).