Does OS X have two linkers ? One static and one dynamic?
Asked Answered
L

1

7

The problem is, I've found out that Mac OS X has an dyld (as I understood a dynamic linker) but also a simple linker ld (as I understood a static one).

The question is: Is it really so ? Two linkers? One static and one dynamic ?

Why they've decided to have two ? Linux has only one linker (ld) which does both static and dynamic linking.

Langue answered 29/3, 2015 at 21:53 Comment(0)
D
7

You have misunderstood the meaning of "linking". Or, thought of another way, you haven't realized it has two meanings.

If it helps, think of dyld as the dynamic loader rather than "linker". dyld is the program which loads the dynamic libraries referenced by an executable into the process's address space. It still involves linking because it requires the resolution of symbol references.

You never invoke dyld as part of a build procedure. You always use ld or, more typically, you ask the compiler to link your program and it invokes ld on your behalf. dyld is only used at run time.

You're incorrect when you assert that Linux doesn't have this distinction. Linux has a dynamic loader, ld.so, which is distinct from the static linker, ld.

Durkee answered 29/3, 2015 at 23:1 Comment(3)
From the : man ld.so The programs ld.so and ld-linux.so* find and load the shared libraries needed by a program, prepare the program to run, and then run it. The difference between these 2 is that ld.so works with a.out old format and ld-linux.so with the newer ELF binary format. So we use the ld-linux.so when we click on our binary in order to execute it , then what kind of "ld" we use while compiling a certain module ? could you give me the path to this "ld" ?Equitable
@Equitable If you run which ld it will tell you.Hornbeam
I understand you don't invoke dyld in the build process. But ,do you ever have to invoke it during run time? And I suppose no variable is passed directly to dyld, instead you only export some environmental variables. Is that right?Sunderance

© 2022 - 2024 — McMap. All rights reserved.