On Fedora 31, I see that gdb knows the symbols of some system binaries, e.g. main
of /usr/bin/true
:
$ gdb -ex 'set height 0' -ex 'disas main' -ex q /bin/true
Reading symbols from /bin/true...
Reading symbols from .gnu_debugdata for /usr/bin/true...
(No debugging symbols found in .gnu_debugdata for /usr/bin/true)
Dump of assembler code for function main:
0x0000000000002550 <+0>: endbr64
0x0000000000002554 <+4>: cmp edi,0x2
[..]
But main
doesn't show up in objdump -d
nor `nm output:
$ objdump -d /usr/bin/true | grep '\<main\>'
$ nm /usr/bin/true | grep main
nm: /usr/bin/true: no symbols
$ nm -D /usr/bin/true | grep '\<main\>'
$
How come? Is gdb able to read the main symbol
from some additional symbol table?
When I compile my own binaries with gcc, nm/objdump show the main
symbol as expected. Also, when I strip such a binary, gdb can't find the main
symbol, as well.
I assume that rpmbuild calls gcc/strip with some special flags that cause the above behavior. What are those?