blob: 679c911b951d9d20b68dd8c5d9dfb52304a81e2e [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Copyright (C) 2000, 2002, 2005 Red Hat, Inc.
Mark Wielaardde2ed972012-06-05 17:15:16 +02002 This file is part of elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00003 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
4
Mark Wielaardde2ed972012-06-05 17:15:16 +02005 This file is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00009
Mark Wielaardde2ed972012-06-05 17:15:16 +020010 elfutils is distributed in the hope that it will be useful, but
Ulrich Drepper361df7d2006-04-04 21:38:57 +000011 WITHOUT ANY WARRANTY; without even the implied warranty of
Mark Wielaardde2ed972012-06-05 17:15:16 +020012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000014
Mark Wielaardde2ed972012-06-05 17:15:16 +020015 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000017
18#include <nlist.h>
19#include <stdio.h>
20#include <stdlib.h>
21
22
23int var = 1;
24
25int bss;
26
27
28int
29foo (int a)
30{
31 return a;
32}
33
34int
35main (int argc, char *argv[] __attribute__ ((unused)))
36{
37 struct nlist nl[6] =
38 {
39 [0] = { .n_name = "var" },
40 [1] = { .n_name = "bss" },
41 [2] = { .n_name = "main" },
42 [3] = { .n_name = "foo" },
43 [4] = { .n_name = "not-there" },
44 [5] = { .n_name = NULL },
45 };
46 int cnt;
47 int result = 0;
48
49 if (nlist (".libs/test-nlist", nl) != 0
50 && nlist ("./test-nlist", nl) != 0)
51 {
52 puts ("nlist failed");
53 exit (1);
54 }
55
56 for (cnt = 0; nl[cnt].n_name != NULL; ++cnt)
57 {
58 if (argc > 1)
59 /* For debugging. */
60 printf ("nl[%d].n_name = \"%s\"\n"
61 "nl[%d].n_value = %ld\n"
62 "nl[%d].n_scnum = %d\n"
63 "nl[%d].n_type = %u\n"
64 "nl[%d].n_sclass = %d\n"
65 "nl[%d].n_numaux = %d\n\n",
66 cnt, nl[cnt].n_name,
67 cnt, nl[cnt].n_value,
68 cnt, nl[cnt].n_scnum,
69 cnt, nl[cnt].n_type,
70 cnt, nl[cnt].n_sclass,
71 cnt, nl[cnt].n_numaux);
72
73 if ((cnt != 4 && nl[cnt].n_value == 0 && nl[cnt].n_scnum == 0
74 && nl[cnt].n_type == 0 && nl[cnt].n_sclass == 0
75 && nl[cnt].n_numaux == 0)
76 || (cnt == 4 && (nl[cnt].n_value != 0 || nl[cnt].n_scnum != 0
77 || nl[cnt].n_type != 0 || nl[cnt].n_sclass != 0
78 || nl[cnt].n_numaux != 0)))
79 result = 1;
80 }
81
82 return foo (result);
83}