Right now, gdb's symbol readers add offsets to symbol addresses as the symbols are created. This means that a symbol table is tied to a program space. However, there is no reason that this needs to be so, and the "objfile splitting" project will change this.
The main benefit of this change is that it will be possible to share symbol tables across program spaces. This is a performance gain for some multi-inferior debugging cases. This will also enable sharing of symbol tables within a given program space if dlmopen is used (and is ever supported in gdb). It may also help with fine-grained breakpoint resetting.
This is called "objfile splitting" because the main task is to split struct objfile into program-space-dependent and program-space-independent pieces.
Some parts of this work have already gone in. In particular, struct objfile_per_bfd_storage is the basis of the split: it holds data that was formerly on the objfile, but which is now independent of the program space and attached to the BFD.
Future changes include:
Check in the obj_section removal patch series. This series is related to objfile splitting because it removes a back-link from symbols to the objfile.
- Push the demangled name cache into the per-BFD data structure. This may be tricky if any debuginfo section requires relocations -- in this case, I think the data cannot be shared. Perhaps some generic approach can be taken here; right now the per-BFD structure is not always shared, and maybe this idea can be expanded.
- Make minimal symbols program-space-independent. This requires:
Computing addresses at runtime, by passing an objfile parameter to SYMBOL_VALUE_ADDRESS;
- ... thus implying that we should use bound minsyms nearly everywhere.
- Fix up minsym.c to understand the new setup.
- Fix up all the symbol readers so they do not apply offsets when constructing minsyms.
- Make partial symbols program-space-independent. This includes the psymtab addrmap.
- This is somewhat tricky because psymtabs have a link to the symtab. If the change is done incrementally, then this will need to (temporarily) change.
- Make full symbols program-space-independent.
- symtabs have a backlink to the objfile
We'll need some form of "bound symbol", so SYMBOL_VALUE_ADDRESS can be given two arguments here.
struct type also has a backlink to the objfile; this should probably change to a link to the obstack instead.
Put sym_fns into per-BFD storage. This item might be pretty easy.
Remove objfile_relocate. Victory!