/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
1 file changed
tree: 5eb8693ebc47c87816b3d9cec41b6ff93a2e75e1
  1. .github/
  2. adbbu/
  3. applypatch/
  4. attr/
  5. bmlutils/
  6. boot_control/
  7. bootloader_message/
  8. bootloader_message_twrp/
  9. crypto/
  10. dosfstools/
  11. edify/
  12. etc/
  13. exfat/
  14. fb2png/
  15. flashutils/
  16. fonts/
  17. fuse/
  18. gpt/
  19. gui/
  20. htcdumlock/
  21. injecttwrp/
  22. libblkid/
  23. libcrecovery/
  24. libmincrypt/
  25. libpixelflinger/
  26. libtar/
  27. minadbd/
  28. minadbd21/
  29. minui/
  30. minui21/
  31. minuitwrp/
  32. minzip/
  33. mmcutils/
  34. mtdutils/
  35. mtp/
  36. openaes/
  37. orscmd/
  38. otafault/
  39. otautil/
  40. pigz/
  41. prebuilt/
  42. private/
  43. res/
  44. res-hdpi/
  45. res-mdpi/
  46. res-xhdpi/
  47. res-xxhdpi/
  48. res-xxxhdpi/
  49. scripts/
  50. sepolicy/
  51. simg2img/
  52. tests/
  53. toolbox/
  54. tools/
  55. toybox/
  56. twrpDigest/
  57. twrpTarMain/
  58. uncrypt/
  59. update_verifier/
  60. updater/
  61. verifier24/
  62. .clang-format
  63. .gitignore
  64. adb_install.cpp
  65. adb_install.h
  66. Android.bp
  67. Android.mk
  68. asn1_decoder.cpp
  69. asn1_decoder.h
  70. BasePartition.cpp
  71. bootloader.h
  72. CleanSpec.mk
  73. common.h
  74. data.cpp
  75. data.hpp
  76. default_device.cpp
  77. device.cpp
  78. device.h
  79. exclude.cpp
  80. exclude.hpp
  81. find_file.cpp
  82. find_file.hpp
  83. fixContexts.cpp
  84. fixContexts.hpp
  85. fuse.h
  86. fuse_sdcard_provider.cpp
  87. fuse_sdcard_provider.h
  88. fuse_sideload.cpp
  89. fuse_sideload.h
  90. fuse_sideload22.cpp
  91. fuse_sideload22.h
  92. infomanager.cpp
  93. infomanager.hpp
  94. install.cpp
  95. install.h
  96. installcommand.cpp
  97. installcommand.h
  98. interlace-frames.py
  99. legacy_properties.h
  100. legacy_property_service.cpp
  101. legacy_property_service.h
  102. mounts.c
  103. mounts.cpp
  104. mounts.h
  105. NOTICE
  106. openrecoveryscript.cpp
  107. openrecoveryscript.hpp
  108. OWNERS
  109. partition.cpp
  110. partitionmanager.cpp
  111. partitions.hpp
  112. PREUPLOAD.cfg
  113. progresstracking.cpp
  114. progresstracking.hpp
  115. README.md
  116. recovery-persist.cpp
  117. recovery-persist.rc
  118. recovery-refresh.cpp
  119. recovery-refresh.rc
  120. recovery.cpp
  121. recovery_ui.h
  122. roots.cpp
  123. roots.h
  124. rotate_logs.cpp
  125. rotate_logs.h
  126. screen_ui.cpp
  127. screen_ui.h
  128. set_metadata.cpp
  129. set_metadata.h
  130. stub_ui.h
  131. tarWrite.c
  132. tarWrite.h
  133. tw_atomic.cpp
  134. tw_atomic.hpp
  135. twcommon.h
  136. twinstall.cpp
  137. twinstall.h
  138. twinstallorig.cpp
  139. twinstallorig.h
  140. twrp-functions.cpp
  141. twrp-functions.hpp
  142. twrp.cpp
  143. twrpAdbBuFifo.cpp
  144. twrpAdbBuFifo.hpp
  145. twrpDigestDriver.cpp
  146. twrpDigestDriver.hpp
  147. twrpTar.cpp
  148. twrpTar.h
  149. twrpTar.hpp
  150. ui.cpp
  151. ui.h
  152. variables.h
  153. verifier.cpp
  154. verifier.h
  155. vr_device.cpp
  156. vr_ui.cpp
  157. vr_ui.h
  158. wear_device.cpp
  159. wear_ui.cpp
  160. wear_ui.h
  161. zipwrap.cpp
  162. zipwrap.hpp
README.md

Team Win Recovery Project (TWRP)

You can find a compiling guide here.