aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat/s-caun64.adb
diff options
context:
space:
mode:
authorDaniel King <dmking@adacore.com>2023-08-01 14:39:39 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-09-05 13:05:12 +0200
commitc416d2f768b73daa28d2fcd0c80656956ae9242c (patch)
treeefcdee05d34e631f9f9a7342c3f6753a37c5511e /gcc/ada/libgnat/s-caun64.adb
parent518f93c17983623107ff2091728c93b02fc0eeb2 (diff)
downloadgcc-c416d2f768b73daa28d2fcd0c80656956ae9242c.zip
gcc-c416d2f768b73daa28d2fcd0c80656956ae9242c.tar.gz
gcc-c416d2f768b73daa28d2fcd0c80656956ae9242c.tar.bz2
ada: Preserve capability validity in address arithmetic
On CHERI targets where System.Address is a capability, arithmetic on addresses should avoid converting to integers and instead use the operations defined in System.Storage_Elements to perform the arithmetic directly on the System.Address object. This preserves the capability's validity throughout the calculation, ensuring that the resulting capability can be dereferenced. gcc/ada/ * libgnat/s-carsi8.adb: Use operations from System.Storage_Elements for address arithmetic. * libgnat/s-carun8.adb: Likewise * libgnat/s-casi128.adb: Likewise * libgnat/s-casi16.adb: Likewise * libgnat/s-casi32.adb: Likewise * libgnat/s-casi64.adb: Likewise * libgnat/s-caun128.adb: Likewise * libgnat/s-caun16.adb: Likewise * libgnat/s-caun32.adb: Likewise * libgnat/s-caun64.adb: Likewise * libgnat/s-geveop.adb: Likewise
Diffstat (limited to 'gcc/ada/libgnat/s-caun64.adb')
-rw-r--r--gcc/ada/libgnat/s-caun64.adb9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/ada/libgnat/s-caun64.adb b/gcc/ada/libgnat/s-caun64.adb
index cca2069..e4246975 100644
--- a/gcc/ada/libgnat/s-caun64.adb
+++ b/gcc/ada/libgnat/s-caun64.adb
@@ -30,6 +30,7 @@
------------------------------------------------------------------------------
with System.Address_Operations; use System.Address_Operations;
+with System.Storage_Elements; use System.Storage_Elements;
with Ada.Unchecked_Conversion;
@@ -82,8 +83,8 @@ package body System.Compare_Array_Unsigned_64 is
end if;
Clen := Clen - 1;
- L := AddA (L, 8);
- R := AddA (R, 8);
+ L := L + Storage_Offset (8);
+ R := R + Storage_Offset (8);
end loop;
-- Case of going by unaligned double words
@@ -99,8 +100,8 @@ package body System.Compare_Array_Unsigned_64 is
end if;
Clen := Clen - 1;
- L := AddA (L, 8);
- R := AddA (R, 8);
+ L := L + Storage_Offset (8);
+ R := R + Storage_Offset (8);
end loop;
end if;