Linux kernel where is main




















With main you propably mean what main is to a program, namely its "entry point". From Linux Device Driver's 2nd Edition :. Whereas an application performs a single task from beginning to end, a module registers itself in order to serve future requests, and its "main" function terminates immediately. It should tell the kernel, "I'm not there anymore; don't ask me to do anything else. S assembly file and the main function is called from there by "calll main" instruction.

Here is that main function:. While the function name main is just a common convention there is no real reason to use it in kernel mode the linux kernel does have a main function for many architectures, and of course usermode linux has a main function. Note the OS runtime loads the main function to start an app, when an operating system boots there is no runtime, the kernel is simply loaded to a address by the boot loader which is loaded by the MBR which is loaded by the hardware.

So while a kernel may contain a function called main it need not be the entry point. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Does Linux kernel have main function? Ask Question. Asked 8 years, 3 months ago. Active 1 year, 1 month ago. Viewed 7k times. Does Kernel have main function? Improve this question. If no one knows the answer why you down vote my question?

With main you propably mean what main is to a program, namely its "entry point"? Despite the huge addition of new features over time, the amount of conditional compilation dropped significantly in 2. The addition of new features to the kernel has been greatly facilitated by this technique and there are no more hairy cross references all over the boot code. But as a side effect, 2. Another side effect of extensive use of ELF sections is that the final pass in compiling the kernel is not a conventional link pass as it used to be.

Every platform now defines exactly how to link the kernel image the vmlinux file by means of an ldscript file; the file is called vmlinux. Use of ld scripts is described in the standard documentation for the binutils package. There is yet another advantage to putting the initialization code into a special section.

Once initialization is complete, that code is no longer needed. Since this code has been isolated, the kernel is able to dump it and reclaim the memory it occupies. Although not trivial, proficient use of Unix tools is outside of the scope of this book.

Here is that main function: Found this code snippet from the kernel for Unix Version 6. For example:. Other "function-undefined" queries related to "Does Linux kernel have main function?

Why the redirect tag on ReactJS Router doesnt work? Hidden input does not pass the value to the server Why does an object from my Amazon S3 bucket load on my pc browser, but not the browser in my iphone browser? Nginx doesn't point to multiple react apps React Native firebase function doesn't fetch correctly under useEffect What does a reactjs app look like in production?

Item doesn't get deleted after launching. Related Questions. How to delete X number of files in a directory Grep issues when using two files - I've tried everything Linux API to determine sockets owned by a process Node. How to use regular expressions in wget for rejecting files? A system programmer defines each OS has its own method the connection between a device, a load module that functions as the device's driver, and the name of the entry point in the load module.

By the time you are writing kernel code you have long moved past the requirement to name every module you write as main. Found this code snippet from the kernel for Unix Version 6. As you can see main is just another program, trying to get started! It is the first arch independent code to run, and sets up a large part of the kernel. TODO how is that address reached exactly? I have to understand the interface Linux exposes to bootloaders. That is the very first x86 kernel code that runs.



0コメント

  • 1000 / 1000