History

Fix problem with PLT and GOT relocs on armel.

TinyCC fails to link correctly to libraries when both R_ARM_PLT32 and R_ARM_GOT32 relocation to a same symbol exist (see http://lists.nongnu.org/archive/html/tinycc-devel/2010-05/msg00032.html for more details). The patch marks all undefined weak symbols found in external libraries as strong. The value of all remaining weak symbols is set to zero just before the section is output. Note by Thomas Preud'homme: it's been 2 months in Debian without any new bug report, hence commiting.

Daniel Glöckner committed 16 years ago

Commit ab7ed481 parent bf374a51 file · +12 −3Browse files

Unified · Split

tccelf.c+12−3
@@ -1356,6 +1356,17 @@ void patch_dynsym_undef(TCCState *s1, Section *s) · 1355 unmodified lines
13561356 #else
13571357 #define HAVE_PHDR 0
13581358 #define EXTRA_RELITEMS 9
1359+
1360+/* zero plt offsets of weak symbols in .dynsym */
1361+void patch_dynsym_undef(TCCState *s1, Section *s)
1362+{
1363+ ElfW(Sym) *sym, *sym_end;
1364+
1365+ sym_end = (ElfW(Sym) *)(s->data + s->data_offset);
1366+ for (sym = (ElfW(Sym) *)s->data + 1; sym < sym_end; sym++)
1367+ if (sym->st_shndx == SHN_UNDEF && ELFW(ST_BIND)(sym->st_info) == STB_WEAK)
1368+ sym->st_value = 0;
1369+}
13591370 #endif
13601371
13611372 ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel)
@@ -1499,7 +1510,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 137 unmodified lines
14991510 type = ELFW(ST_TYPE)(esym->st_info);
15001511 if ((type == STT_FUNC) || (type == STT_GNU_IFUNC)) {
15011512 put_got_entry(s1, R_JMP_SLOT, esym->st_size,
1502− esym->st_info,
1513+ ELFW(ST_INFO)(STB_GLOBAL,type),
15031514 sym - (ElfW(Sym) *)symtab_section->data);
15041515 } else if (type == STT_OBJECT) {
15051516 unsigned long offset;
@@ -2125,10 +2136,8 @@ static int elf_output_file(TCCState *s1, const char *filename) · 619 unmodified lines
21252136 for(i=1;i<s1->nb_sections;i++) {
21262137 s = s1->sections[section_order[i]];
21272138 if (s->sh_type != SHT_NOBITS) {
2128−#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
21292139 if (s->sh_type == SHT_DYNSYM)
21302140 patch_dynsym_undef(s1, s);
2131−#endif
21322141 while (offset < s->sh_offset) {
21332142 fputc(0, f);
21342143 offset++;

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