realloc1.c
up: index
prev: realloc0.c
next: realloc2.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cheriintrin.h>
#include "capprint.h"
int main()
{
int x=42;
int *p0 = &x;
fprintf(stderr,"Original %" PTR_FMT "\n", sptr((void*)p0));
int **p1 = malloc(sizeof(int*));
fprintf(stderr,"Malloc %" PTR_FMT "\n", sptr((void*)p1));
memcpy(p1,&p0,sizeof(int*));
p1 = realloc(p1, 2*sizeof(int*));
fprintf(stderr,"Realloc %" PTR_FMT "\n", sptr((void*)p1));
fprintf(stderr,"Copy %" PTR_FMT "\n", sptr((void*)*p1));
fprintf(stderr,"Pointers are %s\n",
cheri_is_equal_exact(p0,*p1)?"exactly equal":"not equal");
fprintf(stderr,"Value: %d\n",**p1);
}
Experimental data (what does this mean?)
cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi Original (@disabled, 0xffffe6d0 [rwRW,0xffffe6d0-0xffffe6d4])
Malloc (@disabled, 0xffffe3d0 [rwRW,0xffffe3d0-0xffffe3e0])
Realloc (@disabled, 0xffffe090 [rwRW,0xffffe090-0xffffe0b0])
Copy (@disabled, 0xffffe6d0 [rwRW,0xffffe6d0-0xffffe6d4])
Pointers are exactly equal
Value: 42
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia Original (@87, 0xffffe6d0 [rwRW,0xffffe6d0-0xffffe6d4])
Malloc (@125, 0xffffe3d0 [rwRW,0xffffe3d0-0xffffe3e0])
Realloc (@165, 0xffffe090 [rwRW,0xffffe090-0xffffe0b0])
Copy (@87, 0xffffe6d0 [rwRW,0xffffe6d0-0xffffe6d4])
Pointers are exactly equal
Value: 42
clang-riscv-O3-bounds-subobject-safe cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %18 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %17), !dbg !62cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %18 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %17), !dbg !62cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %18 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %17), !dbg !62cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %18 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %17), !dbg !61cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %25 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* %1, i8 addrspace(200)* %24), !dbg !114Original 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
Malloc 0x40a1e000 [rwRW,0x40a1e000-0x40a1e010]
Realloc 0x40a1f000 [rwRW,0x40a1f000-0x40a1f020]
Copy 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
Pointers are exactly equal
Value: 42
clang-riscv-O3-bounds-conservative cheri-bound-allocas: Don't know how to handle intrinsic. Assuming bounds needed %11 = call i1 @llvm.cheri.cap.equal.exact(i8 addrspace(200)* nonnull %0, i8 addrspace(200)* %10), !dbg !96Original 0x3fffdfff0c [rwRW,0x3fffdfff0c-0x3fffdfff10]
Malloc 0x40a1e000 [rwRW,0x40a1e000-0x40a1e010]
Realloc 0x40a1f000 [rwRW,0x40a1f000-0x40a1f020]
Copy 0x3fffdfff0c [rwRW,0x3fffdfff0c-0x3fffdfff10]
Pointers are exactly equal
Value: 42
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 Original 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
Malloc 0x40a1e000 [rwRW,0x40a1e000-0x40a1e010]
Realloc 0x40a1f000 [rwRW,0x40a1f000-0x40a1f020]
Copy 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
Pointers are exactly equal
Value: 42
clang-morello-O3-bounds-subobject-safe Original 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
Malloc 0x40c1e000 [rwRW,0x40c1e000-0x40c1e010]
Realloc 0x40c1f000 [rwRW,0x40c1f000-0x40c1f020]
Copy 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
Pointers are exactly equal
Value: 42
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe Original 0xfffffff7ff4c [rwRW,0xfffffff7ff4c-0xfffffff7ff50]
Malloc 0x40c1e000 [rwRW,0x40c1e000-0x40c1e010]
Realloc 0x40c1f000 [rwRW,0x40c1f000-0x40c1f020]
Copy 0xfffffff7ff4c [rwRW,0xfffffff7ff4c-0xfffffff7ff50]
Pointers are exactly equal
Value: 42
clang-morello-O3-bounds-conservative Original 0xfffffff7fefc [rwRW,0xfffffff7fefc-0xfffffff7ff00]
Malloc 0x40c1e000 [rwRW,0x40c1e000-0x40c1e010]
Realloc 0x40c1f000 [rwRW,0x40c1f000-0x40c1f020]
Copy 0xfffffff7fefc [rwRW,0xfffffff7fefc-0xfffffff7ff00]
Pointers are exactly equal
Value: 42
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only Original 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Malloc 0x40c1e000 [rwRW,0x40c1e000-0x40c1e010]
Realloc 0x40c1f000 [rwRW,0x40c1f000-0x40c1f020]
Copy 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Pointers are exactly equal
Value: 42
gcc-morello-O3 Original 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
Malloc 0x40000120 [rwRW,0x40000120-0x40000130]
Realloc 0x40000120 [rwRW,0x40000120-0x40000140]
Copy 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
Pointers are exactly equal
Value: 42
gcc-morello-O0 Original 0x7fffffcc [rwRW,0x7fffffcc-0x7fffffd0]
Malloc 0x40000120 [rwRW,0x40000120-0x40000130]
Realloc 0x40000120 [rwRW,0x40000120-0x40000140]
Copy 0x7fffffcc [rwRW,0x7fffffcc-0x7fffffd0]
Pointers are exactly equal
Value: 42