mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
x86_64 bound checking failure
The code:
void mul(double *p)
{
*p *= 2.0;
}
failed on x86_64 because register was not loaded after
bound checking call.
Also printed size when pointer indir failes.
This commit is contained in:
parent
fa9795406d
commit
087cf2e579
@ -588,8 +588,9 @@ void * __bound_ptr_indir ## dsize (void *p, size_t offset) \
|
|||||||
if (addr <= tree->size) { \
|
if (addr <= tree->size) { \
|
||||||
if (tree->is_invalid || addr + offset + dsize > tree->size) { \
|
if (tree->is_invalid || addr + offset + dsize > tree->size) { \
|
||||||
POST_SEM (); \
|
POST_SEM (); \
|
||||||
bound_warning("%p is outside of the region (0x%lx..0x%lx)", \
|
bound_warning("%p (size %d) is outside of the region " \
|
||||||
p + offset, (long)tree->start, \
|
"(0x%lx..0x%lx)", \
|
||||||
|
p + offset, dsize, (long)tree->start, \
|
||||||
(long)(tree->start + tree->size - 1)); \
|
(long)(tree->start + tree->size - 1)); \
|
||||||
if (never_fatal <= 0) \
|
if (never_fatal <= 0) \
|
||||||
return INVALID_POINTER; /* return an invalid pointer */ \
|
return INVALID_POINTER; /* return an invalid pointer */ \
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
126_bound_global.c:11: at main: BCHECK: ........ is outside of the region (..................)
|
126_bound_global.c:11: at main: BCHECK: ........ (size 4) is outside of the region (..................)
|
||||||
126_bound_global.c:11: at main: RUNTIME ERROR: invalid memory access
|
126_bound_global.c:11: at main: RUNTIME ERROR: invalid memory access
|
||||||
|
|||||||
@ -21,9 +21,17 @@ double scale(double d)
|
|||||||
return x.d;
|
return x.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mul(double *p)
|
||||||
|
{
|
||||||
|
*p *= 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
|
double d = 4.0;
|
||||||
printf("%g\n", scale(42));
|
printf("%g\n", scale(42));
|
||||||
|
mul(&d);
|
||||||
|
printf("%g\n", d);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
42000
|
42000
|
||||||
|
8
|
||||||
|
|||||||
@ -120,6 +120,7 @@ ST_FUNC void gen_struct_copy(int size);
|
|||||||
|
|
||||||
ST_DATA const char * const target_machine_defs =
|
ST_DATA const char * const target_machine_defs =
|
||||||
"__x86_64__\0"
|
"__x86_64__\0"
|
||||||
|
"__x86_64\0"
|
||||||
"__amd64__\0"
|
"__amd64__\0"
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2020,6 +2021,7 @@ void gen_opf(int op)
|
|||||||
gv(RC_FLOAT);
|
gv(RC_FLOAT);
|
||||||
vswap();
|
vswap();
|
||||||
fc = vtop->c.i; /* bcheck may have saved previous vtop[-1] */
|
fc = vtop->c.i; /* bcheck may have saved previous vtop[-1] */
|
||||||
|
r = vtop->r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ft & VT_BTYPE) == VT_DOUBLE) {
|
if ((ft & VT_BTYPE) == VT_DOUBLE) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user