Linux how to see what is

How can I look inside a Linux .so or .a object and see what functions they contain?

The linker can presumably do this, so is there a command-line tool to list functions in object files and tell me the names of functions and their signatures?

2 Answers 2

For a shared library, you have to use:

Without the -D , nm dumps debug symbols; -D refers to the dynamic symbols that are actually used for dynamic linking. From Ubuntu 12 session:

$ nm /lib/i386-linux-gnu/libc.so.6 nm: /lib/i386-linux-gnu/libc.so.6: no symbols $ nm -D /lib/i386-linux-gnu/libc.so.6 | tail 0011fc20 T xdr_wrapstring 001202c0 T xdrmem_create 00115540 T xdrrec_create 001157f0 T xdrrec_endofrecord 00115740 T xdrrec_eof 00115690 T xdrrec_skiprecord 00120980 T xdrstdio_create 00120c70 T xencrypt 0011d330 T xprt_register 0011d450 T xprt_unregister 

On this system libc.so is stripped of debug symbols, so nm shows nothing; but of course there are symbols for the dynamic linking mechanism revealed by nm -D .

For a .a archive or .o object file, just nm . The symbols are the symbols; if these files are stripped, these objects cannot be used for linking.

Exported sumbols are indicated by a T . Required symbols that must be loaded from other shared objects have a U . Note that the symbol table does not include just functions, but exported variables as well.

Or if you only want to see exported symbols, add the —defined-only flag. eg: nm -D —defined-only /lib/libtest.so

Источник

Читайте также:  Посмотреть юсб устройства линукс

How to find out what a Linux command does

Learn how to locate, read, and use Linux system documentation with man, info, and /usr/share/doc files.

Hands typing on keyboard

Linux distributions contain three powerful sets of documentation to enable users and administrators to get the most out of the system. Knowing how to use these resources effectively is an essential skill for Linux users.

Training & certification

Here are the three documentation sets:

The man pages

Man pages are the go-to resource for nearly every Linux user working at the command line.

What can you discover via the man pages?

  • The command’s summary
  • Options and explanations
  • Examples
  • Author and maintainer

This is perfect for when you cannot recall less commonly used options or work on multiple operating system platforms daily (the options between Linux and Unix versions of commands often differ).

Using the man pages is straightforward; simply type the man command and include the command you need more information about. For example, to display the manual for the ls command, type man ls .

Man pages include a powerful set of search capabilities to help you find exactly what you need. Once the man page is displayed, type a forward slash (/) to enable keyword searching. Simply enter the word you’re looking for after the slash and select Enter. Use the n and N keys to find the next or previous example of the keyword. Use Ctrl+C to end the search.

Man pages are organized into the following sections:

  • User commands (section 1)
  • System calls (section 2)
  • C library functions (section 3)
  • Devices and special files (section 4)
  • File formats and conventions (section 5)
  • Games (section 6)
  • Miscellanea (section 7)
  • System administration tools and daemons (section 8)
Читайте также:  Linux partitions best practice

Typically, a request for a man page goes to section 1 or 8, but you can specify the section (assuming the requested command exists in multiple sections) by typing:

Comfort with accessing man pages and defining keyword searches is an essential Linux user skill. In fact, system documentation in general, and man pages specifically, are called out in the Red Hat Certified System Administrator (RHCSA) exam objectives.

[ See how your operating system is the foundation that solidifies and unifies your IT infrastructure in Why the operating system matters. ]

The info command

The info pages play a similar role to man pages, though they tend to be a little more user-friendly. The man pages are basically a short, terse reference, while info pages tend more toward readability and deeper explanations. The info page system also supports basic linking between documents for easier cross-referencing. This provides a more structured and readable documentation set.

The syntax for info pages is the same as with man :

Documentation

More formal documentation, along with templates, tutorials, licenses, and some configuration files, is found at /usr/share/doc . The files provide significantly more detail than man pages. These package-specific files are usually compressed, but tools such as vim and less handle the content seamlessly.

[ Learn more about Linux in the free training course Red Hat Enterprise Linux Technical Overview. ]

You can see what documentation is available by typing:

Each package has its own subdirectory. Run the following command to see the documentation for the Nano text editor:

The challenge

To help you practice using these resources, I’ve included three simple challenges involving the Nano text editor (so make sure Nano is installed before accomplishing these). The answer key is at the end of the article if you need it.

Читайте также:  Tl wn727n linux drivers

Great Linux resources

Wrap up

Not all systems are internet-connected, and not all reminders need to come from advanced Google searches. Sometimes all a sysadmin needs is a quick hint, «Oh yeah, that’s the option for long format.» Man pages are great for those short prompts. Info pages add more detail, better linking between resources, and more readability. The official documentation stored at /usr/share/doc provides the most depth, examples, templates, license information, and other relevant resources.

Источник

Оцените статью
Adblock
detector