The Linux logical address and the physical address of the key point

Source: Internet
Author: User

This article original for freas_1990, reprint please indicate source: http://blog.csdn.net/freas_1990/article/details/32697735


The following section of code:

#include <stdio.h>greeting () {printf ("Hello, world!\n");} Main () {greeting ();}

After GCC, LD (link, compile), generate an elf executable file, and then use objdump processing, the resulting disassembly code is as follows:

08048368 <greeting>:8048368:55 push%ebp8048369:89 e5 mov%esp,%ebp804836b:83 EC Sub $0x8,%esp804836e:83 EC 0 C Sub $0xc,%esp8048371:68, push $0X80484848048376:E8 FF FF FF call 80482b0 <[email protected]>804837 b:83 C4 Add $0x10,%esp804837e:c9 leave

804837F:C3 ret08048380 <main>:8048380:55 push%ebp8048381:89 e5 mov%esp,%ebp8048383:83 EC Sub $0x8,%esp80483  86:83 e4 F0 and $0xfffffff0,%esp8048389:b8 (xx), MOV $0x0,%eax804838e:83 c0 0f add $0xf,%eax8048391:83 c0 0f add $0XF,%EAX8048394:C1 E8 SHR $0x4,%eax8048397:c1 e0 Geneva shl $0x4,%eax804839a:29 C4 Sub%eax,%esp804839c:e8 C7 FF FF F F Call 8048368 <greeting>80483a1:c9 leave80483a2:c3 ret80483a3:90 NOP
Note that the logical address of this function, greeting, is now 8048368.

Some students with poor foundation should be shocked!

When the source code is compiled, it can generate a specific logical address!

Imagine that our Linux can compile thousands of elf files, each file address is likely to repeat, then, do not conflict?

Hey.

If you have this question, then, it is clear that the copy-on-write mechanism of UNIX tradition is still not understood.

To understand this knowledge point, just focus on the following 3 points:

The 1,linux user process is completely independent on the virtual address (or linear address, in Linux, the two concepts are not different), and the page directory is independent, rather than horizontally cut.

The virtual Address and page directory of each user process in the 2,linux are generated only when the fork + exec is in use.

3, the conversion of the virtual address to the physical address.


Note: This article has a reference to "Linux kernel source code scenario analysis"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.