Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Inspecting GDB Symbol Tables on Linux via Compiler and CLI Utilities

Tech May 15 1

When source code is compiled, human-readable identifiers such as function and variable names are transformed into memory addresses. A symbol table is a data structure produced during compilation that retains the mapping between these identifiers and their corresponding addresses, along with type information, source locations, and scoping details. Debuggers like GDB rely on this table to allow you to refer to symbols by name and to navigate the program’s structure during a debugging session.

To embed symbol information into an ELF binary, include debug data at compile time. With GCC, use the -g flag:

gcc -g -o example example.c

This command generates an executable example that includes DWARF debugging information, which contains the symbol table. Keep in mind that the resulting binary will be larger; production deployments often strip these sections for size and performance reasons.

Several command-line tools let you inspect the symbol table without launching GDB. The nm utility lists symbols from object files:

nm example

By default, nm output is sorted alphabetically and shows symbol names alongside their types and values. You can also use objdump with the -t option for a more detailed table:

objdump -t example

For even richer output, readelf -s displays symbol information directly from ELF sections:

readelf -s example

Inside a GDB session, the debugger itself can query the symbol table. Use info functions to list all defined functions and their load addresses, or info variables to view global and static variables. Additional commands like info types and info scope help you explore the full debugging information available.

Understanding how to generate and read symbol tables equips you to diagnose issues more efficiently and gives you deeper insight into compiled programs.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.