]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ctf: Fix struct size truncation in 32-bit hosts [PR121903,PR121411]
authorDavid Faust <david.faust@oracle.com>
Mon, 15 Sep 2025 22:03:31 +0000 (15:03 -0700)
committerDavid Faust <david.faust@oracle.com>
Mon, 15 Sep 2025 22:14:59 +0000 (15:14 -0700)
The 'size' argument of ctf_add_sou was size_t.  After the prior fixes
for PR121411, this could cause the struct size to be truncated when
encoding extremely large structs on a host where size_t is smaller than
unsigned HOST_WIDE_INT, manifesting for example as the test failure
reported in PR121903.  Change the argument to uHWI to resolve the issue.

PR debug/121411
PR debug/121903

gcc/

* ctfc.h (ctf_add_sou): Change size arg from size_t to uHWI.
* ctfc.cc (ctf_add_sou): Likewise.

gcc/ctfc.cc
gcc/ctfc.h

index 51511d69baa01f000b82ca7e5b368f5743e28a63..221e62e8f45d6249db3753cb2bfc7b218c3748df 100644 (file)
@@ -798,7 +798,7 @@ ctf_add_function (ctf_container_ref ctfc, uint32_t flag, const char * name,
 
 ctf_dtdef_ref
 ctf_add_sou (ctf_container_ref ctfc, uint32_t flag, const char * name,
-            uint32_t kind, size_t size, dw_die_ref die)
+            uint32_t kind, unsigned HOST_WIDE_INT size, dw_die_ref die)
 {
   ctf_dtdef_ref dtd;
 
index 32c73be6a4120234cbe7f40846e8582abed19e3c..26f35f0ac6f92e72e5808123ef13a963b56e0634 100644 (file)
@@ -439,7 +439,7 @@ extern ctf_dtdef_ref ctf_add_function (ctf_container_ref, uint32_t,
                                       const char *, const ctf_funcinfo_t *,
                                       dw_die_ref, bool, int);
 extern ctf_dtdef_ref ctf_add_sou (ctf_container_ref, uint32_t, const char *,
-                                 uint32_t, size_t, dw_die_ref);
+                                 uint32_t, unsigned HOST_WIDE_INT, dw_die_ref);
 
 extern int ctf_add_enumerator (ctf_container_ref, ctf_dtdef_ref, const char *,
                               HOST_WIDE_INT, dw_die_ref);