Work around Clang < 3.7 integrated assembler bug PC-relative relocs

The qversiontagging.h inline assembly expands to:

  .long qt_version_tag@GOTPCREL

Which, with GCC, Clang >= 3.7 and with the option -no-integrated-as in
previous versions, produces the proper relocation (a R_X86_64_GOTPCREL).
With Clang < 3.7, it instead produces a R_X86_64_32, which is unsuitable
for use in shared libraries: 32-bit displacement is insufficiently wide
and would produce linker errors like

 obj/qftp.o: requires dynamic R_X86_64_32 reloc against 'qt_version_tag' which may overflow at runtime; recompile with -fPIC

Instead, force a 64-bit relocation (an R_X86_64_GOT64), which like the
32-bit version is simply an offset into the GOT of where the address of
the symbol is stored.

Task-number: QTBUG-50749
Change-Id: I7a9e11d7b64a4cc78e24ffff142e039c172b802c
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
bb10
Thiago Macieira 2016-01-29 13:41:38 -08:00 committed by Jani Heikkinen
parent 46c73be471
commit 3726c46735
1 changed files with 1 additions and 5 deletions

View File

@ -59,11 +59,7 @@ QT_BEGIN_NAMESPACE
#elif defined(Q_CC_GNU) && !defined(Q_OS_ANDROID)
# if defined(Q_PROCESSOR_X86) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD_KERNEL))
# if defined(Q_PROCESSOR_X86_64) // x86-64 or x32
# if defined(__code_model_large__)
# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
# else
# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n"
# endif
# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
# else // x86
# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
# endif