| 1 |
/* usymbol test case |
| 2 |
* Copyright (C) 2008, Red Hat Inc. |
| 3 |
* |
| 4 |
* This file is part of systemtap, and is free software. You can |
| 5 |
* redistribute it and/or modify it under the terms of the GNU General |
| 6 |
* Public License (GPL); either version 2, or (at your option) any |
| 7 |
* later version. |
| 8 |
* |
| 9 |
* Uses signal to tranfer user space addresses into the kernel where a |
| 10 |
* probe on sigaction will extract them and produce the symbols. To |
| 11 |
* poke into the executable we get the sa_handler from the main executable, |
| 12 |
* and then the library through calling signal. |
| 13 |
* |
| 14 |
* FIXME. We call into the library to get the right symbol. If we |
| 15 |
* register the handler from the main executable. We need to handle |
| 16 |
* @plt symbols (setting a handler in the main executable that is in a |
| 17 |
* shared library will have the @plt address, not the address inside |
| 18 |
* the shared library). |
| 19 |
*/ |
| 20 |
|
| 21 |
#include <signal.h> |
| 22 |
typedef void (*sighandler_t)(int); |
| 23 |
|
| 24 |
// function from our library |
| 25 |
int lib_main (void); |
| 26 |
|
| 27 |
void |
| 28 |
main_handler (int signum) |
| 29 |
{ |
| 30 |
/* dummy handler, just used for the address... */ |
| 31 |
} |
| 32 |
|
| 33 |
int |
| 34 |
main (int argc, char *argv[], char *envp[]) |
| 35 |
{ |
| 36 |
// Use SIGFPE since we never expect that to be triggered. |
| 37 |
signal(SIGFPE, main_handler); |
| 38 |
lib_main(); |
| 39 |
return 0; |
| 40 |
} |