mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-10 10:15:13 -04:00
tests: make no-optimize attribute Clang compatible
This commit is contained in:
parent
b404d6da6e
commit
de3fb50dcc
34 changed files with 113 additions and 67 deletions
|
@ -1,11 +1,12 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "../test_util.h"
|
||||
|
||||
struct foo {
|
||||
uint64_t a, b, c, d;
|
||||
};
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
OPTNONE int main(void) {
|
||||
void *p = new char;
|
||||
struct foo *c = (struct foo *)p;
|
||||
delete c;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
void *p = malloc(128 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
void *p = malloc(128 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
void *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
void *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(256 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(8);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
#include <sys/mman.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
free(malloc(16));
|
||||
char *p = mmap(NULL, 4096 * 16, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
#include <sys/mman.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
free(malloc(16));
|
||||
char *p = mmap(NULL, 4096 * 16, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <malloc.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <malloc.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
void *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <stdbool.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "../test_util.h"
|
||||
|
||||
size_t malloc_object_size(void *ptr);
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
size_t size = malloc_object_size(p);
|
||||
return size != (SLAB_CANARY ? 24 : 32);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <stdbool.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "../test_util.h"
|
||||
|
||||
size_t malloc_object_size(void *ptr);
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
size_t size = malloc_object_size(p + 5);
|
||||
return size != (SLAB_CANARY ? 19 : 27);
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(128 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(0);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
#include <malloc.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(128 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <malloc.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
free((void *)1);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <malloc.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
malloc_usable_size((void *)1);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
void *p = realloc((void *)1, 16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(128 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(128 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(128);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(128);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(0);
|
||||
if (!p) {
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue