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
5656 {
5757 ElfW(Sym) *sym;
5858 int *ptr, *hash, nb_syms, sym_index, h;
59− char *strtab;
59+ unsigned char *strtab;
6060
6161 strtab = s->link->data;
6262 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
115115 if (ELFW(ST_BIND)(info) != STB_LOCAL) {
116116 /* add another hashing entry */
117117 nbuckets = base[0];
118− h = elf_hash(name) % nbuckets;
118+ h = elf_hash((unsigned char *) name) % nbuckets;
119119 *ptr = base[2 + h];
120120 base[2 + h] = sym_index;
121121 base[1]++;
@@ -145,11 +145,11 @@ ST_FUNC int find_elf_sym(Section *s, const char *name) · 23 unmodified lines
145145 if (!hs)
146146 return 0;
147147 nbuckets = ((int *)hs->data)[0];
148− h = elf_hash(name) % nbuckets;
148+ h = elf_hash((unsigned char *) name) % nbuckets;
149149 sym_index = ((int *)hs->data)[2 + h];
150150 while (sym_index != 0) {
151151 sym = &((ElfW(Sym) *)s->data)[sym_index];
152− name1 = s->link->data + sym->st_name;
152+ name1 = (char *) s->link->data + sym->st_name;
153153 if (!strcmp(name, name1))
154154 return sym_index;
155155 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
429429 for_each_elem(symtab_section, 1, sym, ElfW(Sym)) {
430430 sh_num = sym->st_shndx;
431431 if (sh_num == SHN_UNDEF) {
432− name = strtab_section->data + sym->st_name;
432+ name = (char *) strtab_section->data + sym->st_name;
433433 /* Use ld.so to resolve symbol for us (for tcc -run) */
434434 if (do_resolve) {
435435 #if defined TCC_IS_NATIVE && !defined _WIN32
436436 void *addr;
437− name = symtab_section->link->data + sym->st_name;
437+ name = (char *) symtab_section->link->data + sym->st_name;
438438 addr = resolve_sym(s1, name);
439439 if (addr) {
440440 sym->st_value = (addr_t)addr;
@@ -1026,7 +1026,7 @@ static void put_got_entry(TCCState *s1, · 585 unmodified lines
10261026
10271027 if (s1->dynsym) {
10281028 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;
10301030 offset = sym->st_value;
10311031 #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
10321032 if (reloc_type ==
@@ -1198,7 +1198,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 165 unmodified lines
11981198 char *name, buf[1024];
11991199 Section *text_section;
12001200
1201− name = symtab_section->link->data + sym->st_name;
1201+ name = (char *) symtab_section->link->data + sym->st_name;
12021202 text_section = s1->sections[sym->st_shndx];
12031203 /* Modify reloc to target a thumb stub to switch to ARM */
12041204 snprintf(buf, sizeof(buf), "%s_from_thumb", name);
@@ -1566,7 +1566,7 @@ static void bind_exe_dynsyms(TCCState *s1) · 361 unmodified lines
15661566 - if STT_OBJECT symbol -> add it in .bss section with suitable reloc */
15671567 for_each_elem(symtab_section, 1, sym, ElfW(Sym)) {
15681568 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;
15701570 sym_index = find_elf_sym(s1->dynsymtab_section, name);
15711571 if (sym_index) {
15721572 esym = &((ElfW(Sym) *)s1->dynsymtab_section->data)[sym_index];
@@ -1596,7 +1596,7 @@ static void bind_exe_dynsyms(TCCState *s1) · 23 unmodified lines
15961596 for_each_elem(s1->dynsymtab_section, 1, dynsym, ElfW(Sym)) {
15971597 if ((dynsym->st_value == esym->st_value)
15981598 && (ELFW(ST_BIND)(dynsym->st_info) == STB_GLOBAL)) {
1599− char *dynname = s1->dynsymtab_section->link->data
1599+ char *dynname = (char *) s1->dynsymtab_section->link->data
16001600 + dynsym->st_name;
16011601 put_elf_sym(s1->dynsym, offset, dynsym->st_size,
16021602 dynsym->st_info, 0,
@@ -1621,7 +1621,7 @@ static void bind_exe_dynsyms(TCCState *s1) · 18 unmodified lines
16211621 }
16221622 } else if (s1->rdynamic && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
16231623 /* 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;
16251625 put_elf_sym(s1->dynsym, sym->st_value, sym->st_size, sym->st_info,
16261626 0, sym->st_shndx, name);
16271627 }
@@ -1640,7 +1640,7 @@ static void bind_libs_dynsyms(TCCState *s1) · 12 unmodified lines
16401640 corresponding symbol */
16411641 for_each_elem(s1->dynsymtab_section, 1, esym, ElfW(Sym)) {
16421642 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;
16441644 sym_index = find_elf_sym(symtab_section, name);
16451645 if (sym_index) {
16461646 /* XXX: avoid adding a symbol if already present because of
@@ -1682,7 +1682,7 @@ static void export_global_syms(TCCState *s1) · 35 unmodified lines
16821682 } else
16831683 #endif
16841684 {
1685− name = symtab_section->link->data + sym->st_name;
1685+ name = (char *) symtab_section->link->data + sym->st_name;
16861686 dynindex = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
16871687 sym->st_info, 0, sym->st_shndx, name);
16881688 index = sym - (ElfW(Sym) *) symtab_section->data;
@@ -2527,7 +2527,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 838 unmodified lines
25272527 if (i == ehdr.e_shstrndx)
25282528 continue;
25292529 sh = &shdr[i];
2530− sh_name = strsec + sh->sh_name;
2530+ sh_name = (char *) strsec + sh->sh_name;
25312531 /* ignore sections types we do not handle */
25322532 if (sh->sh_type != SHT_PROGBITS &&
25332533 sh->sh_type != SHT_RELX &&
@@ -2648,7 +2648,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 114 unmodified lines
26482648 already defined symbol. It is very important to get
26492649 correct relocations */
26502650 if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
2651− name = strtab + sym->st_name;
2651+ name = (char *) strtab + sym->st_name;
26522652 sym_index = find_elf_sym(symtab_section, name);
26532653 if (sym_index)
26542654 old_to_new_syms[i] = sym_index;
@@ -2664,7 +2664,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 9 unmodified lines
26642664 sym->st_value += sm->offset;
26652665 }
26662666 /* add symbol */
2667− name = strtab + sym->st_name;
2667+ name = (char *) strtab + sym->st_name;
26682668 sym_index = add_elf_sym(symtab_section, sym->st_value, sym->st_size,
26692669 sym->st_info, sym->st_other,
26702670 sym->st_shndx, name);
@@ -2765,7 +2765,7 @@ static int tcc_load_alacarte(TCCState *s1, int fd, int size) · 94 unmodified lines
27652765 goto fail;
27662766 nsyms = get_be32(data);
27672767 ar_index = data + 4;
2768− ar_names = ar_index + nsyms * 4;
2768+ ar_names = (char *) ar_index + nsyms * 4;
27692769
27702770 do {
27712771 bound = 0;
@@ -2898,7 +2898,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 126 unmodified lines
28982898
28992899 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
29002900 if (dt->d_tag == DT_SONAME) {
2901− soname = dynstr + dt->d_un.d_val;
2901+ soname = (char *) dynstr + dt->d_un.d_val;
29022902 }
29032903 }
29042904
@@ -2925,7 +2925,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 20 unmodified lines
29252925 sym_bind = ELFW(ST_BIND)(sym->st_info);
29262926 if (sym_bind == STB_LOCAL)
29272927 continue;
2928− name = dynstr + sym->st_name;
2928+ name = (char *) dynstr + sym->st_name;
29292929 add_elf_sym(s1->dynsymtab_section, sym->st_value, sym->st_size,
29302930 sym->st_info, sym->st_other, sym->st_shndx, name);
29312931 }
@@ -2934,7 +2934,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 2 unmodified lines
29342934 for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
29352935 switch(dt->d_tag) {
29362936 case DT_NEEDED:
2937− name = dynstr + dt->d_un.d_val;
2937+ name = (char *) dynstr + dt->d_un.d_val;
29382938 for(j = 0; j < s1->nb_loaded_dlls; j++) {
29392939 dllref = s1->loaded_dlls[j];
29402940 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
12471247 unsigned int h;
12481248
12491249 h = TOK_HASH_INIT;
1250− s = filename;
1250+ s = (unsigned char *) filename;
12511251 while (*s) {
12521252 h = TOK_HASH_FUNC(h, *s);
12531253 s++;
@@ -2222,7 +2222,7 @@ maybe_newline: · 968 unmodified lines
22222222 goto token_found;
22232223 pts = &(ts->hash_next);
22242224 }
2225− ts = tok_alloc_new(pts, p1, len);
2225+ ts = tok_alloc_new(pts, (char *) p1, len);
22262226 token_found: ;
22272227 } else {
22282228 /* 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
272272 if (stab_section) {
273273 stab_len = stab_section->data_offset;
274274 stab_sym = (Stab_Sym *)stab_section->data;
275− stab_str = stabstr_section->data;
275+ stab_str = (char *) stabstr_section->data;
276276 }
277277
278278 func_name[0] = '\0';
@@ -365,7 +365,7 @@ no_stabs: · 86 unmodified lines
365365 if (wanted_pc >= sym->st_value &&
366366 wanted_pc < sym->st_value + sym->st_size) {
367367 pstrcpy(last_func_name, sizeof(last_func_name),
368− strtab_section->data + sym->st_name);
368+ (char *) strtab_section->data + sym->st_name);
369369 func_addr = sym->st_value;
370370 goto found;
371371 }

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