Glitch in ctfconvert

Shrikanth Kamath shrikanth07 at gmail.com
Fri Sep 6 23:49:57 UTC 2013


There is a glitch with ctfconvert builds the .SUNW_ctf section. It affects
debugging the kernel modules with FBT provider of DTrace.

I observe that the CTF sections built for the kernel modules have a
problem if module symtab stripped or if the symbol table has symbols
reordered. This messes up the FBT probes and shows wrong function name against a
set of arguments.

I presume the ctf mapping of a function to its arguments is done this way after
looking at ctfdump code.

func_name from symtab           arguments dump from ctf_data_t
         ^                                                        ^
         |___symidx____ctfdump_____________|

The detais are fetched from two different places. So when ctfconvert is run the
function arguments are mapped with a particular symbol order.

Post the linker stage the symbols may get reordered. Or if a strip utility is
run the symtab may be removed completely.

When first ctfconvert is run on module.kld
        symbol_X (idx 1)        <-> [args set a in ctf_data_t]
        symbol_Y (idx 2)        <-> [args set b in ctf_data_t]

if symbols get re-arranged post the linker stage

        symbol_Y (idx 1)        <-> [args set a in ctf_data_t]
        symbol_X (idx 2)        <-> [args set b in ctf_data_t]

which means symbol_Y now has args set of symbol_X
Or if 'strip' is run it has totally junk shown against symbol_Y and symbol_X.

Overall this affects when we do a Function Boundary Tracing on the functions to
inspect arguments.


More information about the freebsd-hackers mailing list