Skip to content

Commit

Permalink
Add further -no-pie checks to Rumprun build tools
Browse files Browse the repository at this point in the history
This builds upon the previous commit to add -no-pie anywhere the
relocatable flag (-Wl,-r) is used to handle compilers that enable -pie
by default (Such as Debian Stretch).
  • Loading branch information
kent-mcleod committed Feb 15, 2018
1 parent 35d8119 commit b3c1033
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 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#!EXTRACCFLAGS!#$(EXTRACCFLAGS)#g;' \
-e 's#!CXXFLAGS!#$(BUILDRUMP_TOOL_CXXFLAGS)#g;' \
-e 's#!LDFLAGS_BAKE!#$(LDFLAGS_BAKE)#g;'
chmod 755 $$@
Expand Down
2 changes: 1 addition & 1 deletion app-tools/cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ferment)
${CC} ${CFLAGS} -no-integrated-cpp \
--sysroot !DESTDIR!/rumprun-!MACHINE_GNU_ARCH! \
-specs=!DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib/specs-compile_or_ferment \
-Wl,-r -Wl,-u,main \
!EXTRACCFLAGS! -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
4 changes: 2 additions & 2 deletions app-tools/cookfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ processonefile ()
ln -sf -- "${fabs}" ${LINKPATH}

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

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

${RUMPRUN_COOKFS_CC} !CFLAGS! !CPPFLAGS! -I${RUMPRUN_COOKFS_INCDIR} \
-nostdlib -Wl,-r -o ${TMPDIR}/fin.o ${TMPDIR}/d*.o ${TMPDIR}/constr.c
-nostdlib !EXTRACCFLAGS! -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
3 changes: 2 additions & 1 deletion app-tools/rumprun-bake.in
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,9 @@ done

MACHINE_GNU_ARCH=${RUMPBAKE_TUPLE%%-*}


# Final link using cc to produce the unikernel image.
${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} \
${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} !EXTRACCFLAGS! \
--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 @@ -493,6 +493,14 @@ makeconfig ()
else
echo "CONFIG_CXX=no" >> ${1}
fi

# Check for if compiler supports -no-pie and save to EXTRACCFLAGS
gccnopie=
if [ -z "`echo 'int p=1;' | ${CC} -no-pie -S -o /dev/null -x c - 2>&1`" ]; then
gccnopie=-no-pie
fi
echo "EXTRACCFLAGS=${quote}${gccnopie}${quote}" >> ${1}

}

dobuild ()
Expand Down

0 comments on commit b3c1033

Please sign in to comment.