mirror of
https://github.com/ioacademy-jikim/debugging
synced 2026-08-30 01:09:34 +00:00
first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# dummy
|
||||
@@ -0,0 +1 @@
|
||||
# dummy
|
||||
@@ -0,0 +1 @@
|
||||
# dummy
|
||||
@@ -0,0 +1 @@
|
||||
# dummy
|
||||
@@ -0,0 +1 @@
|
||||
# dummy
|
||||
@@ -0,0 +1 @@
|
||||
# dummy
|
||||
@@ -0,0 +1 @@
|
||||
# dummy
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
include $(top_srcdir)/Makefile.tool-tests.am
|
||||
|
||||
dist_noinst_SCRIPTS = filter_stderr
|
||||
|
||||
INSN_TESTS = cs csg cds cdsg cu21 cu42 ltgjhe
|
||||
|
||||
check_PROGRAMS = $(INSN_TESTS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(addsuffix .stderr.exp,$(INSN_TESTS)) \
|
||||
$(addsuffix .stdout.exp,$(INSN_TESTS)) \
|
||||
$(addsuffix .vgtest,$(INSN_TESTS))
|
||||
|
||||
AM_CFLAGS += @FLAG_M64@
|
||||
AM_CXXFLAGS += @FLAG_M64@
|
||||
AM_CCASFLAGS += @FLAG_M64@
|
||||
|
||||
cs_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
|
||||
csg_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
|
||||
cds_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
uint64_t high;
|
||||
uint64_t low;
|
||||
} quad_word;
|
||||
|
||||
void
|
||||
test(quad_word op1_init, uint64_t op2_init, quad_word op3_init)
|
||||
{
|
||||
int cc; // unused
|
||||
quad_word op1 = op1_init;
|
||||
uint64_t op2 = op2_init;
|
||||
quad_word op3 = op3_init;
|
||||
|
||||
__asm__ volatile (
|
||||
"lmg %%r0,%%r1,%1\n\t"
|
||||
"lmg %%r2,%%r3,%3\n\t"
|
||||
"cds %%r0,%%r2,%2\n\t" // cds 1st,3rd,2nd
|
||||
"stmg %%r0,%%r1,%1\n" // store r0,r1 to op1
|
||||
"stmg %%r2,%%r3,%3\n" // store r2,r3 to op3
|
||||
: "=d" (cc), "+QS" (op1), "+QS" (op2), "+QS" (op3)
|
||||
:
|
||||
: "r0", "r1", "r2", "r3", "cc");
|
||||
|
||||
}
|
||||
|
||||
// Return a quad-word that only bits low[32:63] are undefined
|
||||
quad_word
|
||||
make_undefined(void)
|
||||
{
|
||||
quad_word val;
|
||||
|
||||
val.high = 0;
|
||||
val.low |= 0xFFFFFFFF00000000ull;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void op1_undefined(void)
|
||||
{
|
||||
quad_word op1, op3;
|
||||
uint64_t op2;
|
||||
|
||||
// op1 undefined
|
||||
op1 = make_undefined();
|
||||
op2 = 42;
|
||||
op3.high = op3.low = 0xdeadbeefdeadbabeull;
|
||||
test(op1, op2, op3); // complaint
|
||||
}
|
||||
|
||||
void op2_undefined(void)
|
||||
{
|
||||
quad_word op1, op3;
|
||||
uint64_t op2;
|
||||
|
||||
op1.high = op1.low = 42;
|
||||
// op2 undefined
|
||||
op3.high = op3.low = 0xdeadbeefdeadbabeull;
|
||||
test(op1, op2, op3); // complaint
|
||||
}
|
||||
|
||||
void op3_undefined(void)
|
||||
{
|
||||
quad_word op1, op3;
|
||||
uint64_t op2;
|
||||
|
||||
op1.high = op1.low = 42;
|
||||
op2 = 100;
|
||||
op3 = make_undefined();
|
||||
test(op1, op2, op3); // no complaint; op3 is just copied around
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
op1_undefined();
|
||||
op2_undefined();
|
||||
op3_undefined();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (cds.c:17)
|
||||
by 0x........: op1_undefined (cds.c:50)
|
||||
by 0x........: main (cds.c:77)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (cds.c:17)
|
||||
by 0x........: op2_undefined (cds.c:61)
|
||||
by 0x........: main (cds.c:78)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
prog: cds
|
||||
vgopts: -q
|
||||
@@ -0,0 +1,69 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
uint64_t high;
|
||||
uint64_t low;
|
||||
} __attribute__((aligned(16))) quad_word;
|
||||
|
||||
|
||||
/* CDSG needs quad-word alignment */
|
||||
quad_word _op1, _op2, _op3;
|
||||
|
||||
void
|
||||
test(quad_word op1_init, quad_word op2_init, quad_word op3_init)
|
||||
{
|
||||
int cc; // unused
|
||||
_op1 = op1_init;
|
||||
_op2 = op2_init;
|
||||
_op3 = op3_init;
|
||||
|
||||
__asm__ volatile (
|
||||
"lmg %%r0,%%r1,%1\n\t"
|
||||
"lmg %%r2,%%r3,%3\n\t"
|
||||
"cdsg %%r0,%%r2,%2\n\t" // cdsg 1st,3rd,2nd
|
||||
"stmg %%r0,%%r1,%1\n" // store r0,r1 to op1
|
||||
"stmg %%r2,%%r3,%3\n" // store r2,r3 to op3
|
||||
: "=d"(cc), "+QS" (_op1), "+QS" (_op2), "+QS" (_op3)
|
||||
:
|
||||
: "r0", "r1", "r2", "r3", "cc");
|
||||
}
|
||||
|
||||
void op1_undefined(void)
|
||||
{
|
||||
quad_word op1, op2, op3;
|
||||
|
||||
// op1 undefined
|
||||
op2.high = op2.low = 42;
|
||||
op3.high = op3.low = 0xdeadbeefdeadbabeull;
|
||||
test(op1, op2, op3); // complaint
|
||||
}
|
||||
|
||||
void op2_undefined(void)
|
||||
{
|
||||
quad_word op1, op2, op3;
|
||||
|
||||
op1.high = op1.low = 42;
|
||||
// op2 undefined
|
||||
op3.high = op3.low = 0xdeadbeefdeadbabeull;
|
||||
test(op1, op2, op3); // complaint
|
||||
}
|
||||
|
||||
void op3_undefined(void)
|
||||
{
|
||||
quad_word op1, op2, op3;
|
||||
|
||||
op1.high = op1.low = 42;
|
||||
op2 = op1;
|
||||
// op3 undefined
|
||||
test(op1, op2, op3); // no complaint; op3 is just copied around
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
op1_undefined();
|
||||
op2_undefined();
|
||||
op3_undefined();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (cdsg.c:21)
|
||||
by 0x........: op1_undefined (cdsg.c:39)
|
||||
by 0x........: main (cdsg.c:64)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (cdsg.c:21)
|
||||
by 0x........: op2_undefined (cdsg.c:49)
|
||||
by 0x........: main (cdsg.c:65)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
prog: cdsg
|
||||
vgopts: -q
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
test(int32_t op1_init, int32_t op2_init, int32_t op3_init)
|
||||
{
|
||||
register int32_t op1 asm("8") = op1_init;
|
||||
register int32_t op3 asm("9") = op3_init;
|
||||
|
||||
int32_t op2 = op2_init;
|
||||
int cc = 1;
|
||||
|
||||
__asm__ volatile (
|
||||
"cs 8,9,%1\n\t"
|
||||
"ipm %0\n\t"
|
||||
"srl %0,28\n\t"
|
||||
: "=d" (cc), "+Q" (op2), "+d"(op1), "+d"(op3)
|
||||
:
|
||||
: "cc");
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
int op1, op2, op3;
|
||||
|
||||
test(op1, 0x10000000, 0x12345678); // complaint
|
||||
test(0x10000000, op2, 0x12345678); // complaint
|
||||
test(0x10000000, 0x01000000, op3); // no complaint
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (cs.c:14)
|
||||
by 0x........: main (cs.c:27)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (cs.c:14)
|
||||
by 0x........: main (cs.c:28)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
prog: cs
|
||||
vgopts: -q
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
test(int64_t op1_init, int64_t op2_init, int64_t op3_init)
|
||||
{
|
||||
register int64_t op1 asm("8") = op1_init;
|
||||
register int64_t op3 asm("9") = op3_init;
|
||||
|
||||
int64_t op2 = op2_init;
|
||||
int cc = 1;
|
||||
|
||||
__asm__ volatile (
|
||||
"csg 8,9,%1\n\t"
|
||||
"ipm %0\n\t"
|
||||
"srl %0,28\n\t"
|
||||
: "=d" (cc), "+Q" (op2), "+d"(op1), "+d"(op3)
|
||||
:
|
||||
: "cc");
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
int64_t op1, op2, op3;
|
||||
|
||||
test(op1, 0x1000000000000000ull, 0x1234567887654321ull); // complaint
|
||||
test(0x1000000000000000ull, op2, 0x1234567887654321ull); // complaint
|
||||
test(0x1000000000000000ull, 0x1000000000000000ull, op3); // no complaint
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (csg.c:14)
|
||||
by 0x........: main (csg.c:27)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: test (csg.c:14)
|
||||
by 0x........: main (csg.c:28)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
prog: csg
|
||||
vgopts: -q
|
||||
@@ -0,0 +1,122 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "../../../none/tests/s390x/opcodes.h"
|
||||
|
||||
/* Define various input buffers. */
|
||||
|
||||
/* U+0000 to U+007f: Result is 1 byte for each uint16_t */
|
||||
uint16_t pattern1[] = {
|
||||
0x0000, 0x007f, /* corner cases */
|
||||
0x0047, 0x0056, 0x0045, 0x0021, 0x007b, 0x003a /* misc */
|
||||
};
|
||||
|
||||
/* U+0080 to U+07ff: Result is 2 bytes for each uint16_t */
|
||||
uint16_t pattern2[] = {
|
||||
0x0080, 0x07ff, /* corner cases */
|
||||
0x07df, 0x008f, 0x0100, 0x017f, 0x052f, 0x0600, 0x06ff /* misc */
|
||||
};
|
||||
|
||||
/* U+0800 to U+d7ff: Result is 3 bytes for each uint16_t
|
||||
U+dc00 to U+ffff: Result is 3 bytes for each uint16_t */
|
||||
uint16_t pattern3[] = {
|
||||
0x0800, 0xd7ff, /* corner cases */
|
||||
0xdc00, 0xffff, /* corner cases */
|
||||
0x083f, 0x1a21, 0x1b10, 0x2200, 0x225e, 0x22c9, 0xe001 /* misc */
|
||||
};
|
||||
|
||||
/* U+d800 to U+dbff: Result is 4 bytes for each uint16_t pair */
|
||||
uint16_t pattern4[] = {
|
||||
0xd800, 0xdc00, /* left corner case */
|
||||
0xdbff, 0xdfff, /* right corner case */
|
||||
0xdada, 0xdddd, 0xdeaf, 0xdcdc /* misc */
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
do_cu21(uint8_t *dst, uint64_t dst_len, uint16_t *src, uint64_t src_len)
|
||||
{
|
||||
/* build up the register pairs */
|
||||
register uint16_t *source asm("4") = src;
|
||||
register uint64_t source_len asm("5") = src_len;
|
||||
register uint8_t *dest asm("2") = dst;
|
||||
register uint64_t dest_len asm("3") = dst_len;
|
||||
|
||||
asm volatile(
|
||||
CU21(0,2,4)
|
||||
: "+d"(dest), "+d"(source), "+d"(source_len), "+d"(dest_len)
|
||||
:
|
||||
: "memory", "cc");
|
||||
return;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
/*------------------------------------------------------------*/
|
||||
/* Write to a too small buffer */
|
||||
/*------------------------------------------------------------*/
|
||||
|
||||
/* Write 2 bytes into buffer of length 1 */
|
||||
do_cu21(malloc(1), 10, pattern2, 2); // complaint (2 bytes)
|
||||
|
||||
/* Write 2 bytes into buffer of length 2 */
|
||||
do_cu21(malloc(2), 10, pattern2, 2); // no complaint
|
||||
|
||||
/* Write 3 bytes into buffer of length 1 */
|
||||
do_cu21(malloc(1), 10, pattern3, 2); // 2 complaints (3 = 2+1)
|
||||
|
||||
/* Write 3 bytes into buffer of length 2 */
|
||||
do_cu21(malloc(2), 10, pattern3, 2); // complaint (1 byte)
|
||||
|
||||
/* Write 3 bytes into buffer of length 3 */
|
||||
do_cu21(malloc(3), 10, pattern3, 2); // no complaint
|
||||
|
||||
/* Write 4 bytes into buffer of length 1 */
|
||||
do_cu21(malloc(1), 10, pattern4, 4); // complaint (4 bytes)
|
||||
|
||||
/* Write 4 bytes into buffer of length 2 */
|
||||
do_cu21(malloc(2), 10, pattern4, 4); // complaint (4 bytes)
|
||||
|
||||
/* Write 4 bytes into buffer of length 3 */
|
||||
do_cu21(malloc(3), 10, pattern4, 4); // complaint (4 bytes)
|
||||
|
||||
/* Write 4 bytes into buffer of length 4 */
|
||||
do_cu21(malloc(4), 10, pattern4, 4); // no complaint
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/* Read uninitialised data */
|
||||
/*------------------------------------------------------------*/
|
||||
uint8_t *input = malloc(10);
|
||||
|
||||
/* Input buffer is completely uninitialised */
|
||||
do_cu21(malloc(4), 4, (void *)input, 2); // complaint
|
||||
|
||||
/* Read 2 bytes from input buffer. First byte is uninitialised */
|
||||
input = malloc(10);
|
||||
input[1] = 0x0;
|
||||
do_cu21(malloc(4), 4, (void *)input, 2); // complaint
|
||||
|
||||
/* Read 2 bytes from input buffer. Second byte is uninitialised */
|
||||
input = malloc(10);
|
||||
input[0] = 0x0;
|
||||
do_cu21(malloc(4), 4, (void *)input, 2); // complaint
|
||||
|
||||
/* Read 2 bytes from input buffer. All bytes are initialised */
|
||||
input = malloc(10);
|
||||
input[0] = input[1] = 0x0;
|
||||
do_cu21(malloc(4), 4, (void *)input, 2); // no complaint
|
||||
|
||||
/* Read 4 bytes from input buffer. This iterates once. In the 1st
|
||||
iteration all input bytes are initialised in the 2nd iteration all
|
||||
input bytes are uninitialised. */
|
||||
input = malloc(10);
|
||||
input[0] = input[1] = 0x0;
|
||||
do_cu21(malloc(4), 4, (void *)input, 4); // complaint
|
||||
|
||||
/* Write to NULL */
|
||||
// do_cu21(NULL, 10, pattern1, sizeof pattern1); // complaint
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
Invalid write of size 2
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:62)
|
||||
Address 0x........ is 0 bytes inside a block of size 1 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu21.c:62)
|
||||
|
||||
Invalid write of size 2
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:68)
|
||||
Address 0x........ is 0 bytes inside a block of size 1 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu21.c:68)
|
||||
|
||||
Invalid write of size 1
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:68)
|
||||
Address 0x........ is 1 bytes after a block of size 1 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu21.c:68)
|
||||
|
||||
Invalid write of size 1
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:71)
|
||||
Address 0x........ is 0 bytes after a block of size 2 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu21.c:71)
|
||||
|
||||
Invalid write of size 4
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:77)
|
||||
Address 0x........ is 0 bytes inside a block of size 1 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu21.c:77)
|
||||
|
||||
Invalid write of size 4
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:80)
|
||||
Address 0x........ is 0 bytes inside a block of size 2 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu21.c:80)
|
||||
|
||||
Invalid write of size 4
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:83)
|
||||
Address 0x........ is 0 bytes inside a block of size 3 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu21.c:83)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:94)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:99)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:104)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu21 (cu21.c:45)
|
||||
by 0x........: main (cu21.c:116)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
prog: cu21
|
||||
vgopts: -q
|
||||
@@ -0,0 +1,111 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "../../../none/tests/s390x/opcodes.h"
|
||||
|
||||
/* Define various input buffers. */
|
||||
|
||||
/* U+0000 to U+d7ff: Result is 2 bytes for each uint32_t
|
||||
U+dc00 to U+ffff: Result is 2 bytes for each uint32_t */
|
||||
uint32_t pattern2[] = {
|
||||
0x0000, 0xd7ff, /* corner cases */
|
||||
0xdc00, 0xffff, /* corner cases */
|
||||
0xabba, 0xf00d, 0xd00f, 0x1234 /* misc */
|
||||
};
|
||||
|
||||
/* U+00010000 to U+0010ffff: Result is 4 bytes for each uint32_t */
|
||||
uint32_t pattern4[] = {
|
||||
0x00010000, 0x0010ffff, /* corner cases */
|
||||
0x00010123, 0x00023456, 0x000789ab, 0x00100000 /* misc */
|
||||
};
|
||||
|
||||
static void
|
||||
do_cu42(uint16_t *dst, uint64_t dst_len, uint32_t *src, uint64_t src_len)
|
||||
{
|
||||
/* build up the register pairs */
|
||||
register uint32_t *source asm("4") = src;
|
||||
register uint64_t source_len asm("5") = src_len;
|
||||
register uint16_t *dest asm("2") = dst;
|
||||
register uint64_t dest_len asm("3") = dst_len;
|
||||
|
||||
asm volatile(
|
||||
CU42(2,4)
|
||||
: "+d"(dest), "+d"(source), "+d"(source_len), "+d"(dest_len)
|
||||
:
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
/*------------------------------------------------------------*/
|
||||
/* Write to a too small buffer */
|
||||
/*------------------------------------------------------------*/
|
||||
|
||||
/* Write 2 bytes into buffer of length 1 */
|
||||
do_cu42(malloc(1), 10, pattern2, 4); // complaint (2 bytes)
|
||||
|
||||
/* Write 2 bytes into buffer of length 2 */
|
||||
do_cu42(malloc(2), 10, pattern2, 4); // no complaint
|
||||
|
||||
/* Write 4 bytes into buffer of length 1 */
|
||||
do_cu42(malloc(1), 10, pattern4, 4); // complaint (4 bytes)
|
||||
|
||||
/* Write 4 bytes into buffer of length 2 */
|
||||
do_cu42(malloc(2), 10, pattern4, 4); // complaint (4 bytes)
|
||||
|
||||
/* Write 4 bytes into buffer of length 3 */
|
||||
do_cu42(malloc(3), 10, pattern4, 4); // complaint (4 bytes)
|
||||
|
||||
/* Write 4 bytes into buffer of length 4 */
|
||||
do_cu42(malloc(4), 10, pattern4, 4); // no complaint
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/* Read uninitialised data */
|
||||
/*------------------------------------------------------------*/
|
||||
uint16_t buf[100];
|
||||
uint8_t *input;
|
||||
|
||||
/* Input buffer is completely uninitialised */
|
||||
input = malloc(10);
|
||||
do_cu42(buf, sizeof buf, (void *)input, 4); // complaint
|
||||
|
||||
/* Read 4 bytes from input buffer. First byte is uninitialised */
|
||||
input = malloc(10);
|
||||
input[1] = input[2] = input[3] = 0x0;
|
||||
do_cu42(buf, sizeof buf, (void *)input, 4); // complaint
|
||||
|
||||
/* Read 4 bytes from input buffer. Second byte is uninitialised */
|
||||
input = malloc(10);
|
||||
input[0] = input[2] = input[3] = 0x0;
|
||||
do_cu42(buf, sizeof buf, (void *)input, 4); // complaint
|
||||
|
||||
/* Read 4 bytes from input buffer. Third byte is uninitialised */
|
||||
input = malloc(10);
|
||||
input[0] = input[1] = input[3] = 0x0;
|
||||
do_cu42(buf, sizeof buf, (void *)input, 4); // complaint
|
||||
|
||||
/* Read 4 bytes from input buffer. Fourth byte is uninitialised */
|
||||
input = malloc(10);
|
||||
input[0] = input[1] = input[2] = 0x0;
|
||||
do_cu42(buf, sizeof buf, (void *)input, 4); // complaint
|
||||
|
||||
/* Read 4 bytes from input buffer. All bytes are initialised */
|
||||
input = malloc(10);
|
||||
memset(input, 0, 4);
|
||||
do_cu42(buf, sizeof buf, (void *)input, 4); // no complaint
|
||||
|
||||
/* Read 8 bytes from input buffer. This iterates once. In the 1st
|
||||
iteration all input bytes are initialised in the 2nd iteration all
|
||||
input bytes are uninitialised. */
|
||||
input = malloc(10);
|
||||
memset(input, 0, 4);
|
||||
do_cu42(buf, sizeof buf, (void *)input, 8); // complaint
|
||||
|
||||
|
||||
/* Write to NULL */
|
||||
// do_cu42(NULL, 10, pattern1, sizeof pattern1); // complaint
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
Invalid write of size 2
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:47)
|
||||
Address 0x........ is 0 bytes inside a block of size 1 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu42.c:47)
|
||||
|
||||
Invalid write of size 4
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:53)
|
||||
Address 0x........ is 0 bytes inside a block of size 1 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu42.c:53)
|
||||
|
||||
Invalid write of size 4
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:56)
|
||||
Address 0x........ is 0 bytes inside a block of size 2 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu42.c:56)
|
||||
|
||||
Invalid write of size 4
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:59)
|
||||
Address 0x........ is 0 bytes inside a block of size 3 alloc'd
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: main (cu42.c:59)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:72)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:77)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:82)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:87)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:92)
|
||||
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: do_cu42 (cu42.c:31)
|
||||
by 0x........: main (cu42.c:104)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
prog: cu42
|
||||
vgopts: -q
|
||||
@@ -0,0 +1,3 @@
|
||||
#! /bin/sh
|
||||
|
||||
../filter_stderr "$@"
|
||||
@@ -0,0 +1,75 @@
|
||||
#include <stdio.h>
|
||||
#include "../../../none/tests/s390x/opcodes.h"
|
||||
int main()
|
||||
{
|
||||
int field1, field2;
|
||||
int result;
|
||||
|
||||
/*
|
||||
* gcc does some tricks for checking the highest bit. It seems
|
||||
* to load a full word/double word.
|
||||
* By using mask=10 for brc (jhe) only the msb is influencing
|
||||
* the code flow. This test was inspired by 308427
|
||||
*/
|
||||
asm volatile( "oi %1,128\n\t"
|
||||
"la 1,%1\n\t"
|
||||
LTG(0,0,1,000,00)
|
||||
"jhe 1f\n\t"
|
||||
"lghi %0,0\n\t"
|
||||
"j 2f\n\t"
|
||||
"1:lghi %0,1\n\t"
|
||||
"2:\n\t"
|
||||
:"=d" (result)
|
||||
:"Q" (field1)
|
||||
:"0","cc");
|
||||
|
||||
if (result)
|
||||
printf("Error\n");
|
||||
|
||||
asm volatile( "oi %1,128\n\t"
|
||||
"la 1,%1\n\t"
|
||||
LT(0,0,1,000,00)
|
||||
"jhe 1f\n\t"
|
||||
"lghi %0,0\n\t"
|
||||
"j 2f\n\t"
|
||||
"1:lghi %0,1\n\t"
|
||||
"2:\n\t"
|
||||
:"=d" (result)
|
||||
:"Q" (field2)
|
||||
:"0","cc");
|
||||
|
||||
if (result)
|
||||
printf("Error\n");
|
||||
|
||||
asm volatile( "oi %1,128\n\t"
|
||||
"la 1,%1\n\t"
|
||||
LTG(0,0,1,000,00)
|
||||
"jl 1f\n\t"
|
||||
"lghi %0,1\n\t"
|
||||
"j 2f\n\t"
|
||||
"1:lghi %0,0\n\t"
|
||||
"2:\n\t"
|
||||
:"=d" (result)
|
||||
:"Q" (field1)
|
||||
:"0","cc");
|
||||
|
||||
if (result)
|
||||
printf("Error\n");
|
||||
|
||||
asm volatile( "oi %1,128\n\t"
|
||||
"la 1,%1\n\t"
|
||||
LT(0,0,1,000,00)
|
||||
"jl 1f\n\t"
|
||||
"lghi %0,1\n\t"
|
||||
"j 2f\n\t"
|
||||
"1:lghi %0,0\n\t"
|
||||
"2:\n\t"
|
||||
:"=d" (result)
|
||||
:"Q" (field2)
|
||||
:"0","cc");
|
||||
|
||||
if (result)
|
||||
printf("Error\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
prog: ltgjhe
|
||||
vgopts: -q
|
||||
Reference in New Issue
Block a user