History

Fix warning of clang

Thomas Preud'homme committed 12 years ago

Commit 62d1da11 parent 98afe113 files · +24 −24Browse files

Unified · Split

3 files
  1. tccelf.c +20 −20
  2. tccpp.c +2 −2
  3. tccrun.c +2 −2
tccelf.c+20−20
@@ -56,7 +56,7 @@ static void rebuild_hash(Section *s, unsigned int nb_buckets) · 55 unmodified lines
56{56{
57 ElfW(Sym) *sym;57 ElfW(Sym) *sym;
58 int *ptr, *hash, nb_syms, sym_index, h;58 int *ptr, *hash, nb_syms, sym_index, h;
59 char *strtab;59 unsigned char *strtab;
60 60
61 strtab = s->link->data;61 strtab = s->link->data;
62 nb_syms = s->data_offset / sizeof(ElfW(Sym));62 nb_syms = s->data_offset / sizeof(ElfW(Sym));
@@ -115,7 +115,7 @@ ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, · 52 unmodified lines
115 if (ELFW(ST_BIND)(info) != STB_LOCAL) {115 if (ELFW(ST_BIND)(info) != STB_LOCAL) {
116 /* add another hashing entry */116 /* add another hashing entry */
117 nbuckets = base[0];117 nbuckets = base[0];
118 h = elf_hash(name) % nbuckets;118 h = elf_hash((unsigned char *) name) % nbuckets;
119 *ptr = base[2 + h];119 *ptr = base[2 + h];
120 base[2 + h] = sym_index;120 base[2 + h] = sym_index;
121 base[1]++;121 base[1]++;
@@ -145,11 +145,11 @@ ST_FUNC int find_elf_sym(Section *s, const char *name) · 23 unmodified lines
145 if (!hs)145 if (!hs)
146 return 0;146 return 0;
147 nbuckets = ((int *)hs->data)[0];147 nbuckets = ((int *)hs->data)[0];
148 h = elf_hash(name) % nbuckets;148 h = elf_hash((unsigned char *) name) % nbuckets;
149 sym_index = ((int *)hs->data)[2 + h];149 sym_index = ((int *)hs->data)[2 + h];
150 while (sym_index != 0) {150 while (sym_index != 0) {
151 sym = &((ElfW(Sym) *)s->data)[sym_index];151 sym = &((ElfW(Sym) *)s->data)[sym_index];
152 name1 = s->link->data + sym->st_name;152 name1 = (char *) s->link->data + sym->st_name;
153 if (!strcmp(name, name1))153 if (!strcmp(name, name1))
154 return sym_index;154 return sym_index;
155 sym_index = ((int *)hs->data)[2 + nbuckets + sym_index];155 sym_index = ((int *)hs->data)[2 + nbuckets + sym_index];
@@ -429,12 +429,12 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve) · 273 unmodified lines
429 for_each_elem(symtab_section, 1, sym, ElfW(Sym)) {429 for_each_elem(symtab_section, 1, sym, ElfW(Sym)) {
430 sh_num = sym->st_shndx;430 sh_num = sym->st_shndx;
431 if (sh_num == SHN_UNDEF) {431 if (sh_num == SHN_UNDEF) {
432 name = strtab_section->data + sym->st_name;432 name = (char *) strtab_section->data + sym->st_name;
433 /* Use ld.so to resolve symbol for us (for tcc -run) */433 /* Use ld.so to resolve symbol for us (for tcc -run) */
434 if (do_resolve) {434 if (do_resolve) {
435#if defined TCC_IS_NATIVE && !defined _WIN32435#if defined TCC_IS_NATIVE && !defined _WIN32
436 void *addr;436 void *addr;
437 name = symtab_section->link->data + sym->st_name;437 name = (char *) symtab_section->link->data + sym->st_name;
438 addr = resolve_sym(s1, name);438 addr = resolve_sym(s1, name);
439 if (addr) {439 if (addr) {
440 sym->st_value = (addr_t)addr;440 sym->st_value = (addr_t)addr;
@@ -1026,7 +1026,7 @@ static void put_got_entry(TCCState *s1, · 585 unmodified lines
1026 1026
1027 if (s1->dynsym) {1027 if (s1->dynsym) {
1028 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];1028 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
1029 name = symtab_section->link->data + sym->st_name;1029 name = (char *) symtab_section->link->data + sym->st_name;
1030 offset = sym->st_value;1030 offset = sym->st_value;
1031#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)1031#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
1032 if (reloc_type ==1032 if (reloc_type ==
@@ -1198,7 +1198,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 165 unmodified lines
1198 char *name, buf[1024];1198 char *name, buf[1024];
1199 Section *text_section;1199 Section *text_section;
1200 1200
1201 name = symtab_section->link->data + sym->st_name;1201 name = (char *) symtab_section->link->data + sym->st_name;
1202 text_section = s1->sections[sym->st_shndx];1202 text_section = s1->sections[sym->st_shndx];
1203 /* Modify reloc to target a thumb stub to switch to ARM */1203 /* Modify reloc to target a thumb stub to switch to ARM */
1204 snprintf(buf, sizeof(buf), "%s_from_thumb", name);1204 snprintf(buf, sizeof(buf), "%s_from_thumb", name);
@@ -1566,7 +1566,7 @@ static void bind_exe_dynsyms(TCCState *s1) · 361 unmodified lines
1566 - if STT_OBJECT symbol -> add it in .bss section with suitable reloc */1566 - if STT_OBJECT symbol -> add it in .bss section with suitable reloc */
1567 for_each_elem(symtab_section, 1, sym, ElfW(Sym)) {1567 for_each_elem(symtab_section, 1, sym, ElfW(Sym)) {
1568 if (sym->st_shndx == SHN_UNDEF) {1568 if (sym->st_shndx == SHN_UNDEF) {
1569 name = symtab_section->link->data + sym->st_name;1569 name = (char *) symtab_section->link->data + sym->st_name;
1570 sym_index = find_elf_sym(s1->dynsymtab_section, name);1570 sym_index = find_elf_sym(s1->dynsymtab_section, name);
1571 if (sym_index) {1571 if (sym_index) {
1572 esym = &((ElfW(Sym) *)s1->dynsymtab_section->data)[sym_index];1572 esym = &((ElfW(Sym) *)s1->dynsymtab_section->data)[sym_index];
@@ -1596,7 +1596,7 @@ static void bind_exe_dynsyms(TCCState *s1) · 23 unmodified lines
1596 for_each_elem(s1->dynsymtab_section, 1, dynsym, ElfW(Sym)) {1596 for_each_elem(s1->dynsymtab_section, 1, dynsym, ElfW(Sym)) {
1597 if ((dynsym->st_value == esym->st_value)1597 if ((dynsym->st_value == esym->st_value)
1598 && (ELFW(ST_BIND)(dynsym->st_info) == STB_GLOBAL)) {1598 && (ELFW(ST_BIND)(dynsym->st_info) == STB_GLOBAL)) {
1599 char *dynname = s1->dynsymtab_section->link->data1599 char *dynname = (char *) s1->dynsymtab_section->link->data
1600 + dynsym->st_name;1600 + dynsym->st_name;
1601 put_elf_sym(s1->dynsym, offset, dynsym->st_size,1601 put_elf_sym(s1->dynsym, offset, dynsym->st_size,
1602 dynsym->st_info, 0,1602 dynsym->st_info, 0,
@@ -1621,7 +1621,7 @@ static void bind_exe_dynsyms(TCCState *s1) · 18 unmodified lines
1621 }1621 }
1622 } else if (s1->rdynamic && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {1622 } else if (s1->rdynamic && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
1623 /* if -rdynamic option, then export all non local symbols */1623 /* if -rdynamic option, then export all non local symbols */
1624 name = symtab_section->link->data + sym->st_name;1624 name = (char *) symtab_section->link->data + sym->st_name;
1625 put_elf_sym(s1->dynsym, sym->st_value, sym->st_size, sym->st_info,1625 put_elf_sym(s1->dynsym, sym->st_value, sym->st_size, sym->st_info,
1626 0, sym->st_shndx, name);1626 0, sym->st_shndx, name);
1627 }1627 }
@@ -1640,7 +1640,7 @@ static void bind_libs_dynsyms(TCCState *s1) · 12 unmodified lines
1640 corresponding symbol */1640 corresponding symbol */
1641 for_each_elem(s1->dynsymtab_section, 1, esym, ElfW(Sym)) {1641 for_each_elem(s1->dynsymtab_section, 1, esym, ElfW(Sym)) {
1642 if (esym->st_shndx == SHN_UNDEF) {1642 if (esym->st_shndx == SHN_UNDEF) {
1643 name = s1->dynsymtab_section->link->data + esym->st_name;1643 name = (char *) s1->dynsymtab_section->link->data + esym->st_name;
1644 sym_index = find_elf_sym(symtab_section, name);1644 sym_index = find_elf_sym(symtab_section, name);
1645 if (sym_index) {1645 if (sym_index) {
1646 /* XXX: avoid adding a symbol if already present because of1646 /* XXX: avoid adding a symbol if already present because of
@@ -1682,7 +1682,7 @@ static void export_global_syms(TCCState *s1) · 35 unmodified lines
1682 } else1682 } else
1683#endif1683#endif
1684 {1684 {
1685 name = symtab_section->link->data + sym->st_name;1685 name = (char *) symtab_section->link->data + sym->st_name;
1686 dynindex = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,1686 dynindex = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1687 sym->st_info, 0, sym->st_shndx, name);1687 sym->st_info, 0, sym->st_shndx, name);
1688 index = sym - (ElfW(Sym) *) symtab_section->data;1688 index = sym - (ElfW(Sym) *) symtab_section->data;
@@ -2527,7 +2527,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 838 unmodified lines
2527 if (i == ehdr.e_shstrndx)2527 if (i == ehdr.e_shstrndx)
2528 continue;2528 continue;
2529 sh = &shdr[i];2529 sh = &shdr[i];
2530 sh_name = strsec + sh->sh_name;2530 sh_name = (char *) strsec + sh->sh_name;
2531 /* ignore sections types we do not handle */2531 /* ignore sections types we do not handle */
2532 if (sh->sh_type != SHT_PROGBITS &&2532 if (sh->sh_type != SHT_PROGBITS &&
2533 sh->sh_type != SHT_RELX &&2533 sh->sh_type != SHT_RELX &&
@@ -2648,7 +2648,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 114 unmodified lines
2648 already defined symbol. It is very important to get2648 already defined symbol. It is very important to get
2649 correct relocations */2649 correct relocations */
2650 if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {2650 if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
2651 name = strtab + sym->st_name;2651 name = (char *) strtab + sym->st_name;
2652 sym_index = find_elf_sym(symtab_section, name);2652 sym_index = find_elf_sym(symtab_section, name);
2653 if (sym_index)2653 if (sym_index)
2654 old_to_new_syms[i] = sym_index;2654 old_to_new_syms[i] = sym_index;
@@ -2664,7 +2664,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 9 unmodified lines
2664 sym->st_value += sm->offset;2664 sym->st_value += sm->offset;
2665 }2665 }
2666 /* add symbol */2666 /* add symbol */
2667 name = strtab + sym->st_name;2667 name = (char *) strtab + sym->st_name;
2668 sym_index = add_elf_sym(symtab_section, sym->st_value, sym->st_size,2668 sym_index = add_elf_sym(symtab_section, sym->st_value, sym->st_size,
2669 sym->st_info, sym->st_other,2669 sym->st_info, sym->st_other,
2670 sym->st_shndx, name);2670 sym->st_shndx, name);
@@ -2765,7 +2765,7 @@ static int tcc_load_alacarte(TCCState *s1, int fd, int size) · 94 unmodified lines
2765 goto fail;2765 goto fail;
2766 nsyms = get_be32(data);2766 nsyms = get_be32(data);
2767 ar_index = data + 4;2767 ar_index = data + 4;
2768 ar_names = ar_index + nsyms * 4;2768 ar_names = (char *) ar_index + nsyms * 4;
2769 2769
2770 do {2770 do {
2771 bound = 0;2771 bound = 0;
@@ -2898,7 +2898,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 126 unmodified lines
2898 2898
2899 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {2899 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
2900 if (dt->d_tag == DT_SONAME) {2900 if (dt->d_tag == DT_SONAME) {
2901 soname = dynstr + dt->d_un.d_val;2901 soname = (char *) dynstr + dt->d_un.d_val;
2902 }2902 }
2903 }2903 }
2904 2904
@@ -2925,7 +2925,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 20 unmodified lines
2925 sym_bind = ELFW(ST_BIND)(sym->st_info);2925 sym_bind = ELFW(ST_BIND)(sym->st_info);
2926 if (sym_bind == STB_LOCAL)2926 if (sym_bind == STB_LOCAL)
2927 continue;2927 continue;
2928 name = dynstr + sym->st_name;2928 name = (char *) dynstr + sym->st_name;
2929 add_elf_sym(s1->dynsymtab_section, sym->st_value, sym->st_size,2929 add_elf_sym(s1->dynsymtab_section, sym->st_value, sym->st_size,
2930 sym->st_info, sym->st_other, sym->st_shndx, name);2930 sym->st_info, sym->st_other, sym->st_shndx, name);
2931 }2931 }
@@ -2934,7 +2934,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 2 unmodified lines
2934 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {2934 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
2935 switch(dt->d_tag) {2935 switch(dt->d_tag) {
2936 case DT_NEEDED:2936 case DT_NEEDED:
2937 name = dynstr + dt->d_un.d_val;2937 name = (char *) dynstr + dt->d_un.d_val;
2938 for(j = 0; j < s1->nb_loaded_dlls; j++) {2938 for(j = 0; j < s1->nb_loaded_dlls; j++) {
2939 dllref = s1->loaded_dlls[j];2939 dllref = s1->loaded_dlls[j];
2940 if (!strcmp(name, dllref->name))2940 if (!strcmp(name, dllref->name))
tccpp.c+2−2
@@ -1247,7 +1247,7 @@ static inline int hash_cached_include(const char *filename) · 1246 unmodified lines
1247 unsigned int h;1247 unsigned int h;
1248 1248
1249 h = TOK_HASH_INIT;1249 h = TOK_HASH_INIT;
1250 s = filename;1250 s = (unsigned char *) filename;
1251 while (*s) {1251 while (*s) {
1252 h = TOK_HASH_FUNC(h, *s);1252 h = TOK_HASH_FUNC(h, *s);
1253 s++;1253 s++;
@@ -2222,7 +2222,7 @@ maybe_newline: · 968 unmodified lines
2222 goto token_found;2222 goto token_found;
2223 pts = &(ts->hash_next);2223 pts = &(ts->hash_next);
2224 }2224 }
2225 ts = tok_alloc_new(pts, p1, len);2225 ts = tok_alloc_new(pts, (char *) p1, len);
2226 token_found: ;2226 token_found: ;
2227 } else {2227 } else {
2228 /* slower case */2228 /* slower case */
tccrun.c+2−2
@@ -272,7 +272,7 @@ static addr_t rt_printline(addr_t wanted_pc, const char *msg) · 271 unmodified lines
272 if (stab_section) {272 if (stab_section) {
273 stab_len = stab_section->data_offset;273 stab_len = stab_section->data_offset;
274 stab_sym = (Stab_Sym *)stab_section->data;274 stab_sym = (Stab_Sym *)stab_section->data;
275 stab_str = stabstr_section->data;275 stab_str = (char *) stabstr_section->data;
276 }276 }
277 277
278 func_name[0] = '\0';278 func_name[0] = '\0';
@@ -365,7 +365,7 @@ no_stabs: · 86 unmodified lines
365 if (wanted_pc >= sym->st_value &&365 if (wanted_pc >= sym->st_value &&
366 wanted_pc < sym->st_value + sym->st_size) {366 wanted_pc < sym->st_value + sym->st_size) {
367 pstrcpy(last_func_name, sizeof(last_func_name),367 pstrcpy(last_func_name, sizeof(last_func_name),
368 strtab_section->data + sym->st_name);368 (char *) strtab_section->data + sym->st_name);
369 func_addr = sym->st_value;369 func_addr = sym->st_value;
370 goto found;370 goto found;
371 }371 }

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