KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
glibc provides backtrace() and backtrace_symbols() to get the stack trace of a running program. But for this to work the program has to be built with linker's -rdynamic flag. What is the difference between -g flag passed to gcc vs linker's -rdynamic flag ? For a sample code I did readelf to compare the outputs. -rdynamic seems to produce more info under Symbol table '.dynsym' But I am not quite sure what the additional info is. Even if I strip a program binary built using -rdynamic , backtrace_symbols() continue to work. When strip removes all the symbols from the binary why is it leaving behind whatever was added by the -rdynamic flag ? Edit: Follow-up questions based on Mat's response below.. For the same sample code you took this is the difference I see with -g & -rdynamic without any option.. Symbol table '.dynsym' contains 4 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 218 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 (2) 2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses 3: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ Symbol table '.symtab' contains 70 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000400200 0 SECTION LOCAL DEFAULT 1 2: 000000000040021c 0 SECTION LOCAL DEFAULT 2 with -g there are more sections, more entries in .symtab table but .dynsym remains the same.. [26] .debug_aranges
Tags (comma-separated)
Save Edits
Cancel