build: remove prelinker build build system

This patch removes support for prelinking from the build system.  By now, the
prelinker has outlived its usefulness for several reasons.  Firstly, the
speedup that it afforded in the early days of Android is now nullified by the
speed of hardware, as well as by the presence of Zygote.  Secondly, the space
savings that come with prelinking (measued at 17MB on a recent honeycomb
stingray build) are no longer important either.  Thirdly, prelinking reduces
the effectiveness of Address-Space-Layout Randomization.  Finally, since it is
not part of the gcc suite, the prelinker needs to be maintained separately.

The patch deletes apriori, soslim, lsd, isprelinked, and iself from the source
tree.  It also removes the prelink map.

LOCAL_PRELINK_MODULE becomes a no-op.  Individual Android.mk will get cleaned
separately.  Support for prelinking will have to be removed from the recovery
code and from the dynamic loader as well.

Change-Id: I5839c9c25f7772d5183eedfe20ab924f2a7cd411
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index f947bf6..bc6ed0c 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -75,7 +75,6 @@
 LOCAL_COPY_HEADERS:=
 LOCAL_FORCE_STATIC_EXECUTABLE:=
 LOCAL_ADDITIONAL_DEPENDENCIES:=
-LOCAL_PRELINK_MODULE:=
 LOCAL_COMPRESS_MODULE_SYMBOLS:=
 LOCAL_STRIP_MODULE:=
 LOCAL_POST_PROCESS_COMMAND:=true
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 3a3a5bd..46e0f75 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -52,8 +52,8 @@
 TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
 TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
 TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
-TARGET_STRIP := $(HOST_OUT_EXECUTABLES)/soslim$(HOST_EXECUTABLE_SUFFIX)
-TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip --shady --quiet $< --outfile $@
+TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
 
 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
 
diff --git a/core/combo/select.mk b/core/combo/select.mk
index c886342..86157d1 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -56,8 +56,6 @@
 $(combo_target)JNILIB_SUFFIX := $($(combo_target)SHLIB_SUFFIX)
 $(combo_target)STATIC_LIB_SUFFIX := .a
 
-$(combo_target)PRELINKER_MAP := $(BUILD_SYSTEM)/prelink-$(combo_os_arch).map
-
 # Now include the combo for this specific target.
 include $(BUILD_COMBOS)/$(combo_target)$(combo_os_arch).mk
 
diff --git a/core/config.mk b/core/config.mk
index c6f6288..3b0e92e 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -105,9 +105,6 @@
 # TODO: do symbol compression
 TARGET_COMPRESS_MODULE_SYMBOLS := false
 
-# Default is to prelink modules.
-TARGET_PRELINK_MODULE := true
-
 # Default shell is ash. Other possible value is mksh.
 TARGET_SHELL := ash
 
@@ -236,10 +233,6 @@
 LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
 EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
 
-# Binary prelinker/compressor tools
-APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
-LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX)
-
 # Deal with archaic version of bison on Mac OS X.
 ifeq ($(filter 1.28,$(shell $(YACC) -V)),)
 YACC_HEADER_SUFFIX:= .hpp
diff --git a/core/definitions.mk b/core/definitions.mk
index 6db9d8f..1202362 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -66,7 +66,7 @@
 # These all have an order-only dependency on the copied headers
 ALL_C_CPP_ETC_OBJECTS:=
 
-# The list of dynamic binaries that haven't been stripped/compressed/prelinked.
+# The list of dynamic binaries that haven't been stripped/compressed/etc.
 ALL_ORIGINAL_DYNAMIC_BINARIES:=
 
 # These files go into the SDK
@@ -1221,17 +1221,6 @@
 $(hide) $(TARGET_STRIP_COMMAND)
 endef
 
-define transform-to-prelinked
-@mkdir -p $(dir $@)
-@echo "target Prelink: $(PRIVATE_MODULE) ($@)"
-$(hide) $(APRIORI) \
-		--prelinkmap $(TARGET_PRELINKER_MAP) \
-		--locals-only \
-		--quiet \
-		$< \
-		--output $@
-endef
-
 
 ###########################################################
 ## Commands for running gcc to link an executable
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 005ccf3..437361a 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -88,47 +88,9 @@
 
 
 ###########################################################
-## Pre-link
-###########################################################
-prelink_input := $(compress_output)
-# The output of the prelink step is the binary we want to use
-# for symbolic debugging;  the prelink step may move sections
-# around, so we have to use this version.
-prelink_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_BUILT_MODULE_STEM)
-
-# Skip prelinker if it is FDO instrumentation build.
-ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
-ifneq ($(LOCAL_NO_FDO_SUPPORT),true)
-LOCAL_PRELINK_MODULE := false
-endif
-endif
-
-ifeq ($(LOCAL_PRELINK_MODULE),true)
-$(prelink_output): $(prelink_input) $(TARGET_PRELINKER_MAP) $(APRIORI)
-	$(transform-to-prelinked)
-else
-# Don't prelink the binary, just copy it.  We can't skip this step
-# because people always expect a copy of the binary to appear
-# in the UNSTRIPPED directory.
-#
-# If the binary we're copying is acp or a prerequisite,
-# use cp(1) instead.
-ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
-$(prelink_output): $(prelink_input) | $(ACP)
-	@echo "target Non-prelinked: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-target)
-else
-$(prelink_output): $(prelink_input)
-	@echo "target Non-prelinked: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-target-with-cp)
-endif
-endif
-
-
-###########################################################
 ## Strip
 ###########################################################
-strip_input := $(prelink_output)
+strip_input := $(compress_output)
 strip_output := $(LOCAL_BUILT_MODULE)
 
 ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
@@ -160,5 +122,4 @@
 $(cleantarget): PRIVATE_CLEAN_FILES := \
 			$(PRIVATE_CLEAN_FILES) \
 			$(linked_module) \
-			$(compress_output) \
-			$(prelink_output)
+			$(compress_output)
diff --git a/core/executable.mk b/core/executable.mk
index 623c766..6138adb 100644
--- a/core/executable.mk
+++ b/core/executable.mk
@@ -12,11 +12,6 @@
 LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
 endif
 
-# Executables are not prelinked.  If we decide to start prelinking
-# them, the LOCAL_PRELINK_MODULE definitions should be moved from
-# here and shared_library.make and consolidated in dynamic_binary.make.
-LOCAL_PRELINK_MODULE := false
-
 include $(BUILD_SYSTEM)/dynamic_binary.mk
 
 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
diff --git a/core/main.mk b/core/main.mk
index a5ee6d1..1a30f16 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -479,10 +479,6 @@
 	build/libs \
 	build/target \
 	build/tools/acp \
-	build/tools/apriori \
-	build/tools/soslim \
-	external/elfcopy \
-	external/elfutils \
 	external/yaffs2 \
 	external/zlib
 else	# !BUILD_TINY_ANDROID
diff --git a/core/prelink-linux-arm.map b/core/prelink-linux-arm.map
deleted file mode 100644
index 41cd8cd..0000000
--- a/core/prelink-linux-arm.map
+++ /dev/null
@@ -1,218 +0,0 @@
-# 0xC0000000 - 0xFFFFFFFF Kernel
-# 0xB0100000 - 0xBFFFFFFF Thread 0 Stack
-# 0xB0000000 - 0xB00FFFFF Linker
-# 0xA0000000 - 0xBFFFFFFF Prelinked System Libraries
-# 0x90000000 - 0x9FFFFFFF Prelinked App Libraries
-# 0x80000000 - 0x8FFFFFFF Non-prelinked Libraries
-# 0x40000000 - 0x7FFFFFFF mmap'd stuff
-# 0x10000000 - 0x3FFFFFFF Thread Stacks
-# 0x00000000 - 0x0FFFFFFF .text / .data / heap
-
-# Note: The general rule is that libraries should be aligned on 1MB
-# boundaries. For ease of updating this file, you will find a comment
-# on each line, indicating the observed size of the library, which is
-# one of:
-#
-#     [<64K] observed to be less than 64K
-#     [~1M] rounded up, one megabyte (similarly for other sizes)
-#     [???] no size observed, assumed to be one megabyte
-#
-# note: look at the LOAD sections in the library header:
-#
-#   arm-linux-androideabi-objdump -x <lib>
-#
-
-# core system libraries
-libdl.so                0xB0100000 # [<64K]
-libc.so                 0xAFF00000 # [~2M]
-libstdc++.so            0xAFE00000 # [<64K]
-libm.so                 0xAFD00000 # [~1M]
-liblog.so               0xAFC00000 # [<64K]
-libcutils.so            0xAFB00000 # [~1M]
-libthread_db.so         0xAFA00000 # [<64K]
-libz.so                 0xAF900000 # [~1M]
-libevent.so             0xAF800000 # [???]
-libssl.so               0xAF600000 # [~2M]
-libcrypto.so            0xAF200000 # [~4M]
-libsysutils.so          0xAF100000 # [~1M]
-
-# bluetooth
-liba2dp.so              0xAF000000 # [~1M]
-input.so                0xAEF00000 # [~1M]
-audio.so                0xAEE00000 # [~1M]
-libglib.so              0xAED00000 # [~1M]
-network.so              0xAEC00000 # [~1M]
-libbluetoothd.so        0xAEA00000 # [~2M]
-libbluedroid.so         0xAE900000 # [<64K]
-libbluetooth.so         0xAE800000 # [~1M]
-libdbus.so              0xAE700000 # [~1M]
-
-# extended system libraries
-libril.so               0xAE600000 # [~1M]
-libreference-ril.so     0xAE500000 # [~1M]
-libwpa_client.so        0xAE400000 # [<64K]
-libnetutils.so          0xAE300000 # [~1M]
-
-# core dalvik runtime support
-libandroid_servers.so   0xAE200000 # [~1M]
-libicuuc.so             0xADE00000 # [~4M]
-libicui18n.so           0xAD900000 # [~5M]
-libandroid_runtime.so   0xAD300000 # [~6M]
-libnativehelper.so      0xAD100000 # [~2M]
-libdvm-ARM.so           0xAD000000 # [???]
-libdvm.so               0xACA00000 # [~6M]
-# Note: libicudata.so intentionally omitted
-
-# graphics
-libpixelflinger.so      0xAC900000 # [~1M]
-# libcorecg is for backward-compatibility with donut
-libcorecg.so            0xAC800000 # [???]
-libsurfaceflinger_client.so 0xAC700000 # [~1M]
-libsurfaceflinger.so    0xAC500000 # [~2M]
-libGLES_android.so      0xAC400000 # [~1M]
-libagl.so               0xAC300000 # [???]
-
-libGLESv1_CM.so         0xAC200000 # [~1M]
-libGLESv2.so            0xAC100000 # [~1M]
-libOpenVG_CM.so         0xAC000000 # [???]
-libOpenVGU_CM.so        0xABF00000 # [???]
-libEGL.so               0xABE00000 # [~1M]
-libETC1.so              0xABD00000 # [<64K]
-
-libacc.so               0xABC00000 # [~1M]
-
-libexif.so              0xABB00000 # [~1M]
-libcamera_client.so     0xABA80000 # [~1M]
-libui.so                0xAB900000 # [~1M]
-libgui.so               0xAB800000 # [~1M]
-libskia.so              0xAB100000 # [~2M]
-librs_jni.so            0xAB000000 # [~1M]
-libRS.so                0xA9E00000 # [~2M]
-libandroid.so           0xA9D80000 # [<64K]
-libjnigraphics.so       0xA9D00000 # [<64K]
-libskiagl.so            0xA9C00000 # [~1M]
-
-# audio
-libaudiopolicy.so       0xA9A00000 # [~1M]
-libeffects.so           0xA9980000 # [<64K]
-libaudioeffect_jni.so   0xA9900000 # [<64K]
-libsoundpool.so         0xA9800000 # [~1M]
-libaudio.so             0xA9700000 # [~1M]
-libspeech.so            0xA9600000 # [~1M]
-libsonivox.so           0xA9500000 # [~1M]
-libvorbisidec.so        0xA9400000 # [~1M]
-libmedia_jni.so         0xA9300000 # [~1M]
-libmediaplayerservice.so 0xA9200000 # [~1M]
-libmedia.so             0xA9000000 # [~2M]
-libFFTEm.so             0xA8F00000 # [~1M]
-libSR_AudioIn.so        0xA8E00000 # [~1M] for external/srec
-libaudioflinger.so      0xA8D00000 # [~1M]
-
-# assorted system libraries
-libsqlite.so            0xA8B00000 # [~2M]
-libexpat.so             0xA8A00000 # [~1M]
-libwebcore.so           0xA8200000 # [~8M]
-libbinder.so            0xA8100000 # [~1M]
-libutils.so             0xA8000000 # [~1M]
-libcameraservice.so     0xA7F00000 # [~1M]
-libhardware.so          0xA7E00000 # [<64K]
-libhardware_legacy.so   0xA7D00000 # [~1M]
-libapp_process.so       0xA7C00000 # [???]
-libsystem_server.so     0xA7B00000 # [~1M]
-libime.so               0xA7A00000 # [???]
-libgps.so               0xA7900000 # [~1M]
-libcamera.so            0xA7800000 # [~1M]
-liboemcamera.so         0xA7600000 # [~2M]
-libdiskconfig.so        0xA7500000 # [<64K]
-libemoji.so             0xA7400000 # [<64K]
-libjni_latinime.so      0xA7300000 # [~1M]
-libjni_pinyinime.so     0xA7200000 # [~1M]
-libttssynthproxy.so     0xA7100000 # [~1M] for frameworks/base
-libttspico.so           0xA6F00000 # [~2M] for external/svox
-libmtp.so               0xA6E00000 # [~1M]
-libusbhost.so           0xA6D00000 # [<64K]
-libinput.so             0xA6C00000 # [~1M]
-
-# pv libraries
-libpvasf.so                    0xA6B00000 # [???]
-libpvasfreg.so                 0xA6A00000 # [???]
-libomx_sharedlibrary.so        0xA6900000 # [~1M]
-libopencore_download.so        0xA6800000 # [~1M]
-libopencore_downloadreg.so     0xA6700000 # [~1M]
-libopencore_net_support.so     0xA6400000 # [~3M]
-libopencore_rtsp.so            0xA5E00000 # [~6M]
-libopencore_rtspreg.so         0xA5D00000 # [~1M]
-libopencore_author.so          0xA5900000 # [~4M]
-libomx_aacdec_sharedlibrary.so 0xA5700000 # [~2M]
-libomx_amrdec_sharedlibrary.so 0xA5600000 # [~1M]
-libomx_amrenc_sharedlibrary.so 0xA5500000 # [~1M]
-libomx_avcdec_sharedlibrary.so 0xA5400000 # [~1M]
-libomx_avcenc_sharedlibrary.so 0xA5300000 # [???]
-libomx_m4vdec_sharedlibrary.so 0xA5200000 # [~1M]
-libomx_m4venc_sharedlibrary.so 0xA5100000 # [???]
-libomx_mp3dec_sharedlibrary.so 0xA5000000 # [~1M]
-libopencore_mp4local.so        0xA4E00000 # [~2M]
-libopencore_mp4localreg.so     0xA4D00000 # [~1M]
-libopencore_player.so          0xA4400000 # [~9M]
-
-# opencore hardware support
-libmm-adspsvc.so              0xA4300000 # [<64K]
-libOmxCore.so                 0xA4200000 # [<64K]
-libOmxMpeg4Dec.so             0xA4100000 # [~1M]
-libOmxH264Dec.so              0xA4000000 # [~1M]
-libOmxVidEnc.so               0xA3F00000 # [~1M]
-libopencorehw.so              0xA3E00000 # [~1M]
-libOmxVdec.so                 0xA3D00000 # [~1M]
-libmm-omxcore.so              0xA3C00000 # [<64K]
-
-# pv libraries
-libopencore_common.so         0xA3500000 # [~7M]
-libqcomm_omx.so               0xA3400000 # [<64K]
-
-# stagefright libraries
-libstagefright_amrnb_common.so     0xA3300000 # [~1M]
-libstagefright_avc_common.so       0xA3200000 # [~1M]
-libstagefright_color_conversion.so 0xA3100000 # [<64K]
-libstagefright_omx.so              0xA3000000 # [~1M]
-libstagefrighthw.so                0xA2F00000 # [~1M]
-libstagefright.so                  0xA2B00000 # [~4M]
-
-# libraries for specific hardware
-libgsl.so               0xA2A00000 # [~1M]
-libhtc_acoustic.so      0xA2900000 # [<64K]
-libhtc_ril.so           0xA2800000 # [~1M]
-libreference-cdma-sms.so 0xA2600000 # [<64K] for hardware/ril
-
-# libraries for specific apps or temporary libraries
-libcam_ipl.so           0x9F000000 # [???]
-libwbxml.so             0x9EF00000 # [???]
-libwbxml_jni.so         0x9EE00000 # [~1M]
-libxml2wbxml.so         0x9EB00000 # [~1M]
-libdrm1.so              0x9EA00000 # [~1M]
-libdrm1_jni.so          0x9E900000 # [<64K]
-libwapcore.so           0x9E800000 # [???]
-libstreetview.so        0x9E700000 # [???]
-libwapbrowsertest.so    0x9E600000 # [???]
-libminiglobe.so         0x9E500000 # [???]
-libearth.so             0x9E400000 # [???]
-libembunit.so           0x9E300000 # [<64K]
-libneon.so              0x9E200000 # [???]
-libjni_example.so       0x9E100000 # [???]
-libjni_load_test.so     0x9E000000 # [???]
-libjni_lib_test.so      0x9DF00000 # [???]
-librunperf.so           0x9DE00000 # [???]
-libctest.so             0x9DD00000 # [<64K]
-libUAPI_jni.so          0x9DC00000 # [???]
-librpc.so               0x9DB00000 # [~1M]
-libtrace_test.so        0x9DA00000 # [???]
-libsrec_jni.so          0x9D800000 # [~2M]
-libjpeg.so              0x9D700000 # [~1M]
-libiprouteutil.so       0x9D600000 # [~1M] for external/iproute2
-libnetlink.so           0x9D500000 # [<64K] for external/iproute2
-libpagemap.so           0x9D400000 # [<64K] for system/extras/libpagemap
-libstlport.so           0x9D100000 # [~3M] for external/stlport
-libzxing.so             0x9D000000 # [<64K] for goggles
-libinterstitial.so      0x9CF00000 # [<64K] for goggles
-liblept.so              0x9CA00000 # [~5M] for external/leptonica
-libbcc.so               0x9C600000 # [~4M] for external/llvm
-libchromium_net.so      0x9C400000 # [~2M] for exteral/webkit
diff --git a/core/product.mk b/core/product.mk
index 249582b..cc62e10 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -196,7 +196,6 @@
 	TARGET_BOARD_PLATFORM_GPU \
 	TARGET_BOOTLOADER_BOARD_NAME \
 	TARGET_COMPRESS_MODULE_SYMBOLS \
-	TARGET_PRELINK_MODULE \
 	TARGET_NO_BOOTLOADER \
 	TARGET_NO_KERNEL \
 	TARGET_NO_RECOVERY \
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 940fe61..47a089a 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -13,9 +13,6 @@
 ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
 LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX)
 endif
-ifeq ($(strip $(LOCAL_PRELINK_MODULE)),)
-LOCAL_PRELINK_MODULE := $(strip $(TARGET_PRELINK_MODULE))
-endif
 ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),)
 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
 endif
diff --git a/core/user_tags.mk b/core/user_tags.mk
index 090b7fa..d30e86b 100644
--- a/core/user_tags.mk
+++ b/core/user_tags.mk
@@ -49,7 +49,6 @@
 	apkcheck \
 	applypatch \
 	app_process \
-	apriori \
 	archquery \
 	asm-3.1 \
 	atree \
@@ -155,8 +154,6 @@
 	input \
 	ip \
 	iptables \
-	iself \
-	isprelinked \
 	jarjar \
 	javax.obex \
 	jcommon-1.0.12 \
@@ -221,7 +218,6 @@
 	libeffects \
 	libEGL \
 	libelf \
-	libelfcopy \
 	libESR_Portable \
 	libESR_Shared \
 	libETC1 \
@@ -481,7 +477,6 @@
 	signature-tools \
 	simg2img \
 	simulator \
-	soslim \
 	spec-progress \
 	sqlite3 \
 	stack_dump \