Timeline for What system call is used to load libraries in Linux?
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 28, 2016 at 8:02 | comment | added | kasperd | @Melab The executable and the dynamic linker are not running as two separate applications. Both are mapped into a single address space by the kernel. When the kernel transfers control, it is a single process with code mapped from two files. If more libraries are needed (which is pretty much always the case for dynamically linked executables), there will soon be even more files mapped into the address space of this process. | |
| Feb 28, 2016 at 7:59 | comment | added | kasperd | @Melab Yes, the kernel is aware of the dynamic linker. The kernel will read the path to the dynamic linker from the header of the executable. And the kernel will map both into memory. I don't know whether the entry point which the kernel transfer control to at first is within linker or executable. If I was implementing it, I would probably have the kernel transfer control to an entry point in the linker with a return address on the stack pointing to the entry point of the executable. | |
| Feb 28, 2016 at 5:41 | comment | added | Melab | @kasperd So is the Linux kernel aware of the dynamic loader? Does it call it when application is run? Or does the application itself do that? If the latter, how does another executable have access to the application's memory? | |
| Sep 2, 2015 at 18:33 | comment | added | Johan | mmap as per this answer. Note also that after "open"-ing each library, some (832) bytes are read prior to the mmap call, I presume to check that the library is valid. | |
| Aug 31, 2015 at 17:55 | comment | added | kasperd | Since loading of libraries is done by a library function, I think it is relevant to add that the executable itself and ld-linux are mapped by the kernel as part of the execve system call. | |
| Aug 31, 2015 at 13:06 | comment | added | ysdx | "mmap() is really the critical part": And then the dynamic linker has to do the relocations, initialization and so one (but this is not seen at the system call level). | |
| Aug 31, 2015 at 7:42 | history | answered | Celada | CC BY-SA 3.0 |