Shell
$ cat hello.c
/* hello.c */
#include <stdio.h>
int main ()
{
printf ("Hello, world!\n");
}
$
$ gcc -g hello.c
$
все символы
$ nm a.out
000000000000037c r __abi_tag
0000000000004018 B __bss_start
0000000000004018 b completed.0
w __cxa_finalize@GLIBC_2.2.5
0000000000004008 D __data_start
0000000000004008 W data_start
0000000000001080 t deregister_tm_clones
00000000000010f0 t __do_global_dtors_aux
0000000000003dd8 d __do_global_dtors_aux_fini_array_entry
0000000000004010 D __dso_handle
0000000000003de0 d _DYNAMIC
0000000000004018 D _edata
0000000000004020 B _end
0000000000001154 T _fini
0000000000001130 t frame_dummy
0000000000003dd0 d __frame_dummy_init_array_entry
00000000000020e8 r __FRAME_END__
0000000000003fe8 d _GLOBAL_OFFSET_TABLE_
w __gmon_start__
0000000000002014 r __GNU_EH_FRAME_HDR
0000000000001000 T _init
0000000000002000 R _IO_stdin_used
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
U __libc_start_main@GLIBC_2.34
0000000000001139 T main
U puts@GLIBC_2.2.5
00000000000010b0 t register_tm_clones
0000000000001050 T _start
0000000000004018 D __TMC_END__
$
000000000000037c r __abi_tag
0000000000004018 B __bss_start
0000000000004018 b completed.0
w __cxa_finalize@GLIBC_2.2.5
0000000000004008 D __data_start
0000000000004008 W data_start
0000000000001080 t deregister_tm_clones
00000000000010f0 t __do_global_dtors_aux
0000000000003dd8 d __do_global_dtors_aux_fini_array_entry
0000000000004010 D __dso_handle
0000000000003de0 d _DYNAMIC
0000000000004018 D _edata
0000000000004020 B _end
0000000000001154 T _fini
0000000000001130 t frame_dummy
0000000000003dd0 d __frame_dummy_init_array_entry
00000000000020e8 r __FRAME_END__
0000000000003fe8 d _GLOBAL_OFFSET_TABLE_
w __gmon_start__
0000000000002014 r __GNU_EH_FRAME_HDR
0000000000001000 T _init
0000000000002000 R _IO_stdin_used
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
U __libc_start_main@GLIBC_2.34
0000000000001139 T main
U puts@GLIBC_2.2.5
00000000000010b0 t register_tm_clones
0000000000001050 T _start
0000000000004018 D __TMC_END__
$
Shell
$ objdump -h a.out | grep debug
27 .debug_aranges 00000030 0000000000000000 0000000000000000 0000303f 2**0
28 .debug_info 0000008c 0000000000000000 0000000000000000 0000306f 2**0
29 .debug_abbrev 00000043 0000000000000000 0000000000000000 000030fb 2**0
30 .debug_line 00000050 0000000000000000 0000000000000000 0000313e 2**0
31 .debug_str 00000097 0000000000000000 0000000000000000 0000318e 2**0
32 .debug_line_str 00000020 0000000000000000 0000000000000000 00003225 2**0
$Shell
$ man strip
...
--only-keep-debug
Strip a file, emptying the contents of any sections that would not be stripped by --strip-debug and leaving the debugging sections
intact. In ELF files, this preserves all the note sections in the output as well.
...
$Shell
$ gcc -g hello.c
$ strip --only-keep-debug a.out
$ nm a.out
000000000000037c r __abi_tag
0000000000004018 B __bss_start
0000000000004018 b completed.0
w __cxa_finalize@GLIBC_2.2.5
0000000000004008 B __data_start
0000000000004008 W data_start
0000000000001080 t deregister_tm_clones
00000000000010f0 t __do_global_dtors_aux
0000000000003dd8 b __do_global_dtors_aux_fini_array_entry
0000000000004010 B __dso_handle
0000000000003de0 b _DYNAMIC
0000000000004018 B _edata
0000000000004020 B _end
0000000000001154 T _fini
0000000000001130 t frame_dummy
0000000000003dd0 b __frame_dummy_init_array_entry
00000000000020e8 b __FRAME_END__
0000000000003fe8 b _GLOBAL_OFFSET_TABLE_
w __gmon_start__
0000000000002014 b __GNU_EH_FRAME_HDR
0000000000001000 T _init
0000000000002000 B _IO_stdin_used
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
U __libc_start_main@GLIBC_2.34
0000000000001139 T main
U puts@GLIBC_2.2.5
00000000000010b0 t register_tm_clones
0000000000001050 T _start
0000000000004018 B __TMC_END__
$