[COMMITTED] ada: Fix Ada representation of r_debug and link_map types

Message ID 20230516084048.1501804-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Fix Ada representation of r_debug and link_map types |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès May 16, 2023, 8:40 a.m. UTC
  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(-)
  

Patch

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