public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/8] libctf, dump: do not emit size or alignment if it would error
@ 2021-03-24  1:21 Nick Alcock
  2021-03-24  1:21 ` [PATCH 2/8] include: always do unsigned left-shift in CTF_SET_STID Nick Alcock
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Nick Alcock @ 2021-03-24  1:21 UTC (permalink / raw)
  To: binutils

When we dump normal types, we emit their size and/or alignment:
but size and alignment dumping can return errors if the type is
part of a chain that terminates in a forward.

Emitting 0xffffffff as a size or alignment is unhelpful, so simply
skip emitting this info for any type for which size or alignment
checks return an error, no matter what the error is.

libctf/ChangeLog
2021-03-23  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-dump.c (ctf_dump_format_type): Don't emit size or alignment
	on error.
---
 libctf/ctf-dump.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index 8540212eadd..bd9b50d9479 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -100,6 +100,7 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
       ctf_encoding_t ep;
       ctf_arinfo_t ar;
       int kind, unsliced_kind;
+      ssize_t size, align;
       const char *nonroot_leader = "";
       const char *nonroot_trailer = "";
       const char *idstr = "";
@@ -180,10 +181,10 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
 	  bit = NULL;
 	}
 
-      if (kind != CTF_K_FUNCTION && kind != CTF_K_FORWARD)
+      size = ctf_type_size (fp, id);
+      if (kind != CTF_K_FUNCTION && size >= 0)
 	{
-	  if (asprintf (&bit, " (size 0x%lx)",
-			(unsigned long) ctf_type_size (fp, id)) < 0)
+	  if (asprintf (&bit, " (size 0x%lx)", (unsigned long int) size) < 0)
 	    goto oom;
 
 	  str = str_append (str, bit);
@@ -191,10 +192,11 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
 	  bit = NULL;
 	}
 
-      if (kind != CTF_K_FORWARD)
+      align = ctf_type_align (fp, id);
+      if (align >= 0)
 	{
 	  if (asprintf (&bit, " (aligned at 0x%lx)",
-			(unsigned long) ctf_type_align (fp, id)) < 0)
+			(unsigned long int) align) < 0)
 	    goto oom;
 
 	  str = str_append (str, bit);

base-commit: 70e958370c8f4dc3222b658a725571d8d2f5f98a
-- 
2.31.0.253.gdec51257f3


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-03-25 15:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24  1:21 [PATCH 1/8] libctf, dump: do not emit size or alignment if it would error Nick Alcock
2021-03-24  1:21 ` [PATCH 2/8] include: always do unsigned left-shift in CTF_SET_STID Nick Alcock
2021-03-24  1:21 ` [PATCH 3/8] libctf, serialize: functions with no args have a NULL dtd_vlen Nick Alcock
2021-03-24  1:21 ` [PATCH 4/8] libctf: make ctf_bfdopen_ctfsect a debugger entry point Nick Alcock
2021-03-24  1:21 ` [PATCH 5/8] libctf: don't dereference out-of-bounds locations in the qualifier hashtab Nick Alcock
2021-03-25  0:02   ` Hans-Peter Nilsson
2021-03-25 15:53     ` Nick Alcock
2021-03-24  1:21 ` [PATCH 6/8] libctf: fix memory leak in a test Nick Alcock
2021-03-24  1:21 ` [PATCH 7/8] libctf: fix ELF-in-BFD checks in the presence of ASAN Nick Alcock
2021-03-24  1:21 ` [PATCH 8/8] ld: do not rely on the exact size of the CTF symtypetabs in test results Nick Alcock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).