Wrong prefix checking of global variables

Pavel Kopyl p.kopyl at samsung.com
Mon Jan 25 20:06:15 UTC 2016


I faced with the situation where ./configure makes wrong decision about 
if global variables should be prefixed or not.


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
   elif grep gurkmacka conftest.out >/dev/null; then
     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 

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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_wrong_var_prefix.patch
Type: text/x-patch
Size: 864 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-bugs/attachments/20160125/44d04a59/attachment.bin>

More information about the gmp-bugs mailing list