History

Recognize -Wl,-Bsymbolic

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

Detlef Riekenberg committed 16 years ago

Commit 26505841 parent 5caf6233 files · +9 −0Browse files

Unified · Split

3 files
  1. tcc.c +2 −0
  2. tcc.h +3 −0
  3. tccelf.c +4 −0
tcc.c+2−0
@@ -386,6 +386,8 @@ static int parse_args(TCCState *s, int argc, char **argv) · 385 unmodified lines
386386 if (strstart(optarg, "-Ttext,", &p)) {
387387 s->text_addr = strtoul(p, NULL, 16);
388388 s->has_text_addr = 1;
389+ } else if (strstart(optarg, "-Bsymbolic", &p)) {
390+ s->symbolic = TRUE;
389391 } else if (strstart(optarg, "--section-alignment,", &p)) {
390392 s->section_align = strtoul(p, NULL, 16);
391393 } else if (strstart(optarg, "--image-base,", &p)) {
tcc.h+3−0
@@ -445,6 +445,9 @@ struct TCCState { · 444 unmodified lines
445445 /* if true, all symbols are exported */
446446 int rdynamic;
447447
448+ /* if true, resolve symbols in the current module first (-Wl,Bsymbolic) */
449+ int symbolic;
450+
448451 /* if true, only link in referenced objects from archive */
449452 int alacarte_link;
450453
tccelf.c+4−0
@@ -1575,6 +1575,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1574 unmodified lines
15751575 put_dt(dynamic, DT_SONAME, put_elf_str(dynstr, s1->soname));
15761576 put_dt(dynamic, DT_TEXTREL, 0);
15771577 }
1578+
1579+ if (s1->symbolic)
1580+ put_dt(dynamic, DT_SYMBOLIC, 0);
1581+
15781582 /* add necessary space for other entries */
15791583 saved_dynamic_data_offset = dynamic->data_offset;
15801584 dynamic->data_offset += sizeof(ElfW(Dyn)) * EXTRA_RELITEMS;

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