]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - libctf/testsuite/libctf-regression/nonstatic-var-section-ld.c
7 main (int argc
, char *argv
[])
11 ctf_id_t foo_type
, bar_type
, sym_type
;
12 int found_foo
= 0, found_bar
= 0;
19 fprintf (stderr
, "Syntax: %s PROGRAM\n", argv
[0]);
23 if ((ctf
= ctf_open (argv
[1], NULL
, &err
)) == NULL
)
26 if ((fp
= ctf_dict_open (ctf
, NULL
, &err
)) == NULL
)
29 /* Make sure we can look up only 'foo' as a variable: bar, being nonstatic,
30 should have been erased. */
32 if ((foo_type
= ctf_lookup_variable (fp
, "foo")) == CTF_ERR
)
33 printf ("Cannot look up foo\n", ctf_errmsg (ctf_errno (fp
)));
35 printf ("foo is of type %lx\n", foo_type
);
37 if ((bar_type
= ctf_lookup_variable (fp
, "bar")) == CTF_ERR
)
38 printf ("Cannot look up bar\n", ctf_errmsg (ctf_errno (fp
)));
40 printf ("bar is of type %lx\n", bar_type
);
42 /* Traverse the entire data object section and make sure it contains an entry
43 for bar alone. (This is pure laziness: the section is small and
44 ctf_lookup_by_symbol_name does not yet exist.) */
45 while ((sym_type
= ctf_symbol_next (fp
, &i
, &name
, 0)) != CTF_ERR
)
50 if (strcmp (name
, "foo") == 0)
53 printf ("Found foo in data object section with type %lx, "
54 "but it is static\n", sym_type
);
56 if (strcmp (name
, "bar") == 0)
59 if (ctf_errno (fp
) != ECTF_NEXT_END
)
60 fprintf (stderr
, "Unexpected error iterating over symbols: %s\n",
61 ctf_errmsg (ctf_errno (fp
)));
64 printf ("foo missing from the data object section\n");
66 printf ("bar missing from the data object section\n");
74 fprintf (stderr
, "%s: cannot open: %s\n", argv
[0], ctf_errmsg (err
));