/sbin should come first in the linker search path.

/sbin must come before any other search path when TWRP is built for a
different version of Android than the one on which it will run.

Otherwise, as soon as any of the other paths becomes available via
direct action (i.e. the user mounts a file-system) or indirect action
(e.g. the user flashes a zip that mounts a file-system), incompatible
libraries will be prioritised and loaded instead of the correct ones
from /sbin in TWRP's ramdisk.

This will cause severe disruption of the TWRP environment. Toybox and
other dynamically linked binaries will immediately cease to work; and
since Toybox provides umount, it typically won't be possible to recover
from this state without a reboot.

For example, the following occurs when a Toybox applet is run on a
Samsung Galaxy S10 running Android 10, but using a version of TWRP built
for Android 9:

android:/ # getprop ro.boot.bootloader
CANNOT LINK EXECUTABLE "getprop": cannot locate symbol "_system_properties_init" referenced by "/system_root/system/lib64/libselinux.so"...
linker: CANNOT LINK EXECUTABLE "getprop": cannot locate symbol "_system_properties_init" referenced by "/system_root/system/lib64/libselinux.so"...

Change-Id: I31fe612ebb1c7d9ad71d67be2c615caa3fbb5d6f
diff --git a/Android.mk b/Android.mk
index d0d962f..1bb421a 100755
--- a/Android.mk
+++ b/Android.mk
@@ -519,11 +519,11 @@
     TWRP_REQUIRED_MODULES += ld.config.txt
     ifeq ($(BOARD_VNDK_RUNTIME_DISABLE),true)
         LOCAL_POST_INSTALL_CMD += \
-            sed '0,/^namespace.default.search.paths\s\{1,\}/!b;//a\namespace.default.search.paths += \/sbin' \
+	    sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths  = \/sbin\n\1 +=/' \
                 $(TARGET_OUT_ETC)/ld.config.vndk_lite.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt;
     else
         LOCAL_POST_INSTALL_CMD += \
-            sed '0,/^namespace.default.search.paths\s\{1,\}/!b;//a\namespace.default.search.paths += \/sbin' \
+	    sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths  = \/sbin\n\1 +=/' \
                 $(TARGET_OUT_ETC)/ld.config.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt;
     endif
 endif