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: Wed, 26 May 2021 13:57:17 +0900

Hi, all

In this email thread, I asked about my problem of failing to connect to dlsym 
or dlopen function, and I later wrongly changed the function names to 
__libc_dlsym and __libc_dlopen that are in libc.so which caused seg-fault. (I 
should have connected to libdl.so which really has dlsym and dlyopen functions, 
not to libc.so, I was confused then). I asked at libc-help@sourceware.org 
email-list and someone (Florian Weimer) told me it was surely because -ldl 
option was ignored because it was place too early in the link command.
It was really the case, and I found I added -ldl to the --extra-cflags too 
during the configure and it was placed very early in the final c++ link command 
and was ignored.

I looked into the configure script and figured out how to do it. Now the 
configure command for using libdl.so is this (under build directory):

../configure --target-list=aarch64-softmmu --enable-debug --enable-gtk 
--extra-ldflags="-Wl,--no-as-needed -ldl"

Because the link flas is placed at the end, the -ldl option is not ignored. 
Now the "undefined reference to symbol 'dlsym@@GLIBC_2.2.5'" error is gone, and 
dlopen, dlsym works just ok, 
and I started normal debugging(qemu connected with an external .so file).
Hope this helps anyone.

Thanks,

Chan Kim

PS. This morning I had the debugger hang problem (after initialization) and it 
was solved by fixing ./ddd/init file. 
(I changed "set extended-prompt not set\n\"  to "set extended-prompt (gdb) \n\" 
 https://stackoverflow.com/questions/2914003/ddd-hangs-on-start)

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






reply via email to

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