5

for example android is using bionic rather than glibc, but how to figure out it is really using bionic http://en.wikipedia.org/wiki/Bionic_(software), not glibc?

can i find this information in /proc filesystem, or is there any command which can tell bionic is used on current system?

by the way, is that possible to have more than one c lib on embeded systems?

Swayam
  • 16,294
  • 14
  • 64
  • 102
hugemeow
  • 7,777
  • 13
  • 50
  • 63
  • 1
    If each application program was statically linked with its libc, then different libcs might be in use by different applications. – sawdust Aug 27 '12 at 09:06
  • how to link application statically to its c library? – hugemeow Aug 27 '12 at 09:30
  • 2
    For gcc use the `-static` option when you link. Use the utility `file` to tell you if the executable is static or dynamically linked. I use `strings` to list the libraries and entry points used by a dynamically-linked executable. – sawdust Aug 27 '12 at 10:15
  • 2
    `strace` will only show that open/mmap/close file operations have been performed on the library files. And you would have to run the command on the target board. So `strings` was not a typo. – sawdust Aug 28 '12 at 19:09

1 Answers1

4

If you have code that needs to behave differently depending on whether it's linked with Bionic or Glibc, this can and must be determined at compile time. Bionic and Glibc aren't binary compatible anyway, so you need to commit to one set of headers at compile time.

#if __BIONIC__
/* Bionic-specific code */    
#elif __GLIBC__
/* Glibc-specific code */
#else
#error "This C library is not supported"
#endif

You won't find any information in /proc because /proc contains information about the kernel, not about the C library.

In theory, it is possible to put as many C libraries on a system as you like. However this would be very unusual on an embedded system since these generally try to keep the code size down. The only system where I would expect multiple C libraries is on an embedded developper's machine, if that developper happens not to be cross-compiling (which is rare in the first place). Furthermore, Bionic is only used on Android, and only Bionic is used on Android, so all Android systems have Bionic and other systems don't have Bionic. Non-Android Linux systems have some other library, either Glibc or (on embedded systems) some other libc such as uClibc or Dietlibc.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254