Without -Bsymbolic, a symbol/function in a *.so can be overridden by a symbol/function in the main module. That is the default search order, but not supported by tcc. With -Bsymbolic, the linker tries to resolve a symbol/function in the current module first. The loader in tcc implements this search order. We do not distinguish -Bsymbolic and -Bsymbolic-function -- By by ... Detlef
Unified · Split
| @@ -386,6 +386,8 @@ static int parse_args(TCCState *s, int argc, char **argv) · 385 unmodified lines | ||
| 386 | 386 | if (strstart(optarg, "-Ttext,", &p)) { |
| 387 | 387 | s->text_addr = strtoul(p, NULL, 16); |
| 388 | 388 | s->has_text_addr = 1; |
| 389 | + } else if (strstart(optarg, "-Bsymbolic", &p)) { | |
| 390 | + s->symbolic = TRUE; | |
| 389 | 391 | } else if (strstart(optarg, "--section-alignment,", &p)) { |
| 390 | 392 | s->section_align = strtoul(p, NULL, 16); |
| 391 | 393 | } else if (strstart(optarg, "--image-base,", &p)) { |
| @@ -445,6 +445,9 @@ struct TCCState { · 444 unmodified lines | ||
| 445 | 445 | /* if true, all symbols are exported */ |
| 446 | 446 | int rdynamic; |
| 447 | 447 | |
| 448 | + /* if true, resolve symbols in the current module first (-Wl,Bsymbolic) */ | |
| 449 | + int symbolic; | |
| 450 | + | |
| 448 | 451 | /* if true, only link in referenced objects from archive */ |
| 449 | 452 | int alacarte_link; |
| 450 | 453 | |
| @@ -1575,6 +1575,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1574 unmodified lines | ||
| 1575 | 1575 | put_dt(dynamic, DT_SONAME, put_elf_str(dynstr, s1->soname)); |
| 1576 | 1576 | put_dt(dynamic, DT_TEXTREL, 0); |
| 1577 | 1577 | } |
| 1578 | + | |
| 1579 | + if (s1->symbolic) | |
| 1580 | + put_dt(dynamic, DT_SYMBOLIC, 0); | |
| 1581 | + | |
| 1578 | 1582 | /* add necessary space for other entries */ |
| 1579 | 1583 | saved_dynamic_data_offset = dynamic->data_offset; |
| 1580 | 1584 | dynamic->data_offset += sizeof(ElfW(Dyn)) * EXTRA_RELITEMS; |