CPPFLAGS.${i}+= -I${LIBCDIR}/stdlib
.endfor
+CPPFLAGS.malloc.c+= -D_LIBSYS
+# Avoid magic instrumentation of the malloc data variables, since the heap is
+# reconstructed upon state transfer. We do need to instrument the malloc
+# functions, since we need to hook their mmap/munmap calls.
+SECTIONIFY.malloc.c+= -sectionify-no-override \
+ -sectionify-data-section-map=.*/magic_malloc_data
+
.for f in \
strcspn.o
${f} ${f:C/\.o/.bc/}: ${LIBCDIR}/string/${f:C/\.o/.c/}
.endif # ${USE_BITCODE:Uno} == "yes"
.endfor
-CPPFLAGS.malloc.c+= -D_LIBSYS
-
.for f in \
brksize.o _do_kernel_call_intr.o get_minix_kerninfo.o _ipc.o ucontext.o
${f} ${f:C/\.o/.bc/}: ${LIBMINIXCARCHDIR}/sys/${f:C/\.o/.S/}
#define MAGIC_HIDDEN_ARRAY_PREFIX ".arr.magic"
#define MAGIC_HIDDEN_STR_PREFIX ".str.magic"
+#define MAGIC_MALLOC_VARS_SECTION_PREFIX "magic_malloc_data"
+
/* Magic configuration. */
#ifndef MAGIC_OUTPUT_CTL
#define MAGIC_OUTPUT_CTL 0
static cl::opt<std::string>
MagicDataSections("magic-data-sections",
cl::desc("Specify all the colon-separated magic data section regexes not to instrument"),
- cl::init("^" MAGIC_STATIC_VARS_SECTION_PREFIX ".*$:^" UNBL_SECTION_PREFIX ".*$"), cl::NotHidden, cl::ValueRequired);
+ cl::init("^" MAGIC_STATIC_VARS_SECTION_PREFIX ".*$:^" UNBL_SECTION_PREFIX ".*$:^" MAGIC_MALLOC_VARS_SECTION_PREFIX ".*$"), cl::NotHidden, cl::ValueRequired);
static cl::opt<std::string>
MagicFunctionSections("magic-function-sections",
SHLIB_SHFLAGS+= -Wl,-plugin=${GOLD_PLUGIN} \
-Wl,-plugin-opt=-disable-opt
+SECTIONIFYPASS?=${NETBSDSRCDIR}/minix/llvm/bin/sectionify.so
+
.S.bc: ${.TARGET:.bc=.o}
rm -f ${.TARGET}
ln ${.TARGET:.bc=.o} ${.TARGET}
.c.bc:
${_MKTARGET_COMPILE}
${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} -flto
+ if [ -n '${SECTIONIFY.${.IMPSRC:T}}' ]; then \
+ ${OPT} -load ${SECTIONIFYPASS} -sectionify ${SECTIONIFY.${.IMPSRC:T}} -o ${.TARGET}.tmp ${.TARGET} && mv -f ${.TARGET}.tmp ${.TARGET}; \
+ fi
.cc.bc .cxx.bc .cpp.bc:
${_MKTARGET_COMPILE}