Example: eq1.c

up: index
prev: call1.c
next: eq2.c

    #include <stdio.h>
    #include <cheriintrin.h>
    #include "capprint.h"
    
    void func(int x) {}
    
    int main(void)
    {
        void (*fptr1)(int) = &func;
        void (*fptr2)(int) = cheri_tag_clear(&func);
      
        fprintf(stderr,"Original:\t%" PTR_FMT "\n", sptr((void*)fptr1));
        fprintf(stderr,"Invalidated:\t%" PTR_FMT "\n", sptr((void*)fptr2));
        fprintf(stderr,"Exact %s\n", cheri_is_equal_exact(fptr1,fptr2)?"eq":"neq");
        fprintf(stderr,"(==) %s\n", fptr1==fptr2?"eq":"neq");
    }

Experimental data (what does this mean?)

cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi
 Original: (@disabled, 0x100000386 [rxR,0x100000386-0x100000388] (sentry))
Invalidated: (@disabled, 0x100000386 [rxR,0x100000386-0x100000388] (invalid,sentry))
Exact neq
(==) eq
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 Original: (@empty, 0x100000386 [rxR,0x100000386-0x100000388] (sentry))
Invalidated: (@empty, 0x100000386 [rxR,0x100000386-0x100000388] (invalid,sentry))
Exact neq
(==) eq
 
clang-riscv-O3-bounds-subobject-safe Original: 0x10208c [rxR,0x100000-0x1045c0] (sentry,capmode)
Invalidated: 0x10208c [rxR,0x100000-0x1045c0] (invalid,sentry,capmode)
Exact neq
(==) eq
 
clang-riscv-O0-bounds-subobject-safe
clang-riscv-O0-bounds-aggressive
clang-riscv-O0-bounds-very-aggressive
clang-riscv-O0-bounds-everywhere-unsafe
 Original: 0x10206a [rxR,0x100000-0x104600] (sentry,capmode)
Invalidated: 0x10206a [rxR,0x100000-0x104600] (invalid,sentry,capmode)
Exact neq
(==) eq
 
clang-riscv-O3-bounds-conservative Original: 0x1020ae [rxR,0x100000-0x104600] (sentry,capmode)
Invalidated: 0x1020ae [rxR,0x100000-0x104600] (invalid,sentry,capmode)
Exact neq
(==) eq
 
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only
 Original: 0x10204a [rxR,0x100000-0x1045a0] (sentry,capmode)
Invalidated: 0x10204a [rxR,0x100000-0x1045a0] (invalid,sentry,capmode)
Exact neq
(==) eq
 
clang-morello-O3-bounds-subobject-safe Original: 0x111081 [rxR,0x100000-0x1316c0] (sentry)
Invalidated: 0x111081 [rxR,0x100000-0x1316c0] (invalid,sentry)
Exact neq
(==) eq
 
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe
 Original: 0x110eb1 [rxR,0x100000-0x1314c0] (sentry)
Invalidated: 0x110eb1 [rxR,0x100000-0x1314c0] (invalid,sentry)
Exact neq
(==) eq
 
clang-morello-O3-bounds-conservative Original: 0x1110c1 [rxR,0x100000-0x131700] (sentry)
Invalidated: 0x1110c1 [rxR,0x100000-0x131700] (invalid,sentry)
Exact neq
(==) eq
 
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only
 Original: 0x110e91 [rxR,0x100000-0x131480] (sentry)
Invalidated: 0x110e91 [rxR,0x100000-0x131480] (invalid,sentry)
Exact neq
(==) eq
 
gcc-morello-O3 tests/cheri/eq1.c: In function 'main':
tests/cheri/eq1.c:12:54: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
12 | fprintf(stderr,"Original:\t%" PTR_FMT "\n", sptr((void*)fptr1));
| ^
tests/cheri/eq1.c:13:57: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
13 | fprintf(stderr,"Invalidated:\t%" PTR_FMT "\n", sptr((void*)fptr2));
| ^
Original: 0x4030a1 [rxRE,0x400000-0x427340] (sentry)
Invalidated: 0x4030a1 [rxRE,0x400000-0x427340] (invalid,sentry)
Exact neq
(==) eq
 
gcc-morello-O0 tests/cheri/eq1.c: In function 'main':
tests/cheri/eq1.c:12:54: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
12 | fprintf(stderr,"Original:\t%" PTR_FMT "\n", sptr((void*)fptr1));
| ^
tests/cheri/eq1.c:13:57: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
13 | fprintf(stderr,"Invalidated:\t%" PTR_FMT "\n", sptr((void*)fptr2));
| ^
Original: 0x403885 [rxRE,0x400000-0x4277c0] (sentry)
Invalidated: 0x403885 [rxRE,0x400000-0x4277c0] (invalid,sentry)
Exact neq
(==) eq