Alien-TinyCC
view release on metacpan
or search on metacpan
src/COPYING
view on Meta::CPAN
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
|
src/Changelog
view on Meta::CPAN
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | - removed size limit on strings. Unified string constants handling
with variable declarations.
- added correct support for '\xX' in wchar_t strings.
- added support for bound checking in generated executables
- fixed -I include order.
- fixed incorrect function displayed in runtime error.
version 0.9.9:
- fixed preprocessor expression parsing for
- relocated debug info (.stab section).
- relocated bounds info (.bounds section).
- fixed cast to char of char constants ( '\377' is -1 instead of 255)
- fixed implicit cast for unary plus.
- strings and '__func__' have now 'char[]' type instead of 'char *'
(fixes sizeof() return value).
- added __start_xxx and __stop_xxx symbols in linker.
- better DLL creation support (option -shared begins to work).
- ELF sections and hash tables are resized dynamically.
- executables and DLLs are stripped by default .
|
src/Changelog
view on Meta::CPAN
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | version 0.9.3:
- better and smaller code generator.
- full ISOC99 64 bit 'long long' support.
- full 32 bit 'float' , 64 bit 'double' and 96 bit 'long double' support.
- added '-U' option.
- added assembly sections support.
- even faster startup time by mmaping sections instead of mallocing them.
- added GNUC __attribute__ keyword support (currently supports
'section' and 'aligned' attributes).
- added ELF file output (only usable for debugging now)
- added debug symbol generation (STAB format ).
- added integrated runtime error analysis ( '-g' option: print clear
run time error messages instead of "Segmentation fault" ).
- added first version of tiny memory and bound checker ( '-b' option).
version 0.9.2:
- even faster parsing.
- various syntax parsing fixes.
- fixed external relocation handling for variables or functions pointers.
- better function pointers type handling.
|
src/TODO
view on Meta::CPAN
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | - better local variables handling (needed for other targets)
Not critical:
- C99: fix multiple compound literals inits in blocks (ISOC99
normative example - only relevant when using gotos! -> must add
boolean variable to tell if compound literal was already
initialized).
- add PowerPC or ARM code generator and improve codegen for RISC (need
to suppress VT_LOCAL and use a base register instead). - interactive mode / integrated debugger
- fix preprocessor symbol redefinition
- better constant opt (&&, ||, ?:)
- add portable byte code generator and interpreter for other
unsupported architectures.
- C++: variable declaration in for , minimal 'class' support.
- win32: __intxx. use resolve for bchecked malloc et al. check exception code (exception filter func).
- handle void (__attribute__() *ptr )()
Fixed (probably):
|
src/coff.h
view on Meta::CPAN
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | /*------------------------------------------------------------------------*/
/* Relocatable symbols have a section number of the */
/* section in which they are defined . Otherwise, section */
/* numbers have the following meanings: */
/*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------*/
/* The fundamental type of a symbol packed into the low */
/* 4 bits of the word. */
/*------------------------------------------------------------------------*/
|
src/configure
view on Meta::CPAN
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | --cc=CC use C compiler CC [ $cc ] --extra-cflags= specify compiler flags [ $CFLAGS ]
--extra-ldflags= specify linker options []
--strip-binaries strip symbol tables from resulting binaries
--disable-static make libtcc.so instead of libtcc.a
--disable-rpath disable use of -rpath with the above -- with -libgcc use /lib/libgcc_s.so.1 instead of libtcc.a
--enable-mingw32 build windows version on linux with mingw32
--enable-cygwin build windows version on windows with cygwin
--enable-cross build cross compilers
--enable-assert enable debug assertions
-- with -selinux use mmap for exec mem [needs writable /tmp] --sysincludepaths=... specify system include paths, colon separated
--libpaths=... specify system library paths, colon separated
--crtprefix=... specify locations of crt?.o, colon separated
--elfinterp=... specify elf interpreter
EOF
exit 1
fi
|
src/elf.h
view on Meta::CPAN
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 | |
src/elf.h
view on Meta::CPAN
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 | /* Legal values for sh_type field of Elf32_Shdr. */
|
src/elf.h
view on Meta::CPAN
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 | |
src/elf.h
view on Meta::CPAN
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 | /* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
|
src/elf.h
view on Meta::CPAN
1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 | /* Alpha specific definitions. */
/* Legal values for e_flags field of Elf64_Ehdr. */
/* Legal values for sh_type field of Elf64_Shdr. */
/* These two are primerily concerned with ECOFF debugging info. */
/* Legal values for sh_flags field of Elf64_Shdr. */
/* Legal values for st_other field of Elf64_Sym. */
|
src/libtcc.c
view on Meta::CPAN
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | printf ( "%s: **** new file\n" , file->filename);
preprocess_init(s1);
cur_text_section = NULL;
funcname = "" ;
anon_sym = SYM_FIRST_ANOM;
/* file info: full path + filename */
section_sym = 0; /* avoid warning */
if (s1->do_debug) {
section_sym = put_elf_sym(symtab_section, 0, 0,
ELFW(ST_INFO)(STB_LOCAL, STT_SECTION), 0,
text_section->sh_num, NULL);
getcwd(buf, sizeof(buf));
normalize_slashes(buf);
pstrcat(buf, sizeof(buf), "/" );
put_stabs_r(buf, N_SO, 0, 0,
text_section->data_offset, text_section, section_sym);
|
src/libtcc.c
view on Meta::CPAN
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | parse_flags = PARSE_FLAG_PREPROCESS | PARSE_FLAG_TOK_NUM;
pvtop = vtop;
next ();
decl(VT_CONST);
if (tok != TOK_EOF)
expect( "declaration" );
if (pvtop != vtop)
tcc_warning( "internal compiler error: vstack leak? (%d)" , vtop - pvtop);
/* end of translation unit info */
if (s1->do_debug) {
put_stabs_r(NULL, N_SO, 0, 0,
text_section->data_offset, text_section, section_sym);
}
}
s1->error_set_jmp_enabled = 0;
/* reset define stack, but leave -Dsymbols (may be incorrect if
they are undefined) */
free_defines(define_start);
|
src/libtcc.c
view on Meta::CPAN
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 | SHT_PROGBITS, SHF_ALLOC);
lbounds_section = new_section(s, ".lbounds" ,
SHT_PROGBITS, SHF_ALLOC);
}
if (s->char_is_unsigned) {
tcc_define_symbol(s, "__CHAR_UNSIGNED__" , NULL);
}
/* add debug sections */
if (s->do_debug) {
/* stab symbols */
stab_section = new_section(s, ".stab" , SHT_PROGBITS, 0);
stab_section->sh_entsize = sizeof(Stab_Sym);
stabstr_section = new_section(s, ".stabstr" , SHT_STRTAB, 0);
put_elf_str(stabstr_section, "" );
stab_section-> link = stabstr_section;
/* put first entry */
put_stabs( "" , 0, 0, 0, 0);
}
|
src/libtcc.c
view on Meta::CPAN
1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 | s->do_bench = 1;
break;
case TCC_OPTION_bt:
tcc_set_num_callers(atoi(optarg));
break;
case TCC_OPTION_b:
s->do_bounds_check = 1;
s->do_debug = 1;
break;
case TCC_OPTION_g:
s->do_debug = 1;
break;
case TCC_OPTION_c:
s->output_type = TCC_OUTPUT_OBJ;
break;
case TCC_OPTION_static:
s->static_link = 1;
break;
case TCC_OPTION_shared:
s->output_type = TCC_OUTPUT_DLL;
break;
|
src/stab.h
view on Meta::CPAN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* Indicate the GNU stab.h is in use . */
enum __stab_debug_code
{
LAST_UNUSED_STAB_CODE
};
|
src/tcc-doc.texi
view on Meta::CPAN
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | @item -Wl,-Bsymbolic
Set DT_SYMBOLIC tag.
@end table
Debugger options:
@table @option
@item -g
Generate run time debug information so that you get clear run time
error messages: @code { test.c:68: in function 'test5()' : dereferencing
invalid pointer} instead of the laconic @code {Segmentation
fault}.
@item -b
Generate additional support code to check
memory allocations and array/pointer bounds. @option {-g} is implied. Note
that the generated code is slower and bigger in this case.
Note: @option {-b} is only available on i386 for the moment.
|
src/tcc-doc.texi
view on Meta::CPAN
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 | @item bss_section
contains uninitialized data
@item bounds_section
@itemx lbounds_section
are used when bound checking is activated
@item stab_section
@itemx stabstr_section
are used when debugging is actived to store debug information
@item symtab_section
@itemx strtab_section
contain the exported symbols (currently only used for debugging).
@end table
@section Code generation
@cindex code generation
@subsection Introduction
The TCC code generator directly generates linked binary code in one
pass. It is rather unusual these days (see gcc for example which
|
src/tcc.c
view on Meta::CPAN
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | " -Ldir add library path 'dir'\n"
" -llib link with dynamic or static library 'lib'\n"
" -pthread link with -lpthread and -D_REENTRANT (POSIX Linux)\n"
" -r generate (relocatable) object file\n"
" -rdynamic export all global symbols to dynamic linker\n"
" -shared generate a shared library\n"
" -soname set name for shared library to be used at runtime\n"
" -static static linking\n"
" -Wl,-opt[=val] set linker option (see manual)\n"
"Debugger options:\n"
" -g generate runtime debug info\n"
" -b compile with built-in memory and bounds checker (implies -g)\n"
" -bt N show N callers in stack traces\n"
"Misc options:\n"
" -nostdinc do not use standard system include paths\n"
" -nostdlib do not link with standard crt and libraries\n"
" -Bdir use 'dir' as tcc internal library and include path\n"
|
src/tcc.h
view on Meta::CPAN
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /* target address type */
/* parser debug */
/*
/* preprocessor debug */
/*
/* include file debug */
/*
/* memory leak debug */
/*
/* assembler debug */
/*
/* target selection */
/*
/*
/*
/*
/* default target is I386 */
|
src/tcc.h
view on Meta::CPAN
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | int char_is_unsigned;
int leading_underscore;
/* warning switches */
int warn_write_strings;
int warn_unsupported;
int warn_error;
int warn_none;
int warn_implicit_function_declaration;
/* compile with debug symbol (and use them if error during execution) */ int do_debug;
/* compile with built-in memory and bounds checker */
int do_bounds_check;
addr_t text_addr; /* address of text section */
int has_text_addr;
unsigned long section_align; /* section alignment */
|
src/tcc.h
view on Meta::CPAN
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 | ST_DATA Section *last_text_section ; /* to handle .previous asm directive */
/* bound check related sections */
ST_DATA Section *bounds_section ; /* contains global data bound description */
ST_DATA Section *lbounds_section ; /* contains local data bound description */
/* symbol sections */
ST_DATA Section *symtab_section , *strtab_section ;
/* debug sections */
ST_DATA Section *stab_section , *stabstr_section ;
ST_DATA Sym *sym_free_first ;
ST_DATA void * *sym_pools ;
ST_DATA int nb_sym_pools;
ST_DATA Sym *global_stack ;
ST_DATA Sym *local_stack ;
ST_DATA Sym *local_label_stack ;
|
src/tcc.h
view on Meta::CPAN
1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 | ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;
ST_DATA SValue __vstack[1+/ *to make bcheck happy*/ VSTACK_SIZE], *vtop ;
ST_DATA int rsym, anon_sym, ind, loc;
ST_DATA int const_wanted; /* true if constant wanted */
ST_DATA int nocode_wanted; /* true if no code generation wanted for an expression */
ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */
ST_DATA CType func_vt; /* current function return type (used by return instruction) */
ST_DATA int func_vc;
ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and pc */
ST_DATA char *funcname ;
ST_INLN int is_float( int t);
ST_FUNC int ieee_finite(double d);
ST_FUNC void test_lvalue(void);
ST_FUNC void swap( int *p , int *q );
ST_FUNC void vpushi( int v);
ST_FUNC Sym *external_global_sym ( int v, CType *type , int r);
ST_FUNC void vset(CType *type , int r, int v);
ST_FUNC void vswap(void);
|
src/tcccoff.c
view on Meta::CPAN
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | // now loop through and determine file pointer locations
// for the line number data
for (i = 1; i < s1->nb_sections; i++) {
coff_sec = §ion_header [i];
tcc_sect = s1->sections[i];
coff_sec->s_nlnno = 0;
coff_sec->s_lnnoptr = 0;
if (s1->do_debug && tcc_sect == stext) {
// count how many line nos data
// also find association between source file name and function
// so we can sort the symbol table
Stab_Sym *sym , *sym_end ;
char func_name[MAX_FUNC_NAME_LENGTH],
last_func_name[MAX_FUNC_NAME_LENGTH];
unsigned long func_addr, last_pc, pc;
|
src/tcccoff.c
view on Meta::CPAN
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | break;
}
sym++;
}
}
}
file_hdr.f_symptr = file_pointer; /* file pointer to symtab */
if (s1->do_debug)
file_hdr.f_nsyms = coff_nb_syms; /* number of symtab entries */
else
file_hdr.f_nsyms = 0;
file_pointer += file_hdr.f_nsyms * SYMNMLEN;
// OK now we are all set to write the file
fwrite( &file_hdr , FILHSZ, 1, f);
|
src/tcccoff.c
view on Meta::CPAN
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | fwrite(tcc_sect->reloc,
coff_sec->s_nreloc * sizeof(struct reloc), 1, f);
}
}
}
// group the symbols in order of filename, func1, func2, etc
// finally global symbols
if (s1->do_debug)
SortSymbolTable();
// write line no data
for (i = 1; i < s1->nb_sections; i++) {
coff_sec = §ion_header [i];
tcc_sect = s1->sections[i];
if (s1->do_debug && tcc_sect == stext) {
// count how many line nos data
Stab_Sym *sym , *sym_end ;
char func_name[128], last_func_name[128];
unsigned long func_addr, last_pc, pc;
const char *incl_files [INCLUDE_STACK_SIZE];
int incl_index, len, last_line_num;
const char *str , *p ;
|
src/tcccoff.c
view on Meta::CPAN
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | goto add_incl2;
}
break;
}
sym++;
}
}
}
// write symbol table
if (s1->do_debug) {
int k;
struct syment csym;
AUXFUNC auxfunc;
AUXBF auxbf;
AUXEF auxef;
int i;
Elf32_Sym *p ;
const char *name ;
int nstr;
int n = 0;
|
src/tcccoff.c
view on Meta::CPAN
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | } else if (p->st_info == 0x12) {
// find the function data
for (k = 0; k < nFuncs; k++) {
if (strcmp(name, Func[k]) == 0)
break;
}
if (k >= nFuncs) {
tcc_error( "debug info can't find function: %s" , name);
}
// put a Function Name
csym.n_value = p->st_value; // physical address
csym.n_scnum = CoffTextSectionNo;
csym.n_type = MKTYPE(T_INT, DT_FCN, 0, 0, 0, 0, 0);
csym.n_sclass = C_EXT;
csym.n_numaux = 1;
fwrite( &csym , 18, 1, f);
|
src/tcccoff.c
view on Meta::CPAN
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | fwrite( &auxfunc , 18, 1, f);
n++;
n++;
}
p++;
}
}
if (s1->do_debug) {
// write string table
// first write the size
i = pCoff_str_table - Coff_str_table;
fwrite( &i , 4, 1, f);
// then write the strings
fwrite(Coff_str_table, i, 1, f);
tcc_free(Coff_str_table);
|
src/tcccoff.c
view on Meta::CPAN
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | (char *) symtab_section-> link ->data + p2->st_name;
// find the function data index
for (k = 0; k < nFuncs; k++) {
if (strcmp(name2, Func[k]) == 0)
break;
}
if (k >= nFuncs) {
tcc_error( "debug (sort) info can't find function: %s" , name2);
}
if (strcmp(AssociatedFile[k], name) == 0) {
// yes they match copy it over
NewTable[n++] = *p2 ;
}
}
p2++;
}
|
src/tcccoff.c
view on Meta::CPAN
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 | p = (Elf32_Sym *) symtab_section->data;
for (i = 0; i < nb_syms; i++) {
if (p->st_info != 4 && p->st_info != 0x12) {
NewTable[n++] = *p ;
}
p++;
}
if (n != nb_syms)
tcc_error( "Internal Compiler error, debug info" );
// copy it all back
p = (Elf32_Sym *) symtab_section->data;
for (i = 0; i < nb_syms; i++) {
*p ++ = NewTable[i];
}
tcc_free(NewTable);
}
|
src/tccelf.c
view on Meta::CPAN
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | s->reloc = sr;
}
rel = section_ptr_add(sr, sizeof(ElfW_Rel));
rel->r_offset = offset;
rel->r_info = ELFW(R_INFO)(symbol, type);
rel->r_addend = 0;
}
/* put stab debug information */
ST_FUNC void put_stabs(const char *str , int type, int other, int desc,
unsigned long value)
{
Stab_Sym *sym ;
sym = section_ptr_add(stab_section, sizeof(Stab_Sym));
if (str) {
sym->n_strx = put_elf_str(stabstr_section, str);
} else {
|
src/tccelf.c
view on Meta::CPAN
1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 | s->sh_info,
s->name,
s->reloc ? s->reloc->name : "n"
);
/* when generating a DLL, we include relocations but we may
patch them */
if (file_type == TCC_OUTPUT_DLL &&
s->sh_type == SHT_RELX &&
!(s->sh_flags & SHF_ALLOC)) {
/* //gr: avoid bogus relocs for empty (debug) sections */
if (s1->sections[s->sh_info]->sh_flags & SHF_ALLOC)
prepare_dynamic_rel(s1, s);
else if (s1->do_debug)
s->sh_size = s->data_offset;
} else if (s1->do_debug ||
file_type == TCC_OUTPUT_OBJ ||
(s->sh_flags & SHF_ALLOC) ||
i == (s1->nb_sections - 1)) {
/* we output all sections if debug or object file */
s->sh_size = s->data_offset;
}
}
/* allocate program segment headers */
phdr = tcc_mallocz(phnum * sizeof(ElfW(Phdr)));
if (s1->output_format == TCC_OUTPUT_FORMAT_ELF) {
file_offset = sizeof(ElfW(Ehdr)) + phnum * sizeof(ElfW(Phdr));
} else {
|
src/tccelf.c
view on Meta::CPAN
2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 | put_dt(dynamic, DT_JMPREL, rel_addr);
put_dt(dynamic, DT_PLTREL, DT_REL);
put_dt(dynamic, DT_REL, bss_addr);
put_dt(dynamic, DT_RELSZ, bss_size);
put_dt(dynamic, DT_REL, rel_addr);
put_dt(dynamic, DT_RELSZ, rel_size);
put_dt(dynamic, DT_RELENT, sizeof(ElfW_Rel));
if (s1->do_debug)
put_dt(dynamic, DT_DEBUG, 0);
put_dt(dynamic, DT_NULL, 0);
}
ehdr.e_phentsize = sizeof(ElfW(Phdr));
ehdr.e_phnum = phnum;
ehdr.e_phoff = sizeof(ElfW(Ehdr));
}
/* all other sections come after */
|
src/tccelf.c
view on Meta::CPAN
2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 | }
typedef struct SectionMergeInfo {
Section *s ; /* corresponding existing section */
unsigned long offset; /* offset of the new section in the existing section */
uint8_t new_section; /* true if section 's' was added */
uint8_t link_once; /* true if link once section */
} SectionMergeInfo;
/* load an object file and merge it with current files */
/* XXX: handle correctly stab (debug) info */
ST_FUNC int tcc_load_object_file(TCCState *s1 ,
int fd, unsigned long file_offset)
{
ElfW(Ehdr) ehdr;
ElfW(Shdr) *shdr , *sh ;
int size, i, j, offset, offseti, nb_syms, sym_index, ret;
unsigned char *strsec , *strtab ;
int *old_to_new_syms ;
char *sh_name , *name ;
SectionMergeInfo *sm_table , *sm ;
|
src/tccgen.c
view on Meta::CPAN
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ST_DATA Section *last_text_section ; /* to handle .previous asm directive */
/* bound check related sections */
ST_DATA Section *bounds_section ; /* contains global data bound description */
ST_DATA Section *lbounds_section ; /* contains local data bound description */
/* symbol sections */
ST_DATA Section *symtab_section , *strtab_section ;
/* debug sections */
ST_DATA Section *stab_section , *stabstr_section ;
ST_DATA Sym *sym_free_first ;
ST_DATA void * *sym_pools ;
ST_DATA int nb_sym_pools;
ST_DATA Sym *global_stack ;
ST_DATA Sym *local_stack ;
ST_DATA Sym *scope_stack_bottom ;
ST_DATA Sym *define_stack ;
ST_DATA Sym *global_label_stack ;
|
src/tccgen.c
view on Meta::CPAN
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ST_DATA int *vla_sp_loc ; /* Pointer to variable holding location to store stack pointer on the stack when modifying stack pointer */
ST_DATA int vla_flags; /* VLA_* flags */
ST_DATA SValue __vstack[1+VSTACK_SIZE], *vtop ;
ST_DATA int const_wanted; /* true if constant wanted */
ST_DATA int nocode_wanted; /* true if no code generation wanted for an expression */
ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */
ST_DATA CType func_vt; /* current function return type (used by return instruction) */
ST_DATA int func_vc;
ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and pc */
ST_DATA char *funcname ;
ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;
/* ------------------------------------------------------------------------- */
static void gen_cast(CType *type );
static inline CType *pointed_type (CType *type );
static int is_compatible_types(CType *type1 , CType *type2 );
static int parse_btype(CType *type , AttributeDef *ad );
static void type_decl(CType *type , AttributeDef *ad , int *v , int td);
|
src/tccgen.c
view on Meta::CPAN
4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 | decl(l);
}
static void block( int *bsym , int *csym , int *case_sym , int *def_sym ,
int case_reg, int is_expr)
{
int a, b, c, d;
Sym *s , *frame_bottom ;
/* generate line number info */
if (tcc_state->do_debug &&
(last_line_num != file->line_num || last_ind != ind)) {
put_stabn(N_SLINE, 0, file->line_num, ind - func_ind);
last_ind = ind;
last_line_num = file->line_num;
}
if (is_expr) {
/* default return value is (void) */
vpushi(0);
vtop->type.t = VT_VOID;
|
src/tccgen.c
view on Meta::CPAN
5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 | restore_parse_state( &saved_parse_state );
}
/* patch flexible array member size back to -1, */
/* for possible subsequent similar declarations */
if (flexible_array)
flexible_array->type. ref ->c = -1;
}
no_alloc: ;
}
static void put_func_debug(Sym *sym )
{
char buf[512];
/* stabs info */
/* XXX: we put here a dummy type */
snprintf(buf, sizeof(buf), "%s:%c1" ,
funcname, sym->type.t & VT_STATIC ? 'f' : 'F' );
put_stabs_r(buf, N_FUN, 0, file->line_num, 0,
cur_text_section, sym->c);
/* //gr gdb wants a line at the function */
|
src/tccgen.c
view on Meta::CPAN
5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 | int saved_nocode_wanted = nocode_wanted;
nocode_wanted = 0;
ind = cur_text_section->data_offset;
/* NOTE: we patch the symbol size later */
put_extern_sym(sym, cur_text_section, ind, 0);
funcname = get_tok_str(sym->v, NULL);
func_ind = ind;
/* Initialize VLA state */
vla_sp_loc = &vla_sp_root_loc ;
vla_flags = VLA_NEED_NEW_FRAME;
/* put debug symbol */
if (tcc_state->do_debug)
put_func_debug(sym);
/* push a dummy symbol to enable local sym storage */
sym_push2( &local_stack , SYM_FIELD, 0, 0);
gfunc_prolog( &sym ->type);
rsym = 0;
block(NULL, NULL, NULL, NULL, 0, 0);
gsym(rsym);
gfunc_epilog();
cur_text_section->data_offset = ind;
label_pop( &global_label_stack , NULL);
/* reset local stack */
scope_stack_bottom = NULL;
sym_pop( &local_stack , NULL);
/* end of function */
/* patch symbol size */
((ElfW(Sym) *)symtab_section->data)[sym->c].st_size =
ind - func_ind;
/* patch symbol weakness (this definition overrules any prototype ) */
if (sym->type.t & VT_WEAK)
weaken_symbol(sym);
if (tcc_state->do_debug) {
put_stabn(N_FUN, 0, 0, ind - func_ind);
}
/* It's better to crash than to generate wrong code */
cur_text_section = NULL;
funcname = "" ; /* for safety */
func_vt.t = VT_VOID; /* for safety */
ind = 0; /* for safety */
nocode_wanted = saved_nocode_wanted;
}
|
src/tccpe.c
view on Meta::CPAN
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | if (c == sec_bss && pe->sec_count && si[-1].cls == sec_data) {
/* append .bss to .data */
s->sh_addr = addr = ((addr-1) | (s->sh_addralign-1)) + 1;
addr += s->data_offset;
si[-1].sh_size = addr - si[-1].sh_addr;
continue ;
}
if (c == sec_stab && 0 == pe->s1->do_debug)
continue ;
strcpy(si->name, s->name);
si->cls = c;
si-> ord = k;
si->sh_addr = s->sh_addr = addr = pe_virtual_align(pe, addr);
si->sh_flags = s->sh_flags;
if (c == sec_data && NULL == pe->thunk)
pe->thunk = s;
|
src/tccpp.c
view on Meta::CPAN
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 | continue ;
printf ( "%s: including %s\n" , file->prev->filename, file->filename);
/* update target deps */
dynarray_add((void ***) &s1 ->target_deps, &s1 ->nb_target_deps,
tcc_strdup(buf1));
/* push current file in stack */
++s1->include_stack_ptr;
/* add include file debug info */
if (s1->do_debug)
put_stabs(file->filename, N_BINCL, 0, 0, 0);
tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL;
ch = file->buf_ptr[0];
goto the_end;
}
tcc_error( "include file '%s' not found" , buf);
include_done:
break;
case TOK_IFNDEF:
c = 1;
|
src/tccpp.c
view on Meta::CPAN
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 | /* test if previous '#endif' was after a #ifdef at
start of file */
if (tok_flags & TOK_FLAG_ENDIF) {
printf ( "#endif %s\n" , get_tok_str(file->ifndef_macro_saved, NULL));
add_cached_include(s1, file->filename, file->ifndef_macro_saved);
tok_flags &= ~TOK_FLAG_ENDIF;
}
/* add end of include file debug info */
if (tcc_state->do_debug) {
put_stabd(N_EINCL, 0, 0);
}
/* pop include stack */
tcc_close();
s1->include_stack_ptr--;
p = file->buf_ptr;
goto redo_no_start;
}
}
break;
|
src/tccrun.c
view on Meta::CPAN
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | {
int ( *prog_main )( int , char **);
int ret;
if (tcc_relocate(s1, TCC_RELOCATE_AUTO) < 0)
return -1;
prog_main = tcc_get_symbol_err(s1, s1->runtime_main);
if (s1->do_debug) {
set_exception_handler();
rt_prog_main = prog_main;
}
if (s1->do_bounds_check) {
void ( *bound_init )(void);
void ( *bound_exit )(void);
/* set error function */
|
src/tccrun.c
view on Meta::CPAN
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | /* ------------------------------------------------------------- */
ST_FUNC void tcc_set_num_callers( int n)
{
rt_num_callers = n;
}
/* print the position in the source file of PC value 'pc' by reading
the stabs debug information */
static addr_t rt_printline(addr_t wanted_pc, const char *msg )
{
char func_name[128], last_func_name[128];
addr_t func_addr, last_pc, pc;
const char *incl_files [INCLUDE_STACK_SIZE];
int incl_index, len, last_line_num, i;
const char *str , *p ;
Stab_Sym *stab_sym = NULL, *stab_sym_end , *sym ;
int stab_len = 0;
|
src/tccrun.c
view on Meta::CPAN
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | }
/* Generate a stack backtrace when a CPU exception occurs. */
static void set_exception_handler(void)
{
struct sigaction sigact;
/* install TCC signal handlers to print debug info on fatal
runtime errors */
sigact.sa_flags = SA_SIGINFO | SA_RESETHAND;
sigact.sa_sigaction = sig_error;
sigemptyset( &sigact .sa_mask);
sigaction(SIGFPE, &sigact , NULL);
sigaction(SIGILL, &sigact , NULL);
sigaction(SIGSEGV, &sigact , NULL);
sigaction(SIGBUS, &sigact , NULL);
sigaction(SIGABRT, &sigact , NULL);
}
|
src/tests/tests2/46_grep.c
view on Meta::CPAN
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | int cflag=0, fflag=0, nflag=0, vflag=0, nfile=0, debug=0;
char *pp , lbuf[LMAX], pbuf[PMAX];
char *cclass ();
char *pmatch ();
/*** Display a file name *******************************/
void file(char *s )
{
|
src/tests/tests2/46_grep.c
view on Meta::CPAN
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | /*** Compile the pattern into global pbuf[] ************/
void compile(char *source )
{
char *s ; /* Source string pointer */
char *lp ; /* Last pattern pointer */
int c; /* Current character */
int o; /* Temp */
char *spp ; /* Save beginning of pattern */
s = source;
if (debug)
printf ( "Pattern = \"%s\"\n" , s);
pp = pbuf;
while (c = *s ++) {
/*
* STAR, PLUS and MINUS are special.
*/
if (c == '*' || c == '+' || c == '-' ) {
if (pp == pbuf ||
(o=pp[-1]) == BOL ||
o == EOL ||
|
src/tests/tests2/46_grep.c
view on Meta::CPAN
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | if ( *s )
c = *s ++;
default :
store(CHAR);
store(tolower(c));
}
}
store(ENDPAT);
store(0); /* Terminate string */
if (debug) {
for (lp = pbuf; lp < pp;) {
if ((c = ( *lp ++ & 0377)) < ' ' )
printf ( "\\%o " , c);
else printf ( "%c " , c);
}
printf ( "\n" );
}
}
/*** Compile a class (within []) ***********************/
|
src/tests/tests2/46_grep.c
view on Meta::CPAN
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | {
char *l ; /* Current line pointer */
char *p ; /* Current pattern pointer */
char c; /* Current character */
char *e ; /* End for STAR and PLUS match */
int op; /* Pattern operation */
int n; /* Class counter */
char *are ; /* Start of STAR match */
l = line;
if (debug > 1)
printf ( "pmatch(\"%s\")\n" , line);
p = pattern;
while ((op = *p ++) != ENDPAT) {
if (debug > 1)
printf ( "byte[%d] = 0%o, '%c', op = 0%o\n" ,
l-line, *l , *l , op);
switch(op) {
case CHAR:
if (tolower( *l ++) != *p ++)
return (0);
break;
case BOL:
|
src/tests/tests2/46_grep.c
view on Meta::CPAN
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | help(documentation);
break;
case 'C' :
case 'c' :
++cflag;
break;
case 'D' :
case 'd' :
++debug;
break;
case 'F' :
case 'f' :
++fflag;
break;
case 'n' :
case 'N' :
++nflag;
|
src/tests/tests2/55_lshift_type.c
view on Meta::CPAN
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | do \
{ \
TEST3((X),short); \
TEST3((X), int ); \
TEST3((X),long); \
TEST3((X),long long); \
} \
while (0)
static int debug, nfailed = 0;
static void check (const char *s , int arg1, int shift )
{
int failed = arg1 != shift ;
if (debug || failed)
printf ( "%s %d %d\n" , s, arg1, shift );
nfailed += failed;
}
int main ( int argc, char * *argv )
{
debug = argc > 1;
TEST4(1);
TEST4(-1);
printf ( "%d test(s) failed\n" , nfailed);
return nfailed != 0;
}
|
src/win32/include/winapi/winnt.h
view on Meta::CPAN
3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 | DWORD e32_impmod;
DWORD e32_impmodcnt;
DWORD e32_impproc;
DWORD e32_pagesum;
DWORD e32_datapage;
DWORD e32_preload;
DWORD e32_nrestab;
DWORD e32_cbnrestab;
DWORD e32_nressum;
DWORD e32_autodata;
DWORD e32_debuginfo;
DWORD e32_debuglen;
DWORD e32_instpreload;
DWORD e32_instdemand;
DWORD e32_heapsize;
BYTE e32_res3[12];
DWORD e32_winresoff;
DWORD e32_winreslen;
WORD e32_devid;
WORD e32_ddkver;
} IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER ;
|
src/win32/include/winapi/winnt.h
view on Meta::CPAN
4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 | __CRT_INLINE PVOID __cdecl memcpy_inline(void *dst ,const void *src ,size_t size) {
if (((char *)dst > (char *)src) && ((char *)dst < ((char *)src + size))) {
__debugbreak();
}
return memcpy(dst,src,size);
}
NTSYSAPI SIZE_T NTAPI RtlCompareMemory(const VOID *Source1 ,const VOID *Source2 ,SIZE_T Length);
|
src/win32/lib/msvcrt.def
view on Meta::CPAN
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | _memicmp_l
_mkdir
_mkgmtime
_mkgmtime32
_mkgmtime64
_mktemp
_mktemp_s
_mktime32
_mktime64
_msize
_msize_debug
_nextafter
_onexit
_open
_open_osfhandle
_osplatform
_osver
_outp
_outpd
_outpw
_pclose
|