Jak wyświetlać symbole w plikach obiektowych?

Jak mogę przeglądać symbole wplik o? nm nie działa dla mnie. Używam g++ / linux.

Author: Vadim Kotov, 2010-10-07

5 answers

Zamiast nm, możesz użyć potężnego objdump. Szczegóły na stronie man. Spróbuj objdump -t myfile lub objdump -T myfile. Z flagą -C można również demangle C++ nazwy, jak nm robi.

 65
Author: DarkDust,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-10-07 11:05:25

Czy używałeś cross-kompilatora dla innej platformy? Jeśli tak, musisz użyć odpowiedniego nm LUB objdump commmand.

Na przykład, jeśli użyłeś XXX-YYY-gcc do kompilacji .o plik, musisz użyć XXX-YYY-nm lub XXX-YYY-objdump do przetworzenia plików.

 11
Author: Schedler,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-10-07 11:35:06

Istnieje polecenie, aby sprawdzić, które funkcje są zawarte w pliku obiektowym, bibliotece lub pliku wykonywalnym:

nm
 6
Author: Alok Save,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-10-07 10:58:06

Just run: nm you_obj_file.o | c++filt

 5
Author: Jee lee,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-30 02:20:06

Możesz użyć nm -C .o/lib/exe, na przykład:

xiongyu@ubuntu:~/tmp/build$ nm -C libfile1.a 

file1.cpp.o:
0000000000000000 T f()
0000000000000000 W int fun<int>(int)

Użycie nm -C będzie bardziej czytelne , jeśli użyjesz nm:

xiongyu@ubuntu:~/tmp/build$ nm libfile1.a 

file1.cpp.o:
0000000000000000 T _Z1fv
0000000000000000 W _Z3funIiET_S0_

Jak widzimy, nie jest tak czytelny.

Poniżej jest to, co moje file1.cpp Jak:

xiongyu@ubuntu:~/tmp/build$ vi ../file1.cpp 
#include "head.h"
void f()  {
     int i = fun<int>(42);
}
 0
Author: Jayhello,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-09-29 01:59:29