31

For PE executable, I can list the imported symbols using

dumpbin /imports FILE.EXE

or using the depends utility which is GUI application.

`nm ELF-binary' just returns "no symbols".

1

4 Answers 4

27

Try objdump -T 'ELF-file'

2
  • I thought objdump -T worked mainly on shared libraries... Jul 9, 2010 at 14:35
  • well... not really, if I do: objdump -t /bin/ls it returns: "SYMBOL TABLE: no symbols", with -T (which lists DYNAMIC SYMBOL TABLE) outputs a lot of data, like: "00000000 DF UND 00000000 GLIBC_2.0 strchr" Jul 9, 2010 at 15:11
9

The output from objdump is a little excessive for this purpose, and requires a good bit of parsing to find the actual imports.

I prefer readelf for this purpose:

readelf -d dynamic-buffer-test

Dynamic section at offset 0x630a8 contains 23 entries:
 Tag                Type                 Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]

As you can see, the required libraries are marked with "NEEDED".

2
  • It just depends on the mode in which you invoke it. Try objdump -p /path/to/binary | grep NEEDED.
    – sherrellbc
    Nov 8, 2016 at 21:37
  • 2
    This only seems to list libraries, not symbols.
    – plugwash
    Jul 9, 2019 at 19:57
6

I prefer readelf.

readelf -s <file>

1
  • @Alcaro You have not tried this command. -s dumps the symbol table. In the table, you then have entries marked as undefined UND in the section index. These are the imported symbols. Oct 11, 2023 at 14:35
2

Along with the other answers posted here I would like to propose another. The contents printed are a function of the file format, where ELF lends itself nicely to solving this problem.

objdump -p /path/to/binary | grep NEEDED

The grep simply extracts the contents of the Dynamic Section, but its the format of the objdump -p output that makes this a simple solution.

1
  • This doesn't output imported symbols. Just library dependencies.
    – Dan M.
    Dec 28, 2023 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .