0

When I run libc.so.6 in command line I get information about its version:

[intigua@localhost src]$ /lib/libc.so.6
GNU C Library stable release version 2.5, by Roland McGrath et al.
Copyright (C) 2006 Free Software Foundation, Inc.
...

How do I make my .so to do this?
If I just try to activate a .so I compiled, it just causes a segmentation fault. What is it trying to run?

shoosh
  • 76,898
  • 55
  • 205
  • 325
  • 2
    Add a `main` function, and make it executable? – Some programmer dude Aug 19 '14 at 07:26
  • 1
    wouldn't that interfere with the main() of any program that uses this shared object? – shoosh Aug 19 '14 at 07:31
  • 1
    There might be problems. But you don't actually don't need a `main` function in the library, you can just tell the linker when linking the shared library to use any function you desire to be the entry point, and therefore avoid potential clashes. – Some programmer dude Aug 19 '14 at 07:39
  • @PaulR the question you linked to does not really have a proper answer. Not do the questions linked from it. – shoosh Aug 19 '14 at 07:43
  • Really? What's wrong with [this answer](http://stackoverflow.com/a/4963337/253056), or [this answer](http://stackoverflow.com/a/1451482/253056) ? – Paul R Aug 19 '14 at 07:44
  • @PaulR the first is partial since it takes more than defining this symbol for this to work see [this answer](http://unix.stackexchange.com/questions/7066/executing-a-shared-library). The second is strange because it compiles an executable and not a shared object and I have a feeling there is a better way to do it. – shoosh Aug 19 '14 at 08:03
  • Look more closely at the second one - it compiles a .so, and an executable that uses that .so, to illustrate how the different main functions get called depending on whether you invoke the .so directly or use it in the normal way with an executable. As for the first answer, I don't really understand your objection - it shows the actual source for libc that is responsible for the behaviour you're asking about ? – Paul R Aug 19 '14 at 08:08

0 Answers0