<div class="gmail_quote">On Mon, Aug 8, 2011 at 11:21 AM, Abu Rasheda <span dir="ltr"><<a href="mailto:rcpilot2010@gmail.com">rcpilot2010@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>- grep kallsyms_lookup from /proc/kallsyms (it is there on SL 5.5 and SL 6.0. You can edit your program and assign something like:<br>
<br>int (*my_kallsyms_lookup_name)(const char *name) = (void *) KALLSYMS;<br><br>where KALLSYMS is address found above, or your loading script can feed this address. </div></div></blockquote><div> </div></div></div><div>
This is what i am currently doing but i need a cleaner way of doing this. <br></div></div></blockquote><div><br></div></div><div>Sometime, this is only thing you have, and this is pretty clean. You can write a script, which could pass module parameter for the address of the function. </div>
<div class="im">
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>
<br></div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div class="gmail_quote"><div>if your kernel is compiled with kprobe, you can use it to get address too.<br>
</div></div></blockquote></div><div><br>How do i do it using kprobes? To register a kprobe, i need the address of kallsyms_lookup_name which is what i want in the first place.</div></div></blockquote><div><br></div></div>
<div>
I think following should work.</div><div><br></div><div>
struct kprobe kp;</div><div><br></div><div>memset(&kp, 0, sizeof(kp));</div><div>kp.symbol_name = "kallsyms_lookup_name";</div><div>if (!register_kprobe(&kp))</div><div> {</div><div> my_kallsyms_lookup_name = (void *) kp.addr;</div>
<div> unregister_kprobe(&kp);</div><div> } </div></div></blockquote><div><br></div><div>Thanks. This is what i needed. Worked like a charm.! </div></div><br>