History

Improve weak aliases handling

* Include only the STB_GLOBAL alias symbol in .dynsym section * Stop the loop when STB_GLOBAL symbol is found * Reword / simplify comment

Thomas Preud'homme committed 15 years ago

Commit db9d5f01 parent 921f0021 file · +19 −17Browse files

Unified · Split

tccelf.c+19−17
@@ -1544,23 +1544,25 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1543 unmodified lines
1544 index = put_elf_sym(s1->dynsym, offset, esym->st_size, 1544 index = put_elf_sym(s1->dynsym, offset, esym->st_size,
1545 esym->st_info, 0, 1545 esym->st_info, 0,
1546 bss_section->sh_num, name);1546 bss_section->sh_num, name);
1547 /* Ensure symbol aliases (that is, symbols with1547 // Ensure R_COPY works for weak symbol aliases
1548 the same st_value) resolve to the same1548 if (ELFW(ST_BIND)(esym->st_info) == STB_WEAK) {
1549 address in program .bss or .data section. */1549 dynsym_end = (ElfW(Sym) *)
1550 dynsym_end = (ElfW(Sym) *)1550 (s1->dynsymtab_section->data +
1551 (s1->dynsymtab_section->data +1551 s1->dynsymtab_section->data_offset);
1552 s1->dynsymtab_section->data_offset);1552 for(dynsym = (ElfW(Sym) *)s1->dynsymtab_section->data + 1;
1553 for(dynsym = (ElfW(Sym) *)s1->dynsymtab_section->data + 1;1553 dynsym < dynsym_end; dynsym++) {
1554 dynsym < dynsym_end; dynsym++) {1554 if ((dynsym->st_value == esym->st_value)
1555 if (dynsym->st_value == esym->st_value) {1555 && (ELFW(ST_BIND)(dynsym->st_info) == STB_GLOBAL)) {
1556 char *dynname;1556 char *dynname;
1557 dynname = s1->dynsymtab_section->link->data1557 dynname = s1->dynsymtab_section->link->data
1558 + dynsym->st_name;1558 + dynsym->st_name;
1559 put_elf_sym(s1->dynsym, offset,1559 put_elf_sym(s1->dynsym, offset,
1560 dynsym->st_size,1560 dynsym->st_size,
1561 dynsym->st_info, 0,1561 dynsym->st_info, 0,
1562 bss_section->sh_num,1562 bss_section->sh_num,
1563 dynname);1563 dynname);
1564 break;
1565 }
1564 }1566 }
1565 }1567 }
1566 put_elf_reloc(s1->dynsym, bss_section, 1568 put_elf_reloc(s1->dynsym, bss_section,

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