diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2021-03-18 12:37:52 +0000 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2021-03-18 12:40:41 +0000 |
commit | 69a284867c7c92960653cbeab6f79cd815f1342f (patch) | |
tree | b48c8b256ea735b8fe62da5019c550bc1357667b /libctf/ctf-dump.c | |
parent | e4c78f303df55b3dfc5746c8d1817cc0df1b76c3 (diff) | |
download | fsf-binutils-gdb-69a284867c7c92960653cbeab6f79cd815f1342f.zip fsf-binutils-gdb-69a284867c7c92960653cbeab6f79cd815f1342f.tar.gz fsf-binutils-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-dump.c')
-rw-r--r-- | libctf/ctf-dump.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index 409626a..8540212 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -142,7 +142,10 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag) unsliced_kind = ctf_type_kind_unsliced (fp, id); kind = ctf_type_kind (fp, id); - if (ctf_type_encoding (fp, id, &ep) == 0) + /* Report encodings of everything with an encoding other than enums: + base-type enums cannot have a nonzero cte_offset or cte_bits value. + (Slices of them can, but they are of kind CTF_K_SLICE.) */ + if (unsliced_kind != CTF_K_ENUM && ctf_type_encoding (fp, id, &ep) == 0) { if ((ssize_t) ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT && flag & CTF_FT_BITFIELD) |