tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] [TIPS] empty test program will crash if compiled with -b


From: Sergey Korshunoff
Subject: [Tinycc-devel] [TIPS] empty test program will crash if compiled with -b option
Date: Wed, 25 Mar 2015 16:54:01 +0300

Hi! There is a patch for tcc and test program. If a tcc is not patched
(a call to the __bound_init() is inserted) then a call to the
__bound_init() leads to the crash of the compiled test (tcc -b test.c;
./a.out). Can someone explain while this happens even when
__bound_init() is a null function (does nothing)?

int main ()
{
#ifdef BOUNDS
    int v[10];  // program will crash if compiled with -b option
#endif
    return 0;
}

diff -urN tinycc.old/lib/bcheck.c tinycc/lib/bcheck.c
--- tinycc.old/lib/bcheck.c     2015-03-25 16:38:59.000000000 +0300
+++ tinycc/lib/bcheck.c 2015-03-25 16:40:34.000000000 +0300
@@ -343,6 +343,7 @@
     }
 }

+#if 0
 void __bound_init(void)
 {
     int i;
@@ -419,6 +420,11 @@
         p += 2;
     }
 }
+#else
+void __bound_init(void)
+{
+}
+#endif

 void __bound_main_arg(void **p)
 {
diff -urN tinycc.old/tccelf.c tinycc/tccelf.c
--- tinycc.old/tccelf.c 2015-03-25 16:38:59.000000000 +0300
+++ tinycc/tccelf.c     2015-03-25 16:39:25.000000000 +0300
@@ -1557,7 +1557,8 @@
     add_elf_sym(symtab_section, 0, 0,
                 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
                 bounds_section->sh_num, "__bounds_start");
-#ifdef TCC_TARGET_I386
+#if 0
+//#ifdef TCC_TARGET_I386
     if (s1->output_type != TCC_OUTPUT_MEMORY) {
         /* add 'call __bound_init()' in .init section */
         init_section = find_section(s1, ".init");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]