Skip to content

Commit

Permalink
Added stack trashing detection in generic main
Browse files Browse the repository at this point in the history
  • Loading branch information
tehKaiN committed May 30, 2018
1 parent d77771d commit 88dd170
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions include/ace/generic/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ void genericCreate(void);
void genericProcess(void);
void genericDestroy(void);

#if defined(__GNUC__)
#include <stdint.h>

#if UINT32_MAX == UINTPTR_MAX
#define STACK_CHK_GUARD 0xe2dee396
#else
#define STACK_CHK_GUARD 0x595e9fbd94fda766
#endif

uintptr_t __stack_chk_guard = STACK_CHK_GUARD;

__attribute__((noreturn))
void __stack_chk_fail(void) {
logWrite("ERR: STACK SMASHED\n");
while(1) {}
}
#endif

int main(void) {
systemCreate();
memCreate();
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ ifeq ($(ACE_CC), vc)
AS_FLAGS = +kick13 -c
OBJDUMP =
else ifeq ($(ACE_CC), m68k-amigaos-gcc)
CC_FLAGS_NO_O = $(CC_FLAGS_COMMON) -std=gnu11 -DAMIGA \
-noixemul -Wall -Wextra -fomit-frame-pointer
CC_FLAGS = $(CC_FLAGS_NO_O) $(TARGET_DEFINES) -O3
CC_FLAGS_NO_O = $(CC_FLAGS_COMMON) -std=gnu11 -noixemul -Wall -Wextra \
-fomit-frame-pointer -fstack-protector-all
#-fverbose-asm
ACE_AS = vasmm68k_mot
AS_FLAGS = -quiet -x -m68010 -Faout -ID:\prg\kompilatory\bebbo\m68k-amigaos\sys-include
Expand Down

0 comments on commit 88dd170

Please sign in to comment.