History

factor out symbol weakening into new function

Joe Soroka committed 15 years ago

Commit 8bcb2ae1 parent 0f0c2d91 file · +17 −10Browse files

Unified · Split

tccgen.c+17−10
@@ -255,6 +255,19 @@ ST_FUNC void sym_pop(Sym **ptop, Sym *b) · 254 unmodified lines
255255 *ptop = b;
256256 }
257257
258+static void weaken_symbol(Sym *sym)
259+{
260+ sym->type.t |= VT_WEAK;
261+ if (sym->c > 0) {
262+ int esym_type;
263+ ElfW(Sym) *esym;
264+
265+ esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
266+ esym_type = ELFW(ST_TYPE)(esym->st_info);
267+ esym->st_info = ELFW(ST_INFO)(STB_WEAK, esym_type);
268+ }
269+}
270+
258271 /* ------------------------------------------------------------------------- */
259272
260273 ST_FUNC void swap(int *p, int *q)
@@ -5213,11 +5226,8 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 4952 unmodified lines
52135226 vtop->sym = sym;
52145227 }
52155228 /* patch symbol weakness */
5216− if (type->t & VT_WEAK) {
5217− unsigned char *st_info =
5218− &((ElfW(Sym) *)symtab_section->data)[sym->c].st_info;
5219− *st_info = ELF32_ST_INFO(STB_WEAK, ELF32_ST_TYPE(*st_info));
5220− }
5229+ if (type->t & VT_WEAK)
5230+ weaken_symbol(sym);
52215231 #ifdef CONFIG_TCC_BCHECK
52225232 /* handles bounds now because the symbol must be defined
52235233 before for the relocation */
@@ -5337,11 +5347,8 @@ static void gen_function(Sym *sym) · 113 unmodified lines
53375347 ((ElfW(Sym) *)symtab_section->data)[sym->c].st_size =
53385348 ind - func_ind;
53395349 /* patch symbol weakness (this definition overrules any prototype) */
5340− if (sym->type.t & VT_WEAK) {
5341− unsigned char *st_info =
5342− &((ElfW(Sym) *)symtab_section->data)[sym->c].st_info;
5343− *st_info = ELF32_ST_INFO(STB_WEAK, ELF32_ST_TYPE(*st_info));
5344− }
5350+ if (sym->type.t & VT_WEAK)
5351+ weaken_symbol(sym);
53455352 if (tcc_state->do_debug) {
53465353 put_stabn(N_FUN, 0, 0, ind - func_ind);
53475354 }

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