File: defaultmod1.c

package info (click to toggle)
glibc 2.28-10
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 272,168 kB
  • sloc: ansic: 1,008,602; asm: 259,607; makefile: 11,271; sh: 10,477; python: 6,910; cpp: 4,992; perl: 2,258; awk: 2,005; yacc: 290; pascal: 182; sed: 73
file content (64 lines) | stat: -rw-r--r-- 1,377 bytes parent folder | download | duplicates (45)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <dlfcn.h>
#include <stdio.h>

extern int found_in_mod1 (void);
int
found_in_mod1 (void)
{
  return 1;
}


extern int test_in_mod1 (int (*mainp)(int, char **));
int
test_in_mod1 (int (*mainp)(int, char **))
{
  int (*ifp) (void);
  void *p;
  int result = 0;

  /* Find function `main'.  */
  p = dlsym (RTLD_DEFAULT, "main");
  if (p == NULL)
    {
      printf ("%s: main not found\n", __FILE__);
      result = 1;
    }
  else if ((int (*)(int, char **))p != mainp)
    {
      printf ("%s: wrong address returned for main\n", __FILE__);
      result = 1;
    }
  else
    printf ("%s: main correctly found\n", __FILE__);

  ifp = dlsym (RTLD_DEFAULT, "found_in_mod1");
  if ((void *) ifp == NULL)
    {
      printf ("%s: found_in_mod1 not found\n", __FILE__);
      result = 1;
    }
  else if (ifp () != 1)
    {
      printf ("%s: wrong address returned for found_in_mod1\n", __FILE__);
      result = 1;
    }
  else
    printf ("%s: found_in_mod1 correctly found\n", __FILE__);

  ifp = dlsym (RTLD_DEFAULT, "found_in_mod2");
  if ((void *) ifp == NULL)
    {
      printf ("%s: found_in_mod2 not found\n", __FILE__);
      result = 1;
    }
  else if (ifp () != 2)
    {
      printf ("%s: wrong address returned for found_in_mod2\n", __FILE__);
      result = 1;
    }
  else
    printf ("%s: found_in_mod2 correctly found\n", __FILE__);

  return result;
}