libtests/stackchk: Fix for 64-bit targets

This commit is contained in:
Sebastian Huber
2019-01-09 10:04:01 +01:00
parent e4a19f5b66
commit fe48400d5b

View File

@@ -15,40 +15,28 @@
#include "config.h" #include "config.h"
#endif #endif
#include <rtems.h>
#include <rtems/stackchk.h> #include <rtems/stackchk.h>
#include <rtems/score/heap.h>
#include <rtems/score/percpu.h>
/* forward declarations to avoid warnings */ #include "system.h"
void b(void);
void blow_stack(void);
void b(void)
{
}
void blow_stack(void) void blow_stack(void)
{ {
volatile uint32_t *low, *high;
unsigned char *area;
Thread_Control *executing; Thread_Control *executing;
char *area;
volatile uintptr_t *low;
volatile uintptr_t *high;
b(); executing = _Thread_Get_executing();
/* /*
* Destroy the first and last 16 bytes of our stack... Hope it * Destroy the first and last 4 words of our stack area... Hope it
* does not cause problems :) * does not cause problems :)
*/ */
executing = _Thread_Get_executing(); area = (char *) executing->Start.Initial_stack.area;
area = (unsigned char *)executing->Start.Initial_stack.area; low = (uintptr_t *) area;
high = (uintptr_t *)
/* Look in the stack checker implementation for this magic offset */ (area + executing->Start.Initial_stack.size - 4 * sizeof(*high));
low = (volatile uint32_t *) \
(area + sizeof(Heap_Block) - HEAP_BLOCK_HEADER_SIZE);
high = (volatile uint32_t *)
(area + executing->Start.Initial_stack.size - 16);
low[0] = 0x11111111; low[0] = 0x11111111;
low[1] = 0x22222222; low[1] = 0x22222222;
@@ -59,5 +47,6 @@ void blow_stack(void)
high[1] = 0x66666666; high[1] = 0x66666666;
high[2] = 0x77777777; high[2] = 0x77777777;
high[3] = 0x88888888; high[3] = 0x88888888;
rtems_stack_checker_report_usage(); rtems_stack_checker_report_usage();
} }