cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
71 lines
2.8 KiB
C
71 lines
2.8 KiB
C
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck -check-prefixes CHECK,TYPE %s
|
|
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck -check-prefixes CHECK,TYPE %s
|
|
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s
|
|
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s
|
|
|
|
typedef void (*fptr_t)(void);
|
|
|
|
char *cptr;
|
|
void (*fptr)(void);
|
|
|
|
// CHECK-LABEL: define{{.*}} void @test1
|
|
void test1() {
|
|
// TYPE: [[LOAD:%.*]] = load ptr, ptr @cptr
|
|
// TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64
|
|
// TYPE: call i64 @llvm.ptrauth.resign(i64 [[TOINT]], i32 0, i64 0, i32 0, i64 18983)
|
|
// TYPE: call void {{.*}}() [ "ptrauth"(i32 0, i64 18983) ]
|
|
// ZERO-NOT: @llvm.ptrauth.resign
|
|
|
|
(*(fptr_t)cptr)();
|
|
}
|
|
|
|
// CHECK-LABEL: define{{.*}} i8 @test2
|
|
char test2() {
|
|
return *(char *)fptr;
|
|
|
|
// TYPE: [[LOAD:%.*]] = load ptr, ptr @fptr
|
|
// TYPE: [[CMP:%.*]] = icmp ne ptr [[LOAD]], null
|
|
// TYPE-NEXT: br i1 [[CMP]], label %[[NONNULL:.*]], label %[[CONT:.*]]
|
|
|
|
// TYPE: [[NONNULL]]:
|
|
// TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64
|
|
// TYPE: [[CALL:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TOINT]], i32 0, i64 18983, i32 0, i64 0)
|
|
// TYPE: [[TOPTR:%.*]] = inttoptr i64 [[CALL]] to ptr
|
|
|
|
// TYPE: [[CONT]]:
|
|
// TYPE: phi ptr [ null, {{.*}} ], [ [[TOPTR]], %[[NONNULL]] ]
|
|
// ZERO-NOT: @llvm.ptrauth.resign
|
|
}
|
|
|
|
// CHECK-LABEL: define{{.*}} void @test4
|
|
void test4() {
|
|
(*((fptr_t)(&*((char *)(&*(fptr_t)cptr)))))();
|
|
|
|
// CHECK: [[LOAD:%.*]] = load ptr, ptr @cptr
|
|
// TYPE-NEXT: [[CAST4:%.*]] = ptrtoint ptr [[LOAD]] to i64
|
|
// TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST4]], i32 0, i64 0, i32 0, i64 18983)
|
|
// TYPE-NEXT: [[CAST5:%.*]] = inttoptr i64 [[RESIGN]] to ptr
|
|
// TYPE-NEXT: call void [[CAST5]]() [ "ptrauth"(i32 0, i64 18983) ]
|
|
// ZERO-NOT: @llvm.ptrauth.resign
|
|
// ZERO: call void [[LOAD]]() [ "ptrauth"(i32 0, i64 0) ]
|
|
}
|
|
|
|
void *vptr;
|
|
// CHECK-LABEL: define{{.*}} void @test5
|
|
void test5() {
|
|
vptr = &*(char *)fptr;
|
|
|
|
// TYPE: [[LOAD:%.*]] = load ptr, ptr @fptr
|
|
// TYPE-NEXT: [[CMP]] = icmp ne ptr [[LOAD]], null
|
|
// TYPE-NEXT: br i1 [[CMP]], label %[[NONNULL:.*]], label %[[CONT:.*]]
|
|
|
|
// TYPE: [[NONNULL]]:
|
|
// TYPE: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 18983, i32 0, i64 0)
|
|
// TYPE: [[CAST:%.*]] = inttoptr i64 [[RESIGN]] to ptr
|
|
|
|
// TYPE: [[CONT]]:
|
|
// TYPE: [[PHI:%.*]] = phi ptr [ null, {{.*}} ], [ [[CAST]], %[[NONNULL]] ]
|
|
// TYPE: store ptr [[PHI]], ptr @vptr
|
|
// ZERO-NOT: @llvm.ptrauth.resign
|
|
}
|