History

fix bogus relocations with TCC_OUTPUT_DLL

grischka committed 18 years ago

Commit 0d598ac1 parent 23594b61 file · +17 −2Browse files

Unified · Split

tccelf.c+17−2
@@ -1367,12 +1367,25 @@ int tcc_output_file(TCCState *s1, const char *filename) · 1366 unmodified lines
1367 for(i = 1; i < s1->nb_sections; i++) {1367 for(i = 1; i < s1->nb_sections; i++) {
1368 s = s1->sections[i];1368 s = s1->sections[i];
1369 s->sh_name = put_elf_str(strsec, s->name);1369 s->sh_name = put_elf_str(strsec, s->name);
1370#if 0 //gr
1371 printf("section: f=%08x t=%08x i=%08x %s %s\n",
1372 s->sh_flags,
1373 s->sh_type,
1374 s->sh_info,
1375 s->name,
1376 s->reloc ? s->reloc->name : "n"
1377 );
1378#endif
1370 /* when generating a DLL, we include relocations but we may1379 /* when generating a DLL, we include relocations but we may
1371 patch them */1380 patch them */
1372 if (file_type == TCC_OUTPUT_DLL && 1381 if (file_type == TCC_OUTPUT_DLL &&
1373 s->sh_type == SHT_REL && 1382 s->sh_type == SHT_REL &&
1374 !(s->sh_flags & SHF_ALLOC)) {1383 !(s->sh_flags & SHF_ALLOC)) {
1375 prepare_dynamic_rel(s1, s);1384 /* //gr: avoid bogus relocs for empty (debug) sections */
1385 if (s1->sections[s->sh_info]->sh_flags & SHF_ALLOC)
1386 prepare_dynamic_rel(s1, s);
1387 else if (do_debug)
1388 s->sh_size = s->data_offset;
1376 } else if (do_debug || 1389 } else if (do_debug ||
1377 file_type == TCC_OUTPUT_OBJ || 1390 file_type == TCC_OUTPUT_OBJ ||
1378 (s->sh_flags & SHF_ALLOC) ||1391 (s->sh_flags & SHF_ALLOC) ||
@@ -1595,6 +1608,8 @@ int tcc_output_file(TCCState *s1, const char *filename) · 216 unmodified lines
1595 put_dt(dynamic, DT_REL, rel_addr);1608 put_dt(dynamic, DT_REL, rel_addr);
1596 put_dt(dynamic, DT_RELSZ, rel_size);1609 put_dt(dynamic, DT_RELSZ, rel_size);
1597 put_dt(dynamic, DT_RELENT, sizeof(Elf32_Rel));1610 put_dt(dynamic, DT_RELENT, sizeof(Elf32_Rel));
1611 if (do_debug)
1612 put_dt(dynamic, DT_DEBUG, 0);
1598 put_dt(dynamic, DT_NULL, 0);1613 put_dt(dynamic, DT_NULL, 0);
1599 }1614 }
1600 1615
@@ -1632,7 +1647,7 @@ int tcc_output_file(TCCState *s1, const char *filename) · 31 unmodified lines
1632 /* XXX: ignore sections with allocated relocations ? */1647 /* XXX: ignore sections with allocated relocations ? */
1633 for(i = 1; i < s1->nb_sections; i++) {1648 for(i = 1; i < s1->nb_sections; i++) {
1634 s = s1->sections[i];1649 s = s1->sections[i];
1635 if (s->reloc && s != s1->got)1650 if (s->reloc && s != s1->got && (s->sh_flags & SHF_ALLOC)) //gr
1636 relocate_section(s1, s);1651 relocate_section(s1, s);
1637 }1652 }
1638 1653

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