public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Fix Ada representation of r_debug and link_map types
@ 2023-05-16  8:40 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-05-16  8:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: Marc Poulhiès

Both record types need to have their components 'aliased' to match their
C version. The mismatch could be observed when using LTO:

  warning: type of 'r_debug' does not match original declaration
       [-Wlto-type-mismatch]

  /usr/include/link.h:66:23: note: type 'struct r_debug' should match
  type 'struct  system__traceback__symbolic__module_name__build_...
   ...cache_for_all_modules__r_debug_type'

gcc/ada/

	* libgnat/s-tsmona__linux.adb (link_map, r_debug_type): Add
	'aliased' on all components.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/s-tsmona__linux.adb | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/libgnat/s-tsmona__linux.adb b/gcc/ada/libgnat/s-tsmona__linux.adb
index 7e1b493c991..6b539f13c16 100644
--- a/gcc/ada/libgnat/s-tsmona__linux.adb
+++ b/gcc/ada/libgnat/s-tsmona__linux.adb
@@ -93,23 +93,30 @@ package body Module_Name is
       pragma Convention (C, link_map_acc);
 
       type link_map is record
-         l_addr : Address;
+         l_addr : aliased Address;
          --  Base address of the shared object
 
-         l_name : Address;
+         l_name : aliased Address;
          --  Null-terminated absolute file name
 
-         l_ld   : Address;
+         l_ld   : aliased Address;
          --  Dynamic section
 
-         l_next, l_prev : link_map_acc;
+         l_next, l_prev : aliased link_map_acc;
          --  Chain
       end record;
       pragma Convention (C, link_map);
 
+      type r_debug_state is (RT_CONSISTENT, RT_ADD, RT_DELETE);
+      pragma Convention (C, r_debug_state);
+      pragma Unreferenced (RT_CONSISTENT, RT_ADD, RT_DELETE);
+
       type r_debug_type is record
-         r_version : Integer;
-         r_map : link_map_acc;
+         r_version : aliased int;
+         r_map     : aliased link_map_acc;
+         r_brk     : aliased Address;
+         r_state   : aliased r_debug_state;
+         r_ldbase  : aliased Address;
       end record;
       pragma Convention (C, r_debug_type);
 
-- 
2.40.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-16  8:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16  8:40 [COMMITTED] ada: Fix Ada representation of r_debug and link_map types Marc Poulhiès

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).