tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] bound checking for local variables


From: Sergey Korshunoff
Subject: [Tinycc-devel] bound checking for local variables
Date: Sun, 29 Mar 2015 00:03:19 +0300

Hi! It looks like bound checking for the local arrays is never worked.
I checked tcc 0.9.24 and bonds checking is not works. A current
version of the tcc:
  -- attributes of the lbounds section don't have RELOC parm
(comparing with a bounds section).
  --  a __bound_local_new() function is called with absurd address and
size parms

A test program:
===
#include <stdio.h>
#include <stdlib.h>
int main ()
{
#if 1
    int v[10];
    fprintf(stderr, "&v[0] = %p\n", &v[0]);
    exit(1);

    v[10] = 0;
    fprintf(stderr, "is bounds error catched?\n");
#endif
    return 0;
}
// tcc -b test.c
===

A sections content of the compiled program:
===
  /* bounds */
  {
    0x44, 0xB0, 0x04, 0x08, 0x0C, 0x00, 0x00, 0x00, 0x51, 0xB0, 0x04, 0x08,
    0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  },
  /* pad4 */
  { 0 },
  /* lbounds */
  {
    0xD4, 0xFF, 0xFF, 0xFF, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  },
===

A debug output of the program (### is my comments):
===
bcheck.c, __bound_init() start
bcheck.c, __bound_new_region(0x804b044, c) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0x804b051, 1a) start
bcheck.c, __bound_new_region end
lbaound: start=ffffffd4 size=28 ####### this is content of the lbound
section, a start address is strange

bcheck.c, __bound_init() end

### why so may addresses if lbounds contain only 1 region
### a size of the region is wrong in all cases
bcheck.c, __bound_local_new start p1=bff31018 *p1=bff31088
bcheck.c, __bound_new_region(0x7fe620a0, b765bff4) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0xbff31019, bff310b4) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0x7fe620d4, b77935d0) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0xbff31019, bff310b4) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0x7fe620d4, b77a0fd4) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0x776a400c, b77a0cc0) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0xc7f79508, bff31088) start  ### address
is near &v[0]
bcheck.c, __bound_new_region end
bcheck.c, __bound_new_region(0x149c2038, 5c3fbfb5) start
bcheck.c, __bound_new_region end
bcheck.c, __bound_local_new end
&v[0] = 0xc7f79523
===



reply via email to

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