Now KTCC gives the error "Linker error!" if the symbol was not found.
(Previously KTCC ignored these messages and generated an incorrect binary).

git-svn-id: svn://kolibrios.org@8786 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-06-09 03:07:04 +00:00
parent dc1ebb291a
commit 9396efe6cd

View File

@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
int undef_sym_flag=0;
typedef struct { typedef struct {
char magic[8]; char magic[8];
int version; int version;
@ -101,8 +103,9 @@ void build_reloc(me_info* me)
ss=findsection(me,sect); ss=findsection(me,sect);
if (ss==0) if (ss==0)
{ {
const char *sym_name = strtab_section->data + esym->st_name; const char *sym_name = strtab_section->data + esym->st_name;
tcc_error_noabort("undefined symbol '%s'", sym_name); undef_sym_flag=1;
tcc_error_noabort("undefined symbol '%s'", sym_name);
continue; continue;
} }
if (rel->r_offset>s->data_size) if (rel->r_offset>s->data_size)
@ -252,7 +255,11 @@ int tcc_output_me(TCCState* s1,const char *filename)
me.s1=s1; me.s1=s1;
relocate_common_syms(); relocate_common_syms();
assign_addresses(&me); assign_addresses(&me);
if(undef_sym_flag){
tcc_error("Linker error!");
}
if (s1->do_debug) if (s1->do_debug)
tcc_output_dbgme(filename, &me); tcc_output_dbgme(filename, &me);