History

Fix formatting breakage from "rogue tabs" commit.

gus knight committed 11 years ago

Commit 7f5b95e1 parent 271abe79 files · +404 −406Browse files

Unified · Split

9 files
  1. src/arm/arm-gen.c +26 −26
  2. src/libtcc.c +2 −2
  3. src/tccasm.c +23 −23
  4. src/tcccoff.c +14 −14
  5. src/tccelf.c +138 −138
  6. src/tccgen.c +159 −160
  7. src/tccpe.c +17 −17
  8. src/tms320c67/c67-gen.c +19 −19
  9. src/x86/x86_64-gen.c +6 −7
src/arm/arm-gen.c+26−26
@@ -43,26 +43,26 @@ typedef int RegArgs; · 42 unmodified lines
4343 /* a register can belong to several classes. The classes must be
4444 sorted from more general to more precise (see gv2() code which does
4545 assumptions on it). */
46−#define RC_INT 0x0001 /* generic integer register */
47−#define RC_FLOAT 0x0002 /* generic float register */
48−#define RC_R0 0x0004
49−#define RC_R1 0x0008
50−#define RC_R2 0x0010
51−#define RC_R3 0x0020
52−#define RC_R12 0x0040
53−#define RC_F0 0x0080
54−#define RC_F1 0x0100
55−#define RC_F2 0x0200
56−#define RC_F3 0x0400
46+#define RC_INT 0x0001 /* generic integer register */
47+#define RC_FLOAT 0x0002 /* generic float register */
48+#define RC_R0 0x0004
49+#define RC_R1 0x0008
50+#define RC_R2 0x0010
51+#define RC_R3 0x0020
52+#define RC_R12 0x0040
53+#define RC_F0 0x0080
54+#define RC_F1 0x0100
55+#define RC_F2 0x0200
56+#define RC_F3 0x0400
5757 #ifdef TCC_ARM_VFP
58−#define RC_F4 0x0800
59−#define RC_F5 0x1000
60−#define RC_F6 0x2000
61−#define RC_F7 0x4000
58+#define RC_F4 0x0800
59+#define RC_F5 0x1000
60+#define RC_F6 0x2000
61+#define RC_F7 0x4000
6262 #endif
63−#define RC_IRET RC_R0 /* function return: integer register */
64−#define RC_LRET RC_R1 /* function return: second integer register */
65−#define RC_FRET RC_F0 /* function return: float register */
63+#define RC_IRET RC_R0 /* function return: integer register */
64+#define RC_LRET RC_R1 /* function return: second integer register */
65+#define RC_FRET RC_F0 /* function return: float register */
6666
6767 /* pretty names for the registers */
6868 enum {
@@ -1716,12 +1716,12 @@ void gen_opf(int op) · 1647 unmodified lines
17161716 }
17171717 if (is_zero(-1)) {
17181718 vswap();
1719− switch(op) {
1720− case TOK_LT: op = TOK_GT; break;
1721− case TOK_GE: op = TOK_ULE; break;
1722− case TOK_LE: op = TOK_GE; break;
1723− case TOK_GT: op = TOK_ULT; break;
1724− }
1719+ switch(op) {
1720+ case TOK_LT: op = TOK_GT; break;
1721+ case TOK_GE: op = TOK_ULE; break;
1722+ case TOK_LE: op = TOK_GE; break;
1723+ case TOK_GT: op = TOK_ULT; break;
1724+ }
17251725 }
17261726 x |= 0xB40040; /* fcmpX */
17271727 if (op != TOK_EQ && op != TOK_NE)
@@ -1738,12 +1738,12 @@ void gen_opf(int op) · 10 unmodified lines
17381738 }
17391739 o(0xEEF1FA10); /* fmstat */
17401740
1741− switch(op) {
1741+ switch(op) {
17421742 case TOK_LE: op = TOK_ULE; break;
17431743 case TOK_LT: op = TOK_ULT; break;
17441744 case TOK_UGE: op = TOK_GE; break;
17451745 case TOK_UGT: op = TOK_GT; break;
1746− }
1746+ }
17471747
17481748 vtop->r = VT_CMP;
17491749 vtop->c.i = op;
src/libtcc.c+2−2
@@ -672,7 +672,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 671 unmodified lines
672672 }
673673 #else
674674 if (! (sym->type.t & VT_STATIC))
675− other = (sym->type.t & VT_VIS_MASK) >> VT_VIS_SHIFT;
675+ other = (sym->type.t & VT_VIS_MASK) >> VT_VIS_SHIFT;
676676 #endif
677677 if (tcc_state->leading_underscore && can_add_underscore) {
678678 buf1[0] = '_';
@@ -2257,7 +2257,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 1578 unmodified lines
22572257 tcc_set_options(s, "-lpthread");
22582258
22592259 if (s->output_type == TCC_OUTPUT_EXE)
2260− tcc_set_linker(s, (const char *)linker_arg.data);
2260+ tcc_set_linker(s, (const char *)linker_arg.data);
22612261 cstr_free(&linker_arg);
22622262
22632263 return optind;
src/tccasm.c+23−23
@@ -492,25 +492,25 @@ static void asm_parse_directive(TCCState *s1) · 491 unmodified lines
492492 case TOK_ASM_global:
493493 case TOK_ASM_weak:
494494 case TOK_ASM_hidden:
495− tok1 = tok;
496− do {
497− Sym *sym;
495+ tok1 = tok;
496+ do {
497+ Sym *sym;
498498
499− next();
500− sym = label_find(tok);
501− if (!sym) {
502− sym = label_push(&s1->asm_labels, tok, 0);
503− sym->type.t = VT_VOID;
504− }
505− if (tok1 != TOK_ASM_hidden)
506− sym->type.t &= ~VT_STATIC;
507− if (tok1 == TOK_ASM_weak)
508− sym->type.t |= VT_WEAK;
509− else if (tok1 == TOK_ASM_hidden)
510− sym->type.t |= STV_HIDDEN << VT_VIS_SHIFT;
511− next();
512− } while (tok == ',');
513− break;
499+ next();
500+ sym = label_find(tok);
501+ if (!sym) {
502+ sym = label_push(&s1->asm_labels, tok, 0);
503+ sym->type.t = VT_VOID;
504+ }
505+ if (tok1 != TOK_ASM_hidden)
506+ sym->type.t &= ~VT_STATIC;
507+ if (tok1 == TOK_ASM_weak)
508+ sym->type.t |= VT_WEAK;
509+ else if (tok1 == TOK_ASM_hidden)
510+ sym->type.t |= STV_HIDDEN << VT_VIS_SHIFT;
511+ next();
512+ } while (tok == ',');
513+ break;
514514 case TOK_ASM_string:
515515 case TOK_ASM_ascii:
516516 case TOK_ASM_asciz:
@@ -536,12 +536,12 @@ static void asm_parse_directive(TCCState *s1) · 19 unmodified lines
536536 break;
537537 }
538538 }
539− }
540− break;
539+ }
540+ break;
541541 case TOK_ASM_text:
542542 case TOK_ASM_data:
543543 case TOK_ASM_bss:
544− {
544+ {
545545 char sname[64];
546546 tok1 = tok;
547547 n = 0;
@@ -552,8 +552,8 @@ static void asm_parse_directive(TCCState *s1) · 4 unmodified lines
552552 }
553553 sprintf(sname, (n?".%s%d":".%s"), get_tok_str(tok1, NULL), n);
554554 use_section(s1, sname);
555− }
556− break;
555+ }
556+ break;
557557 case TOK_ASM_file:
558558 {
559559 char filename[512];
src/tcccoff.c+14−14
@@ -21,9 +21,9 @@ · 20 unmodified lines
2121
2222 #include "tcc.h"
2323
24−#define MAXNSCNS 255 /* MAXIMUM NUMBER OF SECTIONS */
24+#define MAXNSCNS 255 /* MAXIMUM NUMBER OF SECTIONS */
2525 #define MAX_STR_TABLE 1000000
26−AOUTHDR o_filehdr; /* OPTIONAL (A.OUT) FILE HEADER */
26+AOUTHDR o_filehdr; /* OPTIONAL (A.OUT) FILE HEADER */
2727
2828 SCNHDR section_header[MAXNSCNS];
2929
@@ -94,21 +94,21 @@ ST_FUNC int tcc_output_coff(TCCState* s1, FILE* f) · 64 unmodified lines
9494 nb_syms = symtab_section->data_offset / sizeof(Elf32_Sym);
9595 coff_nb_syms = FindCoffSymbolIndex("XXXXXXXXXX1");
9696
97− file_hdr.f_magic = COFF_C67_MAGIC; /* magic number */
98− file_hdr.f_timdat = 0; /* time & date stamp */
99− file_hdr.f_opthdr = sizeof(AOUTHDR); /* sizeof(optional hdr) */
100− file_hdr.f_flags = 0x1143; /* flags (copied from what code composer does) */
101− file_hdr.f_TargetID = 0x99; /* for C6x = 0x0099 */
97+ file_hdr.f_magic = COFF_C67_MAGIC; /* magic number */
98+ file_hdr.f_timdat = 0; /* time & date stamp */
99+ file_hdr.f_opthdr = sizeof(AOUTHDR); /* sizeof(optional hdr) */
100+ file_hdr.f_flags = 0x1143; /* flags (copied from what code composer does) */
101+ file_hdr.f_TargetID = 0x99; /* for C6x = 0x0099 */
102102
103− o_filehdr.magic = 0x0108; /* see magic.h */
104− o_filehdr.vstamp = 0x0190; /* version stamp */
103+ o_filehdr.magic = 0x0108; /* see magic.h */
104+ o_filehdr.vstamp = 0x0190; /* version stamp */
105105 o_filehdr.tsize =
106− stext->data_offset; /* text size in bytes, padded to FW bdry */
107− o_filehdr.dsize = sdata->data_offset; /* initialized data " " */
108− o_filehdr.bsize = sbss->data_offset; /* uninitialized data " " */
106+ stext->data_offset; /* text size in bytes, padded to FW bdry */
107+ o_filehdr.dsize = sdata->data_offset; /* initialized data " " */
108+ o_filehdr.bsize = sbss->data_offset; /* uninitialized data " " */
109109 o_filehdr.entrypt = C67_main_entry_point; /* entry pt. */
110− o_filehdr.text_start = stext->sh_addr; /* base of text used for this file */
111− o_filehdr.data_start = sdata->sh_addr; /* base of data used for this file */
110+ o_filehdr.text_start = stext->sh_addr; /* base of text used for this file */
111+ o_filehdr.data_start = sdata->sh_addr; /* base of data used for this file */
112112
113113 // create all the section headers
114114
src/tccelf.c+138−138
@@ -451,7 +451,7 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve) · 450 unmodified lines
451451 if (addr) {
452452 sym->st_value = (addr_t)addr;
453453 #ifdef DEBUG_RELOC
454− printf ("relocate_sym: %s -> 0x%lx\n", name, sym->st_value);
454+ printf ("relocate_sym: %s -> 0x%lx\n", name, sym->st_value);
455455 #endif
456456 goto found;
457457 }
@@ -580,10 +580,10 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 122 unmodified lines
580580 {
581581 int x, is_thumb, is_call, h, blx_avail, is_bl, th_ko;
582582 x = (*(int *) ptr) & 0xffffff;
583− if (sym->st_shndx == SHN_UNDEF)
584− val = s1->plt->sh_addr;
583+ if (sym->st_shndx == SHN_UNDEF)
584+ val = s1->plt->sh_addr;
585585 #ifdef DEBUG_RELOC
586− printf ("reloc %d: x=0x%x val=0x%x ", type, x, val);
586+ printf ("reloc %d: x=0x%x val=0x%x ", type, x, val);
587587 #endif
588588 (*(int *)ptr) &= 0xff000000;
589589 if (x & 0x800000)
@@ -595,8 +595,8 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 5 unmodified lines
595595 is_call = (type == R_ARM_CALL || (type == R_ARM_PC24 && is_bl));
596596 x += val - addr;
597597 #ifdef DEBUG_RELOC
598− printf (" newx=0x%x name=%s\n", x,
599− (char *) symtab_section->link->data + sym->st_name);
598+ printf (" newx=0x%x name=%s\n", x,
599+ (char *) symtab_section->link->data + sym->st_name);
600600 #endif
601601 h = x & 2;
602602 th_ko = (x & 3) && (!blx_avail || !is_call);
@@ -801,17 +801,17 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 198 unmodified lines
801801 if we really need a PLT slot. */
802802 if (sym->st_shndx == SHN_UNDEF)
803803 /* We've put the PLT slot offset into r_addend when generating
804− it, and that's what we must use as relocation value (adjusted
805− by section offset of course). */
806− val = s1->plt->sh_addr + rel->r_addend;
804+ it, and that's what we must use as relocation value (adjusted
805+ by section offset of course). */
806+ val = s1->plt->sh_addr + rel->r_addend;
807807 #ifdef DEBUG_RELOC
808− printf ("reloc %d @ 0x%lx: val=0x%lx name=%s\n", type, addr, val,
809− (char *) symtab_section->link->data + sym->st_name);
808+ printf ("reloc %d @ 0x%lx: val=0x%lx name=%s\n", type, addr, val,
809+ (char *) symtab_section->link->data + sym->st_name);
810810 #endif
811811 if (((val - addr) + ((uint64_t)1 << 27)) & ~(uint64_t)0xffffffc)
812− {
812+ {
813813 tcc_error("R_AARCH64_(JUMP|CALL)26 relocation failed (val=%lx, addr=%lx)", addr, val);
814− }
814+ }
815815 *(uint32_t *)ptr = 0x14000000 | (type == R_AARCH64_CALL26) << 31 |
816816 ((val - addr) >> 2 & 0x3ffffff);
817817 break;
@@ -836,9 +836,9 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 18 unmodified lines
836836 case R_AARCH64_JUMP_SLOT:
837837 /* They don't need addend */
838838 #ifdef DEBUG_RELOC
839− printf ("reloc %d @ 0x%lx: val=0x%lx name=%s\n", type, addr,
840− val - rel->r_addend,
841− (char *) symtab_section->link->data + sym->st_name);
839+ printf ("reloc %d @ 0x%lx: val=0x%lx name=%s\n", type, addr,
840+ val - rel->r_addend,
841+ (char *) symtab_section->link->data + sym->st_name);
842842 #endif
843843 *(addr_t *)ptr = val - rel->r_addend;
844844 break;
@@ -879,12 +879,12 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 34 unmodified lines
879879 qrel->r_offset = rel->r_offset;
880880 if (esym_index) {
881881 qrel->r_info = ELFW(R_INFO)(esym_index, R_X86_64_64);
882− qrel->r_addend = rel->r_addend;
882+ qrel->r_addend = rel->r_addend;
883883 qrel++;
884884 break;
885885 } else {
886− qrel->r_info = ELFW(R_INFO)(0, R_X86_64_RELATIVE);
887− qrel->r_addend = *(long long *)ptr + val;
886+ qrel->r_info = ELFW(R_INFO)(0, R_X86_64_RELATIVE);
887+ qrel->r_addend = *(long long *)ptr + val;
888888 qrel++;
889889 }
890890 }
@@ -917,21 +917,21 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 26 unmodified lines
917917 goto plt32pc32;
918918
919919 case R_X86_64_PLT32:
920− /* We've put the PLT slot offset into r_addend when generating
921− it, and that's what we must use as relocation value (adjusted
922− by section offset of course). */
923− val = s1->plt->sh_addr + rel->r_addend;
924− /* fallthrough. */
925−
926− plt32pc32:
927− {
928− long long diff;
929− diff = (long long)val - addr;
930− if (diff < -2147483648LL || diff > 2147483647LL) {
931− tcc_error("internal error: relocation failed");
920+ /* We've put the PLT slot offset into r_addend when generating
921+ it, and that's what we must use as relocation value (adjusted
922+ by section offset of course). */
923+ val = s1->plt->sh_addr + rel->r_addend;
924+ /* fallthrough. */
925+
926+ plt32pc32:
927+ {
928+ long long diff;
929+ diff = (long long)val - addr;
930+ if (diff < -2147483648LL || diff > 2147483647LL) {
931+ tcc_error("internal error: relocation failed");
932+ }
933+ *(int *)ptr += diff;
932934 }
933− *(int *)ptr += diff;
934− }
935935 break;
936936 case R_X86_64_GLOB_DAT:
937937 case R_X86_64_JUMP_SLOT:
@@ -1080,8 +1080,8 @@ static void build_got(TCCState *s1) · 142 unmodified lines
10801080 and 'info' can be modifed if more precise info comes from the DLL.
10811081 Returns offset of GOT or PLT slot. */
10821082 static unsigned long put_got_entry(TCCState *s1,
1083− int reloc_type, unsigned long size, int info,
1084− int sym_index)
1083+ int reloc_type, unsigned long size, int info,
1084+ int sym_index)
10851085 {
10861086 int index, need_plt_entry;
10871087 const char *name;
@@ -1107,18 +1107,18 @@ static unsigned long put_got_entry(TCCState *s1, · 19 unmodified lines
11071107 #endif
11081108
11091109 if (need_plt_entry && !s1->plt) {
1110− /* add PLT */
1111− s1->plt = new_section(s1, ".plt", SHT_PROGBITS,
1112− SHF_ALLOC | SHF_EXECINSTR);
1113− s1->plt->sh_entsize = 4;
1110+ /* add PLT */
1111+ s1->plt = new_section(s1, ".plt", SHT_PROGBITS,
1112+ SHF_ALLOC | SHF_EXECINSTR);
1113+ s1->plt->sh_entsize = 4;
11141114 }
11151115
11161116 /* If a got/plt entry already exists for that symbol, no need to add one */
11171117 if (sym_index < s1->nb_sym_attrs) {
1118− if (need_plt_entry && s1->sym_attrs[sym_index].plt_offset)
1119− return s1->sym_attrs[sym_index].plt_offset;
1120− else if (!need_plt_entry && s1->sym_attrs[sym_index].got_offset)
1121− return s1->sym_attrs[sym_index].got_offset;
1118+ if (need_plt_entry && s1->sym_attrs[sym_index].plt_offset)
1119+ return s1->sym_attrs[sym_index].plt_offset;
1120+ else if (!need_plt_entry && s1->sym_attrs[sym_index].got_offset)
1121+ return s1->sym_attrs[sym_index].got_offset;
11221122 }
11231123
11241124 symattr = alloc_sym_attr(s1, sym_index);
@@ -1135,7 +1135,7 @@ static unsigned long put_got_entry(TCCState *s1, · 10 unmodified lines
11351135 Section *plt;
11361136 uint8_t *p;
11371137 int modrm;
1138− unsigned long relofs;
1138+ unsigned long relofs;
11391139
11401140 #if defined(TCC_OUTPUT_DLL_WITH_PLT)
11411141 modrm = 0x25;
@@ -1160,10 +1160,10 @@ static unsigned long put_got_entry(TCCState *s1, · 18 unmodified lines
11601160 put32(p + 8, PTR_SIZE * 2);
11611161 }
11621162
1163− /* The PLT slot refers to the relocation entry it needs
1164− via offset. The reloc entry is created below, so its
1165− offset is the current data_offset. */
1166− relofs = s1->got->reloc ? s1->got->reloc->data_offset : 0;
1163+ /* The PLT slot refers to the relocation entry it needs
1164+ via offset. The reloc entry is created below, so its
1165+ offset is the current data_offset. */
1166+ relofs = s1->got->reloc ? s1->got->reloc->data_offset : 0;
11671167 symattr->plt_offset = plt->data_offset;
11681168 p = section_ptr_add(plt, 16);
11691169 p[0] = 0xff; /* jmp *(got + x) */
@@ -1171,20 +1171,20 @@ static unsigned long put_got_entry(TCCState *s1, · 1 unmodified line
11711171 put32(p + 2, s1->got->data_offset);
11721172 p[6] = 0x68; /* push $xxx */
11731173 #ifdef TCC_TARGET_X86_64
1174− /* On x86-64, the relocation is referred to by _index_. */
1175− put32(p + 7, relofs / sizeof (ElfW_Rel));
1174+ /* On x86-64, the relocation is referred to by _index_. */
1175+ put32(p + 7, relofs / sizeof (ElfW_Rel));
11761176 #else
11771177 put32(p + 7, relofs);
11781178 #endif
11791179 p[11] = 0xe9; /* jmp plt_start */
11801180 put32(p + 12, -(plt->data_offset));
11811181
1182− /* If this was an UNDEF symbol set the offset in the
1183− dynsymtab to the PLT slot, so that PC32 relocs to it
1184− can be resolved. */
1185− if (sym->st_shndx == SHN_UNDEF)
1186− offset = plt->data_offset - 16;
1187− }
1182+ /* If this was an UNDEF symbol set the offset in the
1183+ dynsymtab to the PLT slot, so that PC32 relocs to it
1184+ can be resolved. */
1185+ if (sym->st_shndx == SHN_UNDEF)
1186+ offset = plt->data_offset - 16;
1187+ }
11881188 #elif defined(TCC_TARGET_ARM)
11891189 if (need_plt_entry) {
11901190 Section *plt;
@@ -1220,9 +1220,9 @@ static unsigned long put_got_entry(TCCState *s1, · 29 unmodified lines
12201220
12211221 /* the symbol is modified so that it will be relocated to
12221222 the PLT */
1223− if (sym->st_shndx == SHN_UNDEF)
1223+ if (sym->st_shndx == SHN_UNDEF)
12241224 offset = plt->data_offset - 16;
1225− }
1225+ }
12261226 #elif defined(TCC_TARGET_ARM64)
12271227 if (need_plt_entry) {
12281228 Section *plt;
@@ -1250,29 +1250,29 @@ static unsigned long put_got_entry(TCCState *s1, · 21 unmodified lines
12501250 #error unsupported CPU
12511251 #endif
12521252 if (s1->dynsym) {
1253− /* XXX This might generate multiple syms for name. */
1253+ /* XXX This might generate multiple syms for name. */
12541254 index = put_elf_sym(s1->dynsym, offset,
12551255 size, info, 0, sym->st_shndx, name);
12561256 /* Create the relocation (it's against the GOT for PLT
1257− and GOT relocs). */
1257+ and GOT relocs). */
12581258 put_elf_reloc(s1->dynsym, s1->got,
12591259 s1->got->data_offset,
12601260 reloc_type, index);
12611261 } else {
1262− /* Without .dynsym (i.e. static link or memory output) we
1263− still need relocs against the generated got, so as to fill
1264− the entries with the symbol values (determined later). */
1265− put_elf_reloc(symtab_section, s1->got,
1266− s1->got->data_offset,
1267− reloc_type, sym_index);
1262+ /* Without .dynsym (i.e. static link or memory output) we
1263+ still need relocs against the generated got, so as to fill
1264+ the entries with the symbol values (determined later). */
1265+ put_elf_reloc(symtab_section, s1->got,
1266+ s1->got->data_offset,
1267+ reloc_type, sym_index);
12681268 }
12691269 /* And now create the GOT slot itself. */
12701270 ptr = section_ptr_add(s1->got, PTR_SIZE);
12711271 *ptr = 0;
12721272 if (need_plt_entry)
1273− return symattr->plt_offset;
1273+ return symattr->plt_offset;
12741274 else
1275− return symattr->got_offset;
1275+ return symattr->got_offset;
12761276 }
12771277
12781278 /* build GOT and PLT entries */
@@ -1324,8 +1324,8 @@ ST_FUNC void build_got_entries(TCCState *s1) · 45 unmodified lines
13241324 build_got(s1);
13251325 sym_index = ELFW(R_SYM)(rel->r_info);
13261326 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
1327− if (type != R_ARM_GOTOFF && type != R_ARM_GOTPC
1328− && sym->st_shndx == SHN_UNDEF) {
1327+ if (type != R_ARM_GOTOFF && type != R_ARM_GOTPC
1328+ && sym->st_shndx == SHN_UNDEF) {
13291329 unsigned long ofs;
13301330 /* look at the symbol got offset. If none, then add one */
13311331 if (type == R_ARM_GOT32)
@@ -1333,27 +1333,27 @@ ST_FUNC void build_got_entries(TCCState *s1) · 1 unmodified line
13331333 else
13341334 reloc_type = R_ARM_JUMP_SLOT;
13351335 ofs = put_got_entry(s1, reloc_type, sym->st_size,
1336− sym->st_info, sym_index);
1336+ sym->st_info, sym_index);
13371337 #ifdef DEBUG_RELOC
1338− printf ("maybegot: %s, %d, %d --> ofs=0x%x\n",
1339− (char *) symtab_section->link->data + sym->st_name,
1340− type, sym->st_shndx, ofs);
1338+ printf("maybegot: %s, %d, %d --> ofs=0x%x\n",
1339+ (char *) symtab_section->link->data + sym->st_name,
1340+ type, sym->st_shndx, ofs);
13411341 #endif
1342− if (type != R_ARM_GOT32) {
1343− addr_t *ptr = (addr_t*)(s1->sections[s->sh_info]->data
1344− + rel->r_offset);
1345− /* x must be signed! */
1346− int x = *ptr & 0xffffff;
1347− x = (x << 8) >> 8;
1348− x <<= 2;
1349− x += ofs;
1350− x >>= 2;
1342+ if (type != R_ARM_GOT32) {
1343+ addr_t *ptr = (addr_t*)(s1->sections[s->sh_info]->data
1344+ + rel->r_offset);
1345+ /* x must be signed! */
1346+ int x = *ptr & 0xffffff;
1347+ x = (x << 8) >> 8;
1348+ x <<= 2;
1349+ x += ofs;
1350+ x >>= 2;
13511351 #ifdef DEBUG_RELOC
1352− printf ("insn=0x%x --> 0x%x (x==0x%x)\n", *ptr,
1353− (*ptr & 0xff000000) | x, x);
1352+ printf ("insn=0x%x --> 0x%x (x==0x%x)\n", *ptr,
1353+ (*ptr & 0xff000000) | x, x);
13541354 #endif
1355− *ptr = (*ptr & 0xff000000) | x;
1356− }
1355+ *ptr = (*ptr & 0xff000000) | x;
1356+ }
13571357 }
13581358 break;
13591359 case R_ARM_THM_JUMP24:
@@ -1397,20 +1397,20 @@ ST_FUNC void build_got_entries(TCCState *s1) · 37 unmodified lines
13971397 sym_index);
13981398 break;
13991399
1400− case R_AARCH64_JUMP26:
1401− case R_AARCH64_CALL26:
1400+ case R_AARCH64_JUMP26:
1401+ case R_AARCH64_CALL26:
14021402 if (!s1->got)
14031403 build_got(s1);
14041404 sym_index = ELFW(R_SYM)(rel->r_info);
14051405 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
14061406 if (sym->st_shndx == SHN_UNDEF) {
1407− unsigned long ofs;
1408− reloc_type = R_AARCH64_JUMP_SLOT;
1407+ unsigned long ofs;
1408+ reloc_type = R_AARCH64_JUMP_SLOT;
14091409 ofs = put_got_entry(s1, reloc_type, sym->st_size,
1410− sym->st_info, sym_index);
1411− /* We store the place of the generated PLT slot
1412− in our addend. */
1413− rel->r_addend += ofs;
1410+ sym->st_info, sym_index);
1411+ /* We store the place of the generated PLT slot
1412+ in our addend. */
1413+ rel->r_addend += ofs;
14141414 }
14151415 break;
14161416 #elif defined(TCC_TARGET_C67)
@@ -1455,7 +1455,7 @@ ST_FUNC void build_got_entries(TCCState *s1) · 38 unmodified lines
14551455 if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL)
14561456 reloc_type = R_X86_64_GLOB_DAT;
14571457 else
1458− reloc_type = R_X86_64_JUMP_SLOT;
1458+ reloc_type = R_X86_64_JUMP_SLOT;
14591459 ofs = put_got_entry(s1, reloc_type, sym->st_size,
14601460 sym->st_info, sym_index);
14611461 if (type == R_X86_64_PLT32)
@@ -1546,21 +1546,21 @@ static int tcc_add_support(TCCState *s1, const char *filename) · 84 unmodified lines
15461546 snprintf(buf, sizeof(buf), "%s/%s/%s", s1->tcc_lib_path,
15471547 /* an cpu specific path inside tcc_lib_path, mainly for keeping libtcc1.a */
15481548 #ifdef TCC_TARGET_I386
1549− "i386"
1549+ "i386"
15501550 #endif
15511551 #ifdef TCC_TARGET_X86_64
1552− "x86_64"
1552+ "x86_64"
15531553 #endif
15541554 #ifdef TCC_TARGET_ARM
1555− "arm"
1555+ "arm"
15561556 #endif
15571557 #ifdef TCC_TARGET_ARM64
1558− "arm64"
1558+ "arm64"
15591559 #endif
15601560 #ifdef TCC_TARGET_C67
1561− "C67"
1561+ "C67"
15621562 #endif
1563− ,filename);
1563+ , filename);
15641564
15651565 return tcc_add_file(s1, buf, TCC_FILETYPE_BINARY);
15661566 }
@@ -1587,16 +1587,16 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1) · 20 unmodified lines
15871587 when __bound_ptr_add, __bound_new_region,
15881588 __bound_delete_region called */
15891589
1590− int sym_index = find_elf_sym(symtab_section, "__bound_init");
1591− if (sym_index) {
1592− Section *init_section = find_section(s1, ".init");
1593− unsigned char *pinit = section_ptr_add(init_section, 5);
1594− pinit[0] = 0xe8;
1595− put32(pinit + 1, -4);
1596− put_elf_reloc(symtab_section, init_section,
1597− init_section->data_offset - 4, R_386_PC32, sym_index);
1598− }
1599− else
1590+ int sym_index = find_elf_sym(symtab_section, "__bound_init");
1591+ if (sym_index) {
1592+ Section *init_section = find_section(s1, ".init");
1593+ unsigned char *pinit = section_ptr_add(init_section, 5);
1594+ pinit[0] = 0xe8;
1595+ put32(pinit + 1, -4);
1596+ put_elf_reloc(symtab_section, init_section,
1597+ init_section->data_offset - 4, R_386_PC32, sym_index);
1598+ }
1599+ else
16001600 tcc_warning("__bound_init not defined");
16011601 }
16021602 #endif
@@ -1905,11 +1905,11 @@ static void export_global_syms(TCCState *s1) · 302 unmodified lines
19051905 s1->symtab_to_dynsym = tcc_mallocz(sizeof(int) * nb_syms);
19061906 for_each_elem(symtab_section, 1, sym, ElfW(Sym)) {
19071907 if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
1908− name = (char *) symtab_section->link->data + sym->st_name;
1909− dynindex = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1910− sym->st_info, 0, sym->st_shndx, name);
1911− index = sym - (ElfW(Sym) *) symtab_section->data;
1912− s1->symtab_to_dynsym[index] = dynindex;
1908+ name = (char *) symtab_section->link->data + sym->st_name;
1909+ dynindex = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
1910+ sym->st_info, 0, sym->st_shndx, name);
1911+ index = sym - (ElfW(Sym) *) symtab_section->data;
1912+ s1->symtab_to_dynsym[index] = dynindex;
19131913 }
19141914 }
19151915 }
@@ -2179,15 +2179,15 @@ static int layout_sections(TCCState *s1, ElfW(Phdr) *phdr, int phnum, · 263 unmodified lines
21792179 file_offset += s->sh_size;
21802180 }
21812181 }
2182− if (j == 0) {
2183− /* Make the first PT_LOAD segment include the program
2184− headers itself (and the ELF header as well), it'll
2185− come out with same memory use but will make various
2186− tools like binutils strip work better. */
2187− ph->p_offset &= ~(ph->p_align - 1);
2188− ph->p_vaddr &= ~(ph->p_align - 1);
2189− ph->p_paddr &= ~(ph->p_align - 1);
2190− }
2182+ if (j == 0) {
2183+ /* Make the first PT_LOAD segment include the program
2184+ headers itself (and the ELF header as well), it'll
2185+ come out with same memory use but will make various
2186+ tools like binutils strip work better. */
2187+ ph->p_offset &= ~(ph->p_align - 1);
2188+ ph->p_vaddr &= ~(ph->p_align - 1);
2189+ ph->p_paddr &= ~(ph->p_align - 1);
2190+ }
21912191 ph->p_filesz = file_offset - ph->p_offset;
21922192 ph->p_memsz = addr - ph->p_vaddr;
21932193 ph++;
@@ -2662,10 +2662,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 468 unmodified lines
26622662 for_each_elem(s1->dynsym, 1, sym, ElfW(Sym)) {
26632663 if (sym->st_shndx == SHN_UNDEF) {
26642664 /* relocate to PLT if symbol corresponds to a PLT entry,
2665− but not if it's a weak symbol */
2666− if (ELFW(ST_BIND)(sym->st_info) == STB_WEAK)
2667− sym->st_value = 0;
2668− else if (sym->st_value)
2665+ but not if it's a weak symbol */
2666+ if (ELFW(ST_BIND)(sym->st_info) == STB_WEAK)
2667+ sym->st_value = 0;
2668+ else if (sym->st_value)
26692669 sym->st_value += s1->plt->sh_addr;
26702670 } else if (sym->st_shndx < SHN_LORESERVE) {
26712671 /* do symbol relocation */
@@ -2690,14 +2690,14 @@ static int elf_output_file(TCCState *s1, const char *filename) · 18 unmodified lines
26902690 /* Create the ELF file with name 'filename' */
26912691 ret = tcc_write_elf_file(s1, filename, phnum, phdr, file_offset, sec_order);
26922692 if (s1->do_strip) {
2693− int rc;
2694− const char *strip_cmd = "sstrip "; // super strip utility from ELFkickers
2695− const char *null_dev = " 2> /dev/null";
2696− char buf[1050];
2697− snprintf(buf, sizeof(buf), "%s%s%s", strip_cmd, filename, null_dev);
2698− rc = system(buf);
2699− if (rc)
2700− system(buf+1); // call a strip utility from binutils
2693+ int rc;
2694+ const char *strip_cmd = "sstrip "; // super strip utility from ELFkickers
2695+ const char *null_dev = " 2> /dev/null";
2696+ char buf[1050];
2697+ snprintf(buf, sizeof(buf), "%s%s%s", strip_cmd, filename, null_dev);
2698+ rc = system(buf);
2699+ if (rc)
2700+ system(buf+1); // call a strip utility from binutils
27012701 }
27022702 the_end:
27032703 tcc_free(s1->symtab_to_dynsym);
src/tccgen.c+159−160
@@ -1761,18 +1761,18 @@ ST_FUNC void gen_op(int op) · 1760 unmodified lines
17611761 #if 0
17621762 /* #ifdef CONFIG_TCC_BCHECK
17631763 The main reason to removing this code:
1764− #include <stdio.h>
1765− int main ()
1766− {
1767− int v[10];
1768− int i = 10;
1769− int j = 9;
1770− fprintf(stderr, "v+i-j = %p\n", v+i-j);
1771− fprintf(stderr, "v+(i-j) = %p\n", v+(i-j));
1772− }
1764+ #include <stdio.h>
1765+ int main ()
1766+ {
1767+ int v[10];
1768+ int i = 10;
1769+ int j = 9;
1770+ fprintf(stderr, "v+i-j = %p\n", v+i-j);
1771+ fprintf(stderr, "v+(i-j) = %p\n", v+(i-j));
1772+ }
17731773 When this code is on. then the output looks like
1774− v+i-j = 0xfffffffe
1775− v+(i-j) = 0xbff84000
1774+ v+i-j = 0xfffffffe
1775+ v+(i-j) = 0xbff84000
17761776 */
17771777 /* if evaluating constant expression, no code should be
17781778 generated, so no bound check */
@@ -2450,18 +2450,18 @@ static void gen_assign_cast(CType *dt) · 671 unmodified lines
24502450 dbt = dt->t & VT_BTYPE;
24512451 sbt = st->t & VT_BTYPE;
24522452 if (sbt == VT_VOID || dbt == VT_VOID) {
2453− if (sbt == VT_VOID && dbt == VT_VOID)
2454− ; /*
2455− It is Ok if both are void
2456− A test program:
2457− void func1() {}
2458− void func2() {
2459− return func1();
2460− }
2461− gcc accepts this program
2462− */
2463− else
2464− tcc_error("cannot cast from/to void");
2453+ if (sbt == VT_VOID && dbt == VT_VOID)
2454+ ; /*
2455+ It is Ok if both are void
2456+ A test program:
2457+ void func1() {}
2458+ void func2() {
2459+ return func1();
2460+ }
2461+ gcc accepts this program
2462+ */
2463+ else
2464+ tcc_error("cannot cast from/to void");
24652465 }
24662466 if (dt->t & VT_CONSTANT)
24672467 tcc_warning("assignment of read-only location");
@@ -2542,7 +2542,7 @@ ST_FUNC void vstore(void) · 74 unmodified lines
25422542 dbt = ft & VT_BTYPE;
25432543 if ((((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) ||
25442544 (sbt == VT_INT && dbt == VT_SHORT))
2545− && !(vtop->type.t & VT_BITFIELD)) {
2545+ && !(vtop->type.t & VT_BITFIELD)) {
25462546 /* optimize char/short casts */
25472547 delayed_cast = VT_MUSTCAST;
25482548 vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT)));
@@ -2764,20 +2764,20 @@ static void parse_attribute(AttributeDef *ad) · 215 unmodified lines
27642764 next();
27652765 skip(')');
27662766 break;
2767− case TOK_VISIBILITY1:
2768− case TOK_VISIBILITY2:
2767+ case TOK_VISIBILITY1:
2768+ case TOK_VISIBILITY2:
27692769 skip('(');
27702770 if (tok != TOK_STR)
27712771 expect("visibility(\"default|hidden|internal|protected\")");
2772− if (!strcmp (tokc.cstr->data, "default"))
2773− ad->a.visibility = STV_DEFAULT;
2774− else if (!strcmp (tokc.cstr->data, "hidden"))
2775− ad->a.visibility = STV_HIDDEN;
2776− else if (!strcmp (tokc.cstr->data, "internal"))
2777− ad->a.visibility = STV_INTERNAL;
2778− else if (!strcmp (tokc.cstr->data, "protected"))
2779− ad->a.visibility = STV_PROTECTED;
2780− else
2772+ if (!strcmp (tokc.cstr->data, "default"))
2773+ ad->a.visibility = STV_DEFAULT;
2774+ else if (!strcmp (tokc.cstr->data, "hidden"))
2775+ ad->a.visibility = STV_HIDDEN;
2776+ else if (!strcmp (tokc.cstr->data, "internal"))
2777+ ad->a.visibility = STV_INTERNAL;
2778+ else if (!strcmp (tokc.cstr->data, "protected"))
2779+ ad->a.visibility = STV_PROTECTED;
2780+ else
27812781 expect("visibility(\"default|hidden|internal|protected\")");
27822782 next();
27832783 skip(')');
@@ -2973,8 +2973,8 @@ static void struct_decl(CType *type, int u, int tdef) · 189 unmodified lines
29732973 while (tok != '}') {
29742974 parse_btype(&btype, &ad);
29752975 while (1) {
2976− if (flexible)
2977− tcc_error("flexible array member '%s' not at the end of struct",
2976+ if (flexible)
2977+ tcc_error("flexible array member '%s' not at the end of struct",
29782978 get_tok_str(v, NULL));
29792979 bit_size = -1;
29802980 v = 0;
@@ -2990,14 +2990,14 @@ static void struct_decl(CType *type, int u, int tdef) · 9 unmodified lines
29902990 if (tcc_state->ms_extensions == 0)
29912991 expect("identifier");
29922992 }
2993− }
2993+ }
29942994 }
29952995 if (type_size(&type1, &align) < 0) {
2996− if ((a == TOK_STRUCT) && (type1.t & VT_ARRAY) && c)
2997− flexible = 1;
2998− else
2999− tcc_error("field '%s' has incomplete type",
3000− get_tok_str(v, NULL));
2996+ if ((a == TOK_STRUCT) && (type1.t & VT_ARRAY) && c)
2997+ flexible = 1;
2998+ else
2999+ tcc_error("field '%s' has incomplete type",
3000+ get_tok_str(v, NULL));
30013001 }
30023002 if ((type1.t & VT_BTYPE) == VT_FUNC ||
30033003 (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))
@@ -3807,11 +3807,11 @@ ST_FUNC void unary(void) · 803 unmodified lines
38073807 gen_cast(&type);
38083808 }
38093809 } else if (tok == '{') {
3810− /*
3810+ /*
38113811 if (nocode_wanted)
38123812 tcc_error("statement expression in global scope"); */
3813− /* this check breaks compilation of the linux 2.4.26 with the meesage:
3814− linux/include/net/tcp.h:945: error: statement expression in global scope */
3813+ /* this check breaks compilation of the linux 2.4.26 with the meesage:
3814+ linux/include/net/tcp.h:945: error: statement expression in global scope */
38153815
38163816 /* save all registers */
38173817 save_regs(0);
@@ -3872,12 +3872,12 @@ ST_FUNC void unary(void) · 54 unmodified lines
38723872 if ((vtop->type.t & VT_BTYPE) == VT_PTR)
38733873 tcc_error("pointer not accepted for unary plus");
38743874 /* In order to force cast, we add zero, except for floating point
3875− where we really need an noop (otherwise -0.0 will be transformed
3876− into +0.0). */
3877− if (!is_float(vtop->type.t)) {
3878− vpushi(0);
3879− gen_op('+');
3880− }
3875+ where we really need an noop (otherwise -0.0 will be transformed
3876+ into +0.0). */
3877+ if (!is_float(vtop->type.t)) {
3878+ vpushi(0);
3879+ gen_op('+');
3880+ }
38813881 break;
38823882 case TOK_SIZEOF:
38833883 case TOK_ALIGNOF1:
@@ -4050,20 +4050,20 @@ ST_FUNC void unary(void) · 166 unmodified lines
40504050 next();
40514051 unary();
40524052 t = vtop->type.t & VT_BTYPE;
4053− if (is_float(t)) {
4053+ if (is_float(t)) {
40544054 /* In IEEE negate(x) isn't subtract(0,x), but rather
4055− subtract(-0, x). */
4056− vpush(&vtop->type);
4057− if (t == VT_FLOAT)
4058− vtop->c.f = -0.0f;
4059− else if (t == VT_DOUBLE)
4060− vtop->c.d = -0.0;
4061− else
4062− vtop->c.ld = -0.0;
4063− } else
4064− vpushi(0);
4065− vswap();
4066− gen_op('-');
4055+ subtract(-0, x). */
4056+ vpush(&vtop->type);
4057+ if (t == VT_FLOAT)
4058+ vtop->c.f = -0.0f;
4059+ else if (t == VT_DOUBLE)
4060+ vtop->c.d = -0.0;
4061+ else
4062+ vtop->c.ld = -0.0;
4063+ } else
4064+ vpushi(0);
4065+ vswap();
4066+ gen_op('-');
40674067 break;
40684068 case TOK_LAND:
40694069 if (!gnu_ext)
@@ -4142,7 +4142,7 @@ ST_FUNC void unary(void) · 72 unmodified lines
41424142 /* if forward reference, we must point to s */
41434143 if (vtop->r & VT_SYM) {
41444144 vtop->sym = s;
4145− vtop->c.ptr_offset = 0;
4145+ vtop->c.ptr_offset = 0;
41464146 }
41474147 break;
41484148 }
@@ -4312,10 +4312,10 @@ ST_FUNC void unary(void) · 163 unmodified lines
43124312
43134313
43144314 size = type_size(&s->type, &align);
4315− /* We're writing whole regs often, make sure there's enough
4316− space. Assume register size is power of 2. */
4317− if (regsize > align)
4318− align = regsize;
4315+ /* We're writing whole regs often, make sure there's enough
4316+ space. Assume register size is power of 2. */
4317+ if (regsize > align)
4318+ align = regsize;
43194319 loc = (loc - size) & -align;
43204320 addr = loc;
43214321 #if defined(TCC_TARGET_X86_64) && !defined(TCC_TARGET_PE)
@@ -4610,16 +4610,16 @@ static void expr_cond(void) · 288 unmodified lines
46104610 (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_LLONG | VT_UNSIGNED))
46114611 type.t |= VT_UNSIGNED;
46124612 } else if (bt1 == VT_PTR || bt2 == VT_PTR) {
4613− /* If one is a null ptr constant the result type
4614− is the other. */
4615− if (is_null_pointer (vtop))
4616− type = type1;
4617− else if (is_null_pointer (&sv))
4618− type = type2;
4613+ /* If one is a null ptr constant the result type
4614+ is the other. */
4615+ if (is_null_pointer (vtop))
4616+ type = type1;
4617+ else if (is_null_pointer (&sv))
4618+ type = type2;
46194619 /* XXX: test pointer compatibility, C99 has more elaborate
4620− rules here. */
4621− else
4622− type = type1;
4620+ rules here. */
4621+ else
4622+ type = type1;
46234623 } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) {
46244624 /* XXX: test function pointer compatibility */
46254625 type = bt1 == VT_FUNC ? type1 : type2;
@@ -4783,17 +4783,16 @@ static void label_or_decl(int l) · 157 unmodified lines
47834783 int last_tok;
47844784
47854785 /* fast test first */
4786− if (tok >= TOK_UIDENT)
4787− {
4788− /* no need to save tokc because tok is an identifier */
4789− last_tok = tok;
4790− next();
4791− if (tok == ':') {
4786+ if (tok >= TOK_UIDENT) {
4787+ /* no need to save tokc because tok is an identifier */
4788+ last_tok = tok;
4789+ next();
4790+ if (tok == ':') {
4791+ unget_tok(last_tok);
4792+ return;
4793+ }
47924794 unget_tok(last_tok);
4793− return;
47944795 }
4795− unget_tok(last_tok);
4796− }
47974796 decl(l);
47984797 }
47994798
@@ -4891,10 +4890,10 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 91 unmodified lines
48914890 Sym *p;
48924891 switch(vtop->type.t & VT_BTYPE) {
48934892 /* case VT_PTR: */
4894− /* this breaks a compilation of the linux kernel v2.4.26 */
4895− /* pmd_t *new = ({ __asm__ __volatile__("ud2\n") ; ((pmd_t *)1); }); */
4896− /* Look a commit a80acab: Display error on statement expressions with complex return type */
4897− /* A pointer is not a complex return type */
4893+ /* this breaks a compilation of the linux kernel v2.4.26 */
4894+ /* pmd_t *new = ({ __asm__ __volatile__("ud2\n") ; ((pmd_t *)1); }); */
4895+ /* Look a commit a80acab: Display error on statement expressions with complex return type */
4896+ /* A pointer is not a complex return type */
48984897 case VT_STRUCT:
48994898 case VT_ENUM:
49004899 case VT_FUNC:
@@ -5642,38 +5641,38 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 741 unmodified lines
56425641 AttributeDef ad1;
56435642 CType type1;
56445643 next();
5645− if (tcc_state->old_struct_init_code) {
5646− /* an old version of struct initialization.
5647− It have a problems. But with a new version
5648− linux 2.4.26 can't load ramdisk.
5649− */
5650− while (tok == '(') {
5651− par_count++;
5652− next();
5653− }
5654− if (!parse_btype(&type1, &ad1))
5655− expect("cast");
5656− type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
5657− #if 0
5658− if (!is_assignable_types(type, &type1))
5659− tcc_error("invalid type for cast");
5660− #endif
5661− skip(')');
5662− }
5663− else
5664− {
5665− if (tok != '(') {
5644+ if (tcc_state->old_struct_init_code) {
5645+ /* an old version of struct initialization.
5646+ It have a problems. But with a new version
5647+ linux 2.4.26 can't load ramdisk.
5648+ */
5649+ while (tok == '(') {
5650+ par_count++;
5651+ next();
5652+ }
56665653 if (!parse_btype(&type1, &ad1))
5654+ expect("cast");
5655+ type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
5656+ #if 0
5657+ if (!is_assignable_types(type, &type1))
5658+ tcc_error("invalid type for cast");
5659+ #endif
5660+ skip(')');
5661+ }
5662+ else
5663+ {
5664+ if (tok != '(') {
5665+ if (!parse_btype(&type1, &ad1))
56675666 expect("cast");
5668− type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
5669− #if 0
5670− if (!is_assignable_types(type, &type1))
5671− tcc_error("invalid type for cast");
5672− #endif
5673− skip(')');
5674− } else
5675− unget_tok(tok);
5676− }
5667+ type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
5668+ #if 0
5669+ if (!is_assignable_types(type, &type1))
5670+ tcc_error("invalid type for cast");
5671+ #endif
5672+ skip(')');
5673+ } else
5674+ unget_tok(tok);
5675+ }
56775676 }
56785677
56795678 no_oblock = 1;
@@ -5699,28 +5698,28 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 19 unmodified lines
56995698
57005699 /* gr: skip fields from same union - ugly. */
57015700 while (f->next) {
5702− int align = 0;
5703− int f_size = type_size(&f->type, &align);
5704− int f_type = (f->type.t & VT_BTYPE);
5701+ int align = 0;
5702+ int f_size = type_size(&f->type, &align);
5703+ int f_type = (f->type.t & VT_BTYPE);
57055704
57065705 ///printf("index: %2d %08x -- %2d %08x\n", f->c, f->type.t, f->next->c, f->next->type.t);
57075706 /* test for same offset */
57085707 if (f->next->c != f->c)
57095708 break;
57105709 if ((f_type == VT_STRUCT) && (f_size == 0)) {
5711− /*
5712− Lets assume a structure of size 0 can't be a member of the union.
5713− This allow to compile the following code from a linux kernel v2.4.26
5714− typedef struct { } rwlock_t;
5715− struct fs_struct {
5716− int count;
5717− rwlock_t lock;
5718− int umask;
5719− };
5720− struct fs_struct init_fs = { { (1) }, (rwlock_t) {}, 0022, };
5721− tcc-0.9.23 can succesfully compile this version of the kernel.
5722− gcc don't have problems with this code too.
5723− */
5710+ /*
5711+ Lets assume a structure of size 0 can't be a member of the union.
5712+ This allow to compile the following code from a linux kernel v2.4.26
5713+ typedef struct { } rwlock_t;
5714+ struct fs_struct {
5715+ int count;
5716+ rwlock_t lock;
5717+ int umask;
5718+ };
5719+ struct fs_struct init_fs = { { (1) }, (rwlock_t) {}, 0022, };
5720+ tcc-0.9.23 can succesfully compile this version of the kernel.
5721+ gcc don't have problems with this code too.
5722+ */
57245723 break;
57255724 }
57265725 /* if yes, test for bitfield shift */
@@ -5760,21 +5759,21 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 33 unmodified lines
57605759 /* just skip expression */
57615760 parlevel = parlevel1 = 0;
57625761 while ((parlevel > 0 || parlevel1 > 0 ||
5763− (tok != '}' && tok != ',')) && tok != -1) {
5762+ (tok != '}' && tok != ',')) && tok != -1) {
57645763 if (tok == '(')
57655764 parlevel++;
57665765 else if (tok == ')') {
5767− if (parlevel == 0 && parlevel1 == 0)
5768− break;
5766+ if (parlevel == 0 && parlevel1 == 0)
5767+ break;
57695768 parlevel--;
57705769 }
5771− else if (tok == '{')
5772− parlevel1++;
5773− else if (tok == '}') {
5774− if (parlevel == 0 && parlevel1 == 0)
5775− break;
5776− parlevel1--;
5777− }
5770+ else if (tok == '{')
5771+ parlevel1++;
5772+ else if (tok == '}') {
5773+ if (parlevel == 0 && parlevel1 == 0)
5774+ break;
5775+ parlevel1--;
5776+ }
57785777 next();
57795778 }
57805779 } else {
@@ -5995,12 +5994,12 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 214 unmodified lines
59955994 } else {
59965995 /* push global reference */
59975996 sym = get_sym_ref(type, sec, addr, size);
5998− vpushsym(type, sym);
5997+ vpushsym(type, sym);
59995998 }
60005999 /* patch symbol weakness */
60016000 if (type->t & VT_WEAK)
60026001 weaken_symbol(sym);
6003− apply_visibility(sym, type);
6002+ apply_visibility(sym, type);
60046003 #ifdef CONFIG_TCC_BCHECK
60056004 /* handles bounds now because the symbol must be defined
60066005 before for the relocation */
@@ -6236,11 +6235,11 @@ static int decl0(int l, int is_for_loop_init) · 229 unmodified lines
62366235 if (((btype.t & VT_BTYPE) == VT_ENUM ||
62376236 (btype.t & VT_BTYPE) == VT_STRUCT) &&
62386237 tok == ';') {
6239− if ((btype.t & VT_BTYPE) == VT_STRUCT) {
6240− int v = btype.ref->v;
6241− if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM)
6242− tcc_warning("unnamed struct/union that defines no instances");
6243− }
6238+ if ((btype.t & VT_BTYPE) == VT_STRUCT) {
6239+ int v = btype.ref->v;
6240+ if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM)
6241+ tcc_warning("unnamed struct/union that defines no instances");
6242+ }
62446243 next();
62456244 continue;
62466245 }
@@ -6286,7 +6285,7 @@ static int decl0(int l, int is_for_loop_init) · 39 unmodified lines
62866285 if (ad.a.func_export)
62876286 type.t |= VT_EXPORT;
62886287 #endif
6289− type.t |= ad.a.visibility << VT_VIS_SHIFT;
6288+ type.t |= ad.a.visibility << VT_VIS_SHIFT;
62906289
62916290 if (tok == '{') {
62926291 if (l == VT_LOCAL)
@@ -6327,10 +6326,10 @@ static int decl0(int l, int is_for_loop_init) · 34 unmodified lines
63276326 if (sym->type.t & VT_STATIC)
63286327 type.t = (type.t & ~VT_EXTERN) | VT_STATIC;
63296328
6330− /* If the definition has no visibility use the
6331− one from prototype. */
6332− if (! (type.t & VT_VIS_MASK))
6333− type.t |= sym->type.t & VT_VIS_MASK;
6329+ /* If the definition has no visibility use the
6330+ one from prototype. */
6331+ if (! (type.t & VT_VIS_MASK))
6332+ type.t |= sym->type.t & VT_VIS_MASK;
63346333
63356334 if (!is_compatible_types(&sym->type, &type)) {
63366335 func_error1:
src/tccpe.c+17−17
@@ -398,22 +398,22 @@ static int pe_find_import(TCCState * s1, ElfW(Sym) *sym) · 397 unmodified lines
398398 s = pe_export_name(s1, sym);
399399 if (n) {
400400 /* second try: */
401− if (sym->st_other & ST_PE_STDCALL) {
402− /* try w/0 stdcall deco (windows API convention) */
403− p = strrchr(s, '@');
404− if (!p || s[0] != '_')
401+ if (sym->st_other & ST_PE_STDCALL) {
402+ /* try w/0 stdcall deco (windows API convention) */
403+ p = strrchr(s, '@');
404+ if (!p || s[0] != '_')
405+ break;
406+ strcpy(buffer, s+1)[p-s-1] = 0;
407+ } else if (s[0] != '_') { /* try non-ansi function */
408+ buffer[0] = '_', strcpy(buffer + 1, s);
409+ } else if (0 == memcmp(s, "__imp__", 7)) { /* mingw 2.0 */
410+ strcpy(buffer, s + 6);
411+ } else if (0 == memcmp(s, "_imp___", 7)) { /* mingw 3.7 */
412+ strcpy(buffer, s + 6);
413+ } else {
405414 break;
406− strcpy(buffer, s+1)[p-s-1] = 0;
407− } else if (s[0] != '_') { /* try non-ansi function */
408− buffer[0] = '_', strcpy(buffer + 1, s);
409− } else if (0 == memcmp(s, "__imp__", 7)) { /* mingw 2.0 */
410− strcpy(buffer, s + 6);
411− } else if (0 == memcmp(s, "_imp___", 7)) { /* mingw 3.7 */
412− strcpy(buffer, s + 6);
413− } else {
414− break;
415− }
416− s = buffer;
415+ }
416+ s = buffer;
417417 }
418418 sym_index = find_elf_sym(s1->dynsymtab_section, s);
419419 // printf("find (%d) %d %s\n", n, sym_index, s);
@@ -565,9 +565,9 @@ static int pe_write(struct pe_info *pe) · 145 unmodified lines
565565 #endif
566566 /* NT additional fields. */
567567 #if defined(TCC_TARGET_ARM)
568− 0x00100000, /*DWORD ImageBase; */
568+ 0x00100000, /*DWORD ImageBase; */
569569 #else
570− 0x00400000, /*DWORD ImageBase; */
570+ 0x00400000, /*DWORD ImageBase; */
571571 #endif
572572 0x00001000, /*DWORD SectionAlignment; */
573573 0x00000200, /*DWORD FileAlignment; */
src/tms320c67/c67-gen.c+19−19
@@ -30,13 +30,13 @@ typedef int RegArgs; · 29 unmodified lines
3030 /* a register can belong to several classes. The classes must be
3131 sorted from more general to more precise (see gv2() code which does
3232 assumptions on it). */
33−#define RC_INT 0x0001 /* generic integer register */
34−#define RC_FLOAT 0x0002 /* generic float register */
33+#define RC_INT 0x0001 /* generic integer register */
34+#define RC_FLOAT 0x0002 /* generic float register */
3535 #define RC_EAX 0x0004
3636 #define RC_ST0 0x0008
3737 #define RC_ECX 0x0010
3838 #define RC_EDX 0x0020
39−#define RC_INT_BSIDE 0x00000040 /* generic integer register on b side */
39+#define RC_INT_BSIDE 0x00000040 /* generic integer register on b side */
4040 #define RC_C67_A4 0x00000100
4141 #define RC_C67_A5 0x00000200
4242 #define RC_C67_B4 0x00000400
@@ -204,7 +204,7 @@ void C67_g(int c) · 161 unmodified lines
204204 #endif
205205 ind1 = ind + 4;
206206 if (ind1 > (int) cur_text_section->data_allocated)
207− section_realloc(cur_text_section, ind1);
207+ section_realloc(cur_text_section, ind1);
208208 cur_text_section->data[ind] = c & 0xff;
209209 cur_text_section->data[ind + 1] = (c >> 8) & 0xff;
210210 cur_text_section->data[ind + 2] = (c >> 16) & 0xff;
@@ -218,26 +218,26 @@ void gsym_addr(int t, int a) · 7 unmodified lines
218218 {
219219 int n, *ptr;
220220 while (t) {
221− ptr = (int *) (cur_text_section->data + t);
222− {
223− Sym *sym;
221+ ptr = (int *) (cur_text_section->data + t);
222+ {
223+ Sym *sym;
224224
225− // extract 32 bit address from MVKH/MVKL
226− n = ((*ptr >> 7) & 0xffff);
227− n |= ((*(ptr + 1) >> 7) & 0xffff) << 16;
225+ // extract 32 bit address from MVKH/MVKL
226+ n = ((*ptr >> 7) & 0xffff);
227+ n |= ((*(ptr + 1) >> 7) & 0xffff) << 16;
228228
229− // define a label that will be relocated
229+ // define a label that will be relocated
230230
231− sym = get_sym_ref(&char_pointer_type, cur_text_section, a, 0);
232− greloc(cur_text_section, sym, t, R_C60LO16);
233− greloc(cur_text_section, sym, t + 4, R_C60HI16);
231+ sym = get_sym_ref(&char_pointer_type, cur_text_section, a, 0);
232+ greloc(cur_text_section, sym, t, R_C60LO16);
233+ greloc(cur_text_section, sym, t + 4, R_C60HI16);
234234
235− // clear out where the pointer was
235+ // clear out where the pointer was
236236
237− *ptr &= ~(0xffff << 7);
238− *(ptr + 1) &= ~(0xffff << 7);
239− }
240− t = n;
237+ *ptr &= ~(0xffff << 7);
238+ *(ptr + 1) &= ~(0xffff << 7);
239+ }
240+ t = n;
241241 }
242242 }
243243
src/x86/x86_64-gen.c+6−7
@@ -618,7 +618,7 @@ static void gcall_or_jmp(int is_jmp) · 617 unmodified lines
618618 {
619619 int r;
620620 if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
621− ((vtop->r & VT_SYM) || (vtop->c.ll-4) == (int)(vtop->c.ll-4))) {
621+ ((vtop->r & VT_SYM) || (vtop->c.ll-4) == (int)(vtop->c.ll-4))) {
622622 /* constant case */
623623 if (vtop->r & VT_SYM) {
624624 /* relocation case */
@@ -1806,7 +1806,7 @@ int gtst(int inv, int t) · 1181 unmodified lines
18061806 if (v == VT_CMP) {
18071807 /* fast case : can jump directly since flags are set */
18081808 if (vtop->c.i & 0x100)
1809− {
1809+ {
18101810 /* This was a float compare. If the parity flag is set
18111811 the result was unordered. For anything except != this
18121812 means false and we don't jump (anding both conditions).
@@ -1816,13 +1816,12 @@ int gtst(int inv, int t) · 3 unmodified lines
18161816 otherwise if unordered we don't want to jump. */
18171817 vtop->c.i &= ~0x100;
18181818 if (!inv == (vtop->c.i != TOK_NE))
1819− o(0x067a); /* jp +6 */
1820− else
1821− {
1819+ o(0x067a); /* jp +6 */
1820+ else {
18221821 g(0x0f);
18231822 t = psym(0x8a, t); /* jp t */
1824− }
1825− }
1823+ }
1824+ }
18261825 g(0x0f);
18271826 t = psym((vtop->c.i - 16) ^ inv, t);
18281827 } else if (v == VT_JMP || v == VT_JMPI) {