stackprot_test.c 594 B

1234567891011121314151617181920212223242526
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2021 Broadcom
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. static int do_test_stackprot_fail(struct cmd_tbl *cmdtp, int flag, int argc,
  8. char *const argv[])
  9. {
  10. /*
  11. * In order to avoid having the compiler optimize away the stack smashing
  12. * we need to do a little something here.
  13. */
  14. char a[128];
  15. memset(a, 0xa5, 512);
  16. printf("We have smashed our stack as this should not exceed 128: sizeof(a) = %ld\n", strlen(a));
  17. return 0;
  18. }
  19. U_BOOT_CMD(stackprot_test, 1, 1, do_test_stackprot_fail,
  20. "test stack protector fail", "");