From 482d96a0c5d523ace63f56bda6851926b4469dd0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 29 Jan 2012 13:54:19 +0100 Subject: Force -fPIE on ELF if Qt is built with reduced relocations Put in qconfig.h whether qt is compiled with reduced relocations. When using -Bsymbolic-functions (enabled by default on Qt) but not -fPIE, the comparison of the function pointers fail because the addresses are different in Qt, and in the executable. Hence we now enable -fPIE by default on qmake, and force a compilation error when it is not enabled and built with reduced relocations. Done-with: Sune Vuorela Change-Id: Ib3fdba06fab6e8a93b75b4c6cf16cc973ab335db Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/global/qglobal.h') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 33b5b8bd76..ffeb8a2bab 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -62,6 +62,7 @@ #include #endif + #include #include #include @@ -1783,6 +1784,11 @@ Q_CORE_EXPORT int qrand(); # endif #endif +#if defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__) +# error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ + "Compile your code with -fPIC or -fPIE." +#endif + namespace QtPrivate { //like std::enable_if template struct QEnableIf; -- cgit v1.2.3