diff options
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | mkspecs/blackberry-armv7le-qcc/qmake.conf | 12 | ||||
-rw-r--r-- | mkspecs/blackberry-x86-qcc/qmake.conf | 12 | ||||
-rw-r--r-- | mkspecs/common/qcc-base.conf | 2 | ||||
-rw-r--r-- | tools/configure/configureapp.cpp | 36 | ||||
-rw-r--r-- | tools/configure/configureapp.h | 2 |
6 files changed, 75 insertions, 9 deletions
@@ -207,9 +207,9 @@ compilerSupportsFlag() cat >conftest.cpp <<EOF int main() { return 0; } EOF - "$TEST_COMPILER" "$@" -o conftest.o conftest.cpp + $TEST_COMPILER "$@" -o conftest-out.o conftest.cpp ret=$? - rm -f conftest.cpp conftest.o + rm -f conftest.cpp conftest-out.o return $ret } @@ -791,6 +791,7 @@ CFG_DECLARATIVE=auto CFG_DECLARATIVE_DEBUG=yes CFG_WEBKIT=auto # (yes|no|auto|debug) CFG_JAVASCRIPTCORE_JIT=auto +CFG_STACK_PROTECTOR_STRONG=auto CFG_GFX_AVAILABLE="linuxfb transformed qvfb vnc multiscreen directfb" CFG_GFX_ON="linuxfb multiscreen" @@ -898,6 +899,7 @@ XPLATFORM_MINGW=no # Whether target platform is MinGW (win32-g++*) XPLATFORM_INTEGRITY=no # Whether target platform is INTEGRITY (*integrity*) XPLATFORM_SYMBIAN=no # Whether target platform is SYMBIAN (*symbian*) XPLATFORM_SYMBIAN_SBSV2=no # Whether target platform is SYMBIAN_SBSV2 (symbian-sbsv2) +XPLATFORM_QNX=no PLATFORM=$QMAKESPEC QT_CROSS_COMPILE=no OPT_CONFIRM_LICENSE=no @@ -1690,6 +1692,7 @@ while [ "$#" -gt 0 ]; do case "$XPLATFORM" in *integrity*) XPLATFORM_INTEGRITY=yes;; esac case "$XPLATFORM" in *symbian*) XPLATFORM_SYMBIAN=yes;; esac case "$XPLATFORM" in symbian-sbsv2) XPLATFORM_SYMBIAN_SBSV2=yes;; esac + case "$XPLATFORM" in *qnx-*|*blackberry-*) XPLATFORM_QNX=yes;; esac ;; device-option) DEV_VAR=`echo $VAL | sed "s,^\(.*\)=.*,\1,"` @@ -2999,6 +3002,7 @@ case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac case "$XPLATFORM" in *integrity*) XPLATFORM_INTEGRITY=yes;; esac case "$XPLATFORM" in *symbian*) XPLATFORM_SYMBIAN=yes;; esac case "$XPLATFORM" in symbian-sbsv2) XPLATFORM_SYMBIAN_SBSV2=yes;; esac +case "$XPLATFORM" in *qnx-*|*blackberry-*) XPLATFORM_QNX=yes;; esac if [ -d "$PLATFORM" ]; then QMAKESPEC="$PLATFORM" @@ -3478,6 +3482,17 @@ if [ "$CFG_REDUCE_EXPORTS" = "auto" ]; then fi fi +# auto-detect -fstack-protector-strong support (for QNX only currently) +if [ "$XPLATFORM_QNX" = "yes" ]; then + if compilerSupportsFlag -fstack-protector-strong; then + CFG_STACK_PROTECTOR_STRONG=yes + else + CFG_STACK_PROTECTOR_STRONG=no + fi +else + CFG_STACK_PROTECTOR_STRONG=no +fi + # detect the availability of the -Bsymbolic-functions linker optimization if [ "$CFG_REDUCE_RELOCATIONS" != "no" ]; then if "$unixtests/bsymbolic_functions.test" "$TEST_COMPILER" "$OPT_VERBOSE"; then @@ -7274,6 +7289,7 @@ if [ "$CFG_USE_GNUMAKE" = "yes" ]; then QMAKE_CONFIG="$QMAKE_CONFIG GNUmake" fi [ "$CFG_REDUCE_EXPORTS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_exports" +[ "$CFG_STACK_PROTECTOR_STRONG" = "yes" ] && QT_CONFIG="$QT_CONFIG stack-protector-strong" [ "$CFG_REDUCE_RELOCATIONS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_relocations" [ "$CFG_PRECOMPILE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG precompile_header" if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then diff --git a/mkspecs/blackberry-armv7le-qcc/qmake.conf b/mkspecs/blackberry-armv7le-qcc/qmake.conf index 4e72667..5edcf0e 100644 --- a/mkspecs/blackberry-armv7le-qcc/qmake.conf +++ b/mkspecs/blackberry-armv7le-qcc/qmake.conf @@ -2,11 +2,17 @@ # qmake configuration for blackberry x86 systems # +include(../qnx-armv7le-qcc/qmake.conf) + +load(qt_config) + DEFINES += Q_OS_BLACKBERRY CONFIG += blackberry LIBS += -lbps # Blackberry also has support for stack smashing protection in its libc -QMAKE_CFLAGS += -fstack-protector -fstack-protector-all - -include(../qnx-armv7le-qcc/qmake.conf) +contains(QT_CONFIG, stack-protector-strong) { + QMAKE_CFLAGS += -fstack-protector-strong +} else { + QMAKE_CFLAGS += -fstack-protector -fstack-protector-all +} diff --git a/mkspecs/blackberry-x86-qcc/qmake.conf b/mkspecs/blackberry-x86-qcc/qmake.conf index 60b67f8..45d6c4b 100644 --- a/mkspecs/blackberry-x86-qcc/qmake.conf +++ b/mkspecs/blackberry-x86-qcc/qmake.conf @@ -2,11 +2,17 @@ # qmake configuration for blackberry x86 systems # +include(../qnx-x86-qcc/qmake.conf) + +load(qt_config) + DEFINES += Q_OS_BLACKBERRY CONFIG += blackberry LIBS += -lbps # Blackberry also has support for stack smashing protection in its libc -QMAKE_CFLAGS += -fstack-protector -fstack-protector-all - -include(../qnx-x86-qcc/qmake.conf) +contains(QT_CONFIG, stack-protector-strong) { + QMAKE_CFLAGS += -fstack-protector-strong +} else { + QMAKE_CFLAGS += -fstack-protector -fstack-protector-all +} diff --git a/mkspecs/common/qcc-base.conf b/mkspecs/common/qcc-base.conf index 6f8d336..3ceaa8e 100644 --- a/mkspecs/common/qcc-base.conf +++ b/mkspecs/common/qcc-base.conf @@ -14,7 +14,7 @@ QMAKE_CFLAGS_WARN_ON += -Wall -W QMAKE_CFLAGS_WARN_OFF += -w QMAKE_CFLAGS_RELEASE += -O2 QMAKE_CFLAGS_DEBUG += -g -QMAKE_CFLAGS_SHLIB += -fPIC +QMAKE_CFLAGS_SHLIB += -fPIC -shared QMAKE_CFLAGS_STATIC_LIB += -fPIC QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index be28762..21131b6 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1724,6 +1724,7 @@ void Configure::applySpecSpecifics() dictionary[ "FONT_CONFIG" ] = "yes"; dictionary[ "FONT_CONFIG" ] = "yes"; dictionary[ "FREETYPE" ] = "system"; + dictionary[ "STACK_PROTECTOR_STRONG" ] = "auto"; } } @@ -2401,6 +2402,11 @@ bool Configure::checkAvailability(const QString &part) } } else if (part == "DIRECTWRITE") { available = findFile("dwrite.h") && findFile("d2d1.h") && findFile("dwrite.lib"); + } else if (part == "STACK_PROTECTOR_STRONG") { + QStringList compilerAndArgs; + compilerAndArgs += "qcc"; + compilerAndArgs += "-fstack-protector-strong"; + available = dictionary[ "XQMAKESPEC" ].contains("blackberry") && compilerSupportsFlag(compilerAndArgs); } return available; @@ -2504,6 +2510,10 @@ void Configure::autoDetection() if (dictionary["INCREDIBUILD_XGE"] == "auto") dictionary["INCREDIBUILD_XGE"] = checkAvailability("INCREDIBUILD_XGE") ? "yes" : "no"; + // Detection of -fstack-protector-strong support + if (dictionary["STACK_PROTECTOR_STRONG"] == "auto") + dictionary["STACK_PROTECTOR_STRONG"] = checkAvailability("STACK_PROTECTOR_STRONG") ? "yes" : "no"; + // Mark all unknown "auto" to the default value.. for (QMap<QString,QString>::iterator i = dictionary.begin(); i != dictionary.end(); ++i) { if (i.value() == "auto") @@ -2979,6 +2989,9 @@ void Configure::generateOutputVars() // We currently have no switch for QtSvg, so add it unconditionally. qtConfig += "svg"; + if (dictionary["STACK_PROTECTOR_STRONG"] == "yes") + qtConfig += "stack-protector-strong"; + // We currently have no switch for QtConcurrent, so add it unconditionally. qtConfig += "concurrent"; @@ -4426,6 +4439,29 @@ void Configure::saveCmdLine() } #endif // !EVAL +bool Configure::compilerSupportsFlag(const QStringList &compilerAndArgs) +{ + QFile file("conftest.cpp"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + cout << "could not open temp file for writing" << endl; + return false; + } + if (!file.write("int main() { return 0; }\r\n")) { + cout << "could not write to temp file" << endl; + return false; + } + file.close(); + // compilerAndArgs contains compiler because there is no way to query it + QStringList command = compilerAndArgs; + command += "-o"; + command += "conftest-out.o"; + command += "conftest.cpp"; + int code = Environment::execute(command, QStringList(), QStringList()); + file.remove(); + QFile::remove("conftest-out.o"); + return code == 0; +} + bool Configure::isDone() { return !dictionary["DONE"].isEmpty(); diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index ee34b0d..d3f4ca1 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -161,6 +161,8 @@ private: void saveCmdLine(); #endif + bool compilerSupportsFlag(const QStringList &compilerAndArgs); + void desc(const char *description, int startingAt = 0, int wrapIndent = 0); void desc(const char *option, const char *description, bool skipIndent = false, char fillChar = '.'); void desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar = '.'); |