]> Git Repo - binutils.git/blob - libctf/testsuite/libctf-regression/pptrtab.c
libctf, ld: fix symtypetab and var section population under ld -r
[binutils.git] / libctf / testsuite / libctf-regression / pptrtab.c
1 #include <ctf-api.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 int
6 main (int argc, char *argv[])
7 {
8   ctf_dict_t *fp;
9   ctf_archive_t *ctf;
10   ctf_next_t *i = NULL;
11   ctf_id_t type;
12   const char *arcname;
13   char *type_name;
14   int err;
15
16   if (argc != 2)
17     {
18       fprintf (stderr, "Syntax: %s PROGRAM\n", argv[0]);
19       exit(1);
20     }
21
22   if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL)
23     goto open_err;
24
25   /* Make sure we can look up a_t * by name in all non-parent dicts, even though
26      the a_t * and the type it points to are in distinct dicts; make sure we
27      cannot look up b_t *.  */
28
29   while ((fp = ctf_archive_next (ctf, &i, &arcname, 1, &err)) != NULL)
30     {
31       if ((type = ctf_lookup_by_name (fp, "a_t *")) == CTF_ERR)
32         goto err;
33
34       if ((ctf_lookup_by_name (fp, "b_t *")) != CTF_ERR ||
35           ctf_errno (fp) != ECTF_NOTYPE)
36         goto noerr;
37
38       if (ctf_type_reference (fp, type) == CTF_ERR)
39         goto err;
40
41       printf ("%s: a_t * points to a type of kind %i\n", arcname,
42               ctf_type_kind (fp, ctf_type_reference (fp, type)));
43
44       ctf_dict_close (fp);
45     }
46   if (err != ECTF_NEXT_END)
47     goto open_err;
48
49   ctf_close (ctf);
50
51   return 0;
52
53  open_err:
54   fprintf (stderr, "%s: cannot open: %s\n", argv[0], ctf_errmsg (err));
55   return 1;
56  err:
57   fprintf (stderr, "Lookup failed in %s: %s\n", arcname, ctf_errmsg (ctf_errno (fp)));
58   return 1;
59  noerr:
60   fprintf (stderr, "Lookup unexpectedly succeeded in %s\n", arcname);
61   return 1;
62 }
This page took 0.028618 seconds and 4 git commands to generate.