[Asterisk-code-review] check_expr2: fix cross-compile/hardening issues (asterisk[master])
Sebastian Kemper
asteriskteam at digium.com
Sun Jan 12 05:49:11 CST 2020
Sebastian Kemper has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13591 )
Change subject: check_expr2: fix cross-compile/hardening issues
......................................................................
check_expr2: fix cross-compile/hardening issues
When building check_expr2 with ASLR PIE hardening enabled the linker
fails. This is resolved by adding the regular compiler flags when
building the object files from ast_expr2f.c and ast_expr2.c.
Note: The STANDALONE define is removed because it is already defined in
_ASTCFLAGS.
Also, a Makefile variable "CROSS_COMPILING" is added so that the
build system doesn't try to run check_expr2 when cross-compiling,
because that will fail the build as will.
ASTERISK-28685 #close
Signed-off-by: Sebastian Kemper <sebastian_ml at gmx.net>
Change-Id: If435b7db9f9ad8266245bda51c81c220f9658915
---
M configure.ac
M makeopts.in
M utils/Makefile
3 files changed, 8 insertions(+), 2 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/91/13591/1
diff --git a/configure.ac b/configure.ac
index ed26d69..d6fd795 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,6 +230,8 @@
AC_CHECK_TOOL(CXX, g++, :)
AC_CHECK_TOOL(LD, ld, :)
AC_CHECK_TOOL(RANLIB, ranlib, :)
+ CROSS_COMPILING=1
+ AC_SUBST(CROSS_COMPILING)
fi
# Checks for programs.
diff --git a/makeopts.in b/makeopts.in
index cb98726..3580feb 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -66,6 +66,8 @@
BIND8_CFLAGS=@BIND8_CFLAGS@
+CROSS_COMPILING=@CROSS_COMPILING@
+
PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
PTHREAD_LIBS=@PTHREAD_LIBS@
diff --git a/utils/Makefile b/utils/Makefile
index 738d1e4..a64916b 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -180,14 +180,16 @@
check_expr2: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h astmm.o
$(ECHO_PREFIX) echo " [CC] ast_expr2f.c -> ast_expr2fz.o"
- $(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE $(ASTTOPDIR)/main/ast_expr2f.c -o ast_expr2fz.o
+ $(CC) -g -c -I$(ASTTOPDIR)/include $(_ASTCFLAGS) $(ASTTOPDIR)/main/ast_expr2f.c -o ast_expr2fz.o
$(ECHO_PREFIX) echo " [CC] ast_expr2.c -> ast_expr2z.o"
- $(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE2 $(ASTTOPDIR)/main/ast_expr2.c -o ast_expr2z.o
+ $(CC) -g -c -I$(ASTTOPDIR)/include $(_ASTCFLAGS) -DSTANDALONE2 $(ASTTOPDIR)/main/ast_expr2.c -o ast_expr2z.o
$(ECHO_PREFIX) echo " [LD] ast_expr2fz.o ast_expr2z.o -> check_expr2"
$(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o astmm.o -lm $(_ASTLDFLAGS)
$(ECHO_PREFIX) echo " [RM] ast_expr2fz.o ast_expr2z.o"
rm ast_expr2z.o ast_expr2fz.o
+ifneq ($(CROSS_COMPILING),1)
./check_expr2 expr2.testinput
+endif
smsq: smsq.o strcompat.o
smsq: LIBS+=$(POPT_LIB)
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13591
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: If435b7db9f9ad8266245bda51c81c220f9658915
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 1
Gerrit-Owner: Sebastian Kemper <sebastian_ml at gmx.net>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200112/504ba1e2/attachment.html>
More information about the asterisk-code-review
mailing list