> Hi,
> From the source code, I know how SDT works.
> [i]The SDT mechanism works by replacing calls to the undefined routine
> __dtrace_probe_[name] with nop instructions. The relocations are
> logged, and SDT itself will later patch the running binary appropriately.
> [/i]
>
> However, dynamic linker is in unix module. So I have the question, how unix
> module support SDT? Does dtracestubs.s relate to this feature?
>
> Thanks,
>
> Jun Su
The dynamic linker for the kernel isn''t actually in unix, it''s
in "krtld",
which is a separate module. At boot time, the boot loader loads unix,
loads krtld because krtld is unix''s ELF PT_INTERP program, and then
loads
genunix because it''s a DT_NEEDED of unix. But control begins in krtld
(analogous to how in userland control begins in ld.so.1 not a.out)
Once krtld gets control, it relocates all of the primary modules (unix,
genunix, and itself) and then transfers control to the kernel''s _start.
So SDT probes in the unix module are relocated by krtld just as they are
for any other module.
dtracestubs.s is something Bryan and I cooked up to retain the property of
the kernel build that we don''t permit unresolved symbols among the
primaries
at *build* time, which is really important because otherwise kernel developers
could introduce calls to missing functions into the source code and then you
wouldn''t realize this until you had booted your kernel and krtld would
die.
So what we do is we do a link test with ld during the kernel build among
unix, genunix, platmod (if any), and cpumod to ensure this doesn''t
happen.
Since the SDT mechanism introduced this idea of calls to these undefined
__dtrace_probe routines, this fails the link test. So the purpose of
dtracestubs is that it acts like an object file which contains an empty
function and function symbol for each SDT __dtrace_probe which we can add to
the kernel''s link rule at build time to ensure all symbols are
resolvable.
The dtracestubs file itself is auto-generated by the kernel Makefiles.
-Mike
--
Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/