aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-types.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2021-03-18 12:37:52 +0000
committerNick Alcock <nick.alcock@oracle.com>2021-03-18 12:40:41 +0000
commit69a284867c7c92960653cbeab6f79cd815f1342f (patch)
treeb48c8b256ea735b8fe62da5019c550bc1357667b /libctf/ctf-types.c
parente4c78f303df55b3dfc5746c8d1817cc0df1b76c3 (diff)
downloadgdb-69a284867c7c92960653cbeab6f79cd815f1342f.zip
gdb-69a284867c7c92960653cbeab6f79cd815f1342f.tar.gz
gdb-69a284867c7c92960653cbeab6f79cd815f1342f.tar.bz2
libctf: support encodings for enums
The previous commit started to error-check the lookup of ctf_type_encoding for the underlying type that is internally done when carrying out a ctf_type_encoding on a slice. Unfortunately, enums have no encoding, so this has historically been returning an error (which is ignored) and then populating the cte_format with uninitialized data. Now the error is not ignored, this is returning an error, which breaks linking of CTF containing bitfields of enumerated type. CTF format v3 does not record the actual underlying type of a enum, but we can mock up something that is not *too* wrong, and that is at any rate better than uninitialized data. ld/ChangeLog 2021-03-18 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/slice.c: Check slices of enums too. * testsuite/ld-ctf/slice.d: Results adjusted. libctf/ChangeLog 2021-03-18 Nick Alcock <nick.alcock@oracle.com> * ctf-types.c (ctf_type_encoding): Support, after a fashion, for enums. * ctf-dump.c (ctf_dump_format_type): Do not report enums' degenerate encoding.
Diffstat (limited to 'libctf/ctf-types.c')
-rw-r--r--libctf/ctf-types.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c
index ed76eca..9afe06b 100644
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -1157,7 +1157,7 @@ ctf_type_pointer (ctf_dict_t *fp, ctf_id_t type)
return (ctf_set_errno (ofp, ECTF_NOTYPE));
}
-/* Return the encoding for the specified INTEGER or FLOAT. */
+/* Return the encoding for the specified INTEGER, FLOAT, or ENUM. */
int
ctf_type_encoding (ctf_dict_t *fp, ctf_id_t type, ctf_encoding_t *ep)
@@ -1194,6 +1194,12 @@ ctf_type_encoding (ctf_dict_t *fp, ctf_id_t type, ctf_encoding_t *ep)
ep->cte_offset = CTF_FP_OFFSET (data);
ep->cte_bits = CTF_FP_BITS (data);
break;
+ case CTF_K_ENUM:
+ /* v3 only: we must guess at the underlying integral format. */
+ ep->cte_format = CTF_INT_SIGNED;
+ ep->cte_offset = 0;
+ ep->cte_bits = 0;
+ break;
case CTF_K_SLICE:
{
const ctf_slice_t *slice;