]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - libctf/testsuite/libctf-regression/nonstatic-var-section-ld-r.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 both 'foo' and 'bar' as variables, even though one
30 of them is nonstatic: in a full link this should be erased, but this is an
33 if ((foo_type
= ctf_lookup_variable (fp
, "foo")) == CTF_ERR
)
34 printf ("Cannot look up foo\n", ctf_errmsg (ctf_errno (fp
)));
36 printf ("foo is of type %lx\n", foo_type
);
38 if ((bar_type
= ctf_lookup_variable (fp
, "bar")) == CTF_ERR
)
39 printf ("Cannot look up bar\n", ctf_errmsg (ctf_errno (fp
)));
41 printf ("bar is of type %lx\n", bar_type
);
43 /* Traverse the entire data object section and make sure it contains entries
44 for both foo and bar. (This is pure laziness: the section is small and
45 ctf_lookup_by_symbol_name does not yet exist.) */
46 while ((sym_type
= ctf_symbol_next (fp
, &i
, &name
, 0)) != CTF_ERR
)
51 if (strcmp (name
, "foo") == 0)
53 if (strcmp (name
, "bar") == 0)
56 if (ctf_errno (fp
) != ECTF_NEXT_END
)
57 fprintf (stderr
, "Unexpected error iterating over symbols: %s\n",
58 ctf_errmsg (ctf_errno (fp
)));
61 printf ("foo missing from the data object section\n");
63 printf ("bar missing from the data object section\n");
71 fprintf (stderr
, "%s: cannot open: %s\n", argv
[0], ctf_errmsg (err
));