How to list imported symbols in ELF executable?
--------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands
--
Chapters
00:00 Question
00:29 Accepted answer (Score 25)
00:40 Answer 2 (Score 9)
01:14 Answer 3 (Score 5)
01:28 Answer 4 (Score 2)
02:02 Thank you
--
Full question
https://superuser.com/questions/161722/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #compile
#avk47
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands
--
Chapters
00:00 Question
00:29 Accepted answer (Score 25)
00:40 Answer 2 (Score 9)
01:14 Answer 3 (Score 5)
01:28 Answer 4 (Score 2)
02:02 Thank you
--
Full question
https://superuser.com/questions/161722/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #compile
#avk47
ACCEPTED ANSWER
Score 27
Try objdump -T 'ELF-file'
ANSWER 2
Score 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".
ANSWER 3
Score 6
I prefer readelf
.
readelf -s <file>
ANSWER 4
Score 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.