• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2000, 2002 Red Hat, Inc.
2    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
3 
4    This program is Open Source software; you can redistribute it and/or
5    modify it under the terms of the Open Software License version 1.0 as
6    published by the Open Source Initiative.
7 
8    You should have received a copy of the Open Software License along
9    with this program; if not, you may obtain a copy of the Open Software
10    License version 1.0 from http://www.opensource.org/licenses/osl.php or
11    by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
12    3001 King Ranch Road, Ukiah, CA 95482.   */
13 
14 #include <nlist.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 
18 
19 int var = 1;
20 
21 int bss;
22 
23 
24 int
foo(int a)25 foo (int a)
26 {
27   return a;
28 }
29 
30 int
main(int argc,char * argv[])31 main (int argc, char *argv[])
32 {
33   struct nlist nl[6] =
34   {
35     [0] = { .n_name = "var" },
36     [1] = { .n_name = "bss" },
37     [2] = { .n_name = "main" },
38     [3] = { .n_name = "foo" },
39     [4] = { .n_name = "not-there" },
40     [5] = { .n_name = NULL },
41   };
42   int cnt;
43   int result = 0;
44 
45   if (nlist (".libs/test-nlist", nl) != 0
46       && nlist ("./test-nlist", nl) != 0)
47     {
48       puts ("nlist failed");
49       exit (1);
50     }
51 
52   for (cnt = 0; nl[cnt].n_name != NULL; ++cnt)
53     {
54       if (argc > 1)
55 	/* For debugging.  */
56 	printf ("nl[%d].n_name = \"%s\"\n"
57 		"nl[%d].n_value = %ld\n"
58 		"nl[%d].n_scnum = %d\n"
59 		"nl[%d].n_type = %u\n"
60 		"nl[%d].n_sclass = %d\n"
61 		"nl[%d].n_numaux = %d\n\n",
62 		cnt, nl[cnt].n_name,
63 		cnt, nl[cnt].n_value,
64 		cnt, nl[cnt].n_scnum,
65 		cnt, nl[cnt].n_type,
66 		cnt, nl[cnt].n_sclass,
67 		cnt, nl[cnt].n_numaux);
68 
69       if ((cnt != 4 && nl[cnt].n_value == 0 && nl[cnt].n_scnum == 0
70 	   && nl[cnt].n_type == 0 && nl[cnt].n_sclass == 0
71 	   && nl[cnt].n_numaux == 0)
72 	  || (cnt == 4 && (nl[cnt].n_value != 0 || nl[cnt].n_scnum != 0
73 			   || nl[cnt].n_type != 0 || nl[cnt].n_sclass != 0
74 			   || nl[cnt].n_numaux != 0)))
75 	result = 1;
76     }
77 
78   return foo (result);
79 }
80