What does "_dyld_start" mean in my profiling results?

I am profiling C ++ code with callgrind

. This is my first time. I find that the highest level function (the one that I assume triggers all the shots to run the running program) is called _dyld_start

. I'm wondering what exactly it is.

Also, in some of my time-consuming programs, my function main()

takes about 99% of the time of all the functions called _dyld_start

; however, in my program that takes a shorter time (about half a second), I find it main()

takes about 85% of the time _dyld_start

, the rest is dyldbootstrap::start()

. I assume this is a function related to running a C ++ program. Is it reasonable for it to take 85% of the time _dyld_start

?

I am compiling my code using the C ++ 11 standard. I am compiling my OS / X so I am using clang

. My version valgrind

is 3.10.0.

+3


source to share


1 answer


Joshua, any high main function is part of C run-time support (broadly speaking); and if the name of such functions includes "ld" or "dyld", they are part of the dynamic linker .

OSX does not support statically linked applications ( fooobar.com/questions/191760 / ... ), so every executable cannot be loaded without the required shared libraries. The dynamic linker downloads the executable, parses it for the required shared libraries, and loads them. The linker then has to link the library and the executable together (by populating / editing some tables in memory) and only then can it transfer control to the _start

CRT entry point and then to main

.

Executing Mach-O Files, https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html



The Mach-O executable 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 that will be used to load the program. If you are using Xcode, this is always / usr / lib / dyld, the standard OS X dynamic linker.

Dyld man (lists some debug variables for debugging dyld work): https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html

Dyld post: https://www.mikeash.com/pyblog/friday-qa-2012-11-09-dyld-dynamic-linking-on-os-x.html 2012-11-09: dyld: Dynamic linking with OS X Gwynne Ruskind ("What's Still Doing?")

+2


source







All Articles