Home > Enterprise >  how to view the functions and contents of a library [closed]
how to view the functions and contents of a library [closed]

Time:10-05

I want to know how can I see the functions and the contents of a library in C language?

CodePudding user response:

is nm libconfig.a | c filt what you are looking for?

CodePudding user response:

In general, you cannot see the source code of functions of a library (e.g. some libfoo.a or libfoo.so.* Linux files) compiled from C source code.

You should ask for the documentation of that library. If it is developed in house, you may need to discuss with colleagues.

I do like open source libraries like GNU libc or GTK. Because you are allowed to download their source code and study it.

Be aware of code obfuscation techniques and of Rice's theorem. Decompilation of binary libraries is legally forbidden in some countries.

But a lot of libraries are not open source.

On Linux, tools like objdump(1) or readelf(1) could be helpful.

Notice that some libraries (e.g. GNU lightning) are generating new functions and machine code at runtime. Hence the notion of function might be not as easy as you think.

On Linux, programs like my manydl.c or Bismon, or RefPerSys, or SBCL, are generating code at runtime: for manydl.c and Bismon it generates C code and dlopen(3) it after having compiled it as a plugin.

Jacques Pitrat's book Artificial Beings: the conscience of a conscious machine ISBN 978-1-84821-101-8 explains the interest of generating code at runtime. A relevant concept is partial evaluation.

  •  Tags:  
  • c
  • Related