From: Kai W. <kai...@gm...> - 2012-12-27 02:30:13
|
On Wed, Dec 26, 2012 at 6:42 AM, Joseph Koshy <jk...@us...> wrote: > Hello All, > > The proposed `elftc_symbol_table*()` and `elftc_string_table*()` > functions are convenience APIs for managing ELF symbol tables [1] and > string tables [2], respectively. > > These functions would be useful in implementing as(1), and could also > help reduce code duplication in our source tree. > > I have added reference documentation for these proposed functions to > the source tree in changesets [2819] and [2821]. > > Your review & comments of these APIs would be appreciated. Hi, I just briefly read the manual pages. The APIs look really good in general. Besides as(1), I think it can be used in elfcopy(1), ld(1) and other tools. Some questions: * What is the nested symbol table used for? Could you give an example? * Is it possible to customize the elftc_symbol_table_to_image? For example, ld(1) sometimes searchs symbols by name and symbol version. To achieve that, ld(1) stores symbol name is the form "symbol@version", "atoi@FBSD_1.0" for instance. When elftc_symbol_table_to_image is called, ld(1) will want the string "atoi" in the string table, not "atoi@FBSD_1.0". * How does elftc_symbol_table_to_image know where to find symbol size, value, shndx information? Suppose I define a struct: struct _MySymbol { Elftc_Symbol sym_base; uint64_t sym_size; uint64_t sym_value; uint64_t sym_shndx; } How does elftc_symbol_table_to_image know it should use sym_size, sym_value etc? Or it just return an array of GElf_Sym and let the application to fill in the value? * Is it possible to provide a sort API? e.g. elftc_symbol_table_sort(Elftc_Symbol_Table *table, int (*cmp)(Elftc_Symbol *s1, Elftc_Symbol *s2)) * Is it possible to provide a "replace" API? e.g. elftc_symbol_table_replace(Elftc_Symbol_Table *table, Elftc_Symbol *s1, Elftc_Symbol *s2) This API can be used when, for example, symbol resolving in ld(1). When application knows symbol s1 exists in the symbol table, it wants to replace s1 with s2 and expects that s2 will have the same position in the symbol table as s1. * What kind of internal data structures are you going to use to implement symbol table and string table? Will probably have more questions later when I read the string table API manual page. Thanks again for working on these symbol table APIs! We really need these since long ago. Thanks, Kai |