8000 Heap addendum to handle changes in NON-OS SDK 3.0.x by mhightower83 · Pull Request #8746 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Heap addendum to handle changes in NON-OS SDK 3.0.x #8746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 16, 2022
Prev Previous commit
Next Next commit
Patch method changed to use objcopy --replace-sym
Updated script to replaced pvPortMalloc with sdk3_pvPortMalloc
in SDK v3.0 libraries
  • Loading branch information
mhightower83 committed Dec 15, 2022
commit af00494456e274fb25bca75b67f3684e0206fa1d
2 changes: 1 addition & 1 deletion cores/esp8266/heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void IRAM_ATTR vPortFree(void *ptr, const char* file, int line)

Not used for unreleased version NONOSDK3V0.
*/
void* IRAM_ATTR pvEsprMalloc(size_t size, const char* file, int line, bool iram)
void* IRAM_ATTR sdk3_pvPortMalloc(size_t size, const char* file, int line, bool iram)
{
if (iram) {
HeapSelectIram ephemeral;
Expand Down
Binary file modified tools/sdk/lib/NONOSDK300/libairkiss.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libcrypto.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libespnow.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libmain.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libnet80211.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libphy.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libpp.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libsmartconfig.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libwpa.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libwpa2.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK300/libwps.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libairkiss.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libcrypto.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libespnow.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libmain.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libnet80211.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libphy.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libpp.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libsmartconfig.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libwpa.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libwpa2.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK301/libwps.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libairkiss.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libcrypto.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libespnow.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libmain.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libnet80211.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libphy.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libpp.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libsmartconfig.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libwpa.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libwpa2.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK302/libwps.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libairkiss.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libcrypto.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libespnow.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libmain.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libnet80211.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libphy.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libpp.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libsmartconfig.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libwpa.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libwpa2.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK303/libwps.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libairkiss.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libcrypto.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libespnow.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libmain.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libnet80211.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libphy.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libpp.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libsmartconfig.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libwpa.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libwpa2.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK304/libwps.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libairkiss.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libcrypto.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libespnow.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libmain.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libnet80211.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libphy.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libpp.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libsmartconfig.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libwpa.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libwpa2.a
D7AE
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK305/libwps.a
Binary file not shown.
Binary file modified tools/sdk/lib/NONOSDK3V0/libmain.a
Binary file not shown.
49 changes: 33 additions & 16 deletions tools/sdk/lib/fix_sdk_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ patchFile() {
fi
}

grepPatchFile() {
grepPatchFiles() {
local SDKVER OLDNAME NEWNAME FILES OLDNAME64 NEWNAME64 FILE OFFSET PATTERN
SDKVER="${1}"
OLDNAME="${2}"
Expand Down Expand Up @@ -71,6 +71,29 @@ grepPatchFile() {
return
}

redefineSym() {
local SDKVER OLDNAME NEWNAME FILES FILE EXTRA PATTERN
SDKVER="${1}"
OLDNAME="${2}"
NEWNAME="${3}"
FILES="${4}"
[[ "${SDKVER:0:9}" != "NONOSDK30" ]] && return
if [[ -z "${FILES}" ]]; then
echo "redefineSym: bad input: file specification required"
exit 1
fi
PATTERN="UND ${OLDNAME}"
for FILE in $FILES ; do
echo "xtensa-lx106-elf-objcopy --redefine-sym ${OLDNAME}=${NEWNAME} \"$FILE\""
echo "Before:"
xtensa-lx106-elf-nm "$FILE" | grep ${OLDNAME} | sort -u
xtensa-lx106-elf-objcopy --redefine-sym ${OLDNAME}=${NEWNAME} "$FILE"
echo "After:"
xtensa-lx106-elf-nm "$FILE" | grep ${OLDNAME} | sort -u
done
return
}

# # xtensa-lx106-elf-ar x libwpa2.a eap.o
if [[ "--shell" == "$1" ]]; then
# need to poke around a bit
Expand Down Expand Up @@ -114,39 +137,24 @@ elif [[ ${VERSION} == "NONOSDK3V0" ]]; then
addSymbol_system_func1 "0x60"
patchFile "eap.o" "3059" "2" "wAA=" "8CA=" # WPA2-Enterprise patch which replaces a double-free with nop, see #8082
patchFile "eap.o" "26356" "9" "dlBvcnRGcmVl" "ejJFYXBGcmVl" # special vPortFree to recover leaked memory
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
elif [[ ${VERSION} == "NONOSDK300" ]]; then
addSymbol_system_func1 "0x54"
patchFile "eap.o" "19204" "9" "dlBvcnRGcmVl" "ejJFYXBGcmVl" # special vPortFree to recover leaked memory
# v3.0.0 and up use a non-standard pvPortMalloc.
# SDK Library global replace
grepPatchFile "${VERSION}" "pvPortMalloc" "pvEsprMalloc" '*.a' #
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
elif [[ ${VERSION} == "NONOSDK301" ]]; then
addSymbol_system_func1 "0x54"
patchFile "eap.o" "26364" "9" "dlBvcnRGcmVl" "ejJFYXBGcmVl" # special vPortFree to recover leaked memory
grepPatchFile "${VERSION}" "pvPortMalloc" "pvEsprMalloc" '*.a'
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
elif [[ ${VERSION} == "NONOSDK302" ]]; then
addSymbol_system_func1 "0x54"
patchFile "eap.o" "26536" "9" "dlBvcnRGcmVl" "ejJFYXBGcmVl" # special vPortFree to recover leaked memory
grepPatchFile "${VERSION}" "pvPortMalloc" "pvEsprMalloc" '*.a'
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
elif [[ ${VERSION} == "NONOSDK303" ]]; then
addSymbol_system_func1 "0x54"
patchFile "eap.o" "26536" "9" "dlBvcnRGcmVl" "ejJFYXBGcmVl" # special vPortFree to recover leaked memory
grepPatchFile "${VERSION}" "pvPortMalloc" "pvEsprMalloc" '*.a'
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
elif [[ ${VERSION} == "NONOSDK304" ]]; then
addSymbol_system_func1 "0x54"
patchFile "eap.o" "19376" "9" "dlBvcnRGcmVl" "ejJFYXBGcmVl" # special vPortFree to recover leaked memory
grepPatchFile "${VERSION}" "pvPortMalloc" "pvEsprMalloc" '*.a'
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
elif [[ ${VERSION} == "NONOSDK305" ]]; then
addSymbol_system_func1 "0x54"
patchFile "eap.o" "67670" "9" "dlBvcnRGcmVl" "ejJFYXBGcmVl" # special vPortFree to recover leaked memory
grepPatchFile "${VERSION}" "pvPortMalloc" "pvEsprMalloc" '*.a'
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
else
echo "WARN: Unknown address for system_func1() called by system_restart_local()"
fi
Expand All @@ -158,3 +166,12 @@ if [[ $(sha256sum user_interface.o | awk '{print $1}') != $uics || $(sha256sum e
xtensa-lx106-elf-ar r libmain.a eagle_lwip_if.o user_interface.o
fi
rm -f eagle_lwip_if.o user_interface.o eap.o

if [[ ${VERSION} == "NONOSDK3V0" ]]; then
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
elif [[ ${VERSION:0:9} == "NONOSDK30" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for this and the above, bash has a pretty good string matcher through case

case $VERSION in
"NONOSDK3V0") echo "foo" ;;
"NONOSDK30"*) echo "bar" ;;
"I write this in Github Web, syntax may be wrong") echo "baz" ;;
esac

# v3.0.0 and up use a non-standard pvPortMalloc.
# SDK Library global replace
redefineSym "${VERSION}" "pvPortMalloc" "sdk3_pvPortMalloc" '*.a'
xtensa-lx106-elf-objcopy --weaken-symbol load_non_32_wide_handler libmain.a
fi
0