From: Suprateeka R Hegde <hegdesmailbox@gmail.com>
To: gnu-gabi@sourceware.org
Subject: Deferred Binding of Function Pointers in SHLIB
Date: Fri, 01 Jan 2016 00:00:00 -0000 [thread overview]
Message-ID: <36cd44e9-9f62-6784-17d8-22dd3c41e9f6@gmail.com> (raw)
Hi
Consider this case:
---
$ cat libmain.c
#include <stdio.h>
extern void foo(void);
void (*func_p)(void) = foo;
void libmain()
{
printf("printf()\n");
(*func_p)();
}
$ cc -shared -fpic libmain.c -o libmain.so
$ cc main.c -L. -lmain -Wl,--unresolved-symbols=ignore-all
$ LD_LIBRARY_PATH=. ./a.out
./a.out: symbol lookup error: ./libmain.so: undefined symbol: foo
---
Though lazy binding is default, it does not seem to be applicable to
shared libraries. However, if the same libmain.c is made into an
executable, as in:
---
$ cat libmain.c
#include <stdio.h>
extern void foo(void);
void (*func_p)(void) = foo;
int main()
{
printf("printf()\n");
(*func_p)();
return 0;
}
$ cc libmain.c -Wl,--unresolved-symbols=ignore-all
$ ./a.out
printf()
Segmentation fault (core dumped)
---
That means lazy binding has happened. I would like to see both shlibs
and executable behavior same here. What is the problem if we make this
change? This can be part of the GNU-gABI itself.
--
Supra
next reply other threads:[~2016-06-05 7:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-01 0:00 Suprateeka R Hegde [this message]
2016-01-01 0:00 ` Roland McGrath
2016-01-01 0:00 ` Suprateeka R Hegde
2016-01-01 0:00 ` Carlos O'Donell
2016-01-01 0:00 ` Suprateeka R Hegde
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=36cd44e9-9f62-6784-17d8-22dd3c41e9f6@gmail.com \
--to=hegdesmailbox@gmail.com \
--cc=gnu-gabi@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).