This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: About dynamic and external symbols


This is sort of ELF 101, we don't mind pointing you to the answers.
But we're not going to describe all the excruciating detail to you.
docs.sun.com is (at least used to be) a good place for ELF documentation.
There are lots of other versions of the same specs floating around, but
that is pretty coherent and well-organized, and it's reasonably clear to
the seasoned readers what references in their manuals are Solaris-specific
stuff rather than generic ELF.  The stuff you've asked about here is the
same across the board.

> I was wondering what is difference between dynamic and external symbols, 
> ie. nm -D <ELF> and nm -g <ELF> output?

nm is a tool that massages a lot.  To understand ELF stuff, it's better to
use a more verbose and low-level tool like objdump, or better yet,
eu-readelf (or binutils readelf, they each have their points).  nm -D is
like objdump --dynamic-syms, while nm -g is like a subset of the objdump
--syms information.  In {eu-,}readelf both are shown by -s, since at low
level they are encoded the same ways.  The -D stuff is .dynsym, and the -g
is a subset of .symtab.

.symtab is "the symbol table", it's there for debugging and usually removed
by strip.  It's the same in static executables (e.g. vmlinux), which have
no .dynsym at all.  It's a non-SHF_ALLOC section, so it can be stripped
(and never appears in memory).  .dynsym is "the dynamic symbol table", it's
there to direct the dynamic linker at run time.  Hence it's an SHF_ALLOC
section that is part of the text no matter how hard you strip the file,
because it has to appear in memory at run time--DT_SYMTAB points to it.
When you are debugging with only a stripped executable/DSO, you may have
.dynsym to work with but no .symtab.  Similarly, when you are e.g. the
backtrace_symbols() function in libc, you have access to .dynsym in memory
but aren't able to look for .symtab in the file on disk even if it's there.


Thanks,
Roland

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]