How the Linux kernel loads and launches an executable program

Source: Internet
Author: User

How the Linux kernel loads and launches an executable program

Shahuzyoriginal works reproduced please indicate the source "Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000 first, the purpose of the experimentunderstand the process of compiling links and the elf executable file format, programming using exec* Library functions to load an executable file, dynamic link is divided into executables when loading dynamic link and runtime dynamic link, programming practice dynamic Link Library of these two ways to use , using GDB trace to analyze a execve system called Kernel handler Sys_execve, to verify your understanding of the process required to load executable programs on Linux systems, and to pay particular attention to where the new executable program starts? Why does the new executable program execute smoothly after the EXECVE system call returns? What is the difference between a static-linked executable program and a dynamically-linked executable EXECVE system call return?  Second, the experimental content first, enter the experimental building programming environment, enter the Linuxkernel folder, delete the menu, and then clone a new copy.

Then, go to the menu folder and overwrite the test_exec.c test.c,make rootfs.

Then, come to size S, split the programming interface horizontally and start the GDB trace.

Next, the breakpoint is set: Sys_execve, Load_elf_binary, Start_thread. Then step through to the end.

Next, the list can be recalled for internal tracking to view the entry point address. Third, the experiment summary first creates a new process, and then the new process calls the EXECVE () system call executes the specified elf file, then calls the kernel's entry function Sys_execve (), the Sys_execve () service routine modifies the execution context of the current process, and after the system call terminates, The new process starts executing the code placed in the executable file, which is the ability to display the file in the current directory. When the Elf is load_elf_binary () loaded, the function returns to Do_execve () in return to Sys_execve (). The entry point of the Elf executable depends on how the program is linked, and for statically linked executables, if statically linked, Elf_entry is pointing to the header specified in the executable, that is, where the main function corresponds, and if the executable is dependent on other dynamic link libraries, The elf_entry is the starting point for the dynamic linker.

How the Linux kernel loads and launches an executable program

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.