- Notifications
You must be signed in to change notification settings - Fork13.3k
Function Wrapping with-Wl,--wrap Not Working forpostmortem_report() on ESP8266#9193
-
I'm working on an ESP8266 project where I need to override the To achieve this, I attempted to use the linker flag Original Function (in C file):extern"C"staticvoidpostmortem_report(uint32_t sp_dump) {// Original implementation} My Custom Wrapper (in C++ file):extern"C"void__wrap_postmortem_report(uint32_t sp_dump) {// Custom implementation} Linker Flag in Build System:"buildPreferences": [ ["build.extra_flags","-Wl,--wrap=postmortem_report" ] The Problem:Despite setting everything up as described, it seems that my What I've Tried:
"xtensa-lx106-elf-g++" ... -Wl,--wrap=postmortem_report
Questions:
The original code in the asm(".section .text.__wrap_system_restart_local,\"ax\",@progbits\n\t"".literal_position\n\t"".align 4\n\t"".global __wrap_system_restart_local\n\t"".type __wrap_system_restart_local, @function\n\t""\n""__wrap_system_restart_local:\n\t""mov a2, a1\n\t""j postmortem_report\n\t"".size __wrap_system_restart_local, .-__wrap_system_restart_local\n\t"); Any insights or suggestions on what might be going wrong and how to fix it would be greatly appreciated! |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 1 reply
-
(better late than never :) ld won't use your symbol for internal linkage happening in postmortem .o https://sourceware.org/binutils/docs/ld/Options.html#index-_002d_002dwrap_003dsymbol
You'd have to export it first by removing 'static', similarly to how the system restart wrapper works. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Completely agree with you on that one 😅 This makes complete sense to me, so I'll also focus on the postmortem report function dependency for now. Thank you for taking time explaining this to me, and pointing me to the documentation 🤝 |
BetaWas this translation helpful?Give feedback.