strong vApplicationStackOverflowHook
strong vApplicationStackOverflowHook
Hi everyone,
I wrote a specific vApplicationStackOverflowHook function in order to have a special behaviour when hook appends.
But it's still the vApplicationStackOverflowHook of panic.c that is called even if it has a weak attribute.
Do I have to put something in my makefile to set my vApplicationStackOverflowHook function as strongest one.
Regards,
I wrote a specific vApplicationStackOverflowHook function in order to have a special behaviour when hook appends.
But it's still the vApplicationStackOverflowHook of panic.c that is called even if it has a weak attribute.
Do I have to put something in my makefile to set my vApplicationStackOverflowHook function as strongest one.
Regards,
-
- Posts: 9709
- Joined: Thu Nov 26, 2015 4:08 am
Re: strong vApplicationStackOverflowHook
Do you happen to have your custom application hook in a .c file with nothing else in it? If so, you may have to make sure there's an unresolved symbol in there, otherwise the linker will discard the entire .o file.
Re: strong vApplicationStackOverflowHook
Hi, Yes I try with just vApplicationStackOverflowHook function in my freertos_hook.c file : no change.
I try to put the vApplicationStackOverflowHook function inside app_main.c file and it works.
But as soon as I put it in the another file it doesn't work. freertos_hook.c is in the same folder as app_main.c file.
I try to put the vApplicationStackOverflowHook function inside app_main.c file and it works.
But as soon as I put it in the another file it doesn't work. freertos_hook.c is in the same folder as app_main.c file.
-
- Posts: 9709
- Joined: Thu Nov 26, 2015 4:08 am
Re: strong vApplicationStackOverflowHook
Gotcha, then you have that issue. An option to fix this is to declare a symbol in this file, for instance by creating a dummy function:
and then in the component.mk file declaring this dummy function as an unresolved symbol:
That should force the linker to also take this separate file into account.
Code: Select all
void ld_include_stackoverflowhandler_file_dummy_function() {
//dummy
}
Code: Select all
COMPONENT_ADD_LDFLAGS += -u ld_include_stackoverflowhandler_file_dummy_function
Re: strong vApplicationStackOverflowHook
Good guess, it did the trick.
Where can I find more documentation on "COMPONENT_ADD_LDFLAGS" to plainly understand why this works now?
Where can I find more documentation on "COMPONENT_ADD_LDFLAGS" to plainly understand why this works now?
-
- Posts: 9709
- Joined: Thu Nov 26, 2015 4:08 am
Re: strong vApplicationStackOverflowHook
COMPONENT_ADD_LDFLAGS isn't that special, it allows you to add things to the command line for the linking stage of the executable. Here, I just add '-u [symbol]' to it. According to the man-page, the effect of -u is 'Force symbol to be entered in the output file as an undefined symbol.'
This works, because as far as I know, the linker works on a base of unresolved symbols. It starts (for example) to find the function called main(), then looks at which functions and variables (those are the 'symbols') that uses, and finds those. It then looks at the functions and variables those use, etc, until it has found all functions and variables.
Now, the issue is that vApplicationStackOverflowHook normally is marked 'weak', which means ld will mark it as 'resolved, but overridable'. Because it's still resolved, it can decide the entire program is linked (no unresolved symbols) before it looked at the object file containg your strong vApplicationStackOverflowHook function; this causes that function to be ignored.
By adding a dummy unresolved symbol to the command line, the linker can't be done linking until it has resolved that function. You're effectively forcing it to also evaluate the file with your vApplicationStackOverflowHook in it.
I can't exactly tell you where I picked up that tidbit, though; it may be somewhere in the ld manual.
This works, because as far as I know, the linker works on a base of unresolved symbols. It starts (for example) to find the function called main(), then looks at which functions and variables (those are the 'symbols') that uses, and finds those. It then looks at the functions and variables those use, etc, until it has found all functions and variables.
Now, the issue is that vApplicationStackOverflowHook normally is marked 'weak', which means ld will mark it as 'resolved, but overridable'. Because it's still resolved, it can decide the entire program is linked (no unresolved symbols) before it looked at the object file containg your strong vApplicationStackOverflowHook function; this causes that function to be ignored.
By adding a dummy unresolved symbol to the command line, the linker can't be done linking until it has resolved that function. You're effectively forcing it to also evaluate the file with your vApplicationStackOverflowHook in it.
I can't exactly tell you where I picked up that tidbit, though; it may be somewhere in the ld manual.
Re: strong vApplicationStackOverflowHook
Hello! I got similar problem! My project have so many components (cmake) and [mqtt component] have many weak functions when data callback is called. I use this to parse json inside anothers modules and not inside mqtt core.ESP_Sprite wrote: ↑Thu Dec 13, 2018 4:43 amGotcha, then you have that issue. An option to fix this is to declare a symbol in this file, for instance by creating a dummy function:and then in the component.mk file declaring this dummy function as an unresolved symbol:Code: Select all
void ld_include_stackoverflowhandler_file_dummy_function() { //dummy }
That should force the linker to also take this separate file into account.Code: Select all
COMPONENT_ADD_LDFLAGS += -u ld_include_stackoverflowhandler_file_dummy_function
When I use weak function inside another module, this is never replaced, but when I use this same function inside main.cpp this works fine.
How can I solve this inside CmakeList component?
-
- Posts: 9709
- Joined: Thu Nov 26, 2015 4:08 am
Re: strong vApplicationStackOverflowHook
Does the dummy function plus -u [dummy-functionname] trick not work?
Re: strong vApplicationStackOverflowHook
No, my question is how to add this flag to my custom component using CMake and not .mk. I tried to put this flag in .mk of main folder but when execute, CPU still calling the weak function.ESP_Sprite wrote: ↑Fri May 06, 2022 1:27 amDoes the dummy function plus -u [dummy-functionname] trick not work?
-
- Posts: 9709
- Joined: Thu Nov 26, 2015 4:08 am
Re: strong vApplicationStackOverflowHook
See the docs for that.
Who is online
Users browsing this forum: No registered users and 125 guests