public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gauryogesh.nsit at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/55872] Crash issue with RTLD_DEEPBIND usage with stdc++ library Date: Mon, 07 Jan 2013 10:31:00 -0000 [thread overview] Message-ID: <bug-55872-4-6idEtOddqN@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55872-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55872 --- Comment #4 from Yogesh Gaur <gauryogesh.nsit at gmail dot com> 2013-01-07 10:31:19 UTC --- Hello, Actually issue is combination of copy_relocation plus RTLD_DEEPBIND flag. If I didn't give -fPIE flag while compiling my executable and pass RTLD_DEEPBIND flag while opening library using dlopen(), then result is un-expected. I checked similar issue exist on gcc also: ------------------------------Source Code ----------------------------- $ cat main.c #include <dlfcn.h> extern int alpha; int main() { char const * const name = "./lib1.so"; void * handle = dlopen(name, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND); typedef void (*library_function_type)(); library_function_type func1 = dlsym(handle, "func1"); alpha = 10; (*func1)(); func2(); dlclose(handle); return 0; } $ cat lib1.c #include <stdio.h> extern int alpha; void func1(){ printf("lib1: Addr=%p, value=%d\n", &alpha, alpha); } $ cat lib2.c #include <stdio.h> int alpha; void func2(){ printf("lib2: Addr=%p, value=%d\n", &alpha, alpha); } -------------------------------- END ---------------------------------- Compilation command and output: gcc -shared -fPIC lib2.c -o lib2.so gcc -shared -fPIC lib1.c lib2.so -o lib1.so gcc -ldl main.c lib2.so -o a.out LD_LIBRARY_PATH=$PWD ./a.out lib1: Addr=0x7f5a39663028, value=0 lib2: Addr=0x601038, value=10 ========================================= Thus for same symbol, alpha, we get two addresses values. If I remove RTLD_DEEPBIND while opening library, I didn't get this issue: lib1: Addr=0x601038, value=10 lib2: Addr=0x601038, value=10 Reason for this also I know that in case of RTLD_DEEPBIND scope of search for lib1.so is its internal library first and then only global library's being searched. I want to know that apart from usage of -fPIE flag at compilation time did any-other solution exist for this issue? As using -fPIE has it's own side-affect. -- Regards, Yogesh Gaur.
prev parent reply other threads:[~2013-01-07 10:31 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-01-04 10:28 [Bug libstdc++/55872] New: " gauryogesh.nsit at gmail dot com 2013-01-04 10:30 ` [Bug libstdc++/55872] " gauryogesh.nsit at gmail dot com 2013-01-04 11:02 ` redi at gcc dot gnu.org 2013-01-07 0:12 ` gauryogesh.nsit at gmail dot com 2013-01-07 10:31 ` gauryogesh.nsit at gmail dot com [this message]
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=bug-55872-4-6idEtOddqN@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.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: linkBe 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).