diff options
-rw-r--r-- | ld/ChangeLog | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-ctf/nonrepresentable-member.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-ctf/nonrepresentable-member.d | 25 | ||||
-rw-r--r-- | libctf/ChangeLog | 4 | ||||
-rw-r--r-- | libctf/ctf-types.c | 19 |
5 files changed, 53 insertions, 6 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 470e446..c613b39 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,9 @@ 2021-10-25 Nick Alcock <nick.alcock@oracle.com> + * testsuite/ld-ctf/nonrepresentable-member.*: New test. + +2021-10-25 Nick Alcock <nick.alcock@oracle.com> + * testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf. * testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise. diff --git a/ld/testsuite/ld-ctf/nonrepresentable-member.c b/ld/testsuite/ld-ctf/nonrepresentable-member.c new file mode 100644 index 0000000..b3657af --- /dev/null +++ b/ld/testsuite/ld-ctf/nonrepresentable-member.c @@ -0,0 +1,7 @@ +struct blah +{ + int boring; + int __attribute__((vector_size(8))) foo; + const int __attribute__((vector_size(8))) bar; + int this_is_printed; +} wibble __attribute__((__used__)); diff --git a/ld/testsuite/ld-ctf/nonrepresentable-member.d b/ld/testsuite/ld-ctf/nonrepresentable-member.d new file mode 100644 index 0000000..6c76253 --- /dev/null +++ b/ld/testsuite/ld-ctf/nonrepresentable-member.d @@ -0,0 +1,25 @@ +#as: +#source: nonrepresentable-member.c +#objdump: --ctf +#ld: -shared +#name: Nonrepresentable members + +.*: +file format .* + +Contents of CTF section .ctf: + + Header: + Magic number: 0xdff2 + Version: 4 \(CTF_VERSION_3\) +#... + Types: +#... + 0x[0-9a-f]*: \(kind 6\) struct blah .* + *\[0x0\] boring: ID 0x[0-9a-f]*: \(kind 1\) int .* + *\[0x[0-9a-f]*\] foo: .* \(.*represent.*\) + *\[0x[0-9a-f]*\] bar: .* \(.*represent.*\) + *\[0x[0-9a-f]*\] this_is_printed: ID 0x[0-9a-f]*: \(kind 1\) int .* +#... + + Strings: +#... diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 879e128..245987f 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,5 +1,9 @@ 2021-10-25 Nick Alcock <nick.alcock@oracle.com> + * ctf-types.c (ctf_type_rvisit): Handle nonrepresentable types. + +2021-10-25 Nick Alcock <nick.alcock@oracle.com> + * ctf-dump.c (ctf_dump_type): Do not abort on error. 2021-09-27 Nick Alcock <nick.alcock@oracle.com> diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c index 243de93..5583485 100644 --- a/libctf/ctf-types.c +++ b/libctf/ctf-types.c @@ -1641,20 +1641,27 @@ ctf_type_rvisit (ctf_dict_t *fp, ctf_id_t type, ctf_visit_f *func, unsigned char *vlen; ssize_t size, increment, vbytes; uint32_t kind, n, i = 0; + int nonrepresentable = 0; int rc; - if ((type = ctf_type_resolve (fp, type)) == CTF_ERR) - return -1; /* errno is set for us. */ + if ((type = ctf_type_resolve (fp, type)) == CTF_ERR) { + if (ctf_errno (fp) != ECTF_NONREPRESENTABLE) + return -1; /* errno is set for us. */ + else + nonrepresentable = 1; + } - if ((tp = ctf_lookup_by_id (&fp, type)) == NULL) - return -1; /* errno is set for us. */ + if (!nonrepresentable) + if ((tp = ctf_lookup_by_id (&fp, type)) == NULL) + return -1; /* errno is set for us. */ if ((rc = func (name, otype, offset, depth, arg)) != 0) return rc; - kind = LCTF_INFO_KIND (fp, tp->ctt_info); + if (!nonrepresentable) + kind = LCTF_INFO_KIND (fp, tp->ctt_info); - if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) + if (nonrepresentable || (kind != CTF_K_STRUCT && kind != CTF_K_UNION)) return 0; ctf_get_ctt_size (fp, tp, &size, &increment); |