Skip to content

Commit

Permalink
PR: add -no-pie option to app-tools templates
Browse files Browse the repository at this point in the history
This adds it statically instead of runtime checks.
  • Loading branch information
kent-mcleod committed Feb 15, 2018
1 parent 786946c commit fbcc68f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions app-tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ ${TOOLOBJ}/${2}: ${1} Makefile ${TOOLOBJ}
-e 's#!PLATFORM!#$(PLATFORM)#g;' \
-e 's#!CPPFLAGS!#$(BUILDRUMP_TOOL_CPPFLAGS)#g;' \
-e 's#!CFLAGS!#$(BUILDRUMP_TOOL_CFLAGS)#g;' \
-e 's#!GCCNOPIE!#$(GCCNOPIE)#g;' \
-e 's#!CXXFLAGS!#$(BUILDRUMP_TOOL_CXXFLAGS)#g;' \
-e 's#!LDFLAGS_BAKE!#$(LDFLAGS_BAKE)#g;'
chmod 755 $$@
Expand Down
6 changes: 1 addition & 5 deletions app-tools/cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,14 @@ compile)
;;
ferment)
meta1="$(${PRMETA} "${OUTFILE}" 2>/dev/null)"
nopieoption=
if [ -z "`echo 'int p=1;' | ${CC} -no-pie -S -o /dev/null -x c - 2>&1`" ]; then
nopieoption=-no-pie
fi

# Link the real (from user's PoV) output file as a relocatable object,
# with no rump components. '-u main' is necessary to pull in main if the
# user is linking it in from a library.
${CC} ${CFLAGS} -no-integrated-cpp \
--sysroot !DESTDIR!/rumprun-!MACHINE_GNU_ARCH! \
-specs=!DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib/specs-compile_or_ferment \
${nopieoption} -Wl,-r -Wl,-u,main \
!GCCNOPIE! -Wl,-r -Wl,-u,main \
"$@" !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/share/!TOOLTUPLE!-recipe.s ${EXTRALIBS} || die

# If the presumed output file did not change, and the compiler
Expand Down
9 changes: 2 additions & 7 deletions app-tools/cookfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ setfilevars ()
rf=_rumpfs_f${fn}
}

nopieoption=
if [ -z "`echo 'int p=1;' | ${RUMPRUN_COOKFS_CC} -no-pie -S -o /dev/null -x c - 2>&1`" ]; then
nopieoption=-no-pie
fi

processonefile ()
{

Expand All @@ -169,7 +164,7 @@ processonefile ()
ln -sf -- "${fabs}" ${LINKPATH}

${RUMPRUN_COOKFS_CC} !CFLAGS! !CPPFLAGS! -nostdlib \
${nopieoption} -Wl,-r,-b,binary -o ${TMPDIR}/d${fn}.o ${LINKPATH}
!GCCNOPIE! -Wl,-r,-b,binary -o ${TMPDIR}/d${fn}.o ${LINKPATH}

${RUMPRUN_COOKFS_OBJCOPY} \
--redefine-sym ${LINKPATH_BIN}_start=${rf}_start \
Expand Down Expand Up @@ -238,7 +233,7 @@ exec 1>&3 3>&-
unset IFS

${RUMPRUN_COOKFS_CC} !CFLAGS! !CPPFLAGS! -I${RUMPRUN_COOKFS_INCDIR} \
-nostdlib ${nopieoption} -Wl,-r -o ${TMPDIR}/fin.o ${TMPDIR}/d*.o ${TMPDIR}/constr.c
-nostdlib !GCCNOPIE! -Wl,-r -o ${TMPDIR}/fin.o ${TMPDIR}/d*.o ${TMPDIR}/constr.c
${RUMPRUN_COOKFS_OBJCOPY} ${LSYM} ${TMPDIR}/fin.o ${OUTFILE}

totsize=$(${RUMPRUN_COOKFS_SIZE} ${OUTFILE} | awk 'NR == 2{print $4}')
Expand Down
6 changes: 1 addition & 5 deletions app-tools/rumprun-bake.in
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,9 @@ done

MACHINE_GNU_ARCH=${RUMPBAKE_TUPLE%%-*}

nopieoption=
if [ -z "`echo 'int p=1;' | ${RUMPBAKE_BACKINGCC} -no-pie -S -o /dev/null -x c - 2>&1`" ]; then
nopieoption=-no-pie
fi

# Final link using cc to produce the unikernel image.
${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} ${nopieoption} \
${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} !GCCNOPIE! \
--sysroot ${RUMPBAKE_TOOLDIR}/rumprun-${MACHINE_GNU_ARCH} \
-specs=${RUMPBAKE_TOOLDIR}/rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/specs-bake \
-o ${OUTPUT} ${allobjs} \
Expand Down
8 changes: 8 additions & 0 deletions build-rr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ checktools ()
echo '>>'
sleep ${delay}
fi

# Check for if compiler supports -no-pie and set nopieoption

This comment has been minimized.

Copy link
@kent-mcleod

kent-mcleod Feb 15, 2018

Author Contributor

s/nopieoption/GCCNOPIE

GCCNOPIE=
if [ -z "`echo 'int p=1;' | $CC -no-pie -S -o /dev/null -x c - 2>&1`" ]; then
GCCNOPIE=-no-pie
fi
export GCCNOPIE

}

buildrump ()
Expand Down

0 comments on commit fbcc68f

Please sign in to comment.