GNU Binutils with patches for OS216
修訂 | cb2b796c8599a961f0104900e1902026b393de3d (tree) |
---|---|
時間 | 2019-09-24 22:06:32 |
作者 | Nick Alcock <nick.alcock@orac...> |
Commiter | Nick Alcock |
libctf: get the encoding of non-ints/fps in the dynamic space right
If you call ctf_type_encoding() on a slice, you are meant to get the
encoding of the slice with the format of the underlying type. If
you call it on a non-int, non-fp, non-slice, you're meant to get the
error ECTF_INTNOTFP.
None of this was implemented for types in the dynamic space (which, now,
is *all* types in writable containers). Instead, we were always
returning the encoding as if it were a float, which for all other types
consulted the wrong part of a discriminated union and returned garbage.
(Curiously, existing users were more disturbed by the lack of an error
in the non-int/fp/slice case than they were about getting garbage back.)
libctf/
* ctf-types.c (ctf_type_encoding): Fix the dynamic case to
work right for non-int/fps.
@@ -1,3 +1,8 @@ | ||
1 | +2019-08-09 Nick Alcock <nick.alcock@oracle.com> | |
2 | + | |
3 | + * ctf-types.c (ctf_type_encoding): Fix the dynamic case to | |
4 | + work right for non-int/fps. | |
5 | + | |
1 | 6 | 2019-08-08 Nick Alcock <nick.alcock@oracle.com> |
2 | 7 | |
3 | 8 | * ctf-types.c (ctf_type_name): Don't strlen a potentially- |
@@ -739,7 +739,27 @@ ctf_type_encoding (ctf_file_t *fp, ctf_id_t type, ctf_encoding_t *ep) | ||
739 | 739 | |
740 | 740 | if ((dtd = ctf_dynamic_type (ofp, type)) != NULL) |
741 | 741 | { |
742 | - *ep = dtd->dtd_u.dtu_enc; | |
742 | + switch (LCTF_INFO_KIND (fp, tp->ctt_info)) | |
743 | + { | |
744 | + case CTF_K_INTEGER: | |
745 | + case CTF_K_FLOAT: | |
746 | + *ep = dtd->dtd_u.dtu_enc; | |
747 | + break; | |
748 | + case CTF_K_SLICE: | |
749 | + { | |
750 | + const ctf_slice_t *slice; | |
751 | + ctf_encoding_t underlying_en; | |
752 | + slice = &dtd->dtd_u.dtu_slice; | |
753 | + | |
754 | + data = ctf_type_encoding (fp, slice->cts_type, &underlying_en); | |
755 | + ep->cte_format = underlying_en.cte_format; | |
756 | + ep->cte_offset = slice->cts_offset; | |
757 | + ep->cte_bits = slice->cts_bits; | |
758 | + break; | |
759 | + } | |
760 | + default: | |
761 | + return (ctf_set_errno (ofp, ECTF_NOTINTFP)); | |
762 | + } | |
743 | 763 | return 0; |
744 | 764 | } |
745 | 765 |