Hello,
I faced with the situation where ./configure makes wrong decision about
if global variables should be prefixed or not.
Conditions.
Version: trunk (GNU MP 6.1.99)
Host type: armv7l-unknown-linux-gnueabi
Compiler: Linaro GCC 4.9.2
./configure \
--prefix=/usr \
--includedir=/usr/include \
--libdir=/usr/lib \
--enable-cxx \
To check if a global variable should be prefixed with underscore
./configure "greps" variable's name in object file in the following test:
cat conftest.c
int gurkmacka;
cat configure
..
$NM conftest.$OBJEXT >conftest.out
if grep _gurkmacka conftest.out >/dev/null; then
gmp_cv_asm_underscore=yes
elif grep gurkmacka conftest.out >/dev/null; then
gmp_cv_asm_underscore=no
else
echo "configure: $NM doesn't have gurkmacka:" >&5
cat conftest.out >&5
...
Generally it works fine, but being built with enabled AddressSanitizer
(-fsanitize=address, -fno-common), compiler generates instrumented code and
object file contains additional symbols whose names may incorporate
"_gurkmacka" as a substring, though actually global variable is not
prefixed.
Lets see an example:
Without AddressSanitizer:
cat conftest.out
00000004 C gurkmacka
With AddressSanitizer:
cat conftest.out
00000000 t _GLOBAL__sub_D_00099_0_gurkmacka
00000000 t _GLOBAL__sub_I_00099_1_gurkmacka
U __aeabi_unwind_cpp_pr0
U __asan_init
U __asan_register_globals
U __asan_unregister_globals
U __asan_version_mismatch_check_v6
00000000 B gurkmacka
Based on the former example ./configure erroneously assumes that global
variables should be prefixed.**
Attached patch fixes this issue.
-Pavel
changeset: 17030:7f39e874f4dc
tag: tip
user: Pavel Kopyl <[email protected]>
date: Mon Jan 25 21:17:43 2016 +0300
summary: Fix wrong prefix checking of global variables.
diff -r 7421da954a7b -r 7f39e874f4dc acinclude.m4
--- a/acinclude.m4 Fri Jan 15 22:42:22 2016 +0100
+++ b/acinclude.m4 Mon Jan 25 21:17:43 2016 +0300
@@ -1754,9 +1754,9 @@
gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC"
if AC_TRY_EVAL(gmp_compile); then
$NM conftest.$OBJEXT >conftest.out
- if grep _gurkmacka conftest.out >/dev/null; then
+ if grep "\<_gurkmacka\>$" conftest.out >/dev/null; then
gmp_cv_asm_underscore=yes
- elif grep gurkmacka conftest.out >/dev/null; then
+ elif grep "\<gurkmacka\>$" conftest.out >/dev/null; then
gmp_cv_asm_underscore=no
else
echo "configure: $NM doesn't have gurkmacka:" >&AC_FD_CC
_______________________________________________
gmp-bugs mailing list
[email protected]
https://gmplib.org/mailman/listinfo/gmp-bugs