2 * COFF file handling for TCC
4 * Copyright (c) 2003, 2004 TK
5 * Copyright (c) 2004 Fabrice Bellard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 /* XXX: this file uses tcc_error() to the effect of exit(1) */
27 #define MAXNSCNS 255 /* MAXIMUM NUMBER OF SECTIONS */
28 #define MAX_STR_TABLE 1000000
29 AOUTHDR o_filehdr
; /* OPTIONAL (A.OUT) FILE HEADER */
31 SCNHDR section_header
[MAXNSCNS
];
33 #define MAX_FUNCS 1000
34 #define MAX_FUNC_NAME_LENGTH 128
37 char Func
[MAX_FUNCS
][MAX_FUNC_NAME_LENGTH
];
38 char AssociatedFile
[MAX_FUNCS
][MAX_FUNC_NAME_LENGTH
];
39 int LineNoFilePtr
[MAX_FUNCS
];
40 int EndAddress
[MAX_FUNCS
];
41 int LastLineNo
[MAX_FUNCS
];
42 int FuncEntries
[MAX_FUNCS
];
44 int OutputTheSection(Section
* sect
);
45 short int GetCoffFlags(const char *s
);
46 void SortSymbolTable(TCCState
*s1
);
47 Section
*FindSection(TCCState
* s1
, const char *sname
);
49 int C67_main_entry_point
;
51 int FindCoffSymbolIndex(TCCState
* s1
, const char *func_name
);
64 unsigned short lineno
;
65 unsigned short nentries
;
73 unsigned short lineno
;
74 unsigned short dummy1
;
77 unsigned short dummy4
;
80 ST_FUNC
int tcc_output_coff(TCCState
*s1
, FILE *f
)
85 char *Coff_str_table
, *pCoff_str_table
;
86 int CoffTextSectionNo
, coff_nb_syms
;
87 FILHDR file_hdr
; /* FILE HEADER STRUCTURE */
88 Section
*stext
, *sdata
, *sbss
;
89 int i
, NSectionsToOutput
= 0;
91 Coff_str_table
= pCoff_str_table
= NULL
;
93 stext
= FindSection(s1
, ".text");
94 sdata
= FindSection(s1
, ".data");
95 sbss
= FindSection(s1
, ".bss");
97 nb_syms
= symtab_section
->data_offset
/ sizeof(Elf32_Sym
);
98 coff_nb_syms
= FindCoffSymbolIndex(s1
, "XXXXXXXXXX1");
100 file_hdr
.f_magic
= COFF_C67_MAGIC
; /* magic number */
101 file_hdr
.f_timdat
= 0; /* time & date stamp */
102 file_hdr
.f_opthdr
= sizeof(AOUTHDR
); /* sizeof(optional hdr) */
103 file_hdr
.f_flags
= 0x1143; /* flags (copied from what code composer does) */
104 file_hdr
.f_TargetID
= 0x99; /* for C6x = 0x0099 */
106 o_filehdr
.magic
= 0x0108; /* see magic.h */
107 o_filehdr
.vstamp
= 0x0190; /* version stamp */
108 o_filehdr
.tsize
= stext
->data_offset
; /* text size in bytes, padded to FW bdry */
109 o_filehdr
.dsize
= sdata
->data_offset
; /* initialized data " " */
110 o_filehdr
.bsize
= sbss
->data_offset
; /* uninitialized data " " */
111 o_filehdr
.entrypt
= C67_main_entry_point
; /* entry pt. */
112 o_filehdr
.text_start
= stext
->sh_addr
; /* base of text used for this file */
113 o_filehdr
.data_start
= sdata
->sh_addr
; /* base of data used for this file */
116 // create all the section headers
118 file_pointer
= FILHSZ
+ sizeof(AOUTHDR
);
120 CoffTextSectionNo
= -1;
122 for (i
= 1; i
< s1
->nb_sections
; i
++) {
123 coff_sec
= §ion_header
[i
];
124 tcc_sect
= s1
->sections
[i
];
126 if (OutputTheSection(tcc_sect
)) {
129 if (CoffTextSectionNo
== -1 && tcc_sect
== stext
)
130 CoffTextSectionNo
= NSectionsToOutput
; // rem which coff sect number the .text sect is
132 strcpy(coff_sec
->s_name
, tcc_sect
->name
); /* section name */
134 coff_sec
->s_paddr
= tcc_sect
->sh_addr
; /* physical address */
135 coff_sec
->s_vaddr
= tcc_sect
->sh_addr
; /* virtual address */
136 coff_sec
->s_size
= tcc_sect
->data_offset
; /* section size */
137 coff_sec
->s_scnptr
= 0; /* file ptr to raw data for section */
138 coff_sec
->s_relptr
= 0; /* file ptr to relocation */
139 coff_sec
->s_lnnoptr
= 0; /* file ptr to line numbers */
140 coff_sec
->s_nreloc
= 0; /* number of relocation entries */
141 coff_sec
->s_flags
= GetCoffFlags(coff_sec
->s_name
); /* flags */
142 coff_sec
->s_reserved
= 0; /* reserved byte */
143 coff_sec
->s_page
= 0; /* memory page id */
145 file_pointer
+= sizeof(SCNHDR
);
149 file_hdr
.f_nscns
= NSectionsToOutput
; /* number of sections */
151 // now loop through and determine file pointer locations
155 for (i
= 1; i
< s1
->nb_sections
; i
++) {
156 coff_sec
= §ion_header
[i
];
157 tcc_sect
= s1
->sections
[i
];
159 if (OutputTheSection(tcc_sect
)) {
161 coff_sec
->s_scnptr
= file_pointer
; /* file ptr to raw data for section */
162 file_pointer
+= coff_sec
->s_size
;
166 // now loop through and determine file pointer locations
167 // for the relocation data
169 for (i
= 1; i
< s1
->nb_sections
; i
++) {
170 coff_sec
= §ion_header
[i
];
171 tcc_sect
= s1
->sections
[i
];
173 if (OutputTheSection(tcc_sect
)) {
174 // put relocations data
175 if (coff_sec
->s_nreloc
> 0) {
176 coff_sec
->s_relptr
= file_pointer
; /* file ptr to relocation */
177 file_pointer
+= coff_sec
->s_nreloc
* sizeof(struct reloc
);
182 // now loop through and determine file pointer locations
183 // for the line number data
185 for (i
= 1; i
< s1
->nb_sections
; i
++) {
186 coff_sec
= §ion_header
[i
];
187 tcc_sect
= s1
->sections
[i
];
189 coff_sec
->s_nlnno
= 0;
190 coff_sec
->s_lnnoptr
= 0;
192 if (s1
->do_debug
&& tcc_sect
== stext
) {
193 // count how many line nos data
195 // also find association between source file name and function
196 // so we can sort the symbol table
199 Stab_Sym
*sym
, *sym_end
;
200 char func_name
[MAX_FUNC_NAME_LENGTH
],
201 last_func_name
[MAX_FUNC_NAME_LENGTH
];
202 unsigned long func_addr
, last_pc
, pc
;
203 const char *incl_files
[INCLUDE_STACK_SIZE
];
204 int incl_index
, len
, last_line_num
;
207 coff_sec
->s_lnnoptr
= file_pointer
; /* file ptr to linno */
213 last_func_name
[0] = '\0';
214 last_pc
= 0xffffffff;
216 sym
= (Stab_Sym
*) stab_section
->data
+ 1;
218 (Stab_Sym
*) (stab_section
->data
+
219 stab_section
->data_offset
);
222 while (sym
< sym_end
) {
223 switch (sym
->n_type
) {
224 /* function start or end */
226 if (sym
->n_strx
== 0) {
230 file_pointer
+= LINESZ
;
232 pc
= sym
->n_value
+ func_addr
;
235 EndAddress
[nFuncs
] = pc
;
236 FuncEntries
[nFuncs
] =
238 LineNoFilePtr
[nFuncs
]) / LINESZ
- 1;
239 LastLineNo
[nFuncs
++] = last_line_num
+ 1;
241 // beginning of function
243 LineNoFilePtr
[nFuncs
] = file_pointer
;
245 file_pointer
+= LINESZ
;
248 (const char *) stabstr_section
->data
+
251 p
= strchr(str
, ':');
253 pstrcpy(func_name
, sizeof(func_name
), str
);
254 pstrcpy(Func
[nFuncs
], sizeof(func_name
), str
);
257 if (len
> sizeof(func_name
) - 1)
258 len
= sizeof(func_name
) - 1;
259 memcpy(func_name
, str
, len
);
260 memcpy(Func
[nFuncs
], str
, len
);
261 func_name
[len
] = '\0';
264 // save the file that it came in so we can sort later
265 pstrcpy(AssociatedFile
[nFuncs
], sizeof(func_name
),
266 incl_files
[incl_index
- 1]);
268 func_addr
= sym
->n_value
;
272 /* line number info */
274 pc
= sym
->n_value
+ func_addr
;
277 last_line_num
= sym
->n_desc
;
280 strcpy(last_func_name
, func_name
);
283 file_pointer
+= LINESZ
;
288 (const char *) stabstr_section
->data
+ sym
->n_strx
;
290 if (incl_index
< INCLUDE_STACK_SIZE
) {
291 incl_files
[incl_index
++] = str
;
299 if (sym
->n_strx
== 0) {
300 incl_index
= 0; /* end of translation unit */
303 (const char *) stabstr_section
->data
+
305 /* do not add path */
307 if (len
> 0 && str
[len
- 1] != '/')
318 file_hdr
.f_symptr
= file_pointer
; /* file pointer to symtab */
321 file_hdr
.f_nsyms
= coff_nb_syms
; /* number of symtab entries */
323 file_hdr
.f_nsyms
= 0;
325 file_pointer
+= file_hdr
.f_nsyms
* SYMNMLEN
;
327 // OK now we are all set to write the file
330 fwrite(&file_hdr
, FILHSZ
, 1, f
);
331 fwrite(&o_filehdr
, sizeof(o_filehdr
), 1, f
);
333 // write section headers
334 for (i
= 1; i
< s1
->nb_sections
; i
++) {
335 coff_sec
= §ion_header
[i
];
336 tcc_sect
= s1
->sections
[i
];
338 if (OutputTheSection(tcc_sect
)) {
339 fwrite(coff_sec
, sizeof(SCNHDR
), 1, f
);
344 for (i
= 1; i
< s1
->nb_sections
; i
++) {
345 coff_sec
= §ion_header
[i
];
346 tcc_sect
= s1
->sections
[i
];
348 if (OutputTheSection(tcc_sect
)) {
349 fwrite(tcc_sect
->data
, tcc_sect
->data_offset
, 1, f
);
353 // write relocation data
354 for (i
= 1; i
< s1
->nb_sections
; i
++) {
355 coff_sec
= §ion_header
[i
];
356 tcc_sect
= s1
->sections
[i
];
358 if (OutputTheSection(tcc_sect
)) {
359 // put relocations data
360 if (coff_sec
->s_nreloc
> 0) {
361 fwrite(tcc_sect
->reloc
,
362 coff_sec
->s_nreloc
* sizeof(struct reloc
), 1, f
);
368 // group the symbols in order of filename, func1, func2, etc
369 // finally global symbols
374 // write line no data
376 for (i
= 1; i
< s1
->nb_sections
; i
++) {
377 coff_sec
= §ion_header
[i
];
378 tcc_sect
= s1
->sections
[i
];
380 if (s1
->do_debug
&& tcc_sect
== stext
) {
381 // count how many line nos data
384 Stab_Sym
*sym
, *sym_end
;
385 char func_name
[128], last_func_name
[128];
386 unsigned long func_addr
, last_pc
, pc
;
387 const char *incl_files
[INCLUDE_STACK_SIZE
];
388 int incl_index
, len
, last_line_num
;
396 last_func_name
[0] = '\0';
399 sym
= (Stab_Sym
*) stab_section
->data
+ 1;
401 (Stab_Sym
*) (stab_section
->data
+
402 stab_section
->data_offset
);
404 while (sym
< sym_end
) {
405 switch (sym
->n_type
) {
406 /* function start or end */
408 if (sym
->n_strx
== 0) {
411 CoffLineNo
.l_addr
.l_paddr
= last_pc
;
412 CoffLineNo
.l_lnno
= last_line_num
+ 1;
413 fwrite(&CoffLineNo
, 6, 1, f
);
415 pc
= sym
->n_value
+ func_addr
;
419 // beginning of function
422 (const char *) stabstr_section
->data
+
426 p
= strchr(str
, ':');
428 pstrcpy(func_name
, sizeof(func_name
), str
);
431 if (len
> sizeof(func_name
) - 1)
432 len
= sizeof(func_name
) - 1;
433 memcpy(func_name
, str
, len
);
434 func_name
[len
] = '\0';
436 func_addr
= sym
->n_value
;
440 // output a function begin
442 CoffLineNo
.l_addr
.l_symndx
=
443 FindCoffSymbolIndex(s1
, func_name
);
444 CoffLineNo
.l_lnno
= 0;
446 fwrite(&CoffLineNo
, 6, 1, f
);
450 /* line number info */
452 pc
= sym
->n_value
+ func_addr
;
456 strcpy(last_func_name
, func_name
);
458 // output a line reference
460 CoffLineNo
.l_addr
.l_paddr
= last_pc
;
462 if (last_line_num
== -1) {
463 CoffLineNo
.l_lnno
= sym
->n_desc
;
465 CoffLineNo
.l_lnno
= last_line_num
+ 1;
468 fwrite(&CoffLineNo
, 6, 1, f
);
471 last_line_num
= sym
->n_desc
;
478 (const char *) stabstr_section
->data
+ sym
->n_strx
;
480 if (incl_index
< INCLUDE_STACK_SIZE
) {
481 incl_files
[incl_index
++] = str
;
489 if (sym
->n_strx
== 0) {
490 incl_index
= 0; /* end of translation unit */
493 (const char *) stabstr_section
->data
+
495 /* do not add path */
497 if (len
> 0 && str
[len
- 1] != '/')
507 // write symbol table
520 Coff_str_table
= (char *) tcc_malloc(MAX_STR_TABLE
);
521 pCoff_str_table
= Coff_str_table
;
524 p
= (Elf32_Sym
*) symtab_section
->data
;
527 for (i
= 0; i
< nb_syms
; i
++) {
529 name
= symtab_section
->link
->data
+ p
->st_name
;
531 for (k
= 0; k
< 8; k
++)
532 csym
._n
._n_name
[k
] = 0;
534 if (strlen(name
) <= 8) {
535 strcpy(csym
._n
._n_name
, name
);
537 if (pCoff_str_table
- Coff_str_table
+ strlen(name
) >
539 tcc_error("String table too large");
541 csym
._n
._n_n
._n_zeroes
= 0;
542 csym
._n
._n_n
._n_offset
=
543 pCoff_str_table
- Coff_str_table
+ 4;
545 strcpy(pCoff_str_table
, name
);
546 pCoff_str_table
+= strlen(name
) + 1; // skip over null
550 if (p
->st_info
== 4) {
551 // put a filename symbol
552 csym
.n_value
= 33; // ?????
553 csym
.n_scnum
= N_DEBUG
;
555 csym
.n_sclass
= C_FILE
;
557 fwrite(&csym
, 18, 1, f
);
560 } else if (p
->st_info
== 0x12) {
561 // find the function data
563 for (k
= 0; k
< nFuncs
; k
++) {
564 if (strcmp(name
, Func
[k
]) == 0)
569 tcc_error("debug info can't find function: %s", name
);
571 // put a Function Name
573 csym
.n_value
= p
->st_value
; // physical address
574 csym
.n_scnum
= CoffTextSectionNo
;
575 csym
.n_type
= MKTYPE(T_INT
, DT_FCN
, 0, 0, 0, 0, 0);
576 csym
.n_sclass
= C_EXT
;
578 fwrite(&csym
, 18, 1, f
);
583 auxfunc
.size
= EndAddress
[k
] - p
->st_value
;
584 auxfunc
.fileptr
= LineNoFilePtr
[k
];
585 auxfunc
.nextsym
= n
+ 6; // tktk
587 fwrite(&auxfunc
, 18, 1, f
);
591 strcpy(csym
._n
._n_name
, ".bf");
592 csym
.n_value
= p
->st_value
; // physical address
593 csym
.n_scnum
= CoffTextSectionNo
;
595 csym
.n_sclass
= C_FCN
;
597 fwrite(&csym
, 18, 1, f
);
603 auxbf
.nentries
= FuncEntries
[k
];
604 auxbf
.localframe
= 0;
605 auxbf
.nextentry
= n
+ 6;
607 fwrite(&auxbf
, 18, 1, f
);
611 strcpy(csym
._n
._n_name
, ".ef");
612 csym
.n_value
= EndAddress
[k
]; // physical address
613 csym
.n_scnum
= CoffTextSectionNo
;
615 csym
.n_sclass
= C_FCN
;
617 fwrite(&csym
, 18, 1, f
);
622 auxef
.lineno
= LastLineNo
[k
];
627 fwrite(&auxef
, 18, 1, f
);
632 // try an put some type info
634 if ((p
->st_other
& VT_BTYPE
) == VT_DOUBLE
) {
635 csym
.n_type
= T_DOUBLE
; // int
636 csym
.n_sclass
= C_EXT
;
637 } else if ((p
->st_other
& VT_BTYPE
) == VT_FLOAT
) {
638 csym
.n_type
= T_FLOAT
;
639 csym
.n_sclass
= C_EXT
;
640 } else if ((p
->st_other
& VT_BTYPE
) == VT_INT
) {
641 csym
.n_type
= T_INT
; // int
642 csym
.n_sclass
= C_EXT
;
643 } else if ((p
->st_other
& VT_BTYPE
) == VT_SHORT
) {
644 csym
.n_type
= T_SHORT
;
645 csym
.n_sclass
= C_EXT
;
646 } else if ((p
->st_other
& VT_BTYPE
) == VT_BYTE
) {
647 csym
.n_type
= T_CHAR
;
648 csym
.n_sclass
= C_EXT
;
650 csym
.n_type
= T_INT
; // just mark as a label
651 csym
.n_sclass
= C_LABEL
;
655 csym
.n_value
= p
->st_value
;
658 fwrite(&csym
, 18, 1, f
);
665 fwrite(&auxfunc
, 18, 1, f
);
676 // write string table
678 // first write the size
679 i
= pCoff_str_table
- Coff_str_table
;
682 // then write the strings
683 fwrite(Coff_str_table
, i
, 1, f
);
685 tcc_free(Coff_str_table
);
693 // group the symbols in order of filename, func1, func2, etc
694 // finally global symbols
696 void SortSymbolTable(TCCState
*s1
)
699 Elf32_Sym
*p
, *p2
, *NewTable
;
702 NewTable
= (Elf32_Sym
*) tcc_malloc(nb_syms
* sizeof(Elf32_Sym
));
704 p
= (Elf32_Sym
*) symtab_section
->data
;
707 // find a file symbol, copy it over
708 // then scan the whole symbol list and copy any function
709 // symbols that match the file association
711 for (i
= 0; i
< nb_syms
; i
++) {
712 if (p
->st_info
== 4) {
713 name
= (char *) symtab_section
->link
->data
+ p
->st_name
;
715 // this is a file symbol, copy it over
719 p2
= (Elf32_Sym
*) symtab_section
->data
;
721 for (j
= 0; j
< nb_syms
; j
++) {
722 if (p2
->st_info
== 0x12) {
723 // this is a func symbol
726 (char *) symtab_section
->link
->data
+ p2
->st_name
;
728 // find the function data index
730 for (k
= 0; k
< nFuncs
; k
++) {
731 if (strcmp(name2
, Func
[k
]) == 0)
736 tcc_error("debug (sort) info can't find function: %s", name2
);
739 if (strcmp(AssociatedFile
[k
], name
) == 0) {
740 // yes they match copy it over
751 // now all the filename and func symbols should have been copied over
752 // copy all the rest over (all except file and funcs)
754 p
= (Elf32_Sym
*) symtab_section
->data
;
755 for (i
= 0; i
< nb_syms
; i
++) {
756 if (p
->st_info
!= 4 && p
->st_info
!= 0x12) {
763 tcc_error("Internal Compiler error, debug info");
767 p
= (Elf32_Sym
*) symtab_section
->data
;
768 for (i
= 0; i
< nb_syms
; i
++) {
776 int FindCoffSymbolIndex(TCCState
*s1
, const char *func_name
)
782 p
= (Elf32_Sym
*) symtab_section
->data
;
784 for (i
= 0; i
< nb_syms
; i
++) {
786 name
= (char *) symtab_section
->link
->data
+ p
->st_name
;
788 if (p
->st_info
== 4) {
789 // put a filename symbol
791 } else if (p
->st_info
== 0x12) {
793 if (strcmp(func_name
, name
) == 0)
798 // put a Function Name
817 return n
; // total number of symbols
820 int OutputTheSection(Section
* sect
)
822 const char *s
= sect
->name
;
824 if (!strcmp(s
, ".text"))
826 else if (!strcmp(s
, ".data"))
832 short int GetCoffFlags(const char *s
)
834 if (!strcmp(s
, ".text"))
835 return STYP_TEXT
| STYP_DATA
| STYP_ALIGN
| 0x400;
836 else if (!strcmp(s
, ".data"))
838 else if (!strcmp(s
, ".bss"))
840 else if (!strcmp(s
, ".stack"))
841 return STYP_BSS
| STYP_ALIGN
| 0x200;
842 else if (!strcmp(s
, ".cinit"))
843 return STYP_COPY
| STYP_DATA
| STYP_ALIGN
| 0x200;
848 Section
*FindSection(TCCState
* s1
, const char *sname
)
853 for (i
= 1; i
< s1
->nb_sections
; i
++) {
856 if (!strcmp(sname
, s
->name
))
860 tcc_error("could not find section %s", sname
);
864 ST_FUNC
int tcc_load_coff(TCCState
* s1
, int fd
)
866 // tktk TokenSym *ts;
869 unsigned int str_size
;
870 char *Coff_str_table
, *name
;
874 FILHDR file_hdr
; /* FILE HEADER STRUCTURE */
876 f
= fdopen(fd
, "rb");
878 tcc_error("Unable to open .out file for input");
881 if (fread(&file_hdr
, FILHSZ
, 1, f
) != 1)
882 tcc_error("error reading .out file for input");
884 if (fread(&o_filehdr
, sizeof(o_filehdr
), 1, f
) != 1)
885 tcc_error("error reading .out file for input");
887 // first read the string table
889 if (fseek(f
, file_hdr
.f_symptr
+ file_hdr
.f_nsyms
* SYMESZ
, SEEK_SET
))
890 tcc_error("error reading .out file for input");
892 if (fread(&str_size
, sizeof(int), 1, f
) != 1)
893 tcc_error("error reading .out file for input");
896 Coff_str_table
= (char *) tcc_malloc(str_size
);
898 if (fread(Coff_str_table
, str_size
- 4, 1, f
) != 1)
899 tcc_error("error reading .out file for input");
901 // read/process all the symbols
903 // seek back to symbols
905 if (fseek(f
, file_hdr
.f_symptr
, SEEK_SET
))
906 tcc_error("error reading .out file for input");
908 for (i
= 0; i
< file_hdr
.f_nsyms
; i
++) {
909 if (fread(&csym
, SYMESZ
, 1, f
) != 1)
910 tcc_error("error reading .out file for input");
912 if (csym
._n
._n_n
._n_zeroes
== 0) {
913 name
= Coff_str_table
+ csym
._n
._n_n
._n_offset
- 4;
915 name
= csym
._n
._n_name
;
918 for (k
= 0; k
< 8; k
++)
926 // if (strcmp("_DAC_Buffer",name)==0) // tktk
929 if (((csym
.n_type
& 0x30) == 0x20 && csym
.n_sclass
== 0x2) || ((csym
.n_type
& 0x30) == 0x30 && csym
.n_sclass
== 0x2) || (csym
.n_type
== 0x4 && csym
.n_sclass
== 0x2) || (csym
.n_type
== 0x8 && csym
.n_sclass
== 0x2) || // structures
930 (csym
.n_type
== 0x18 && csym
.n_sclass
== 0x2) || // pointer to structure
931 (csym
.n_type
== 0x7 && csym
.n_sclass
== 0x2) || // doubles
932 (csym
.n_type
== 0x6 && csym
.n_sclass
== 0x2)) // floats
934 // strip off any leading underscore (except for other main routine)
936 if (name
[0] == '_' && strcmp(name
, "_main") != 0)
939 tcc_add_symbol(s1
, name
, (void*)(uintptr_t)csym
.n_value
);
941 // skip any aux records
943 if (csym
.n_numaux
== 1) {
944 if (fread(&csym
, SYMESZ
, 1, f
) != 1)
945 tcc_error("error reading .out file for input");