History

Clean tccelf.c

- remove debug printf and commented out code - remove C++-like comments - remove whitespace at end of lines - replace tabs by spaces

Thomas Preud'homme committed 12 years ago

Commit 3d4b57f1 parent 6f3569e1 file · +182 −202Browse files

Unified · Split

tccelf.c+182−202
@@ -1,6 +1,6 @@
11 /*
22 * ELF file handling for TCC
3− *
3+ *
44 * Copyright (c) 2001-2004 Fabrice Bellard
55 *
66 * This library is free software; you can redistribute it and/or
@@ -38,7 +38,7 @@ ST_FUNC int put_elf_str(Section *s, const char *sym) · 31 unmodified lines
3838 static unsigned long elf_hash(const unsigned char *name)
3939 {
4040 unsigned long h = 0, g;
41−
41+
4242 while (*name) {
4343 h = (h << 4) + *name++;
4444 g = h & 0xf0000000;
@@ -91,7 +91,7 @@ ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, · 46 unmodified lines
9191 int nbuckets, h;
9292 ElfW(Sym) *sym;
9393 Section *hs;
94−
94+
9595 sym = section_ptr_add(s, sizeof(ElfW(Sym)));
9696 if (name)
9797 name_offset = put_elf_str(s->link, name);
@@ -139,7 +139,7 @@ ST_FUNC int find_elf_sym(Section *s, const char *name) · 41 unmodified lines
139139 Section *hs;
140140 int nbuckets, sym_index, h;
141141 const char *name1;
142−
142+
143143 hs = s->hash;
144144 if (!hs)
145145 return 0;
@@ -198,7 +198,7 @@ ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size, · 52 unmodified lines
198198 sym_bind = ELFW(ST_BIND)(info);
199199 sym_type = ELFW(ST_TYPE)(info);
200200 sym_vis = ELFW(ST_VISIBILITY)(other);
201−
201+
202202 if (sym_bind != STB_LOCAL) {
203203 /* we search global or weak symbols */
204204 sym_index = find_elf_sym(s, name);
@@ -257,8 +257,8 @@ ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size, · 52 unmodified lines
257257 }
258258 } else {
259259 do_def:
260− sym_index = put_elf_sym(s, value, size,
261− ELFW(ST_INFO)(sym_bind, sym_type), other,
260+ sym_index = put_elf_sym(s, value, size,
261+ ELFW(ST_INFO)(sym_bind, sym_type), other,
262262 sh_num, name);
263263 }
264264 return sym_index;
@@ -311,11 +311,11 @@ ST_FUNC void put_stabs(const char *str, int type, int other, int desc, · 46 unmodified lines
311311 sym->n_value = value;
312312 }
313313
314−ST_FUNC void put_stabs_r(const char *str, int type, int other, int desc,
314+ST_FUNC void put_stabs_r(const char *str, int type, int other, int desc,
315315 unsigned long value, Section *sec, int sym_index)
316316 {
317317 put_stabs(str, type, other, desc, value);
318− put_elf_reloc(symtab_section, stab_section,
318+ put_elf_reloc(symtab_section, stab_section,
319319 stab_section->data_offset - sizeof(unsigned int),
320320 R_DATA_32, sym_index);
321321 }
@@ -370,7 +370,7 @@ static void sort_syms(TCCState *s1, Section *s) · 48 unmodified lines
370370 }
371371 p++;
372372 }
373−
373+
374374 /* we copy the new symbols to the old */
375375 memcpy(s->data, new_syms, nb_syms * sizeof(ElfW(Sym)));
376376 tcc_free(new_syms);
@@ -390,7 +390,7 @@ static void sort_syms(TCCState *s1, Section *s) · 13 unmodified lines
390390 }
391391 }
392392 }
393−
393+
394394 tcc_free(old_to_new_syms);
395395 }
396396
@@ -588,13 +588,13 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 191 unmodified lines
588588 case R_386_16:
589589 if (s1->output_format != TCC_OUTPUT_FORMAT_BINARY) {
590590 output_file:
591− tcc_error("can only produce 16-bit binary files");
591+ tcc_error("can only produce 16-bit binary files");
592592 }
593593 *(short *)ptr += val;
594594 break;
595595 case R_386_PC16:
596596 if (s1->output_format != TCC_OUTPUT_FORMAT_BINARY)
597− goto output_file;
597+ goto output_file;
598598 *(short *)ptr += val - addr;
599599 break;
600600 #elif defined(TCC_TARGET_ARM)
@@ -642,7 +642,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 41 unmodified lines
642642 guard its use */
643643 case R_ARM_THM_PC22:
644644 case R_ARM_THM_JUMP24:
645− {
645+ {
646646 int x, hi, lo, s, j1, j2, i1, i2, imm10, imm11;
647647 int to_thumb, is_call, to_plt, blx_bit = 1 << 12;
648648 Section *plt;
@@ -720,7 +720,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 71 unmodified lines
720720 *(int *)ptr |= x;
721721 else
722722 *(int *)ptr += x;
723− }
723+ }
724724 break;
725725 case R_ARM_THM_MOVT_ABS:
726726 case R_ARM_THM_MOVW_ABS_NC:
@@ -737,7 +737,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 10 unmodified lines
737737 *(int *)ptr |= x;
738738 else
739739 *(int *)ptr += x;
740− }
740+ }
741741 break;
742742 case R_ARM_PREL31:
743743 {
@@ -784,15 +784,15 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 40 unmodified lines
784784 case R_C60LO16:
785785 {
786786 uint32_t orig;
787−
788− /* put the low 16 bits of the absolute address */
789− // add to what is already there
790−
787+
788+ /* put the low 16 bits of the absolute address
789+ add to what is already there */
790+
791791 orig = ((*(int *)(ptr )) >> 7) & 0xffff;
792792 orig |= (((*(int *)(ptr+4)) >> 7) & 0xffff) << 16;
793−
794− //patch both at once - assumes always in pairs Low - High
795−
793+
794+ /* patch both at once - assumes always in pairs Low - High */
795+
796796 *(int *) ptr = (*(int *) ptr & (~(0xffff << 7)) ) | (((val+orig) & 0xffff) << 7);
797797 *(int *)(ptr+4) = (*(int *)(ptr+4) & (~(0xffff << 7)) ) | ((((val+orig)>>16) & 0xffff) << 7);
798798 }
@@ -990,7 +990,7 @@ static void build_got(TCCState *s1) · 191 unmodified lines
990990 /* if no got, then create it */
991991 s1->got = new_section(s1, ".got", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
992992 s1->got->sh_entsize = 4;
993− add_elf_sym(symtab_section, 0, 4, ELFW(ST_INFO)(STB_GLOBAL, STT_OBJECT),
993+ add_elf_sym(symtab_section, 0, 4, ELFW(ST_INFO)(STB_GLOBAL, STT_OBJECT),
994994 0, s1->got->sh_num, "_GLOBAL_OFFSET_TABLE_");
995995 ptr = section_ptr_add(s1->got, 3 * PTR_SIZE);
996996 #if PTR_SIZE == 4
@@ -1014,7 +1014,7 @@ static void build_got(TCCState *s1) · 17 unmodified lines
10141014 /* put a got entry corresponding to a symbol in symtab_section. 'size'
10151015 and 'info' can be modifed if more precise info comes from the DLL */
10161016 static void put_got_entry(TCCState *s1,
1017− int reloc_type, unsigned long size, int info,
1017+ int reloc_type, unsigned long size, int info,
10181018 int sym_index)
10191019 {
10201020 int index;
@@ -1092,7 +1092,7 @@ static void put_got_entry(TCCState *s1, · 71 unmodified lines
10921092 if (reloc_type == R_ARM_JUMP_SLOT) {
10931093 Section *plt;
10941094 uint8_t *p;
1095−
1095+
10961096 /* if we build a DLL, we add a %ebx offset */
10971097 if (s1->output_type == TCC_OUTPUT_DLL)
10981098 tcc_error("DLLs unimplemented!");
@@ -1110,14 +1110,14 @@ static void put_got_entry(TCCState *s1, · 11 unmodified lines
11101110
11111111 if (s1->sym_attrs[sym_index].plt_thumb_stub) {
11121112 p = section_ptr_add(plt, 20);
1113− put32(p , 0x4778); // bx pc
1114− put32(p+2, 0x46c0); // nop
1113+ put32(p , 0x4778); /* bx pc */
1114+ put32(p+2, 0x46c0); /* nop */
11151115 p += 4;
11161116 } else
11171117 p = section_ptr_add(plt, 16);
1118− put32(p , 0xe59fc004); // ldr ip, [pc, #4] // offset in GOT
1119− put32(p+4, 0xe08fc00c); // add ip, pc, ip // absolute address or offset
1120− put32(p+8, 0xe59cf000); // ldr pc, [ip] // load absolute address or load offset
1118+ put32(p , 0xe59fc004); /* ldr ip, [pc, #4] ; offset in GOT */
1119+ put32(p+4, 0xe08fc00c); /* add ip, pc, ip ; absolute address or offset */
1120+ put32(p+8, 0xe59cf000); /* ldr pc, [ip] ; load absolute address or load offset */
11211121 put32(p+12, s1->got->data_offset);
11221122
11231123 /* the symbol is modified so that it will be relocated to
@@ -1130,11 +1130,11 @@ static void put_got_entry(TCCState *s1, · 6 unmodified lines
11301130 #else
11311131 #error unsupported CPU
11321132 #endif
1133− index = put_elf_sym(s1->dynsym, offset,
1133+ index = put_elf_sym(s1->dynsym, offset,
11341134 size, info, 0, sym->st_shndx, name);
11351135 /* put a got entry */
1136− put_elf_reloc(s1->dynsym, s1->got,
1137− s1->got->data_offset,
1136+ put_elf_reloc(s1->dynsym, s1->got,
1137+ s1->got->data_offset,
11381138 reloc_type, index);
11391139 }
11401140 ptr = section_ptr_add(s1->got, PTR_SIZE);
@@ -1177,7 +1177,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 36 unmodified lines
11771177 reloc_type = R_386_GLOB_DAT;
11781178 else
11791179 reloc_type = R_386_JMP_SLOT;
1180− put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
1180+ put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
11811181 sym_index);
11821182 }
11831183 break;
@@ -1196,7 +1196,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 12 unmodified lines
11961196 reloc_type = R_ARM_GLOB_DAT;
11971197 else
11981198 reloc_type = R_ARM_JUMP_SLOT;
1199− put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
1199+ put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
12001200 sym_index);
12011201 }
12021202 break;
@@ -1215,7 +1215,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 12 unmodified lines
12151215 reloc_type = R_C60_GLOB_DAT;
12161216 else
12171217 reloc_type = R_C60_JMP_SLOT;
1218− put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
1218+ put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
12191219 sym_index);
12201220 }
12211221 break;
@@ -1235,7 +1235,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 13 unmodified lines
12351235 reloc_type = R_X86_64_GLOB_DAT;
12361236 else
12371237 reloc_type = R_X86_64_JUMP_SLOT;
1238− put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
1238+ put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
12391239 sym_index);
12401240 }
12411241 break;
@@ -1251,7 +1251,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 9 unmodified lines
12511251
12521252 ST_FUNC Section *new_symtab(TCCState *s1,
12531253 const char *symtab_name, int sh_type, int sh_flags,
1254− const char *strtab_name,
1254+ const char *strtab_name,
12551255 const char *hash_name, int hash_sh_flags)
12561256 {
12571257 Section *symtab, *strtab, *hash;
@@ -1263,7 +1263,7 @@ ST_FUNC Section *new_symtab(TCCState *s1, · 5 unmodified lines
12631263 put_elf_str(strtab, "");
12641264 symtab->link = strtab;
12651265 put_elf_sym(symtab, 0, 0, 0, 0, 0, NULL);
1266−
1266+
12671267 nb_buckets = 1;
12681268
12691269 hash = new_section(s1, hash_name, SHT_HASH, hash_sh_flags);
@@ -1293,7 +1293,7 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) · 23 unmodified lines
12931293 long end_offset;
12941294 char sym_start[1024];
12951295 char sym_end[1024];
1296−
1296+
12971297 snprintf(sym_start, sizeof(sym_start), "__%s_start", section_name + 1);
12981298 snprintf(sym_end, sizeof(sym_end), "__%s_end", section_name + 1);
12991299
@@ -1305,11 +1305,11 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) · 5 unmodified lines
13051305 end_offset = s->data_offset;
13061306 }
13071307
1308− add_elf_sym(symtab_section,
1308+ add_elf_sym(symtab_section,
13091309 0, 0,
13101310 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
13111311 s->sh_num, sym_start);
1312− add_elf_sym(symtab_section,
1312+ add_elf_sym(symtab_section,
13131313 end_offset, 0,
13141314 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
13151315 s->sh_num, sym_end);
@@ -1385,15 +1385,15 @@ ST_FUNC void tcc_add_linker_symbols(TCCState *s1) · 69 unmodified lines
13851385 int i;
13861386 Section *s;
13871387
1388− add_elf_sym(symtab_section,
1388+ add_elf_sym(symtab_section,
13891389 text_section->data_offset, 0,
13901390 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
13911391 text_section->sh_num, "_etext");
1392− add_elf_sym(symtab_section,
1392+ add_elf_sym(symtab_section,
13931393 data_section->data_offset, 0,
13941394 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
13951395 data_section->sh_num, "_edata");
1396− add_elf_sym(symtab_section,
1396+ add_elf_sym(symtab_section,
13971397 bss_section->data_offset, 0,
13981398 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
13991399 bss_section->sh_num, "_end");
@@ -1401,7 +1401,7 @@ ST_FUNC void tcc_add_linker_symbols(TCCState *s1) · 1 unmodified line
14011401 add_init_array_defines(s1, ".preinit_array");
14021402 add_init_array_defines(s1, ".init_array");
14031403 add_init_array_defines(s1, ".fini_array");
1404−
1404+
14051405 /* add start and stop symbols for sections whose name can be
14061406 expressed in C */
14071407 for(i = 1; i < s1->nb_sections; i++) {
@@ -1422,7 +1422,7 @@ ST_FUNC void tcc_add_linker_symbols(TCCState *s1) · 14 unmodified lines
14221422 p++;
14231423 }
14241424 snprintf(buf, sizeof(buf), "__start_%s", s->name);
1425− add_elf_sym(symtab_section,
1425+ add_elf_sym(symtab_section,
14261426 0, 0,
14271427 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
14281428 s->sh_num, buf);
@@ -1459,8 +1459,8 @@ static void tcc_output_binary(TCCState *s1, FILE *f, · 30 unmodified lines
14591459 }
14601460
14611461 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
1462−#define HAVE_PHDR 1
1463−#define EXTRA_RELITEMS 14
1462+#define HAVE_PHDR 1
1463+#define EXTRA_RELITEMS 14
14641464
14651465 /* move the relocation value from .dynsym to .got */
14661466 void patch_dynsym_undef(TCCState *s1, Section *s)
@@ -1468,19 +1468,19 @@ void patch_dynsym_undef(TCCState *s1, Section *s) · 1 unmodified line
14681468 uint32_t *gotd = (void *)s1->got->data;
14691469 ElfW(Sym) *sym, *sym_end;
14701470
1471− gotd += 3; // dummy entries in .got
1471+ gotd += 3; /* dummy entries in .got */
14721472 /* relocate symbols in .dynsym */
14731473 sym_end = (ElfW(Sym) *)(s->data + s->data_offset);
14741474 for (sym = (ElfW(Sym) *)s->data + 1; sym < sym_end; sym++) {
1475− if (sym->st_shndx == SHN_UNDEF) {
1476− *gotd++ = sym->st_value + 6; // XXX 6 is magic ?
1477− sym->st_value = 0;
1478− }
1475+ if (sym->st_shndx == SHN_UNDEF) {
1476+ *gotd++ = sym->st_value + 6; /* XXX 6 is magic ? */
1477+ sym->st_value = 0;
1478+ }
14791479 }
14801480 }
14811481 #else
1482−#define HAVE_PHDR 0
1483−#define EXTRA_RELITEMS 9
1482+#define HAVE_PHDR 0
1483+#define EXTRA_RELITEMS 9
14841484
14851485 /* zero plt offsets of weak symbols in .dynsym */
14861486 void patch_dynsym_undef(TCCState *s1, Section *s)
@@ -1496,45 +1496,45 @@ void patch_dynsym_undef(TCCState *s1, Section *s) · 9 unmodified lines
14961496
14971497 ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel)
14981498 {
1499− int sym_index = ELFW(R_SYM) (rel->r_info);
1500− ElfW(Sym) *sym = &((ElfW(Sym) *) symtab_section->data)[sym_index];
1501− unsigned long offset;
1502−
1503− if (sym_index >= s1->nb_sym_attrs)
1504− return;
1505− offset = s1->sym_attrs[sym_index].got_offset;
1506− section_reserve(s1->got, offset + PTR_SIZE);
1499+ int sym_index = ELFW(R_SYM) (rel->r_info);
1500+ ElfW(Sym) *sym = &((ElfW(Sym) *) symtab_section->data)[sym_index];
1501+ unsigned long offset;
1502+
1503+ if (sym_index >= s1->nb_sym_attrs)
1504+ return;
1505+ offset = s1->sym_attrs[sym_index].got_offset;
1506+ section_reserve(s1->got, offset + PTR_SIZE);
15071507 #ifdef TCC_TARGET_X86_64
1508− /* only works for x86-64 */
1509− put32(s1->got->data + offset + 4, sym->st_value >> 32);
1508+ /* only works for x86-64 */
1509+ put32(s1->got->data + offset + 4, sym->st_value >> 32);
15101510 #endif
1511− put32(s1->got->data + offset, sym->st_value & 0xffffffff);
1511+ put32(s1->got->data + offset, sym->st_value & 0xffffffff);
15121512 }
15131513
15141514 ST_FUNC void fill_got(TCCState *s1)
15151515 {
1516− Section *s;
1517− ElfW_Rel *rel, *rel_end;
1518− int i;
1519−
1520− for(i = 1; i < s1->nb_sections; i++) {
1521− s = s1->sections[i];
1522− if (s->sh_type != SHT_RELX)
1523− continue;
1524− /* no need to handle got relocations */
1525− if (s->link != symtab_section)
1526− continue;
1527− rel_end = (ElfW_Rel *) (s->data + s->data_offset);
1528− for(rel = (ElfW_Rel *) s->data; rel < rel_end; rel++) {
1529− switch (ELFW(R_TYPE) (rel->r_info)) {
1530− case R_X86_64_GOT32:
1531− case R_X86_64_GOTPCREL:
1532− case R_X86_64_PLT32:
1533− fill_got_entry(s1, rel);
1534− break;
1535− }
1536− }
1537− }
1516+ Section *s;
1517+ ElfW_Rel *rel, *rel_end;
1518+ int i;
1519+
1520+ for(i = 1; i < s1->nb_sections; i++) {
1521+ s = s1->sections[i];
1522+ if (s->sh_type != SHT_RELX)
1523+ continue;
1524+ /* no need to handle got relocations */
1525+ if (s->link != symtab_section)
1526+ continue;
1527+ rel_end = (ElfW_Rel *) (s->data + s->data_offset);
1528+ for(rel = (ElfW_Rel *) s->data; rel < rel_end; rel++) {
1529+ switch (ELFW(R_TYPE) (rel->r_info)) {
1530+ case R_X86_64_GOT32:
1531+ case R_X86_64_GOTPCREL:
1532+ case R_X86_64_PLT32:
1533+ fill_got_entry(s1, rel);
1534+ break;
1535+ }
1536+ }
1537+ }
15381538 }
15391539
15401540
@@ -1574,7 +1574,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 33 unmodified lines
15741574 dynamic = NULL;
15751575 dynstr = NULL; /* avoid warning */
15761576 saved_dynamic_data_offset = 0; /* avoid warning */
1577−
1577+
15781578 if (file_type != TCC_OUTPUT_OBJ) {
15791579 relocate_common_syms();
15801580
@@ -1587,10 +1587,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 6 unmodified lines
15871587
15881588 if (file_type == TCC_OUTPUT_EXE) {
15891589 char *ptr;
1590− /* allow override the dynamic loader */
1591− const char *elfint = getenv("LD_SO");
1592− if (elfint == NULL)
1593− elfint = DEFAULT_ELFINTERP(s1);
1590+ /* allow override the dynamic loader */
1591+ const char *elfint = getenv("LD_SO");
1592+ if (elfint == NULL)
1593+ elfint = DEFAULT_ELFINTERP(s1);
15941594 /* add interpreter section only if executable */
15951595 interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC);
15961596 interp->sh_addralign = 1;
@@ -1600,18 +1600,18 @@ static int elf_output_file(TCCState *s1, const char *filename) · 3 unmodified lines
16001600
16011601 /* add dynamic symbol table */
16021602 s1->dynsym = new_symtab(s1, ".dynsym", SHT_DYNSYM, SHF_ALLOC,
1603− ".dynstr",
1603+ ".dynstr",
16041604 ".hash", SHF_ALLOC);
16051605 dynstr = s1->dynsym->link;
1606−
1606+
16071607 /* add dynamic section */
1608− dynamic = new_section(s1, ".dynamic", SHT_DYNAMIC,
1608+ dynamic = new_section(s1, ".dynamic", SHT_DYNAMIC,
16091609 SHF_ALLOC | SHF_WRITE);
16101610 dynamic->link = dynstr;
16111611 dynamic->sh_entsize = sizeof(ElfW(Dyn));
1612−
1612+
16131613 /* add PLT */
1614− s1->plt = new_section(s1, ".plt", SHT_PROGBITS,
1614+ s1->plt = new_section(s1, ".plt", SHT_PROGBITS,
16151615 SHF_ALLOC | SHF_EXECINSTR);
16161616 s1->plt->sh_entsize = 4;
16171617
@@ -1643,7 +1643,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 25 unmodified lines
16431643 * function wanted by the caller of dlsym
16441644 * instead of the address of the function that
16451645 * would return that address */
1646− put_got_entry(s1, R_JMP_SLOT, esym->st_size,
1646+ put_got_entry(s1, R_JMP_SLOT, esym->st_size,
16471647 ELFW(ST_INFO)(STB_GLOBAL,STT_FUNC),
16481648 sym - (ElfW(Sym) *)symtab_section->data);
16491649 } else if (type == STT_OBJECT) {
@@ -1652,10 +1652,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 2 unmodified lines
16521652 offset = bss_section->data_offset;
16531653 /* XXX: which alignment ? */
16541654 offset = (offset + 16 - 1) & -16;
1655− index = put_elf_sym(s1->dynsym, offset, esym->st_size,
1656− esym->st_info, 0,
1655+ index = put_elf_sym(s1->dynsym, offset, esym->st_size,
1656+ esym->st_info, 0,
16571657 bss_section->sh_num, name);
1658− // Ensure R_COPY works for weak symbol aliases
1658+ /* Ensure R_COPY works for weak symbol aliases */
16591659 if (ELFW(ST_BIND)(esym->st_info) == STB_WEAK) {
16601660 dynsym_end = (ElfW(Sym) *)
16611661 (s1->dynsymtab_section->data +
@@ -1676,7 +1676,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 14 unmodified lines
16761676 }
16771677 }
16781678 }
1679− put_elf_reloc(s1->dynsym, bss_section,
1679+ put_elf_reloc(s1->dynsym, bss_section,
16801680 offset, R_COPY, index);
16811681 offset += esym->st_size;
16821682 bss_section->data_offset = offset;
@@ -1691,17 +1691,17 @@ static int elf_output_file(TCCState *s1, const char *filename) · 8 unmodified lines
16911691 tcc_error_noabort("undefined symbol '%s'", name);
16921692 }
16931693 }
1694− } else if (s1->rdynamic &&
1694+ } else if (s1->rdynamic &&
16951695 ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
16961696 /* if -rdynamic option, then export all non
16971697 local symbols */
16981698 name = symtab_section->link->data + sym->st_name;
1699− put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1700− sym->st_info, 0,
1699+ put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1700+ sym->st_info, 0,
17011701 sym->st_shndx, name);
17021702 }
17031703 }
1704−
1704+
17051705 if (s1->nb_errors)
17061706 goto fail;
17071707
@@ -1719,8 +1719,8 @@ static int elf_output_file(TCCState *s1, const char *filename) · 11 unmodified lines
17191719 /* XXX: avoid adding a symbol if already
17201720 present because of -rdynamic ? */
17211721 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
1722− put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1723− sym->st_info, 0,
1722+ put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1723+ sym->st_info, 0,
17241724 sym->st_shndx, name);
17251725 } else {
17261726 if (ELFW(ST_BIND)(esym->st_info) == STB_WEAK) {
@@ -1745,24 +1745,24 @@ static int elf_output_file(TCCState *s1, const char *filename) · 18 unmodified lines
17451745 ELFW(ST_TYPE)(sym->st_info) == STT_GNU_IFUNC)
17461746 && sym->st_shndx == SHN_UNDEF) {
17471747 int visibility = ELFW(ST_BIND)(sym->st_info);
1748− put_got_entry(s1, R_JMP_SLOT, sym->st_size,
1748+ put_got_entry(s1, R_JMP_SLOT, sym->st_size,
17491749 ELFW(ST_INFO)(visibility,STT_FUNC),
17501750 sym - (ElfW(Sym) *)symtab_section->data);
17511751 }
17521752 else if (ELFW(ST_TYPE)(sym->st_info) == STT_OBJECT) {
1753− put_got_entry(s1, R_X86_64_GLOB_DAT, sym->st_size,
1754− sym->st_info,
1753+ put_got_entry(s1, R_X86_64_GLOB_DAT, sym->st_size,
1754+ sym->st_info,
17551755 sym - (ElfW(Sym) *)symtab_section->data);
17561756 }
17571757 else
17581758 #endif
17591759 {
17601760 name = symtab_section->link->data + sym->st_name;
1761− index = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1762− sym->st_info, 0,
1761+ index = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1762+ sym->st_info, 0,
17631763 sym->st_shndx, name);
1764− s1->symtab_to_dynsym[sym -
1765− (ElfW(Sym) *)symtab_section->data] =
1764+ s1->symtab_to_dynsym[sym -
1765+ (ElfW(Sym) *)symtab_section->data] =
17661766 index;
17671767 }
17681768 }
@@ -1770,7 +1770,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1 unmodified line
17701770 }
17711771
17721772 build_got_entries(s1);
1773−
1773+
17741774 /* add a list of needed dlls */
17751775 for(i = 0; i < s1->nb_loaded_dlls; i++) {
17761776 DLLReference *dllref = s1->loaded_dlls[i];
@@ -1806,7 +1806,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 29 unmodified lines
18061806 /* we add a section for symbols */
18071807 strsec = new_section(s1, ".shstrtab", SHT_STRTAB, 0);
18081808 put_elf_str(strsec, "");
1809−
1809+
18101810 /* compute number of sections */
18111811 shnum = s1->nb_sections;
18121812
@@ -1814,7 +1814,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1 unmodified line
18141814 section_order = tcc_malloc(sizeof(int) * shnum);
18151815 section_order[0] = 0;
18161816 sh_order_index = 1;
1817−
1817+
18181818 /* compute number of program headers */
18191819 switch(file_type) {
18201820 default:
@@ -1839,27 +1839,18 @@ static int elf_output_file(TCCState *s1, const char *filename) · 18 unmodified lines
18391839 for(i = 1; i < s1->nb_sections; i++) {
18401840 s = s1->sections[i];
18411841 s->sh_name = put_elf_str(strsec, s->name);
1842−#if 0 /* gr */
1843− printf("section: f=%08x t=%08x i=%08x %s %s\n",
1844− s->sh_flags,
1845− s->sh_type,
1846− s->sh_info,
1847− s->name,
1848− s->reloc ? s->reloc->name : "n"
1849− );
1850−#endif
18511842 /* when generating a DLL, we include relocations but we may
18521843 patch them */
1853− if (file_type == TCC_OUTPUT_DLL &&
1854− s->sh_type == SHT_RELX &&
1844+ if (file_type == TCC_OUTPUT_DLL &&
1845+ s->sh_type == SHT_RELX &&
18551846 !(s->sh_flags & SHF_ALLOC)) {
1856− /* //gr: avoid bogus relocs for empty (debug) sections */
1847+ /* gr: avoid bogus relocs for empty (debug) sections */
18571848 if (s1->sections[s->sh_info]->sh_flags & SHF_ALLOC)
18581849 prepare_dynamic_rel(s1, s);
18591850 else if (s1->do_debug)
18601851 s->sh_size = s->data_offset;
18611852 } else if (s1->do_debug ||
1862− file_type == TCC_OUTPUT_OBJ ||
1853+ file_type == TCC_OUTPUT_OBJ ||
18631854 (s->sh_flags & SHF_ALLOC) ||
18641855 i == (s1->nb_sections - 1)) {
18651856 /* we output all sections if debug or object file */
@@ -1869,7 +1860,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 3 unmodified lines
18691860
18701861 /* allocate program segment headers */
18711862 phdr = tcc_mallocz(phnum * sizeof(ElfW(Phdr)));
1872−
1863+
18731864 if (s1->output_format == TCC_OUTPUT_FORMAT_ELF) {
18741865 file_offset = sizeof(ElfW(Ehdr)) + phnum * sizeof(ElfW(Phdr));
18751866 } else {
@@ -1877,14 +1868,14 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1 unmodified line
18771868 }
18781869 if (phnum > 0) {
18791870 /* compute section to program header mapping */
1880− if (s1->has_text_addr) {
1871+ if (s1->has_text_addr) {
18811872 int a_offset, p_offset;
18821873 addr = s1->text_addr;
18831874 /* we ensure that (addr % ELF_PAGE_SIZE) == file_offset %
18841875 ELF_PAGE_SIZE */
18851876 a_offset = (int) (addr & (s1->section_align - 1));
18861877 p_offset = file_offset & (s1->section_align - 1);
1887− if (a_offset < p_offset)
1878+ if (a_offset < p_offset)
18881879 a_offset += s1->section_align;
18891880 file_offset += (a_offset - p_offset);
18901881 } else {
@@ -1895,7 +1886,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 4 unmodified lines
18951886 /* compute address after headers */
18961887 addr += (file_offset & (s1->section_align - 1));
18971888 }
1898−
1889+
18991890 /* dynamic relocation table information, for .dynamic section */
19001891 rel_size = 0;
19011892 rel_addr = 0;
@@ -1915,7 +1906,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 13 unmodified lines
19151906 else
19161907 ph->p_flags = PF_R | PF_W;
19171908 ph->p_align = s1->section_align;
1918−
1909+
19191910 /* we do the following ordering: interp, symbol tables,
19201911 relocations, progbits, nobits */
19211912 /* XXX: do faster and simpler sorting */
@@ -1924,11 +1915,11 @@ static int elf_output_file(TCCState *s1, const char *filename) · 2 unmodified lines
19241915 s = s1->sections[i];
19251916 /* compute if section should be included */
19261917 if (j == 0) {
1927− if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) !=
1918+ if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) !=
19281919 SHF_ALLOC)
19291920 continue;
19301921 } else {
1931− if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) !=
1922+ if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) !=
19321923 (SHF_ALLOC | SHF_WRITE))
19331924 continue;
19341925 }
@@ -1954,12 +1945,12 @@ static int elf_output_file(TCCState *s1, const char *filename) · 19 unmodified lines
19541945
19551946 /* section matches: we align it and add its size */
19561947 tmp = addr;
1957− addr = (addr + s->sh_addralign - 1) &
1948+ addr = (addr + s->sh_addralign - 1) &
19581949 ~(s->sh_addralign - 1);
19591950 file_offset += (int) ( addr - tmp );
19601951 s->sh_offset = file_offset;
19611952 s->sh_addr = addr;
1962−
1953+
19631954 /* update program header infos */
19641955 if (ph->p_offset == 0) {
19651956 ph->p_offset = file_offset;
@@ -1969,14 +1960,14 @@ static int elf_output_file(TCCState *s1, const char *filename) · 3 unmodified lines
19691960 /* update dynamic relocation infos */
19701961 if (s->sh_type == SHT_RELX) {
19711962 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
1972− if (!strcmp(strsec->data + s->sh_name, ".rel.got")) { // rel_size == 0) {
1963+ if (!strcmp(strsec->data + s->sh_name, ".rel.got")) {
19731964 rel_addr = addr;
1974− rel_size += s->sh_size; // XXX only first rel.
1975− }
1976− if (!strcmp(strsec->data + s->sh_name, ".rel.bss")) { // rel_size == 0) {
1965+ rel_size += s->sh_size; /* XXX only first rel. */
1966+ }
1967+ if (!strcmp(strsec->data + s->sh_name, ".rel.bss")) {
19771968 bss_addr = addr;
1978− bss_size = s->sh_size; // XXX only first rel.
1979− }
1969+ bss_size = s->sh_size; /* XXX only first rel. */
1970+ }
19801971 #else
19811972 if (rel_size == 0)
19821973 rel_addr = addr;
@@ -2010,18 +2001,18 @@ static int elf_output_file(TCCState *s1, const char *filename) · 27 unmodified lines
20102001 ph = &phdr[0];
20112002
20122003 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
2013− {
2014− int len = phnum * sizeof(ElfW(Phdr));
2015−
2016− ph->p_type = PT_PHDR;
2017− ph->p_offset = sizeof(ElfW(Ehdr));
2018− ph->p_vaddr = interp->sh_addr - len;
2019− ph->p_paddr = ph->p_vaddr;
2020− ph->p_filesz = ph->p_memsz = len;
2021− ph->p_flags = PF_R | PF_X;
2022− ph->p_align = 4; // interp->sh_addralign;
2023− ph++;
2024− }
2004+ {
2005+ int len = phnum * sizeof(ElfW(Phdr));
2006+
2007+ ph->p_type = PT_PHDR;
2008+ ph->p_offset = sizeof(ElfW(Ehdr));
2009+ ph->p_vaddr = interp->sh_addr - len;
2010+ ph->p_paddr = ph->p_vaddr;
2011+ ph->p_filesz = ph->p_memsz = len;
2012+ ph->p_flags = PF_R | PF_X;
2013+ ph->p_align = 4; /* interp->sh_addralign; */
2014+ ph++;
2015+ }
20252016 #endif
20262017
20272018 ph->p_type = PT_INTERP;
@@ -2033,13 +2024,13 @@ static int elf_output_file(TCCState *s1, const char *filename) · 5 unmodified lines
20332024 ph->p_flags = PF_R;
20342025 ph->p_align = interp->sh_addralign;
20352026 }
2036−
2027+
20372028 /* if dynamic section, then add corresponing program header */
20382029 if (dynamic) {
20392030 ElfW(Sym) *sym_end;
20402031
20412032 ph = &phdr[phnum - 1];
2042−
2033+
20432034 ph->p_type = PT_DYNAMIC;
20442035 ph->p_offset = dynamic->sh_offset;
20452036 ph->p_vaddr = dynamic->sh_addr;
@@ -2155,14 +2146,14 @@ static int elf_output_file(TCCState *s1, const char *filename) · 109 unmodified lines
21552146 if (phnum > 0 && (s->sh_flags & SHF_ALLOC))
21562147 continue;
21572148 section_order[sh_order_index++] = i;
2158−
2159− file_offset = (file_offset + s->sh_addralign - 1) &
2149+
2150+ file_offset = (file_offset + s->sh_addralign - 1) &
21602151 ~(s->sh_addralign - 1);
21612152 s->sh_offset = file_offset;
21622153 if (s->sh_type != SHT_NOBITS)
21632154 file_offset += s->sh_size;
21642155 }
2165−
2156+
21662157 /* if building executable or DLL, then relocate each section
21672158 except the GOT which is already relocated */
21682159 if (file_type != TCC_OUTPUT_OBJ) {
@@ -2207,7 +2198,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 38 unmodified lines
22072198 else
22082199 mode = 0777;
22092200 unlink(filename);
2210− fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
2201+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
22112202 if (fd < 0) {
22122203 tcc_error_noabort("could not write '%s'", filename);
22132204 goto fail;
@@ -2223,10 +2214,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 9 unmodified lines
22232214 #endif
22242215 if (s1->output_format == TCC_OUTPUT_FORMAT_ELF) {
22252216 sort_syms(s1, symtab_section);
2226−
2217+
22272218 /* align to 4 */
22282219 file_offset = (file_offset + 3) & -4;
2229−
2220+
22302221 /* fill header */
22312222 ehdr.e_ident[0] = ELFMAG0;
22322223 ehdr.e_ident[1] = ELFMAG1;
@@ -2271,7 +2262,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 38 unmodified lines
22712262 ehdr.e_shentsize = sizeof(ElfW(Shdr));
22722263 ehdr.e_shnum = shnum;
22732264 ehdr.e_shstrndx = shnum - 1;
2274−
2265+
22752266 fwrite(&ehdr, 1, sizeof(ElfW(Ehdr)), f);
22762267 fwrite(phdr, 1, phnum * sizeof(ElfW(Phdr)), f);
22772268 offset = sizeof(ElfW(Ehdr)) + phnum * sizeof(ElfW(Phdr));
@@ -2296,7 +2287,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 18 unmodified lines
22962287 fputc(0, f);
22972288 offset++;
22982289 }
2299−
2290+
23002291 for(i=0;i<s1->nb_sections;i++) {
23012292 sh = &shdr;
23022293 memset(sh, 0, sizeof(ElfW(Shdr)));
@@ -2363,9 +2354,9 @@ typedef struct SectionMergeInfo { · 60 unmodified lines
23632354
23642355 /* load an object file and merge it with current files */
23652356 /* XXX: handle correctly stab (debug) info */
2366−ST_FUNC int tcc_load_object_file(TCCState *s1,
2357+ST_FUNC int tcc_load_object_file(TCCState *s1,
23672358 int fd, unsigned long file_offset)
2368−{
2359+{
23692360 ElfW(Ehdr) ehdr;
23702361 ElfW(Shdr) *shdr, *sh;
23712362 int size, i, j, offset, offseti, nb_syms, sym_index, ret;
@@ -2400,10 +2391,10 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 28 unmodified lines
24002391 return -1;
24012392 }
24022393 /* read sections */
2403− shdr = load_data(fd, file_offset + ehdr.e_shoff,
2394+ shdr = load_data(fd, file_offset + ehdr.e_shoff,
24042395 sizeof(ElfW(Shdr)) * ehdr.e_shnum);
24052396 sm_table = tcc_mallocz(sizeof(SectionMergeInfo) * ehdr.e_shnum);
2406−
2397+
24072398 /* load section names */
24082399 sh = &shdr[ehdr.e_shstrndx];
24092400 strsec = load_data(fd, file_offset + sh->sh_offset, sh->sh_size);
@@ -2431,7 +2422,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 21 unmodified lines
24312422 strtab = load_data(fd, file_offset + sh->sh_offset, sh->sh_size);
24322423 }
24332424 }
2434−
2425+
24352426 /* now examine each section and try to merge its content with the
24362427 ones in memory */
24372428 for(i = 1; i < ehdr.e_shnum; i++) {
@@ -2442,11 +2433,11 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 4 unmodified lines
24422433 sh_name = strsec + sh->sh_name;
24432434 /* ignore sections types we do not handle */
24442435 if (sh->sh_type != SHT_PROGBITS &&
2445− sh->sh_type != SHT_RELX &&
2436+ sh->sh_type != SHT_RELX &&
24462437 #ifdef TCC_ARM_EABI
24472438 sh->sh_type != SHT_ARM_EXIDX &&
24482439 #endif
2449− sh->sh_type != SHT_NOBITS &&
2440+ sh->sh_type != SHT_NOBITS &&
24502441 sh->sh_type != SHT_PREINIT_ARRAY &&
24512442 sh->sh_type != SHT_INIT_ARRAY &&
24522443 sh->sh_type != SHT_FINI_ARRAY &&
@@ -2459,7 +2450,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 6 unmodified lines
24592450 for(j = 1; j < s1->nb_sections;j++) {
24602451 s = s1->sections[j];
24612452 if (!strcmp(s->name, sh_name)) {
2462− if (!strncmp(sh_name, ".gnu.linkonce",
2453+ if (!strncmp(sh_name, ".gnu.linkonce",
24632454 sizeof(".gnu.linkonce") - 1)) {
24642455 /* if a 'linkonce' section is already present, we
24652456 do not add it again. It is a little tricky as
@@ -2518,7 +2509,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 52 unmodified lines
25182509 next: ;
25192510 }
25202511
2521− /* //gr relocate stab strings */
2512+ /* gr relocate stab strings */
25222513 if (stab_index && stabstr_index) {
25232514 Stab_Sym *a, *b;
25242515 unsigned o;
@@ -2526,7 +2517,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 1 unmodified line
25262517 a = (Stab_Sym *)(s->data + sm_table[stab_index].offset);
25272518 b = (Stab_Sym *)(s->data + s->data_offset);
25282519 o = sm_table[stabstr_index].offset;
2529− while (a < b)
2520+ while (a < b)
25302521 a->n_strx += o, a++;
25312522 }
25322523
@@ -2577,8 +2568,8 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 44 unmodified lines
25772568 }
25782569 /* add symbol */
25792570 name = strtab + sym->st_name;
2580− sym_index = add_elf_sym(symtab_section, sym->st_value, sym->st_size,
2581− sym->st_info, sym->st_other,
2571+ sym_index = add_elf_sym(symtab_section, sym->st_value, sym->st_size,
2572+ sym->st_info, sym->st_other,
25822573 sym->st_shndx, name);
25832574 old_to_new_syms[i] = sym_index;
25842575 }
@@ -2639,7 +2630,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 54 unmodified lines
26392630 break;
26402631 }
26412632 }
2642−
2633+
26432634 ret = 0;
26442635 the_end:
26452636 tcc_free(symtab);
@@ -2690,9 +2681,6 @@ static int tcc_load_alacarte(TCCState *s1, int fd, int size) · 44 unmodified lines
26902681 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
26912682 if(sym->st_shndx == SHN_UNDEF) {
26922683 off = get_be32(ar_index + i * 4) + sizeof(ArchiveHeader);
2693−#if 0
2694− printf("%5d\t%s\t%08x\n", i, p, sym->st_shndx);
2695−#endif
26962684 ++bound;
26972685 lseek(fd, off, SEEK_SET);
26982686 if(tcc_load_object_file(s1, fd, off) < 0) {
@@ -2722,7 +2710,7 @@ ST_FUNC int tcc_load_archive(TCCState *s1, int fd) · 23 unmodified lines
27222710
27232711 /* skip magic which was already checked */
27242712 read(fd, magic, sizeof(magic));
2725−
2713+
27262714 for(;;) {
27272715 len = read(fd, &hdr, sizeof(hdr));
27282716 if (len == 0)
@@ -2740,7 +2728,6 @@ ST_FUNC int tcc_load_archive(TCCState *s1, int fd) · 11 unmodified lines
27402728 break;
27412729 }
27422730 ar_name[i + 1] = '\0';
2743− // printf("name='%s' size=%d %s\n", ar_name, size, ar_size);
27442731 file_offset = lseek(fd, 0, SEEK_CUR);
27452732 /* align to even */
27462733 size = (size + 1) & ~1;
@@ -2767,7 +2754,7 @@ ST_FUNC int tcc_load_archive(TCCState *s1, int fd) · 20 unmodified lines
27672754 is referenced by the user (so it should be added as DT_NEEDED in
27682755 the generated ELF file) */
27692756 ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level)
2770−{
2757+{
27712758 ElfW(Ehdr) ehdr;
27722759 ElfW(Shdr) *shdr, *sh, *sh1;
27732760 int i, j, nb_syms, nb_dts, sym_bind, ret;
@@ -2776,7 +2763,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 2 unmodified lines
27762763 unsigned char *dynstr;
27772764 const char *name, *soname;
27782765 DLLReference *dllref;
2779−
2766+
27802767 read(fd, &ehdr, sizeof(ehdr));
27812768
27822769 /* test CPU specific stuff */
@@ -2811,10 +2798,10 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 28 unmodified lines
28112798 break;
28122799 }
28132800 }
2814−
2801+
28152802 /* compute the real library name */
28162803 soname = tcc_basename(filename);
2817−
2804+
28182805 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
28192806 if (dt->d_tag == DT_SONAME) {
28202807 soname = dynstr + dt->d_un.d_val;
@@ -2832,8 +2819,6 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 11 unmodified lines
28322819 goto the_end;
28332820 }
28342821 }
2835−
2836− // printf("loading dll '%s'\n", soname);
28372822
28382823 /* add the dll and its level */
28392824 dllref = tcc_mallocz(sizeof(DLLReference) + strlen(soname));
@@ -2993,11 +2978,6 @@ static int ld_next(TCCState *s1, char *name, int name_size) · 153 unmodified lines
29932978 inp();
29942979 break;
29952980 }
2996−#if 0
2997− printf("tok=%c %d\n", c, c);
2998− if (c == LD_TOK_NAME)
2999− printf(" name=%s\n", name);
3000−#endif
30012981 return c;
30022982 }
30032983
@@ -3101,7 +3081,7 @@ ST_FUNC int tcc_load_ldscript(TCCState *s1) · 97 unmodified lines
31013081 char cmd[64];
31023082 char filename[1024];
31033083 int t, ret;
3104−
3084+
31053085 ch = file->buf_ptr[0];
31063086 ch = handle_eob();
31073087 for(;;) {
@@ -3136,4 +3116,4 @@ ST_FUNC int tcc_load_ldscript(TCCState *s1) · 28 unmodified lines
31363116 }
31373117 return 0;
31383118 }
3139−#endif /* ndef TCC_TARGET_PE */
3119+#endif /* !TCC_TARGET_PE */

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