From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mscreen.etri.re.kr (mscreen.etri.re.kr [129.254.9.16]) by sourceware.org (Postfix) with ESMTPS id 78373385E02C for ; Tue, 25 May 2021 04:47:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 78373385E02C Received: from unknown (HELO send001-relay.gov-dooray.com) (211.180.235.152) by 129.254.9.16 with ESMTP; 25 May 2021 13:47:30 +0900 X-Original-SENDERIP: 211.180.235.152 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: libc-help@sourceware.org Received: from [10.162.225.112] (HELO smtp002-imp.gov-dooray.com) ([10.162.225.112]) by send001-relay.gov-dooray.com with SMTP id dc3260d560ac8162; Tue, 25 May 2021 13:47:30 +0900 Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp002-imp.gov-dooray.com with SMTP id 5d7dd52f60ac8162; Tue, 25 May 2021 13:47:30 +0900 From: To: Subject: undefined reference to symbol 'dlsym@@GLIBC_2.2.5' during qemu build Date: Tue, 25 May 2021 13:47:29 +0900 Message-ID: <025a01d75121$117aa560$346ff020$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AddRIQuC7Esbbr6cSJCp7T3DPGq74w== Content-Language: ko X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, HTML_MESSAGE, SPF_HELO_NONE, SPF_PASS, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2021 04:47:37 -0000 Hello, glibc users/developers, I'm adding a code into qemu-5.1.0 and this code should use an external shared library file (libaxpusim.so) that one of my colleagues made. (I'm on ubuntu 20.04, x86_64 machine). I added -ldl to the build flags for qemu using the configure --extra-cflags/--extra-cxxflags/--extra-ldflags options and can see they are really set. But when I actually do "make", it gives me this error and I can't figure out why. (error message at the end) LINK aarch64-softmmu/qemu-system-aarch64 /usr/bin/ld: ../hw/misc/axpu_if.o: undefined reference to symbol 'dlsym@@GLIBC_2.2.5' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make[1]: *** [Makefile:219: qemu-system-aarch64] Error 1 make: *** [Makefile:527: aarch64-softmmu/all] Error 2 Here is the "ldd --version" command output. My system's glibc version seems to be 2.31 (ubuntu 20.04), but I don't know why it's looking for the symbol dlsym from glibc_2.2.5. ckim@ckim-ubuntu:~/xxx/qemu-5.1.0/build$ ldd --version ldd (Ubuntu GLIBC 2.31-0ubuntu9.2) 2.31 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper. Later, I found /usr/lib/x86_64-linux-gnu/libc.so is a text file with contents /* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf64-x86-64) GROUP ( /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a AS_NEEDED ( /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ) ) So I used "nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep dlsym" and found the functions name is in the .so file is __glibc_dlsym, not dlsym. So I changed the name dlsym to __libc_dlsym and likewise changed dlopen to __glibc_dlopen and since dlerror was not defined there, I substituted it with a print. With those changes it builds ok. But whe the code runs, the __libc_dlopen opens the .so file, but the __libc_dlsym causes segmentation fault. Strange thing is, with the same external libaxpusim.so file, another independent application was built ok and runs ok (using same code using dlopen and dlsym, without changing dlopen, dlsym function name). So I guess I should be able to build modified qemu without the names changes to dlopen and dlsym. Could anyone tell me in what situation I might be in now, and how I can solve this segmentation fault error problem? (the __libc_dloopen_model return value seems normal, a nonzero pointer). If I follow glibc using gdb, the segmentation fault occurs in this code. Glibc-2.31/elf/dl-libc.c) 106 args->loadbase = GLRO(dl_lookup_symbol_x) (args->name, args->map, &args->ref, 107 args->map->l_local_scope, NULL, 0, 108 DL_LOOKUP_RETURN_NEWEST, NULL); Any suggestion or hint will also be appreciated. Thanks! Chan Kim