public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
* Deferred Binding of Function Pointers in SHLIB
@ 2016-01-01  0:00 Suprateeka R Hegde
  2016-01-01  0:00 ` Roland McGrath
  0 siblings, 1 reply; 5+ messages in thread
From: Suprateeka R Hegde @ 2016-01-01  0:00 UTC (permalink / raw)
  To: gnu-gabi

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

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

end of thread, other threads:[~2016-06-18  4:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01  0:00 Deferred Binding of Function Pointers in SHLIB Suprateeka R Hegde
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

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