Guest User

Untitled

a guest
Feb 14th, 2012
130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <os.h>
  2.  
  3. int f(void) {
  4.     return 42;
  5. }
  6.  
  7. typedef struct type1_t {
  8.     const char *name;
  9.     const char *desc;
  10.     int (*fp)(void);
  11. } type1_t;
  12.  
  13. type1_t DUMMY_bootstrap = {"foobar", "foobar bootstrap", f};
  14.  
  15. extern type1_t DUMMY_bootstrap;
  16.  
  17. static type1_t *bootstrap[] = {
  18.     &DUMMY_bootstrap,
  19.     NULL
  20. };
  21.  
  22. int main(void) {
  23.     nl_relocdata((unsigned int *)bootstrap, 1);
  24.     nl_relocdata((unsigned int *)&bootstrap[0]->name, 1);
  25.     nl_relocdata((unsigned int *)&bootstrap[0]->desc, 1);
  26.     nl_relocdata((unsigned int *)&bootstrap[0]->fp, 1); /* This doesn't seem to work as it fails at line 29 */
  27.     printf("bootstrap[0]->name: %s\n", bootstrap[0]->name);
  28.     printf("bootstrap[0]->desc: %s\n", bootstrap[0]->desc);
  29.     printf("bootstrap[0]->fp(): %d\n", bootstrap[0]->fp()); /* Does not work */
  30.     return 0;
  31. }
RAW Paste Data