History

Improve comments for symbol export and binding

Thomas Preud'homme committed 10 years ago

Commit 9e6610b1 parent e9769a71 file · +9 −5Browse files

Unified · Split

tccelf.c+9−5
@@ -2069,16 +2069,17 @@ static void bind_exe_dynsyms(TCCState *s1) · 2068 unmodified lines
20692069 }
20702070 }
20712071
2072−/* Bind symbols of libraries: export non local symbols of executable that
2073− resolve undefined symbols of shared libraries */
2072+/* Bind symbols of libraries: export all non local symbols of executable that
2073+ are referenced by shared libraries. The reason is that the dynamic loader
2074+ search symbol first in executable and then in libraries. Therefore a
2075+ reference to a symbol already defined by a library can still be resolved by
2076+ a symbol in the executable. */
20742077 static void bind_libs_dynsyms(TCCState *s1)
20752078 {
20762079 const char *name;
20772080 int sym_index;
20782081 ElfW(Sym) *sym, *esym;
20792082
2080− /* now look at unresolved dynamic symbols and export
2081− corresponding symbol */
20822083 for_each_elem(s1->dynsymtab_section, 1, esym, ElfW(Sym)) {
20832084 name = (char *) s1->dynsymtab_section->link->data + esym->st_name;
20842085 sym_index = find_elf_sym(symtab_section, name);
@@ -2096,7 +2097,10 @@ static void bind_libs_dynsyms(TCCState *s1) · 11 unmodified lines
20962097 }
20972098 }
20982099
2099−/* Export all non local symbols (for shared libraries) */
2100+/* Export all non local symbols. This is used by shared libraries so that the
2101+ non local symbols they define can resolve a reference in another shared
2102+ library or in the executable. Correspondingly, it allows undefined local
2103+ symbols to be resolved by other shared libraries or by the executable. */
21002104 static void export_global_syms(TCCState *s1)
21012105 {
21022106 int nb_syms, dynindex, index;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t