Go to file
Thiago Macieira 19b7f854a2 Enable -mno-direct-extern-access and ELF protected visibility
The -mno-direct-extern-access tells the compiler and linker that
references to symbols outside this ELF module mustn't be direct and must
instead always go through the GOT or PLT (the PLT can additionally be
disabled with -fno-plt). The ELF protected visibility tells the compiler
and linker that this symbol is present in the dynamic symbol table as an
export, but it cannot be interposed by another ELF module.

This option is required for user code to link properly to Qt, otherwise
they will get linker errors (assuming GNU binutils >= 2.39) or runtime
failures (glibc >= 2.35). Both versions of glibc and binutils are older
than GCC 12, so it's a safe assumption they are in use and downgrading
the toolchain or libc is not supported. Adding this option to the
compilation is assured for CMake and qmake-based projects.

For example, all accessess to QCoreApplication::self in QtCore, after
this change and with GCC 12 are relocation-free and direct:

000000000013ebf0 <QCoreApplicationPrivate::checkInstance(char const*)>:
  13ebf0:       cmpq   $0x0,0x4f73d0(%rip)        # 635fc8 <QCoreApplication::self>
  13ebf8:       setne  %al
  13ebfb:       je     a90fe <QCoreApplicationPrivate::checkInstance(char const*) [clone .cold]>
  13ec01:       ret

Meanwhile, accesses to the same variable in other modules are indirect
via the GOT:

   66650:       mov    0x876e1(%rip),%rax        # edd38 <QCoreApplication::self@Qt_6>
   66657:       cmpq   $0x0,(%rax)

This replaces the -Bsymbolic and -Bsymbolic-functions (broken)
functionality that Qt has been using or attempting to use since ~2006.

See https://gitlab.com/x86-psABIs/x86-64-ABI/-/issues/8#note_606975128

Change-Id: Iad4b0a3e5c06570b9f5f571b26ed564aa0811e47
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-03-10 17:10:57 -08:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Provide a qtpaths wrapper script when cross-building Qt 2021-11-08 13:41:03 +01:00
cmake Enable -mno-direct-extern-access and ELF protected visibility 2022-03-10 17:10:57 -08:00
coin CI: Increase timeout for waiting QNX qemu to start 2022-03-09 22:38:16 +02:00
config.tests CMake: add detection of x86 VAES and AVX512VBMI2 features 2022-03-08 00:31:30 -08:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Document use of android:allowNativeHeapPointerTagging in the manifest 2022-03-05 17:37:33 +02:00
examples secure UDP server: do not use deprecated protocol (DTLS 1.0) 2022-03-10 08:23:00 +00:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec Install 3rdparty headers for static builds 2022-02-19 01:52:32 +01:00
mkspecs Enable -mno-direct-extern-access and ELF protected visibility 2022-03-10 17:10:57 -08:00
qmake qmake: Fix overlong command lines for static Qt builds on Windows 2022-02-21 12:37:19 +01:00
src Enable -mno-direct-extern-access and ELF protected visibility 2022-03-10 17:10:57 -08:00
tests QStyle: Fix cases when logicalValue is outside range 2022-03-10 12:39:11 +01:00
util pro2cmake: Introduce qmake2cmake convenience scripts 2022-03-08 03:45:30 +01:00
.cmake.conf Bump version to 6.4.0 2022-01-31 17:20:06 +02:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Assume qhelpgenerator in libexec instead of bin 2021-11-08 19:27:32 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
CMakeLists.txt Use REALPATH based check for symbolic links on Windows 2022-01-07 14:31:38 +01:00
conanfile.py Conan: Include Android specific option values in 'package_id' 2022-03-01 00:01:04 +00:00
config_help.txt configure: CMake: Add -no-prefix option 2022-02-24 19:46:01 +01:00
configure Remove unsupported, host-related options from configure shell script 2021-08-05 02:44:27 +02:00
configure.bat configure.bat: Fix call without arguments 2022-02-16 12:05:48 +01:00
configure.cmake Enable -mno-direct-extern-access and ELF protected visibility 2022-03-10 17:10:57 -08:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
LICENSE.FDL Remove trailing whitespace in LICENSE.FDL 2021-11-26 18:28:49 +01:00
LICENSE.GPL2 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3-EXCEPT Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.QT-LICENSE-AGREEMENT Update LICENSE.QT-LICENSE-AGREEMENT 2022-02-16 17:19:34 +02:00
qt_cmdline.cmake configure: CMake: Add -no-prefix option 2022-02-24 19:46:01 +01:00
sync.profile Network: Use public suffix database in DAFSA format 2022-02-24 19:36:26 +01:00