xiaoxiang781216 commented on a change in pull request #1558:
URL: https://github.com/apache/incubator-nuttx/pull/1558#discussion_r468570685
##########
File path: libs/libc/stdlib/lib_stackchk.c
##########
@@ -0,0 +1,60 @@
+/****************************************************************************
+ * libs/libc/stdlib/lib_stackchk.c
Review comment:
> * how does it fail?
This is link error from arm:
```
arm-none-eabi-ld:
/home/xiaoxiang/nuttx/nuttx/staging/libarch.a(stm32_can.o):(.rodata.cst4+0x0):
undefined reference to `__stack_chk_guard'
```
> * how do you ensure eg. host-privided __stack_chk_fail is not used?
>
From the dissamble code:
```
000000000000b571 <__stack_chk_fail>:
* None.
*
****************************************************************************/
void __stack_chk_fail(void)
{
b571: 55 push %rbp
b572: 48 89 e5 mov %rsp,%rbp
b575: 48 83 ec 10 sub $0x10,%rsp
b579: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
b580: 00 00
b582: 48 89 45 f8 mov %rax,-0x8(%rbp)
b586: 31 c0 xor %eax,%eax
PANIC();
b588: be 39 00 00 00 mov $0x39,%esi
b58d: 48 8d 3d 68 0c 03 00 lea 0x30c68(%rip),%rdi #
3c1fc <g_nullstring+0xd8>
b594: e8 72 04 00 00 callq ba0b <_assert>
```
> even today, when building sim for macOS, ssp things are on by default in
the host cc and ./nuttx is linked with host-provided __stack_chk_fail etc.
> is the situation different for linux?
Yes, Linux will link libssp.a by default too, but it isn't a big issue to
provide our implementation to overwrite the default one. Actually, it's good to
run the same code for simulator and the real hardware.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]