Forking and Executing the Process
To create a process using BSD system calls, your process must call the fork system call. The fork call creates a logical copy of your process, then returns the ID of the new process to your process. Both the original process and the new process continue executing from the call to fork; the only difference is that fork returns the ID of the new process to the original process and zero to the new process. (The fork function returns -1 to the original process and sets errno to a specific error value if the new process could not be created.)
To run a different executable, your process must call the execve system call with a pathname specifying the location of the alternate executable. The execve call replaces the program currently in memory with a different executable file.
A Mach-O executable file contains a header consisting of a set of load commands. For programs that use shared libraries or frameworks, one of these commands specifies the location of the linker to be used to load the program. If you use Xcode, this is always /usr/lib/dyld, the standard Mac OS X dynamic linker.
When you call the execve routine, the kernel first loads the specified program file and examines the mach_header structure at the start of the file. The kernel verifies that the file appear to be a valid Mach-O file and interprets the load commands stored in the header. The kernel then loads the dynamic linker specified by the load commands into memory and executes the dynamic linker on the program file.
The dynamic linker loads all the shared libraries that the main program links against (the dependent libraries) and binds enough of the symbols to start the program. It then calls the entry point function. At build time, the static linker adds the standard entry point function to the main executable file from the object file /usr/lib/crt1.o. This function sets up the runtime environment state for the kernel and calls static initializers for C++ objects, initializes the Objective-C runtime, and then calls the program’s main function.
http://www.cs.miami.edu/home/burt/learning/Csc521.091/docs/MachOTopics.pdf
相关文章
- node - DeprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `use
- SVN更新报错问题(Please execute the 'Cleanup' command)
- Performs the analysis process on a text and return the tokens breakdown of the text
- Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
- [git] git遇到的问题Please make sure you have the correct access rights and the repository exists.”
- [React] Use the useReducer Hook and Dispatch Actions to Update State (useReducer, useMemo, useEffect)
- [ES6] The Iterator Protocol
- [HTTPS] MAN IN THE MIDDLE (MITM)
- The nodes should be added to the underlying vendor clusterware before adding them to the CRS cluster
- linux下vi操作Found a swap file by the name
- [CSS 3] Enabling CSS manipulation inside the shadow DOM using the part pseudo class
- [NgRx] Setting up NgRx Router Store and the Time-Travelling Debugger
- [Angular] Control the dependency lookup with @Host, @Self, @SkipSelf and @Optional
- [Unit Testing] Set the timeout of a Test in Mocha
- [NativeScript] Style NativeScript views using the default core theme
- Initializer provides no value for this binding element and the binding element has no default value
- Unexpected XML declaration. The XML declaration must be the first node in the document and no white
- 【36.86%】【codeforces 558B】Amr and The Large Array
- 【codeforces 767B】The Queue
- 【codeforces 602E】Kleofáš and the n-thlon
- Paper:《The Illustrated Transformer》翻译与解读
- 成功解决404 Not Found Not Found The requested URL was not found on the server. If yo
- 已解决ERROR: Could not find a version that satisfies the requirement opencv-python4.5.5.62A (from versi
- 已解决ValueError: Of the four parameters: start, end, periods, and freq, exactly three must be specifie
- The difference between the request time and the current time is too large.阿里云oss上传图片报错
- hdu 1028 Ignatius and the Princess III
- POJ 3311 Hie with the Pie(状压DP + Floyd)
- hdu 4869 Turn the pokers
- UVA10056 - What is the Probability ?(概率)
- Nginx报错Mixed Content: The page was loaded over HTTPS, This content should also be served over https
- 转载:Introducing the software testing ice-cream cone (anti-pattern)
- Your configuration specifies to merge with the ref
- 【异常】Flyway failed to initialize: none of the following migration scripts locations could be found
- The differences between Docker, containerd, CRI-O and runc