diff options
| author | Thomas Preud'homme <robotux@celest.fr> | 2016-11-12 23:16:04 +0800 |
|---|---|---|
| committer | Thomas Preud'homme <robotux@celest.fr> | 2016-12-03 17:26:51 +0000 |
| commit | 9e6610b0aaa9aae149ec575b86c8eb86a35e081a (patch) | |
| tree | 83985de8c6f036756cfc074f0431529b1a384648 | |
| parent | e9769a7249444872200c8c1f1a2f2252c498056f (diff) | |
| download | tinycc-9e6610b0aaa9aae149ec575b86c8eb86a35e081a.tar.gz tinycc-9e6610b0aaa9aae149ec575b86c8eb86a35e081a.tar.bz2 | |
Improve comments for symbol export and binding
| -rw-r--r-- | tccelf.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -2069,16 +2069,17 @@ static void bind_exe_dynsyms(TCCState *s1) } } -/* Bind symbols of libraries: export non local symbols of executable that - resolve undefined symbols of shared libraries */ +/* Bind symbols of libraries: export all non local symbols of executable that + are referenced by shared libraries. The reason is that the dynamic loader + search symbol first in executable and then in libraries. Therefore a + reference to a symbol already defined by a library can still be resolved by + a symbol in the executable. */ static void bind_libs_dynsyms(TCCState *s1) { const char *name; int sym_index; ElfW(Sym) *sym, *esym; - /* now look at unresolved dynamic symbols and export - corresponding symbol */ for_each_elem(s1->dynsymtab_section, 1, esym, ElfW(Sym)) { name = (char *) s1->dynsymtab_section->link->data + esym->st_name; sym_index = find_elf_sym(symtab_section, name); @@ -2096,7 +2097,10 @@ static void bind_libs_dynsyms(TCCState *s1) } } -/* Export all non local symbols (for shared libraries) */ +/* Export all non local symbols. This is used by shared libraries so that the + non local symbols they define can resolve a reference in another shared + library or in the executable. Correspondingly, it allows undefined local + symbols to be resolved by other shared libraries or by the executable. */ static void export_global_syms(TCCState *s1) { int nb_syms, dynindex, index; |
