Example: intptr7a.c

up: index
prev: intptr7.c
next: intptr8.c

    #include <stdint.h>
    #include <stdio.h>
    #include <limits.h>
    #include "capprint.h"
    
    int main()
    {
        int x[2]={42,43};
    
        // intptr_t
        intptr_t ip = (intptr_t)&x;
        fprintf(stderr,"cap %" PTR_FMT "\n", sptr((void*)ip));
        print_cap_bytes("cap(hex)",(unsigned char*)&ip);
        
        intptr_t ip2 = ip & UINT_MAX;
        fprintf(stderr,"cap&uint %" PTR_FMT "\n", sptr((void*)ip2)); 
    
        intptr_t ip3 = ip & INT_MAX;
        fprintf(stderr,"cap&int %" PTR_FMT "\n", sptr((void*)ip3)); // non-rep
    
        // uintptr_t
        uintptr_t uip = (uintptr_t)&x;
        fprintf(stderr,"ucap %" PTR_FMT "\n", sptr((void*)uip));
    
        uintptr_t uip2 = uip & UINT_MAX;
        fprintf(stderr,"ucap&uint %" PTR_FMT "\n", sptr((void*)uip2)); 
    
        uintptr_t uip3 = uip & INT_MAX;
        fprintf(stderr,"ucap&int %" PTR_FMT "\n", sptr((void*)uip3)); // non-rep
    }

Experimental data (what does this mean?)

cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi
 cap (@disabled, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
cap(hex) dc00000066f4e6ec00000000ffffe6ec
cap&uint (@disabled, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
cap&int (@disabled, 0x7fffe6ec [?-?] (notag))
ucap (@disabled, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
ucap&uint (@disabled, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
ucap&int (@disabled, 0x7fffe6ec [?-?] (notag))
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 cap (@86, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
cap(hex) dc00000066f4e6ec00000000ffffe6ec
cap&uint (@86, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
cap&int (@empty, 0x7fffe6ec [?-?] (notag))
ucap (@86, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
ucap&uint (@86, 0xffffe6ec [rwRW,0xffffe6ec-0xffffe6f4])
ucap&int (@empty, 0x7fffe6ec [?-?] (notag))
 
clang-riscv-O3-bounds-subobject-safe cap 0x3fffdffef8 [rwRW,0x3fffdffef8-0x3fffdfff00]
cap(hex) d17d000007c1befc0000003fffdffef8
cap&uint 0xffdffef8 [rwRW,0xffdffef8-0xffdfff00] (invalid)
cap&int 0x7fdffef8 [rwRW,0x7fdffef8-0x7fdfff00] (invalid)
ucap 0x3fffdffef8 [rwRW,0x3fffdffef8-0x3fffdfff00]
ucap&uint 0xffdffef8 [rwRW,0xffdffef8-0xffdfff00] (invalid)
ucap&int 0x7fdffef8 [rwRW,0x7fdffef8-0x7fdfff00] (invalid)
 
clang-riscv-O3-bounds-conservative cap 0x3fffdffee8 [rwRW,0x3fffdffee8-0x3fffdffef0]
cap(hex) d17d000007bdbeec0000003fffdffee8
cap&uint 0xffdffee8 [rwRW,0xffdffee8-0xffdffef0] (invalid)
cap&int 0x7fdffee8 [rwRW,0x7fdffee8-0x7fdffef0] (invalid)
ucap 0x3fffdffee8 [rwRW,0x3fffdffee8-0x3fffdffef0]
ucap&uint 0xffdffee8 [rwRW,0xffdffee8-0xffdffef0] (invalid)
ucap&int 0x7fdffee8 [rwRW,0x7fdffee8-0x7fdffef0] (invalid)
 
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only
clang-riscv-O0-bounds-subobject-safe
clang-riscv-O0-bounds-aggressive
clang-riscv-O0-bounds-very-aggressive
clang-riscv-O0-bounds-everywhere-unsafe
 cap 0x3fffdfff68 [rwRW,0x3fffdfff68-0x3fffdfff70]
cap(hex) d17d000007ddbf6c0000003fffdfff68
cap&uint 0xffdfff68 [rwRW,0xffdfff68-0xffdfff70] (invalid)
cap&int 0x7fdfff68 [rwRW,0x7fdfff68-0x7fdfff70] (invalid)
ucap 0x3fffdfff68 [rwRW,0x3fffdfff68-0x3fffdfff70]
ucap&uint 0xffdfff68 [rwRW,0xffdfff68-0xffdfff70] (invalid)
ucap&int 0x7fdfff68 [rwRW,0x7fdfff68-0x7fdfff70] (invalid)
 
clang-morello-O3-bounds-subobject-safe cap 0xfffffff7fee8 [rwRW,0xfffffff7fee8-0xfffffff7fef0]
cap(hex) dc5d40007ef0fee80000fffffff7fee8
cap&uint 0xfff7fee8 [rwRW,0xfff7fee8-0xfff7fef0] (invalid)
cap&int 0x7ff7fee8 [rwRW,0x7ff7fee8-0x7ff7fef0] (invalid)
ucap 0xfffffff7fee8 [rwRW,0xfffffff7fee8-0xfffffff7fef0]
ucap&uint 0xfff7fee8 [rwRW,0xfff7fee8-0xfff7fef0] (invalid)
ucap&int 0x7ff7fee8 [rwRW,0x7ff7fee8-0x7ff7fef0] (invalid)
 
clang-morello-O3-bounds-conservative cap 0xfffffff7ff08 [rwRW,0xfffffff7ff08-0xfffffff7ff10]
cap(hex) dc5d40007f10ff080000fffffff7ff08
cap&uint 0xfff7ff08 [rwRW,0xfff7ff08-0xfff7ff10] (invalid)
cap&int 0x7ff7ff08 [rwRW,0x7ff7ff08-0x7ff7ff10] (invalid)
ucap 0xfffffff7ff08 [rwRW,0xfffffff7ff08-0xfffffff7ff10]
ucap&uint 0xfff7ff08 [rwRW,0xfff7ff08-0xfff7ff10] (invalid)
ucap&int 0x7ff7ff08 [rwRW,0x7ff7ff08-0x7ff7ff10] (invalid)
 
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe
 cap 0xfffffff7ff48 [rwRW,0xfffffff7ff48-0xfffffff7ff50]
cap(hex) dc5d40007f50ff480000fffffff7ff48
cap&uint 0xfff7ff48 [rwRW,0xfff7ff48-0xfff7ff50] (invalid)
cap&int 0x7ff7ff48 [rwRW,0x7ff7ff48-0x7ff7ff50] (invalid)
ucap 0xfffffff7ff48 [rwRW,0xfffffff7ff48-0xfffffff7ff50]
ucap&uint 0xfff7ff48 [rwRW,0xfff7ff48-0xfff7ff50] (invalid)
ucap&int 0x7ff7ff48 [rwRW,0x7ff7ff48-0x7ff7ff50] (invalid)
 
gcc-morello-O3 cap 0x7fffffc8 [rwRW,0x7fffffc8-0x7fffffd0]
cap(hex) dfffc0007fd0ffc8000000007fffffc8
cap&uint 0x7fffffc8 [rwRW,0x7fffffc8-0x7fffffd0]
cap&int 0x7fffffc8 [rwRW,0x7fffffc8-0x7fffffd0]
ucap 0x7fffffc8 [rwRW,0x7fffffc8-0x7fffffd0]
ucap&uint 0x7fffffc8 [rwRW,0x7fffffc8-0x7fffffd0]
ucap&int 0x7fffffc8 [rwRW,0x7fffffc8-0x7fffffd0]
 
gcc-morello-O0 cap 0x7fffff88 [rwRW,0x7fffff88-0x7fffff90]
cap(hex) dfffc0007f90ff88000000007fffff88
cap&uint 0x7fffff88 [rwRW,0x7fffff88-0x7fffff90]
cap&int 0x7fffff88 [rwRW,0x7fffff88-0x7fffff90]
ucap 0x7fffff88 [rwRW,0x7fffff88-0x7fffff90]
ucap&uint 0x7fffff88 [rwRW,0x7fffff88-0x7fffff90]
ucap&int 0x7fffff88 [rwRW,0x7fffff88-0x7fffff90]