qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: how to include out of tree source during the qemu build? ==> undefin


From: ckim
Subject: RE: how to include out of tree source during the qemu build? ==> undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
Date: Mon, 24 May 2021 16:39:05 +0900

I tried "find /usr -name libc.so" and 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 ) )

I used "nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep dlsym" and found the 
functions name is now __glibc_dlsym, not dlsym. So I changed the name.
Also dlopen was changed to __glibc_dlopen and since dlerror was not defined 
there, I substituted it with a print. With those changes it builds ok.
Hope it helps anyone. (but I don't know how the code was compiled ok in a build 
for a separate application, in the same system..)

Thanks!
Chan Kim


> -----Original Message-----
> From: ckim@etri.re.kr <ckim@etri.re.kr>
> Sent: Monday, May 24, 2021 2:11 PM
> To: 'Peter Maydell' <peter.maydell@linaro.org>
> Cc: 'qemu-discuss' <qemu-discuss@nongnu.org>
> Subject: RE: how to include out of tree source during the qemu build? ==>
> undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
> 
> Hi, all,
> 
> I added --extra-ldflags=-ldl (and --extra-cflags options which I need)
> during the configuration and can see QEMU_LDFLAGS now contain -ldl during
> the make.
> But I still see this error below(make run under build directory, this is
> qemu-5.1.0).
> (The source code hw/misc/axpu_if.c contains #include <dlfcn.h> line. )
> 
> /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
> 
> To see my glibc version, I tried this,
> 
> 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.
> 
> The corresponding code (using dlopen and dlsym) can be compiled ok in my
> system when run separately so I don't think I should install lower version
> of glibc.
> I don't know what to try. Has anybody any suggestion?
> Thanks!
> Chan Kim
> 
> > -----Original Message-----
> > From: Peter Maydell <peter.maydell@linaro.org>
> > Sent: Thursday, May 20, 2021 6:10 PM
> > To: Chan Kim <ckim@etri.re.kr>
> > Cc: qemu-discuss <qemu-discuss@nongnu.org>
> > Subject: Re: how to include out of tree source during the qemu build?
> >
> > On Thu, 20 May 2021 at 06:11, <ckim@etri.re.kr> wrote:
> > > I’m trying to include a out-of-tree source in a peripheral model and
> > want to connect to a .so file during qemu operation.
> > >
> > > (This .so files was made by my colleague and contains the behaviors
> > > of a
> > peripheral.
> > >
> > > I want to place the codes needed to link to this .so file outside
> > > the
> > source tree as much as possible and use #include or VPATH in Makefile.
> > >
> > > I’ll use dlopen and dlsym functions to the .so file and use the
> > functions there).
> > >
> > > If I want to add an include path or VPATH, where should I give them
> > during the configure/make process and how?
> >
> > You're largely on your own here:
> >  (1) you're using an old version of QEMU which predates the complete
> >      overhaul of the build system
> >  (2) you're trying to do something that upstream has very little
> >      interest in
> >
> > I would probably try to treat this .so file like any other library
> > that QEMU might need to use -- have configure find it and set up any
> > cflags/ldflags settings necessary to compile and link to it.
> >
> > > Also, I started reading
> > https://qemu.readthedocs.io/en/latest/devel/build-system.html but this
> > is for the latest version.
> > >
> > > And in this documents, it says it shows how to build qemu under the
> > source tree and out of tree.
> > >
> > > In the out of tree build option header, it says, “VPATH, build
> > > artifacts
> > outside of QEMU source tree entirely” and I can’t understand why it
> > contains the word VPATH.
> >
> > The old (pre-meson) build system used GNU Make's VPATH feature
> > https://www.gnu.org/software/make/manual/html_node/General-Search.html
> > in order to support "run make in a build directory that is not the
> > same as the source directory". Under meson we still support that (and
> > indeed we now *only* support source-and-build-trees different), but
> > the mechanism has changed. The build-system docs should probably not
> > really use the word "VPATH" any longer as it's a bit confusing.
> >
> > > And this document is for the latest version.(6.x.x) but where can I
> > > read
> > the equivalent document for version 5.1.0?
> >
> > It will be in the source tree for 5.1.0, or it won't exist at all
> > because we hadn't documented the build system yet.
> >
> > thanks
> > -- PMM







reply via email to

[Prev in Thread] Current Thread [Next in Thread]