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@xxxxxxxxx> 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
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
|