Subject: RE: dynamic linker in NetBSD
To: None <netbsd-help@NetBSD.org>
From: Madhvesh R S <madhvesh.s@ap.sony.com>
List: netbsd-help
Date: 02/10/2004 15:21:59
Hi,

I am referring to NetBSD-v1.6
I executed one simple sin() function
in a test program and then ran ldd to check
what all shared libraries are used. I got
the following result

-lm.0 ==> /usr/lib/libm387.so.0
-lm.0 ==> /usr/lib/libm.so.0
-lc.12 ==> /usr/lib/libx.so.12


I am trying to understand the dynamic linker
of NetBSD and where it gets invoked. I summarize
my understanding of dynamic linker for ELF formats
as below

Sequence:
	NetBSD-Kernel->NetBSD-Loader->Application

1. NetBSD kernel :
	First loads the a.out into memory
	Then locates dynamic section
	Determines the loader using PT_INTERP (is this libexec_elf.so ??)
	maps the loader and constrcuts the aux-vector
	starts the loader program

2. NetBSD loader:
	First relocates self
	reads info from aux-vector
	loads the other libraries( in my sample like libm387, libm, libc)
	jumps to entry point specified in aux-vector

3. Application (a.out):
	If it makes dlopen() calls, this will be resolved by loader
(libexec_elf.so)
	dlopen() will not be resolved by libc. Is this correct?

Is my understanding of sequence of flow is correct?
If dlopen/dlsym, dlerr are part of libexec_elf.so, i am not
finding this shared library list in /usr/lib folder. Can
anyone tell me which library in the form .so form plays the
role of dynamic linker?

Thanks in advance
-MS


-----Original Message-----
From: Madhvesh Sulibhavi [mailto:madhvesh.s@ap.sony.com]
Sent: Friday, February 06, 2004 3:06 PM
To: Nick Hudson; netbsd-help@NetBSD.org
Subject: RE: dynamic linker in NetBSD


Hi,

Thanks for the reply.
I want to know the path in which NetBSD gcc compiler specs file will be
present. I think i need to modify this file to go ahead with my own
dynamic linker

-MS

-----Original Message-----
From: Nick Hudson [mailto:skrll@netbsd.org]
Sent: Friday, February 06, 2004 2:46 PM
To: Madhvesh Sulibhavi; netbsd-help@NetBSD.org
Subject: Re: dynamic linker in NetBSD


On Friday 06 February 2004 9:06 am, Madhvesh R S wrote:
> Hi,
>
> I am referring to NetBSD-v1.6. Can any one tell me which part of code
in
> libc folder implements the dynamic-linker for NetBSD?

Its not in the libc directory...

> I want to know the source path of this code in the distribution. Is
this
> similar to linux-glibc ld.so? But i am not finding equivalent ld.so in
> NetBSD system which can be used while executing any executbale (a.out)

... you want src/libexec/ld.aout_so or maybe src/libexec/ld.elf_so

> In NetBSD is it possible to provide another dynamic linker to gcc
compiler
> instead of default ld.so used for application execution?
> But i have one doubt.., in NetBSD ld.so i am not finding in /usr/lib
path,
> whether this is part of some other library name or it will be present
> in different path?

You can specify a different dynamic linker with the -dynamic-linker
gcc/ld
option.

HTH,
Nick