public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* undefined reference to symbol 'dlsym@@GLIBC_2.2.5' during qemu build
@ 2021-05-25  4:47 ckim
  2021-05-25  7:36 ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: ckim @ 2021-05-25  4:47 UTC (permalink / raw)
  To: libc-help

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-26  4:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25  4:47 undefined reference to symbol 'dlsym@@GLIBC_2.2.5' during qemu build ckim
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

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).