-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cheribsdtest: binaries with malloc in early constructor
Add a set of binaries with a simple constructor at priority 101 that calls malloc and free. Make sure the exit successfully.
- Loading branch information
1 parent
75ce19d
commit 7513353
Showing
9 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.include <src.opts.mk> | ||
|
||
SUBDIR= purecap purecap-dynamic | ||
.if (${MACHINE_ABI:Mpurecap} && ${MACHINE_ABI:Mbenchmark}) || ${MK_LIB64CB} == "yes" | ||
SUBDIR+= purecap-benchmark purecap-benchmark-dynamic | ||
.endif | ||
|
||
.include <bsd.subdir.mk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.include <src.opts.mk> | ||
|
||
BINDIR= /usr/libexec | ||
|
||
.if ${.CURDIR:M*benchmark*} | ||
.if !${MACHINE_ABI:Mbenchmark} | ||
NEED_COMPAT= 64CB | ||
.include <bsd.compat.mk> | ||
.endif | ||
.else | ||
.if !${MACHINE_ABI:Mpurecap} | ||
NEED_COMPAT= 64C | ||
.include <bsd.compat.mk> | ||
.endif | ||
.endif | ||
|
||
PROG:= ${.PARSEDIR:tA:T}-${.CURDIR:T} | ||
.PATH: ${.PARSEDIR} | ||
SRCS:= ${.PARSEDIR:tA:T}.c | ||
MAN= | ||
|
||
.if ${.CURDIR:M*static*} | ||
NO_SHARED=t | ||
.endif |
21 changes: 21 additions & 0 deletions
21
libexec/malloc_early_constructor/malloc_early_constructor.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdlib.h> | ||
|
||
/* | ||
* Perform a malloc in the earliest allowed non-system constructor. | ||
* If malloc is not initialized before this point it could fail. | ||
*/ | ||
__attribute__((__constructor__(101))) | ||
static void | ||
foo(void) | ||
{ | ||
void * volatile ptr; | ||
|
||
ptr = malloc(1); | ||
free(ptr); | ||
} | ||
|
||
int | ||
main(void) | ||
{ | ||
return (0); | ||
} |
3 changes: 3 additions & 0 deletions
3
libexec/malloc_early_constructor/purecap-benchmark-dynamic/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# See ../Makefile.inc | ||
|
||
.include <bsd.prog.mk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# See ../Makefile.inc | ||
|
||
.include <bsd.prog.mk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# See ../Makefile.inc | ||
|
||
.include <bsd.prog.mk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# See ../Makefile.inc | ||
|
||
.include <bsd.prog.mk> | ||