esp32: Move the linker wrap options out of the project CMakeLists.

For in-tree builds, these are effectively equivalent. However for
out-of-tree builds it's preferable to have as little as possible in the
top-level CMakeLists.txt file (as the out-of-tree build needs its own
copy).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
diff --git a/ports/esp32/esp32_common.cmake b/ports/esp32/esp32_common.cmake
index 565f6fe..48f067d 100644
--- a/ports/esp32/esp32_common.cmake
+++ b/ports/esp32/esp32_common.cmake
@@ -236,6 +236,13 @@
 target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree)
 target_link_libraries(${MICROPY_TARGET} usermod)
 
+# Enable the panic handler wrapper
+idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND)
+
+# Patch LWIP memory pool allocators (see lwip_patch.c)
+idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=memp_malloc" APPEND)
+idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=memp_free" APPEND)
+
 # Collect all of the include directories and compile definitions for the IDF components,
 # including those added by the IDF Component Manager via idf_components.yaml.
 foreach(comp ${__COMPONENT_NAMES_RESOLVED})