Function Wrapping with -Wl,--wrap
Not Working for postmortem_report()
on ESP8266
#9193
DRSDavidSoft
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on an ESP8266 project where I need to override the
postmortem_report()
function in a way that ensures my custom implementation is called instead of the original one. The original function is defined asstatic
in a C file, which means it has internal linkage and is only visible within that file.To achieve this, I attempted to use the linker flag
-Wl,--wrap=postmortem_report
to wrap the function and redirect calls to__wrap_postmortem_report
, which I have defined in my C++ code. Here’s the relevant code:Original Function (in C file):
My Custom Wrapper (in C++ file):
Linker Flag in Build System:
The Problem:
Despite setting everything up as described, it seems that my
__wrap_postmortem_report()
function is not being called whenpostmortem_report()
is invoked. Instead, the originalpostmortem_report()
is still executed.What I've Tried:
-Wl,--wrap=postmortem_report
flag is correctly passed to the linker:"xtensa-lx106-elf-g++" ... -Wl,--wrap=postmortem_report
__wrap_postmortem_report
has external linkage by usingextern "C"
.-O0
) to rule out issues related to inlining or optimization.postmortem_report
function in the project (thestatic
one).Questions:
static
keyword in the original function be interfering with the wrapping process, despite the linker flag?__wrap_postmortem_report()
function is called instead of the original?The original code in the
core_esp8266_postmortem.cpp
file references thepostmortem_report()
in the assembly as well:Any insights or suggestions on what might be going wrong and how to fix it would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions