It seems that libbfd is returning some messed up data structures in some cases.
In my case, symbol->section is messed up for all symbols. It always points to
some uninitialised memory.
I have seen this while using oprofile and having a segfault in opreport (while
opreport tried to access sym->section).
Here are more details, with full listings of the data structures:
To be more exact, this is with binutils-2.19.1. I also tried binutils-2.18 and
have some very similar behaviour there. (You can see more details in the
oprofile bug report.)
Most likely you have built oprofile using bfd headers that don't match the
libbfd you are linking against.
Thanks a lot, that was the problem. It seems that I had left an old bfd.h in
/usr/local/includes and all system build scripts (Gentoo Portage) used that one
instead of the one in /usr/include. Removing the file from /usr/local/include,
recompiling binutils and oprofile solved the problem.