From: <ckim@etri.re.kr>
To: <libc-help@sourceware.org>
Subject: undefined reference to symbol 'dlsym@@GLIBC_2.2.5' during qemu build
Date: Tue, 25 May 2021 13:47:29 +0900 [thread overview]
Message-ID: <025a01d75121$117aa560$346ff020$@etri.re.kr> (raw)
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
next reply other threads:[~2021-05-25 4:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-25 4:47 ckim [this message]
2021-05-25 7:36 ` Florian Weimer
2021-05-25 12:17 ` ckim
2021-05-25 12:21 ` Florian Weimer
2021-05-26 1:16 ` ckim
2021-05-26 1:48 ` Jeffrey Walton
2021-05-26 4:57 ` ckim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='025a01d75121$117aa560$346ff020$@etri.re.kr' \
--to=ckim@etri.re.kr \
--cc=libc-help@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).