Reconcile with honeycomb-LTE-release ics-factoryrom-release
Change-Id: I1a4e39e9520e2574fa8e4cdcf37c4c05a0017895
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 7b028ec..62a3a09 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -71,12 +71,38 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/iself)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/lsd)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/apriori)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/isprelinked)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/soslim)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/YouTube*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/librtp_jni_intermediates)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/JAVA_LIBRARIES/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/buildspec.mk.default b/buildspec.mk.default
index 46aee69..2f84016 100644
--- a/buildspec.mk.default
+++ b/buildspec.mk.default
@@ -45,16 +45,9 @@
#CUSTOM_MODULES:=
endif
-# Uncomment this if you want the simulator, otherwise, build for arm
-ifndef TARGET_SIMULATOR
-#TARGET_SIMULATOR:=true
-endif
-
-# Set this to debug or release if you care. Otherwise, it defaults to
-# release for arm and debug for the simulator.
+# Set this to debug or release if you care. Otherwise, it defaults to release.
ifndef TARGET_BUILD_TYPE
#TARGET_BUILD_TYPE:=release
-#TARGET_BUILD_TYPE:=debug
endif
# Uncomment this if you want the host tools built in debug mode. Otherwise
diff --git a/core/Makefile b/core/Makefile
index de341e2..a81c981 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -16,17 +16,22 @@
# e.g., "system/etc/file.xml".
# The filter part means "only eval the copy-one-file rule if this
# src:dest pair is the first one to match the same dest"
-unique_product_copy_files_destinations := $(sort \
- $(foreach cf,$(PRODUCT_COPY_FILES), $(call word-colon,2,$(cf))))
+#$(1): the src:dest pair
+define check-product-copy-files
+$(if $(filter %.apk, $(1)),$(error \
+ Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
+endef
+unique_product_copy_files_destinations :=
$(foreach cf,$(PRODUCT_COPY_FILES), \
$(eval _src := $(call word-colon,1,$(cf))) \
$(eval _dest := $(call word-colon,2,$(cf))) \
- $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
+ $(call check-product-copy-files,$(cf)) \
+ $(if $(filter $(unique_product_copy_files_destinations),$(_dest)),, \
$(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
$(eval $(call copy-one-file,$(_src),$(_fulldest))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
- $(eval unique_product_copy_files_destinations := $(filter-out $(_dest), \
- $(unique_product_copy_files_destinations)))))
+ $(eval unique_product_copy_files_destinations += $(_dest))))
+unique_product_copy_files_destinations :=
# -----------------------------------------------------------------
# docs/index.html
@@ -41,7 +46,11 @@
INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
ADDITIONAL_DEFAULT_PROPERTIES := \
- $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
+ $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
+ADDITIONAL_DEFAULT_PROPERTIES += \
+ $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(ADDITIONAL_DEFAULT_PROPERTIES),=)
$(INSTALLED_DEFAULT_PROP_TARGET):
@echo Target buildinfo: $@
@@ -51,13 +60,16 @@
echo "#" >> $@;
$(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
echo "$(line)" >> $@;)
+ build/tools/post_process_props.py $@
# -----------------------------------------------------------------
# build.prop
INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
ADDITIONAL_BUILD_PROPERTIES := \
- $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+ $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(ADDITIONAL_BUILD_PROPERTIES),=)
# A list of arbitrary tags describing the build configuration.
# Force ":=" so we can use +=
@@ -65,9 +77,16 @@
ifeq ($(TARGET_BUILD_TYPE),debug)
BUILD_VERSION_TAGS += debug
endif
-# Apps are always signed with test keys, and may be re-signed in a post-build
-# step. If that happens, the "test-keys" tag will be removed by that step.
+# The "test-keys" tag marks builds signed with the old test keys,
+# which are available in the SDK. "dev-keys" marks builds signed with
+# non-default dev keys (usually private keys from a vendor directory).
+# Both of these tags will be removed and replaced with "release-keys"
+# when the target-files is signed in a post-build step.
+ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
BUILD_VERSION_TAGS += test-keys
+else
+BUILD_VERSION_TAGS += dev-keys
+endif
BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
# A human-readable string that descibes this build in detail.
@@ -161,6 +180,7 @@
echo "#" >> $@; )
$(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
echo "$(line)" >> $@;)
+ $(hide) build/tools/post_process_props.py $@
build_desc :=
@@ -227,6 +247,8 @@
private_key=""' >> $@;,\
echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
+ # In case $(PACKAGES) is empty.
+ $(hide) touch $@
.PHONY: apkcerts-list
apkcerts-list: $(APKCERTS_FILE)
@@ -251,14 +273,14 @@
# -----------------------------------------------------------------
-# The test key is used to sign this package, and as the key required
+# The dev key is used to sign this package, and as the key required
# for future OTA packages installed by this system. Actual product
# deliverables will be re-signed by hand. We expect this file to
# exist with the suffixes ".x509.pem" and ".pk8".
-DEFAULT_KEY_CERT_PAIR := $(SRC_TARGET_DIR)/product/security/testkey
+DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
-# Rules that need to be present for the simulator, even
+# Rules that need to be present for the all targets, even
# if they don't do anything.
.PHONY: systemimage
systemimage:
@@ -306,8 +328,6 @@
ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
-ifneq ($(TARGET_SIMULATOR),true)
-
# #################################################################
# Targets for boot/OS images
# #################################################################
@@ -644,9 +664,9 @@
endif
# Keys authorized to sign OTA packages this build will accept. The
-# build always uses test-keys for this; release packaging tools will
+# build always uses dev-keys for this; release packaging tools will
# substitute other keys for this one.
-OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
+OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
# Generate a file containing the keys that will be read by the
# recovery binary.
@@ -718,9 +738,6 @@
# -----------------------------------------------------------------
# system image
#
-systemimage_intermediates := \
- $(call intermediates-dir-for,PACKAGING,systemimage)
-BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
$(ALL_PREBUILT) \
@@ -728,6 +745,33 @@
$(ALL_GENERATED_SOURCES) \
$(ALL_DEFAULT_INSTALLED_MODULES))
+FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
+# -----------------------------------------------------------------
+# installed file list
+# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
+# We put installed-files.txt ahead of image itself in the dependency graph
+# so that we can get the size stat even if the build fails due to too large
+# system image.
+INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
+$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
+ @echo Installed file list: $@
+ @mkdir -p $(dir $@)
+ @rm -f $@
+ $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
+
+.PHONY: installed-file-list
+installed-file-list: $(INSTALLED_FILES_FILE)
+ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
+$(call dist-for-goals, sdk win_sdk, $(INSTALLED_FILES_FILE))
+endif
+ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
+$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
+endif
+
+systemimage_intermediates := \
+ $(call intermediates-dir-for,PACKAGING,systemimage)
+BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
+
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
## generate an ext image
# $(1): output file
@@ -747,7 +791,7 @@
endef
endif # INTERNAL_USERIMAGES_USE_EXT
-$(BUILT_SYSTEMIMAGE): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
+$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
$(call build-systemimage-target,$@)
INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
@@ -1069,23 +1113,26 @@
ifdef INTERNAL_USERIMAGES_SPARSE_EXT_FLAG
$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(zip_root)/META/misc_info.txt
endif
+ $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
ifdef PRODUCT_EXTRA_RECOVERY_KEYS
$(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
endif
@# Zip everything up, preserving symlinks
$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
- @# Run fs_config on all the system files in the zip, and save the output
- $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
- $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
+ @# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/boot_filesystem_config.txt
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/recovery_filesystem_config.txt
+ $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
-ifneq ($(TARGET_SIMULATOR),true)
ifneq ($(TARGET_PRODUCT),sdk)
ifeq ($(filter generic%,$(TARGET_DEVICE)),)
ifneq ($(TARGET_NO_KERNEL),true)
+ifneq ($(recovery_fstab),)
# -----------------------------------------------------------------
# OTA update package
@@ -1138,30 +1185,10 @@
.PHONY: updatepackage
updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
+endif # recovery_fstab is defined
endif # TARGET_NO_KERNEL != true
endif # TARGET_DEVICE != generic*
endif # TARGET_PRODUCT != sdk
-endif # TARGET_SIMULATOR != true
-
-# -----------------------------------------------------------------
-# installed file list
-# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
-# gets the DexOpt one if we're doing that.
-INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
-$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
- @echo Installed file list: $@
- @mkdir -p $(dir $@)
- @rm -f $@
- $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
-
-.PHONY: installed-file-list
-installed-file-list: $(INSTALLED_FILES_FILE)
-ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
-$(call dist-for-goals, sdk win_sdk, $(INSTALLED_FILES_FILE))
-endif
-ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
-$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
-endif
# -----------------------------------------------------------------
# A zip of the tests that are built when running "make tests".
@@ -1261,8 +1288,6 @@
$(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
zip -@ -q $@
-endif # TARGET_SIMULATOR != true
-
# -----------------------------------------------------------------
# dalvik something
.PHONY: dalvikfiles
@@ -1271,11 +1296,9 @@
# -----------------------------------------------------------------
# The emulator package
-ifneq ($(TARGET_SIMULATOR),true)
-
INTERNAL_EMULATOR_PACKAGE_FILES += \
$(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
- prebuilt/android-arm/kernel/kernel-qemu \
+ prebuilt/android-$(TARGET_ARCH)/kernel/kernel-qemu \
$(INSTALLED_RAMDISK_TARGET) \
$(INSTALLED_SYSTEMIMAGE) \
$(INSTALLED_USERDATAIMAGE_TARGET)
@@ -1288,8 +1311,6 @@
@echo "Package: $@"
$(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
-endif
-
# -----------------------------------------------------------------
# The pdk package (Platform Development Kit)
@@ -1300,8 +1321,6 @@
# -----------------------------------------------------------------
# The SDK
-ifneq ($(TARGET_SIMULATOR),true)
-
# The SDK includes host-specific components, so it belongs under HOST_OUT.
sdk_dir := $(HOST_OUT)/sdk
@@ -1341,11 +1360,29 @@
atree_dir := development/build
+# sdk/build/tools.atree contains the generic rules, while
+#
+# sdk/build/tools.$(TARGET_ARCH).atree contains target-specific rules
+# the latter is optional.
+#
+sdk_tools_atree_files := sdk/build/tools.atree
+ifneq (,$(strip $(wildcard sdk/build/tools.$(TARGET_ARCH).atree)))
+ sdk_tools_atree_files += sdk/build/tools.$(TARGET_ARCH).atree
+endif
+
sdk_atree_files := \
$(atree_dir)/sdk.exclude.atree \
$(atree_dir)/sdk.atree \
$(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
- sdk/build/tools.atree
+ $(sdk_tools_atree_files)
+
+# development/build/sdk-android-<abi>.atree is used to differentiate
+# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
+# files like the kernel image. We use TARGET_CPU_ABI because we don't
+# have a better way to distinguish between CPU models.
+ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
+ sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
+endif
deps := \
$(target_notice_file_txt) \
@@ -1359,7 +1396,7 @@
$(INSTALLED_BUILD_PROP_TARGET) \
$(ATREE_FILES) \
$(atree_dir)/sdk.atree \
- sdk/build/tools.atree \
+ $(sdk_tools_atree_files) \
$(HOST_OUT_EXECUTABLES)/atree \
$(HOST_OUT_EXECUTABLES)/line_endings
@@ -1373,12 +1410,6 @@
#
#SDK_GNU_ERROR := true
-ifeq ($(HOST_OS),darwin)
-HOST_STRIP_SDK_LLVM := strip
-else
-HOST_STRIP_SDK_LLVM := strip --strip-all
-endif
-
$(INTERNAL_SDK_TARGET): $(deps)
@echo "Package SDK: $@"
$(hide) rm -rf $(PRIVATE_DIR) $@
@@ -1400,14 +1431,14 @@
-I $(TARGET_COMMON_OUT_ROOT) \
-v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
-v "OUT_DIR=$(OUT_DIR)" \
+ -v "TARGET_ARCH=$(TARGET_ARCH)" \
+ -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
+ -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
-o $(PRIVATE_DIR) && \
cp -f $(target_notice_file_txt) \
- $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
+ $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
- for f in $(PRIVATE_DIR)/platform-tools/llvm-rs-cc-* ; do \
- if [ -f "$$f" ]; then $(HOST_STRIP_SDK_LLVM) "$$f"; fi; \
- done && \
HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
chmod -R ug+rwX $(PRIVATE_DIR) && \
@@ -1424,8 +1455,6 @@
include $(TOPDIR)development/build/tools/windows_sdk.mk
endif
-endif # !simulator
-
# -----------------------------------------------------------------
# Findbugs
INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
diff --git a/core/apicheck_msg_current.txt b/core/apicheck_msg_current.txt
index 5d3a913..440e7f8 100644
--- a/core/apicheck_msg_current.txt
+++ b/core/apicheck_msg_current.txt
@@ -6,10 +6,10 @@
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.
- 2) You can update current.xml by executing the following command:
+ 2) You can update current.txt by executing the following command:
make update-api
- To submit the revised current.xml to the main Android repository,
+ To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 25564b2..e18b6ec 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -122,12 +122,16 @@
LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS) user)
endif
-# The definition of should-install-to-system will be different depending
-# on which goal (e.g., sdk or just droid) is being built.
ifdef LOCAL_IS_HOST_MODULE
- use_data :=
+ partition_tag :=
else
- use_data := $(if $(call should-install-to-system,$(LOCAL_MODULE_TAGS)),,_DATA)
+ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
+ partition_tag := _VENDOR
+else
+ # The definition of should-install-to-system will be different depending
+ # on which goal (e.g., sdk or just droid) is being built.
+ partition_tag := $(if $(call should-install-to-system,$(LOCAL_MODULE_TAGS)),,_DATA)
+endif
endif
LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
@@ -145,7 +149,7 @@
LOCAL_MODULE_PATH := $(strip $(LOCAL_MODULE_PATH))
ifeq ($(LOCAL_MODULE_PATH),)
- LOCAL_MODULE_PATH := $($(my_prefix)OUT$(use_data)_$(LOCAL_MODULE_CLASS))
+ LOCAL_MODULE_PATH := $($(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS))
ifeq ($(strip $(LOCAL_MODULE_PATH)),)
$(error $(LOCAL_PATH): unhandled LOCAL_MODULE_CLASS "$(LOCAL_MODULE_CLASS)")
endif
@@ -194,14 +198,8 @@
LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
built_module_path :=
-# LOCAL_UNINSTALLABLE_MODULE is only allowed to be used by the
-# internal STATIC_LIBRARIES build files.
LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
-ifdef LOCAL_UNINSTALLABLE_MODULE
- ifeq (,$(filter $(LOCAL_MODULE_CLASS),JAVA_LIBRARIES STATIC_LIBRARIES))
- $(error $(LOCAL_PATH): Illegal use of LOCAL_UNINSTALLABLE_MODULE)
- endif
-else
+ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
endif
@@ -234,7 +232,7 @@
endif # LOCAL_SDK_VERSION
$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
-$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(PRIVATE_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
+$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
$(transform-aidl-to-java)
-include $(aidl_java_sources:%.java=%.P)
@@ -368,10 +366,11 @@
) \
)
# The arguments to jar that will include these files in a jar file.
+ # Quote the file name to handle special characters (such as #) correctly.
extra_jar_args := \
$(foreach group,$(java_resource_file_groups), \
- $(addprefix -C $(word 1,$(subst :,$(space),$(group))) , \
- $(wordlist 2,9999,$(subst :,$(space),$(group))) \
+ $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
+ $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
) \
)
java_resource_file_groups :=
diff --git a/core/binary.mk b/core/binary.mk
index f81cc5e..e488200 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -9,10 +9,6 @@
## Sanity check for LOCAL_NDK_VERSION
######################################
my_ndk_version_root :=
-ifeq ($(TARGET_SIMULATOR),true)
- # NDK does not support sim build.
- LOCAL_NDK_VERSION :=
-endif
ifdef LOCAL_NDK_VERSION
ifdef LOCAL_IS_HOST_MODULE
$(error $(LOCAL_PATH): LOCAL_NDK_VERSION can not be used in host module)
@@ -60,13 +56,70 @@
endif
else
# LOCAL_NDK_STL_VARIANT is gnustl_static
- my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/include
+ my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/include \
+ $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/include
my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/libstdc++.a
endif
endif
-
endif
+##################################################
+# Compute the dependency of the shared libraries
+##################################################
+# On the target, we compile with -nostdlib, so we must add in the
+# default system shared libraries, unless they have requested not
+# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
+# supply that, for example, when building libc itself.
+ifdef LOCAL_IS_HOST_MODULE
+ ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
+ LOCAL_SYSTEM_SHARED_LIBRARIES :=
+ endif
+else
+ ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
+ LOCAL_SYSTEM_SHARED_LIBRARIES := $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
+ endif
+endif
+
+# Logging used to be part of libcutils (target) and libutils (sim);
+# hack modules that use those other libs to also include liblog.
+# All of this complexity is to make sure that liblog only appears
+# once, and appears just before libcutils or libutils on the link
+# line.
+# TODO: remove this hack and change all modules to use liblog
+# when necessary.
+define insert-liblog
+ $(if $(filter liblog,$(1)),$(1), \
+ $(if $(filter libcutils,$(1)), \
+ $(patsubst libcutils,liblog libcutils,$(1)) \
+ , \
+ $(patsubst libutils,liblog libutils,$(1)) \
+ ) \
+ )
+endef
+ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES)))
+ LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES))
+endif
+ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES)))
+ LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES))
+endif
+ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES)))
+ LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES))
+endif
+
+ifdef LOCAL_NDK_VERSION
+ # Get the list of INSTALLED libraries as module names.
+ # We can not compute the full path of the LOCAL_SHARED_LIBRARIES for
+ # they may cusomize their install path with LOCAL_MODULE_PATH
+ installed_shared_library_module_names := \
+ $(LOCAL_SHARED_LIBRARIES)
+else
+ installed_shared_library_module_names := \
+ $(LOCAL_SYSTEM_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES)
+endif
+# The real dependency will be added after all Android.mks are loaded and the install paths
+# of the shared libraries are determined.
+LOCAL_REQUIRED_MODULES += $(installed_shared_library_module_names)
+
#######################################
include $(BUILD_SYSTEM)/base_rules.mk
#######################################
@@ -137,6 +190,12 @@
endif
endif
+ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
+$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
+else
+$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
+endif
+
###########################################################
## Define arm-vs-thumb-mode flags.
###########################################################
@@ -266,7 +325,7 @@
## C++: Compile .cpp files to .o.
###########################################################
-# we also do this on host modules and sim builds, even though
+# we also do this on host modules, even though
# it's not really arm, because there are files that are shared.
cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(LOCAL_SRC_FILES)))
cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
@@ -378,7 +437,7 @@
objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
ifneq ($(strip $(objc_objects)),)
-$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) $(PRIVATE_ADDITIONAL_DEPENDENCIES)
+$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-$(PRIVATE_HOST)m-to-o)
-include $(objc_objects:%.o=%.P)
endif
@@ -443,47 +502,7 @@
###########################################################
# Standard library handling.
-#
-# On the target, we compile with -nostdlib, so we must add in the
-# default system shared libraries, unless they have requested not
-# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
-# supply that, for example, when building libc itself.
###########################################################
-ifdef LOCAL_IS_HOST_MODULE
- ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
- LOCAL_SYSTEM_SHARED_LIBRARIES :=
- endif
-else
- ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
- LOCAL_SYSTEM_SHARED_LIBRARIES := $($(my_prefix)DEFAULT_SYSTEM_SHARED_LIBRARIES)
- endif
-endif
-
-# Logging used to be part of libcutils (target) and libutils (sim);
-# hack modules that use those other libs to also include liblog.
-# All of this complexity is to make sure that liblog only appears
-# once, and appears just before libcutils or libutils on the link
-# line.
-# TODO: remove this hack and change all modules to use liblog
-# when necessary.
-define insert-liblog
- $(if $(filter liblog,$(1)),$(1), \
- $(if $(filter libcutils,$(1)), \
- $(patsubst libcutils,liblog libcutils,$(1)) \
- , \
- $(patsubst libutils,liblog libutils,$(1)) \
- ) \
- )
-endef
-ifneq (,$(filter libcutils libutils,$(LOCAL_SHARED_LIBRARIES)))
- LOCAL_SHARED_LIBRARIES := $(call insert-liblog,$(LOCAL_SHARED_LIBRARIES))
-endif
-ifneq (,$(filter libcutils libutils,$(LOCAL_STATIC_LIBRARIES)))
- LOCAL_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_STATIC_LIBRARIES))
-endif
-ifneq (,$(filter libcutils libutils,$(LOCAL_WHOLE_STATIC_LIBRARIES)))
- LOCAL_WHOLE_STATIC_LIBRARIES := $(call insert-liblog,$(LOCAL_WHOLE_STATIC_LIBRARIES))
-endif
###########################################################
# The list of libraries that this module will link against are in
@@ -520,12 +539,6 @@
$(addsuffix $(so_suffix), \
$(LOCAL_SHARED_LIBRARIES)))
-# Get the list of INSTALLED libraries. Strip off the various
-# intermediates directories and point to the common lib dirs.
-installed_shared_libraries := \
- $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
- $(notdir $(built_shared_libraries)))
-
my_system_shared_libraries_fullpath := \
$(my_ndk_stl_shared_lib_fullpath) \
$(addprefix $(my_ndk_version_root)/usr/lib/, \
@@ -539,10 +552,6 @@
$(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
$(addsuffix $(so_suffix), \
$(LOCAL_SHARED_LIBRARIES)))
-
-installed_shared_libraries := \
- $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
- $(notdir $(built_shared_libraries)))
endif
built_static_libraries := \
@@ -568,6 +577,11 @@
$(foreach lib,$(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \
NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
+# Default is -fno-rtti.
+ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
+LOCAL_RTTI_FLAG := -fno-rtti
+endif
+
###########################################################
# Rule-specific variable definitions
###########################################################
@@ -575,6 +589,7 @@
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS)
@@ -597,12 +612,6 @@
$(built_static_libraries) \
$(built_whole_libraries)
-# Make LOCAL_INSTALLED_MODULE depend on the installed versions of the
-# libraries so they get installed along with it. We don't need to
-# rebuild it when installing it, though, so this can be an order-only
-# dependency.
-$(LOCAL_INSTALLED_MODULE): | $(installed_shared_libraries)
-
# Also depend on the notice files for any static libraries that
# are linked into this module. This will force them to be installed
# when this module is.
diff --git a/core/build-system.html b/core/build-system.html
index e547185..760589a 100644
--- a/core/build-system.html
+++ b/core/build-system.html
@@ -516,16 +516,8 @@
</tr>
</table>
-<h4>TARGET_SIMULATOR</h4>
-<p>If we're building the simulator, as opposed to the arm or emulator builds,
-<code>TARGET_SIMULATOR</code> will be set to <code>true</code>.
-
<h4>Some Examples</h4>
-<pre>ifeq ($(TARGET_SIMULATOR),true)
-LOCAL_CFLAGS += -DSIMULATOR
-endif
-
-ifeq ($(TARGET_BUILD_TYPE),release)
+<pre>ifeq ($(TARGET_BUILD_TYPE),release)
LOCAL_CFLAGS += -DNDEBUG=1
endif
diff --git a/core/build_id.mk b/core/build_id.mk
index 796504b..e415e8d 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -1,4 +1,3 @@
-
#
# Copyright (C) 2008 The Android Open Source Project
#
@@ -14,9 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
+#
+# Defines branch-specific values.
+#
+
# BUILD_ID is usually used to specify the branch name
# (like "MAIN") or a branch name and a release candidate
-# (like "CRB01"). It must be a single word, and is
+# (like "TC1-RC5"). It must be a single word, and is
# capitalized by convention.
+#
+BUILD_ID := ICS_FACTORYROM
-export BUILD_ID=HLK75D
+# DISPLAY_BUILD_NUMBER should only be set for development branches,
+# If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
+# a more descriptive BUILD_ID_DISPLAY, otherwise BUILD_ID_DISPLAY
+# is the same as BUILD_ID
+DISPLAY_BUILD_NUMBER := true
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index 821b03a..2639cae 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -117,13 +117,13 @@
building_sdk :=
endif
-# A change in the list of locales warrants an installclean, too.
-locale_list := $(subst $(space),$(comma),$(strip $(PRODUCT_LOCALES)))
+# A change in the list of aapt configs warrants an installclean, too.
+aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG))
current_build_config := \
- $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)-{$(locale_list)}
+ $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)-{$(aapt_config_list)}
building_sdk :=
-locale_list :=
+aapt_config_list :=
force_installclean := false
# Read the current state from the file, if present.
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 2d8c15a..643a138 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -27,6 +27,8 @@
LOCAL_PREBUILT_OBJ_FILES:=
LOCAL_STATIC_JAVA_LIBRARIES:=
LOCAL_STATIC_LIBRARIES:=
+# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking.
+LOCAL_GROUP_STATIC_LIBRARIES:=
LOCAL_WHOLE_STATIC_LIBRARIES:=
LOCAL_SHARED_LIBRARIES:=
LOCAL_IS_HOST_MODULE:=
@@ -40,6 +42,7 @@
LOCAL_ASFLAGS:=
LOCAL_CFLAGS:=
LOCAL_CPPFLAGS:=
+LOCAL_RTTI_FLAG:=
LOCAL_C_INCLUDES:=
LOCAL_LDFLAGS:=
LOCAL_LDLIBS:=
@@ -75,7 +78,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
@@ -91,6 +93,7 @@
LOCAL_DX_FLAGS:=
LOCAL_CERTIFICATE:=
LOCAL_SDK_VERSION:=
+LOCAL_SDK_RES_VERSION:=
LOCAL_NDK_VERSION:=
LOCAL_NDK_STL_VARIANT:=
LOCAL_NO_EMMA_INSTRUMENT:=
@@ -102,12 +105,15 @@
LOCAL_WARNINGS_ENABLE:=
LOCAL_MANIFEST_FILE:=
LOCAL_RENDERSCRIPT_INCLUDES:=
+LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE:=
LOCAL_RENDERSCRIPT_CC:=
+LOCAL_RENDERSCRIPT_TARGET_API:=
LOCAL_BUILD_HOST_DEX:=
LOCAL_DEX_PREOPT:=
LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,full
LOCAL_PROTOC_FLAGS:=
LOCAL_NO_CRT:=
+LOCAL_PROPRIETARY_MODULE:=
# Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
# iterate over thousands of entries every time.
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index b829108..544a29e 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -66,7 +66,9 @@
$(PRIVATE_ALL_OBJECTS) \
$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(PRIVATE_LDLIBS) \
-o $@ \
$(PRIVATE_LDFLAGS) \
@@ -82,7 +84,9 @@
$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
$(PRIVATE_ALL_OBJECTS) \
$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_LDLIBS) \
$(HOST_LIBGCC)
diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk
index c871613..5ae4972 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -45,13 +45,8 @@
# We build everything in 32-bit, because some host tools are
# 32-bit-only anyway (emulator, acc), and because it gives us
# more consistency between the host tools and the target.
-# The exception is the host side of the simulator, which
-# requires to use the default size, as wxWidgets code otherwise
-# fails to build.
-ifneq ($(TARGET_SIMULATOR),true)
HOST_GLOBAL_CFLAGS += -m32
HOST_GLOBAL_LDFLAGS += -m32
-endif
HOST_GLOBAL_CFLAGS += -fPIC
HOST_GLOBAL_CFLAGS += \
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 3a3a5bd..8c89143 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -47,13 +47,22 @@
prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-
endif
-TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
-TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
-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 $@
+# Only define these if there's actually a gcc in there.
+# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
+ifneq ($(wildcard $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)),)
+ TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
+ TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
+ 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 := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+ ifeq ($(TARGET_BUILD_VARIANT),user)
+ TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-all $< -o $@
+ else
+ TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-all $< -o $@ && \
+ $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
+ endif
+endif
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
@@ -105,6 +114,13 @@
-include $(android_config_h) \
-I $(arch_include_dir)
+# This warning causes dalvik not to build with gcc 4.6 and -Werror.
+# We cannot turn it off blindly since the option is not available
+# in gcc-4.4.x
+ifneq ($(filter 4.6.0%, $(shell $(TARGET_CC) --version)),)
+TARGET_GLOBAL_CFLAGS += -Wno-unused-but-set-variable
+endif
+
# This is to avoid the dreaded warning compiler message:
# note: the mangling of 'va_list' has changed in GCC 4.4
#
@@ -237,7 +253,9 @@
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-o $@ \
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
@@ -258,7 +276,9 @@
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
$(PRIVATE_ALL_OBJECTS) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
$(TARGET_FDO_LIB) \
diff --git a/core/combo/TARGET_linux-sh.mk b/core/combo/TARGET_linux-sh.mk
index 654539c..b8e00dd 100644
--- a/core/combo/TARGET_linux-sh.mk
+++ b/core/combo/TARGET_linux-sh.mk
@@ -29,7 +29,13 @@
TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+
+ifeq ($(TARGET_BUILD_VARIANT),user)
TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
+else
+TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \
+ $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
+endif
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
@@ -125,7 +131,9 @@
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-o $@ \
$(PRIVATE_LDFLAGS) \
@@ -145,7 +153,9 @@
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
$(PRIVATE_ALL_OBJECTS) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(PRIVATE_LDFLAGS) \
$(TARGET_LIBGCC) \
$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
@@ -160,7 +170,9 @@
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_OBJECTS) \
+ -Wl,--start-group \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ -Wl,--end-group \
$(TARGET_LIBGCC) \
$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 412ec69..0fb6edc 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -17,19 +17,6 @@
# Configuration for Linux on x86 as a target.
# Included by combo/select.mk
-ifeq ($(TARGET_SIMULATOR),true)
-# When building for the simulator, use the HOST settings as TARGET settings
-TARGET_CC := $(HOST_CC)
-TARGET_CXX := $(HOST_CXX)
-TARGET_AR := $(HOST_AR)
-TARGET_GLOBAL_CFLAGS := $(HOST_GLOBAL_CFLAGS) -m32
-TARGET_GLOBAL_LDFLAGS := $(HOST_GLOBAL_LDFLAGS) -m32 -lpthread
-TARGET_NO_UNDEFINED_LDFLAGS := $(HOST_NO_UNDEFINED_LDFLAGS)
-ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
-TARGET_ARCH_VARIANT := x86
-endif
-else #simulator
-
# Provide a default variant.
ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
TARGET_ARCH_VARIANT := x86
@@ -38,7 +25,7 @@
# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
TARGET_TOOLS_PREFIX := \
- prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-unknown-linux-gnu-4.2.1/bin/i686-unknown-linux-gnu-
+ prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-android-linux-4.4.3/bin/i686-android-linux-
endif
TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
@@ -47,12 +34,17 @@
TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+
+ifeq ($(TARGET_BUILD_VARIANT),user)
TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
+else
+TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \
+ $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
+endif
ifneq ($(wildcard $(TARGET_CC)),)
TARGET_LIBGCC := \
- $(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a) \
- $(shell $(TARGET_CC) -m32 -print-file-name=libgcc_eh.a)
+ $(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a)
endif
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
@@ -76,23 +68,45 @@
KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
TARGET_GLOBAL_CFLAGS += \
+ -O2 \
-Ulinux \
- -m32 \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -Wstrict-aliasing=2 \
-fPIC \
+ -ffunction-sections \
+ -finline-functions \
+ -finline-limit=300 \
+ -fno-inline-functions-called-once \
+ -fno-short-enums \
+ -fstrict-aliasing \
+ -funswitch-loops \
+ -funwind-tables \
-include $(call select-android-config-h,target_linux-x86)
+# Needs to be fixed later
+#TARGET_GLOBAL_CFLAGS += \
+# -fstack-protector
+
+# Needs to be added for RELEASE
+#TARGET_GLOBAL_CFLAGS += \
+# -DNDEBUG
+
TARGET_GLOBAL_CPPFLAGS += \
-fno-use-cxa-atexit
ifeq ($(TARGET_ARCH_VARIANT),x86-atom)
- TARGET_GLOBAL_CFLAGS += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2 -mfpmath=sse -msse2
+ TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -DUSE_SSSE3 -DUSE_SSE2 -mfpmath=sse
else
TARGET_GLOBAL_CFLAGS += -march=i686
endif
+TARGET_GLOBAL_CFLAGS += -mbionic
TARGET_GLOBAL_CFLAGS += -D__ANDROID__
-TARGET_GLOBAL_LDFLAGS += -m32
+TARGET_GLOBAL_LDFLAGS += -m32
+TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
+TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
TARGET_C_INCLUDES := \
$(libc_root)/arch-x86/include \
@@ -127,7 +141,9 @@
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-o $@ \
$(PRIVATE_LDFLAGS) \
@@ -148,7 +164,9 @@
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
$(PRIVATE_ALL_OBJECTS) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(PRIVATE_LDFLAGS) \
$(TARGET_LIBGCC) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
@@ -169,5 +187,3 @@
-Wl,--end-group \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
endef
-
-endif #simulator
diff --git a/core/combo/select.mk b/core/combo/select.mk
index c886342..cdeb68a 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -56,19 +56,27 @@
$(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
ifneq ($(USE_CCACHE),)
- ccache := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache
- # prepend ccache if necessary
- ifneq ($(ccache),$(firstword $($(combo_target)CC)))
- $(combo_target)CC := $(ccache) $($(combo_target)CC)
+ CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG)
+ # If we are cross-compiling Windows binaries on Linux
+ # then use the linux ccache binary instead.
+ ifeq ($(HOST_OS)-$(BUILD_OS),windows-linux)
+ CCACHE_HOST_TAG := linux-$(BUILD_ARCH)
endif
- ifneq ($(ccache),$(firstword $($(combo_target)CXX)))
- $(combo_target)CXX := $(ccache) $($(combo_target)CXX)
+ ccache := prebuilt/$(CCACHE_HOST_TAG)/ccache/ccache
+ # Check that the executable is here.
+ ccache := $(strip $(wildcard $(ccache)))
+ ifdef ccache
+ # prepend ccache if necessary
+ ifneq ($(ccache),$(firstword $($(combo_target)CC)))
+ $(combo_target)CC := $(ccache) $($(combo_target)CC)
+ endif
+ ifneq ($(ccache),$(firstword $($(combo_target)CXX)))
+ $(combo_target)CXX := $(ccache) $($(combo_target)CXX)
+ endif
+ ccache =
endif
- ccache =
endif
diff --git a/core/config.mk b/core/config.mk
index c6f6288..41e60ea 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -105,11 +105,8 @@
# 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
+# Default shell is mksh. Other possible value is ash.
+TARGET_SHELL := mksh
# ###############################################################
# Include sub-configuration files
@@ -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
@@ -277,6 +270,12 @@
endif
endif
+# Is the host JDK 64-bit version?
+HOST_JDK_IS_64BIT_VERSION :=
+ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),)
+HOST_JDK_IS_64BIT_VERSION := true
+endif
+
# It's called md5 on Mac OS and md5sum on Linux
ifeq ($(HOST_OS),darwin)
MD5SUM:=md5 -q
@@ -284,6 +283,18 @@
MD5SUM:=md5sum
endif
+APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
+APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
+APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"
+
+# The default key if not set as LOCAL_CERTIFICATE
+ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
+ DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
+else
+ DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
+endif
+
# ###############################################################
# Set up final options.
# ###############################################################
@@ -308,13 +319,9 @@
# Many host compilers don't support these flags, so we have to make
# sure to only specify them for the target compilers checked in to
-# the source tree. The simulator passes the target flags to the
-# host compiler, so only set them for the target when the target
-# is not the simulator.
-ifneq ($(TARGET_SIMULATOR),true)
+# the source tree.
TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
-endif
HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
@@ -356,14 +363,10 @@
$(patsubst $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r%,%, \
$(wildcard $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r*)))
-INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml
+INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
# This is the standard way to name a directory containing prebuilt target
# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
-ifeq ($(TARGET_SIMULATOR),true)
- TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
-else
- TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
-endif
+TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/definitions.mk b/core/definitions.mk
index fe4b534..1afc0f4 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
@@ -154,7 +154,7 @@
# $(1): List of directories to look for under this directory
define all-named-subdir-makefiles
-$(wildcard $(addsuffix /Android.mk, $(addprefix $(my-dir)/,$(1))))
+$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))
endef
###########################################################
@@ -312,7 +312,7 @@
define find-subdir-assets
$(if $(1),$(patsubst ./%,%, \
- $(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -type f -and -not -type l ; fi)), \
+ $(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \
$(warning Empty argument supplied to find-subdir-assets) \
)
endef
@@ -600,6 +600,21 @@
endef
###########################################################
+## Given a list of pairs, if multiple pairs have the same
+## first components, keep only the first pair.
+##
+## $(1): list of pairs
+## $(2): the separator word, such as ":", "=", etc.
+define uniq-pairs-by-first-component
+$(eval _upbfc_fc_set :=)\
+$(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\
+ $(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\
+ $(eval _upbfc_fc_set += $(_first)))))\
+$(eval _upbfc_fc_set :=)\
+$(eval _first:=)
+endef
+
+###########################################################
## MODULE_TAG set operations
###########################################################
@@ -786,6 +801,7 @@
-p $(PRIVATE_RS_OUTPUT_DIR)/src \
-d $(PRIVATE_RS_OUTPUT_DIR) \
-a $@ -MD \
+ $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
$(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
$(PRIVATE_RS_SOURCE_FILES)
#$(hide) $(LLVM_RS_LINK) \
@@ -856,22 +872,19 @@
@mkdir -p $(dir $@)
@echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
$(hide) $(PRIVATE_CXX) \
- $(foreach incdir, \
- $(PRIVATE_C_INCLUDES) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(addprefix -isystem ,\
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
- $(PRIVATE_TARGET_PROJECT_INCLUDES) \
- $(PRIVATE_TARGET_C_INCLUDES) \
- ) \
- , \
- -I $(incdir) \
- ) \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $(PRIVATE_TARGET_PROJECT_INCLUDES) \
+ $(PRIVATE_TARGET_C_INCLUDES)))) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
$(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
$(PRIVATE_ARM_CFLAGS) \
) \
- -fno-rtti \
+ $(PRIVATE_RTTI_FLAG) \
$(PRIVATE_CFLAGS) \
$(PRIVATE_CPPFLAGS) \
$(PRIVATE_DEBUG_CFLAGS) \
@@ -888,15 +901,12 @@
define transform-c-or-s-to-o-no-deps
@mkdir -p $(dir $@)
$(hide) $(PRIVATE_CC) \
- $(foreach incdir, \
- $(PRIVATE_C_INCLUDES) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(addprefix -isystem ,\
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
- $(PRIVATE_TARGET_PROJECT_INCLUDES) \
- $(PRIVATE_TARGET_C_INCLUDES) \
- ) \
- , \
- -I $(incdir) \
- ) \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $(PRIVATE_TARGET_PROJECT_INCLUDES) \
+ $(PRIVATE_TARGET_C_INCLUDES)))) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
@@ -952,15 +962,12 @@
@mkdir -p $(dir $@)
@echo "host C++: $(PRIVATE_MODULE) <= $<"
$(hide) $(PRIVATE_CXX) \
- $(foreach incdir, \
- $(PRIVATE_C_INCLUDES) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(addprefix -isystem ,\
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
- $(HOST_PROJECT_INCLUDES) \
- $(HOST_C_INCLUDES) \
- ) \
- , \
- -I $(incdir) \
- ) \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $(HOST_PROJECT_INCLUDES) \
+ $(HOST_C_INCLUDES)))) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(HOST_GLOBAL_CFLAGS) \
@@ -982,15 +989,12 @@
define transform-host-c-or-s-to-o-no-deps
@mkdir -p $(dir $@)
$(hide) $(PRIVATE_CC) \
- $(foreach incdir, \
- $(PRIVATE_C_INCLUDES) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(addprefix -isystem ,\
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
- $(HOST_PROJECT_INCLUDES) \
- $(HOST_C_INCLUDES) \
- ) \
- , \
- -I $(incdir) \
- ) \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $(HOST_PROJECT_INCLUDES) \
+ $(HOST_C_INCLUDES)))) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(HOST_GLOBAL_CFLAGS) \
@@ -1143,7 +1147,9 @@
-Wl,--whole-archive \
$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-o $@ \
$(PRIVATE_LDLIBS)
@@ -1191,7 +1197,9 @@
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-o $@ \
$(PRIVATE_LDLIBS)
@@ -1221,17 +1229,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
@@ -1251,7 +1248,9 @@
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-o $@ \
$(PRIVATE_LDLIBS)
@@ -1302,7 +1301,9 @@
-Wl,--whole-archive \
$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-o $@ \
$(PRIVATE_LDLIBS)
@@ -1333,12 +1334,12 @@
# Maybe we should just use approach (1).
# This rule creates the R.java and Manifest.java files, both of which
-# are PRODUCT-neutral. Don't pass PRODUCT_AAPT_CONFIG to this invocation.
+# are PRODUCT-neutral. Don't pass PRIVATE_PRODUCT_AAPT_CONFIG to this invocation.
define create-resource-java-files
@mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR)
@mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT))
$(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \
- $(eval # PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \
+ $(eval # PRIVATE_PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \
$(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
$(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
$(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \
@@ -1346,8 +1347,8 @@
$(addprefix -A , $(PRIVATE_ASSET_DIR)) \
$(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
$(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \
- $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
- $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
+ $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
$(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \
$(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \
$(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
@@ -1360,6 +1361,12 @@
xlint_unchecked := -Xlint:unchecked
endif
+ifeq (true, $(ENABLE_INCREMENTALJAVAC))
+incremental_dex := --incremental
+else
+incremental_dex :=
+endif
+
# emit-line, <word list>, <output file>
define emit-line
$(if $(1),echo -n '$(strip $(1)) ' >> $(2))
@@ -1435,7 +1442,7 @@
fi
$(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \
| sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
-$(hide) $(1) -encoding ascii \
+$(hide) $(1) -encoding UTF-8 \
$(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \
$(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \
$(2) \
@@ -1477,7 +1484,7 @@
@echo "(Incremental) build source files:"
@cat $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
$(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
- $(1) -encoding ascii \
+ $(1) -encoding UTF-8 \
$(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \
$(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \
$(2) \
@@ -1518,6 +1525,7 @@
$(hide) $(DX) \
$(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1536M) \
--dex --output=$@ \
+ $(incremental_dex) \
$(if $(NO_OPTIMIZE_DX), \
--no-optimize) \
$(if $(GENERATE_DEX_DEBUG), \
@@ -1550,13 +1558,13 @@
#them in their manifest.
define add-assets-to-package
$(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \
- $(addprefix -c , $(PRODUCT_AAPT_CONFIG)) \
+ $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \
$(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
$(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \
$(addprefix -A , $(PRIVATE_ASSET_DIR)) \
$(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
- $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
- $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
+ $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
$(addprefix --product , $(TARGET_AAPT_CHARACTERISTICS)) \
$(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \
$(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \
@@ -1584,7 +1592,9 @@
endef
define add-java-resources-to-package
-$(hide) jar uf $@ $(PRIVATE_EXTRA_JAR_ARGS)
+$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(dir $@)jar-arg-list)
+$(hide) jar uf $@ @$(dir $@)jar-arg-list
+@rm -f $(dir $@)jar-arg-list
endef
# Sign a package using the specified key/cert.
@@ -1627,7 +1637,7 @@
define transform-host-java-to-package
@echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH))
-$(hide) if [ ! -z "$(PRIVATE_EXTRA_JAR_ARGS)" ]; then jar uf $@ $(PRIVATE_EXTRA_JAR_ARGS); fi
+$(if $(PRIVATE_EXTRA_JAR_ARGS), $(call add-java-resources-to-package))
endef
###########################################################
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 9f44c32..b801ac2 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -4,7 +4,7 @@
####################################
# TODO: replace it with device's BOOTCLASSPATH
-DEXPREOPT_BOOT_JARS := core:apache-xml:bouncycastle:ext:framework:android.policy:services:core-junit
+DEXPREOPT_BOOT_JARS := core:core-junit:bouncycastle:ext:framework:android.policy:services:apache-xml:filterfw
DEXPREOPT_BOOT_JARS_MODULES := $(subst :, ,$(DEXPREOPT_BOOT_JARS))
DEXPREOPT_BUILD_DIR := $(OUT_DIR)
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index 505d127..91d8166 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -82,13 +82,13 @@
endif # !LOCAL_IS_HOST_MODULE
-intermediates := $(call local-intermediates-dir)
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
$(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH))
$(full_target): PRIVATE_JAVA_FILES := $(filter %.java,$(full_src_files))
$(full_target): PRIVATE_JAVA_FILES += $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
-$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
-$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates)/droiddoc-src-list
+$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
+$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates.COMMON)/droiddoc-src-list
ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),)
$(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR)
@@ -154,7 +154,7 @@
$(hide) ( \
javadoc \
\@$(PRIVATE_SRC_LIST_FILE) \
- -J-Xmx1024m \
+ -J-Xmx1280m \
$(PRIVATE_PROFILING_OPTIONS) \
-quiet \
-doclet com.google.doclava.Doclava \
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index c94d943..e0de464 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -5,9 +5,8 @@
ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
-ifeq ($(TARGET_SIMULATOR),true)
- ABP:=$(ABP):$(TARGET_OUT_EXECUTABLES)
-else
+# Add the toolchain bin dir if it actually exists
+ifneq ($(wildcard $(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-linux-androideabi-4.4.x/bin),)
# this should be copied to HOST_OUT_EXECUTABLES instead
ABP:=$(ABP):$(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-linux-androideabi-4.4.x/bin
endif
@@ -65,7 +64,6 @@
$(info PLATFORM_VERSION=$(PLATFORM_VERSION))
$(info TARGET_PRODUCT=$(TARGET_PRODUCT))
$(info TARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT))
-$(info TARGET_SIMULATOR=$(TARGET_SIMULATOR))
$(info TARGET_BUILD_TYPE=$(TARGET_BUILD_TYPE))
$(info TARGET_BUILD_APPS=$(TARGET_BUILD_APPS))
$(info TARGET_ARCH=$(TARGET_ARCH))
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 005ccf3..0ca1858 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -86,49 +86,20 @@
compress_output := $(compress_input)
endif
-
###########################################################
-## Pre-link
+## Store a copy with symbols for symbolic debugging
###########################################################
-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) ($@)"
+symbolic_input := $(compress_output)
+symbolic_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_BUILT_MODULE_STEM)
+$(symbolic_output) : $(symbolic_input) | $(ACP)
+ @echo "target Symbolic: $(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 := $(symbolic_output)
strip_output := $(LOCAL_BUILT_MODULE)
ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
@@ -160,5 +131,5 @@
$(cleantarget): PRIVATE_CLEAN_FILES := \
$(PRIVATE_CLEAN_FILES) \
$(linked_module) \
- $(compress_output) \
- $(prelink_output)
+ $(symbolic_output) \
+ $(compress_output)
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 800a9bf..c3ae3b0 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -1,6 +1,5 @@
# Variables we check:
# HOST_BUILD_TYPE = { release debug }
-# TARGET_SIMULATOR = { true <null> }
# TARGET_BUILD_TYPE = { release debug }
# and we output a bunch of variables, see the case statement at
# the bottom for the full list
@@ -19,16 +18,12 @@
CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
# ---------------------------------------------------------------
-# The product defaults to generic on hardware and sim on sim
+# The product defaults to generic on hardware
# NOTE: This will be overridden in product_config.mk if make
# was invoked with a PRODUCT-xxx-yyy goal.
ifeq ($(TARGET_PRODUCT),)
-ifeq ($(TARGET_SIMULATOR),true)
-TARGET_PRODUCT := sim
-else
TARGET_PRODUCT := full
endif
-endif
# the variant -- the set of files that are included for a build
@@ -36,18 +31,6 @@
TARGET_BUILD_VARIANT := eng
endif
-# Read the product specs so we an get TARGET_DEVICE and other
-# variables that we need in order to locate the output files.
-include $(BUILD_SYSTEM)/product_config.mk
-
-build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
-ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
-$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
-$(error must be empty or one of: eng user userdebug tests)
-endif
-
-
-
# ---------------------------------------------------------------
# Set up configuration for host machine. We don't do cross-
# compiles except for arm, so the HOST is whatever we are
@@ -119,17 +102,15 @@
HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
endif
-# Default to building dalvikvm on hosts that support it...
-ifeq ($(HOST_OS),linux)
-# ... but not if we're building the sim...
-ifneq ($(TARGET_SIMULATOR),true)
-# ... or if the if the option is already set
-ifeq ($(WITH_HOST_DALVIK),)
- WITH_HOST_DALVIK := true
-endif
-endif
-endif
+# Read the product specs so we an get TARGET_DEVICE and other
+# variables that we need in order to locate the output files.
+include $(BUILD_SYSTEM)/product_config.mk
+build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
+ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
+$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
+$(error must be empty or one of: eng user userdebug tests)
+endif
# ---------------------------------------------------------------
# Set up configuration for target machine.
@@ -138,20 +119,10 @@
# TARGET_ARCH = { arm | x86 }
-# if we're build the simulator, HOST_* is TARGET_* (except for BUILD_TYPE)
-# otherwise it's <arch>-linux
-ifeq ($(TARGET_SIMULATOR),true)
-ifneq ($(HOST_OS),linux)
-$(error TARGET_SIMULATOR=true is only supported under Linux)
-endif
-TARGET_ARCH := $(HOST_ARCH)
-TARGET_OS := $(HOST_OS)
-else
ifeq ($(TARGET_ARCH),)
TARGET_ARCH := arm
endif
TARGET_OS := linux
-endif
# the target build type defaults to release
ifneq ($(TARGET_BUILD_TYPE),debug)
@@ -183,15 +154,7 @@
BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(BUILD_ARCH)
-ifeq ($(TARGET_SIMULATOR),true)
- # Any arch- or os-specific parts of the simulator (everything
- # under product/) are actually host-dependent.
- # But, the debug type is controlled by TARGET_BUILD_TYPE and not
- # HOST_BUILD_TYPE.
- TARGET_PRODUCT_OUT_ROOT := $(HOST_OUT_$(TARGET_BUILD_TYPE))/pr
-else
- TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
-endif
+TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
@@ -243,6 +206,14 @@
TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
+TARGET_OUT_VENDOR := $(PRODUCT_OUT)/system/vendor
+TARGET_OUT_VENDOR_EXECUTABLES:= $(TARGET_OUT_VENDOR)/bin
+TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES:= $(TARGET_OUT_VENDOR)/xbin
+TARGET_OUT_VENDOR_SHARED_LIBRARIES:= $(TARGET_OUT_VENDOR)/lib
+TARGET_OUT_VENDOR_JAVA_LIBRARIES:= $(TARGET_OUT_VENDOR)/framework
+TARGET_OUT_VENDOR_APPS:= $(TARGET_OUT_VENDOR)/app
+TARGET_OUT_VENDOR_ETC := $(TARGET_OUT_VENDOR)/etc
+
TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
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/find-jdk-tools-jar.sh b/core/find-jdk-tools-jar.sh
index ed0b127..e1278c3 100755
--- a/core/find-jdk-tools-jar.sh
+++ b/core/find-jdk-tools-jar.sh
@@ -5,9 +5,9 @@
if [ -z "$JAVAC" ] ; then
exit 1
fi
- while [ -L $JAVAC ] ; do
- LSLINE=$(ls -l $JAVAC)
- JAVAC=$(echo -n $LSLINE | sed -e "s/.* -> //")
+ while [ -L "$JAVAC" ] ; do
+ LSLINE=$(ls -l "$JAVAC")
+ JAVAC=$(echo -n "$LSLINE" | sed -e "s/.* -> //")
done
echo $JAVAC | sed -e "s:\(.*\)/bin/javac.*:\\1/lib/tools.jar:"
fi
diff --git a/core/host_native_test.mk b/core/host_native_test.mk
index 2a77f1e..a5d87e4 100644
--- a/core/host_native_test.mk
+++ b/core/host_native_test.mk
@@ -5,10 +5,9 @@
LOCAL_CFLAGS += -DGTEST_OS_LINUX -DGTEST_HAS_STD_STRING -O0 -g
LOCAL_C_INCLUDES += \
- bionic/libstdc++/include \
- external/gtest/include \
- external/astl/include
-LOCAL_STATIC_LIBRARIES += libgtest_host libgtest_main_host libastl_host
+ external/gtest/include
+
+LOCAL_STATIC_LIBRARIES += libgtest_host libgtest_main_host
LOCAL_SHARED_LIBRARIES +=
include $(BUILD_HOST_EXECUTABLE)
diff --git a/core/java.mk b/core/java.mk
index 464f772..1cde62b 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -29,7 +29,7 @@
endif
else
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
- LOCAL_JAVA_LIBRARIES := core core-junit ext framework $(LOCAL_JAVA_LIBRARIES)
+ LOCAL_JAVA_LIBRARIES := core core-junit ext framework filterfw $(LOCAL_JAVA_LIBRARIES)
endif
endif
@@ -135,6 +135,23 @@
RenderScript_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/RenderScript.stamp
renderscript_intermediate := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript
+renderscript_target_api :=
+
+ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
+renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
+else
+ifneq (,$(LOCAL_SDK_VERSION))
+# Set target-api for LOCAL_SDK_VERSIONs other than current.
+ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION)))
+renderscript_target_api := $(LOCAL_SDK_VERSION)
+endif
+endif # LOCAL_SDK_VERSION is set
+endif # LOCAL_RENDERSCRIPT_TARGET_API is set
+
+ifeq ($(LOCAL_RENDERSCRIPT_CC),)
+LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
+endif
+
# prepend the RenderScript system include path
ifneq ($(filter-out current,$(LOCAL_SDK_VERSION)),)
LOCAL_RENDERSCRIPT_INCLUDES := \
@@ -143,13 +160,13 @@
$(LOCAL_RENDERSCRIPT_INCLUDES)
else
LOCAL_RENDERSCRIPT_INCLUDES := \
- $(TOPDIR)external/clang/lib/Headers \
- $(TOPDIR)frameworks/base/libs/rs/scriptc \
- $(LOCAL_RENDERSCRIPT_INCLUDES)
+ $(TOPDIR)external/clang/lib/Headers \
+ $(TOPDIR)frameworks/base/libs/rs/scriptc \
+ $(LOCAL_RENDERSCRIPT_INCLUDES)
endif
-ifeq ($(LOCAL_RENDERSCRIPT_CC),)
-LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
+ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
+LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
endif
$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES)
@@ -158,6 +175,7 @@
# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
# automatically found by the java compiling function transform-java-to-classes.jar.
$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
+$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api)
$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
$(transform-renderscripts-to-java-and-bc)
@@ -331,17 +349,16 @@
ALL_MODULES.$(LOCAL_MODULE).PROGUARD_ENABLED:=$(LOCAL_PROGUARD_ENABLED)
+# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
+# will work even when intermediates != intermediates.COMMON.
+$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
+$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
# If you instrument class files that have local variable debug information in
# them emma does not correctly maintain the local variable table.
# This will cause an error when you try to convert the class files for Android.
# The workaround here is to build different dex file here based on emma switch
# then later copy into classes.dex. When emma is on, dx is run with --no-locals
# option to remove local variable information
-
-# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
-# will work even when intermediates != intermediates.COMMON.
-$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
-$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
ifneq ($(LOCAL_NO_EMMA_COMPILE),true)
$(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals
endif
diff --git a/core/java_library.mk b/core/java_library.mk
index dbf6981..23417d0 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -42,10 +42,13 @@
#################################
ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
-# No dex or resources; all we want are the .class files.
-$(common_javalib.jar) : $(full_classes_jar)
+# No dex; all we want are the .class files with resources.
+$(common_javalib.jar) : $(full_classes_jar) $(java_resource_sources)
@echo "target Static Jar: $(PRIVATE_MODULE) ($@)"
$(copy-file-to-target)
+ifneq ($(extra_jar_args),)
+ $(add-java-resources-to-package)
+endif
$(LOCAL_BUILT_MODULE): $(common_javalib.jar)
$(copy-file-to-target)
diff --git a/core/legacy_prebuilts.mk b/core/legacy_prebuilts.mk
index 6a999c1..41943b1 100644
--- a/core/legacy_prebuilts.mk
+++ b/core/legacy_prebuilts.mk
@@ -40,7 +40,6 @@
bp.img \
brcm_guci_drv \
bypassfactory \
- cacerts.bks \
cdt.bin \
chat-ril \
cmu6plus.ok.zip \
diff --git a/core/main.mk b/core/main.mk
index cd4aad2..6841b36 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -12,6 +12,13 @@
# this turns off the suffix rules built into make
.SUFFIXES:
+# this turns off the RCS / SCCS implicit rules of GNU Make
+% : RCS/%,v
+% : RCS/%
+% : %,v
+% : s.%
+% : SCCS/s.%
+
# If a rule fails, delete $@.
.DELETE_ON_ERROR:
@@ -73,17 +80,6 @@
$(info Checking build tools versions...)
-ifeq ($(BUILD_OS),linux)
-build_arch := $(shell uname -m)
-ifneq (64,$(findstring 64,$(build_arch)))
-$(warning ************************************************************)
-$(warning You are attempting to build on a 32-bit system.)
-$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
-$(warning ************************************************************)
-$(error stop)
-endif
-endif
-
ifneq ($(HOST_OS),windows)
ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
# check for a case sensitive file system
@@ -117,14 +113,17 @@
# Check for the correct version of java
-java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
+java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$$]')
+ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
+java_version :=
+endif
ifeq ($(strip $(java_version)),)
$(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of java.)
$(info $(space))
$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
-$(info The correct version is: 1.6.)
+$(info The correct version is: Java SE 1.6.)
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)http://source.android.com/source/download.html)
@@ -235,13 +234,15 @@
enable_target_debugging :=
endif
- # TODO: Remove this and the corresponding block in
- # config/product_config.make once host-based Dalvik preoptimization is
- # working.
+ # Turn on Dalvik preoptimization for user builds, but only if not
+ # explicitly disabled and the build is running on Linux (since host
+ # Dalvik isn't built for non-Linux hosts).
ifneq (true,$(DISABLE_DEXPREOPT))
- ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
- WITH_DEXPREOPT := true
- endif
+ ifeq ($(user_variant),user)
+ ifeq ($(HOST_OS),linux)
+ WITH_DEXPREOPT := true
+ endif
+ endif
endif
# Disallow mock locations by default for user builds
@@ -258,12 +259,12 @@
ifeq (true,$(strip $(enable_target_debugging)))
# Target is more debuggable and adbd is on by default
- ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
# Include the debugging/testing OTA keys in this build.
INCLUDE_TEST_OTA_KEYS := true
else # !enable_target_debugging
# Target is less debuggable and adbd is off by default
- ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
endif # !enable_target_debugging
## eng ##
@@ -403,6 +404,7 @@
development/host \
development/tools/etc1tool \
development/tools/line_endings \
+ development/tools/emulator/opengl \
external/clang \
external/easymock \
external/expat \
@@ -413,6 +415,7 @@
external/zlib \
frameworks/base \
frameworks/compile \
+ sdk/avdlauncher \
sdk/emulator/mksdcard \
sdk/sdklauncher \
system/core/adb \
@@ -431,6 +434,7 @@
sdk/archquery \
sdk/androidprefs \
sdk/apkbuilder \
+ sdk/assetstudio \
sdk/common \
sdk/ddms \
sdk/hierarchyviewer2 \
@@ -439,8 +443,11 @@
sdk/layoutlib_api \
sdk/layoutopt \
sdk/ninepatch \
+ sdk/rule_api \
sdk/sdkstats \
sdk/sdkmanager \
+ sdk/swtmenubar \
+ sdk/traceview \
development/apps \
development/tools/mkstubs \
packages
@@ -456,7 +463,7 @@
else # !SDK_ONLY
ifeq ($(BUILD_TINY_ANDROID), true)
-# TINY_ANDROID is a super-minimal build configuration, handy for board
+# TINY_ANDROID is a super-minimal build configuration, handy for board
# bringup and very low level debugging
subdirs := \
@@ -467,10 +474,7 @@
build/libs \
build/target \
build/tools/acp \
- build/tools/apriori \
- build/tools/soslim \
- external/elfcopy \
- external/elfutils \
+ external/mksh \
external/yaffs2 \
external/zlib
else # !BUILD_TINY_ANDROID
@@ -818,9 +822,10 @@
sdk: $(ALL_SDK_TARGETS)
ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
$(call dist-for-goals,sdk win_sdk, \
- $(ALL_SDK_TARGETS) \
- $(SYMBOLS_ZIP) \
- )
+ $(ALL_SDK_TARGETS) \
+ $(SYMBOLS_ZIP) \
+ $(INSTALLED_BUILD_PROP_TARGET) \
+)
endif
.PHONY: samplecode
diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk
index 7602673..50a4a38 100644
--- a/core/multi_prebuilt.mk
+++ b/core/multi_prebuilt.mk
@@ -22,6 +22,7 @@
prebuilt_static_java_libraries := $(LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES)
prebuilt_is_host := $(LOCAL_IS_HOST_MODULE)
prebuilt_module_tags := $(LOCAL_MODULE_TAGS)
+prebuilt_strip_module := $(LOCAL_STRIP_MODULE)
ifndef multi_prebuilt_once
@@ -34,6 +35,7 @@
# $(5): OVERRIDE_BUILT_MODULE_PATH
# $(6): UNINSTALLABLE_MODULE
# $(7): BUILT_MODULE_STEM
+# $(8): LOCAL_STRIP_MODULE
#
# Elements in the file list may be bare filenames,
# or of the form "<modulename>:<filename>".
@@ -65,6 +67,8 @@
$(eval LOCAL_BUILT_MODULE_STEM := $(notdir $(LOCAL_SRC_FILES))) \
) \
$(eval LOCAL_MODULE_SUFFIX := $(suffix $(LOCAL_SRC_FILES))) \
+ $(if $(filter user,$(TARGET_BUILD_VARIANT)), \
+ $(eval LOCAL_STRIP_MODULE := $(8))) \
$(eval include $(BUILD_PREBUILT)) \
)
endef
@@ -85,7 +89,10 @@
$(prebuilt_is_host), \
SHARED_LIBRARIES, \
$(prebuilt_module_tags), \
- $($(if $(prebuilt_is_host),HOST,TARGET)_OUT_INTERMEDIATE_LIBRARIES))
+ $($(if $(prebuilt_is_host),HOST,TARGET)_OUT_INTERMEDIATE_LIBRARIES), \
+ , \
+ , \
+ $(prebuilt_strip_module))
$(call auto-prebuilt-boilerplate, \
$(prebuilt_executables), \
diff --git a/core/notice_files.mk b/core/notice_files.mk
index fd76d51..74beb49 100644
--- a/core/notice_files.mk
+++ b/core/notice_files.mk
@@ -2,9 +2,9 @@
## Track NOTICE files
###########################################################
-notice_file:=$(shell find $(LOCAL_PATH) -maxdepth 1 -name NOTICE)
+notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
-ifneq ($(strip $(notice_file)),)
+ifdef notice_file
# This relies on the name of the directory in PRODUCT_OUT matching where
# it's installed on the target - i.e. system, data, etc. This does
diff --git a/core/package.mk b/core/package.mk
index 8ca9033..398e487 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -19,7 +19,7 @@
##
## Additional inputs from base_rules.make:
## LOCAL_PACKAGE_NAME: The name of the package; the directory
-## will be called this.
+## will be called this.
##
## MODULE, MODULE_PATH, and MODULE_SUFFIX will
## be set for you.
@@ -161,9 +161,21 @@
include $(BUILD_SYSTEM)/java.mk
#################################
+LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
+ifeq ($(LOCAL_SDK_RES_VERSION),)
+ LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
+endif
+
full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
$(LOCAL_INTERMEDIATE_TARGETS): \
- PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+ PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION)))
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+endif
ifneq ($(all_resources),)
@@ -192,15 +204,15 @@
-name Manifest.java 2> /dev/null`; do \
dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \
mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
- $(ACP) -fpt $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+ $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
done;
$(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
-name R.java 2> /dev/null`; do \
dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \
mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
- $(ACP) -fpt $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
+ $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
|| exit 31; \
- $(ACP) -fpt $$GENERATED_R_FILE $@ || exit 32; \
+ $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
done; \
$(proguard_options_file): $(R_file_stamp)
@@ -214,7 +226,7 @@
# add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target
# can't know anything about PRODUCT. Clear it out just for this target.
-$(resource_export_package): PRODUCT_AAPT_CONFIG :=
+$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT)
@echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
$(create-empty-package)
@@ -233,7 +245,7 @@
$(full_classes_compiled_jar): $(R_file_stamp)
endif
-endif # all_resources
+endif # all_resources
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
# We need to explicitly clear this var so that we don't
@@ -243,23 +255,23 @@
# Most packages should link against the resources defined by framework-res.
# Even if they don't have their own resources, they may use framework
# resources.
-ifneq ($(filter-out current,$(LOCAL_SDK_VERSION)),)
+ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION)),)
# for released sdk versions, the platform resources were built into android.jar.
framework_res_package_export := \
- $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/android.jar
+ $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
framework_res_package_export_deps := $(framework_res_package_export)
-else # LOCAL_SDK_VERSION
+else # LOCAL_SDK_RES_VERSION
framework_res_package_export := \
- $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
+ $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
# We can't depend directly on the export.apk file; it won't get its
# PRIVATE_ vars set up correctly if we do. Instead, depend on the
# corresponding R.stamp file, which lists the export.apk as a dependency.
framework_res_package_export_deps := \
- $(dir $(framework_res_package_export))src/R.stamp
-endif # LOCAL_SDK_VERSION
+ $(dir $(framework_res_package_export))src/R.stamp
+endif # LOCAL_SDK_RES_VERSION
$(R_file_stamp): $(framework_res_package_export_deps)
$(LOCAL_INTERMEDIATE_TARGETS): \
- PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
+ PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
endif # LOCAL_NO_STANDARD_LIBRARIES
ifneq ($(full_classes_jar),)
@@ -292,20 +304,20 @@
# Secure release builds will have their packages signed after the fact,
# so it's ok for these private keys to be in the clear.
ifeq ($(LOCAL_CERTIFICATE),)
- LOCAL_CERTIFICATE := testkey
+ LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
endif
ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
# The special value "EXTERNAL" means that we will sign it with the
- # default testkey, apply predexopt, but then expect the final .apk
+ # default devkey, apply predexopt, but then expect the final .apk
# (after dexopting) to be signed by an outside tool.
- LOCAL_CERTIFICATE := testkey
+ LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1
endif
# If this is not an absolute certificate, assign it to a generic one.
ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
- LOCAL_CERTIFICATE := $(SRC_TARGET_DIR)/product/security/$(LOCAL_CERTIFICATE)
+ LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
endif
private_key := $(LOCAL_CERTIFICATE).pk8
certificate := $(LOCAL_CERTIFICATE).x509.pem
@@ -330,7 +342,9 @@
LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
endif
ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
- $(LOCAL_BUILT_MODULE): PRODUCT_AAPT_CONFIG :=
+ $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
+else
+ $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
endif
$(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
@echo "target Package: $(PRIVATE_MODULE) ($@)"
diff --git a/core/pathmap.mk b/core/pathmap.mk
index 428594f..6c6ff2e 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -48,7 +48,8 @@
libthread_db:bionic/libthread_db/include \
mkbootimg:system/core/mkbootimg \
recovery:bootable/recovery \
- system-core:system/core/include
+ system-core:system/core/include \
+ speex:external/speex/include
#
# Returns the path to the requested module's include directory,
@@ -87,7 +88,6 @@
sax \
telephony \
wifi \
- vpn \
keystore \
icu4j \
voip \
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index 8f9eafb..54a7fa9 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -16,17 +16,33 @@
$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
endif
-ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
-ifeq (true,$(WITH_DEXPREOPT))
-ifeq (,$(TARGET_BUILD_APPS))
-ifndef LOCAL_DEX_PREOPT
-LOCAL_DEX_PREOPT := true
+ifdef LOCAL_IS_HOST_MODULE
+ my_prefix:=HOST_
+else
+ my_prefix:=TARGET_
endif
-endif
-endif
+ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
+ # Put the built targets of all shared libraries in a common directory
+ # to simplify the link line.
+ OVERRIDE_BUILT_MODULE_PATH := $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
endif
-include $(BUILD_SYSTEM)/base_rules.mk
+ifeq ($(LOCAL_STRIP_MODULE),true)
+ ifdef LOCAL_IS_HOST_MODULE
+ $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
+ endif
+ ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
+ $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
+ endif
+ ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
+ $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
+ endif
+ include $(BUILD_SYSTEM)/dynamic_binary.mk
+ built_module := $(linked_module)
+else
+ include $(BUILD_SYSTEM)/base_rules.mk
+ built_module := $(LOCAL_BUILT_MODULE)
+endif
# Deal with the OSX library timestamp issue when installing
# a prebuilt simulator library.
@@ -38,59 +54,18 @@
PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
-# Ensure that prebuilt .apks have been aligned.
-ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
-ifeq ($(LOCAL_DEX_PREOPT),true)
-# Make sure the boot jars get dexpreopt-ed first
-$(LOCAL_BUILT_MODULE): $(DEXPREOPT_BOOT_ODEXS) | $(DEXPREOPT) $(DEXOPT) $(AAPT)
-endif
-$(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ZIPALIGN)
- $(transform-prebuilt-to-target-with-zipalign)
-ifeq ($(LOCAL_DEX_PREOPT),true)
- $(hide) rm -f $(patsubst %.apk,%.odex,$@)
- $(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
- $(call dexpreopt-remove-classes.dex,$@)
-
-built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
-$(built_odex): $(LOCAL_BUILT_MODULE)
-endif
-else
-ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
-$(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
- $(transform-prebuilt-to-target-strip-comments)
-else
-$(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
- $(transform-prebuilt-to-target)
-endif
-endif
-
-ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
-# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
-# while the deps should be in the common dir, so we make a copy in the common dir.
-# For nonstatic library, $(common_javalib_jar) is the dependency file,
-# while $(common_classes_jar) is used to link.
-common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
-common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
-
-$(common_classes_jar) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
- $(transform-prebuilt-to-target)
-
-$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
- $(transform-prebuilt-to-target)
-
-# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
-$(LOCAL_BUILT_MODULE) : $(common_javalib_jar)
-endif # TARGET JAVA_LIBRARIES
-
ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
# The magic string "EXTERNAL" means this package will be signed with
- # the test key throughout the build process, but we expect the final
- # package to be signed with a different key.
+ # the default dev key throughout the build process, but we expect
+ # the final package to be signed with a different key.
#
# This can be used for packages where we don't have access to the
# keys, but want the package to be predexopt'ed.
- LOCAL_CERTIFICATE := testkey
+ LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
+
+ $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+ $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
endif
ifeq ($(LOCAL_CERTIFICATE),)
ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
@@ -110,14 +85,57 @@
else
# If this is not an absolute certificate, assign it to a generic one.
ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
- LOCAL_CERTIFICATE := $(SRC_TARGET_DIR)/product/security/$(LOCAL_CERTIFICATE)
+ LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
endif
PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
+
+ $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+ $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
endif
+ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
+ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
+# Ensure that presigned .apks have been aligned.
+$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ZIPALIGN)
+ $(transform-prebuilt-to-target-with-zipalign)
+else
+# Sign and align non-presigned .apks.
+$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
+ $(transform-prebuilt-to-target)
+ $(sign-package)
+ $(align-package)
+endif
+else
+ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
+$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
+ $(transform-prebuilt-to-target-strip-comments)
+else
+$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
+ $(transform-prebuilt-to-target)
+endif
+endif
+
+ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
+# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
+# while the deps should be in the common dir, so we make a copy in the common dir.
+# For nonstatic library, $(common_javalib_jar) is the dependency file,
+# while $(common_classes_jar) is used to link.
+common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
+common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
+
+$(common_classes_jar) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
+ $(transform-prebuilt-to-target)
+
+$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
+ $(transform-prebuilt-to-target)
+
+# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
+$(built_module) : $(common_javalib_jar)
+endif # TARGET JAVA_LIBRARIES
+
ifneq ($(prebuilt_module_is_a_library),)
ifneq ($(LOCAL_IS_HOST_MODULE),)
$(transform-host-ranlib-copy-hack)
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 c2b398e..72cb2f7 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -63,11 +63,13 @@
PRODUCT_NAME \
PRODUCT_MODEL \
PRODUCT_LOCALES \
+ PRODUCT_AAPT_CONFIG \
PRODUCT_PACKAGES \
PRODUCT_DEVICE \
PRODUCT_MANUFACTURER \
PRODUCT_BRAND \
PRODUCT_PROPERTY_OVERRIDES \
+ PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
PRODUCT_CHARACTERISTICS \
PRODUCT_COPY_FILES \
PRODUCT_OTA_PUBLIC_KEYS \
@@ -80,7 +82,9 @@
PRODUCT_SDK_ADDON_COPY_FILES \
PRODUCT_SDK_ADDON_COPY_MODULES \
PRODUCT_SDK_ADDON_DOC_MODULE \
- PRODUCT_DEFAULT_WIFI_CHANNELS
+ PRODUCT_DEFAULT_WIFI_CHANNELS \
+ PRODUCT_DEFAULT_DEV_CERTIFICATE \
+
define dump-product
$(info ==== $(1) ====)\
@@ -197,7 +201,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 \
@@ -231,6 +234,9 @@
BOARD_INSTALLER_CMDLINE \
+_product_stash_var_list += \
+ DEFAULT_SYSTEM_DEV_CERTIFICATE
+
#
# Stash vaues of the variables in _product_stash_var_list.
# $(1): Renamed prefix
diff --git a/core/product_config.mk b/core/product_config.mk
index 4f4f97d..e673d5c 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -112,8 +112,8 @@
# The build server wants to do make PRODUCT-dream-installclean
# which really means TARGET_PRODUCT=dream make installclean.
ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
- MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT)
- TARGET_BUILD_VARIANT := eng
+ MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT)
+ TARGET_BUILD_VARIANT := eng
default_goal_substitution :=
else
default_goal_substitution := $(DEFAULT_GOAL)
@@ -124,15 +124,6 @@
default_goal_substitution := tests-build-target
endif
- # Hack to make the linux build servers use dexpreopt (emulator-based
- # preoptimization). Most engineers don't use this type of target
- # ("make PRODUCT-blah-user"), so this should only tend to happen when
- # using buildbot.
- # TODO: Remove this once host Dalvik preoptimization is working.
- ifeq ($(TARGET_BUILD_VARIANT),user)
- WITH_DEXPREOPT_buildbot := true
- endif
-
# Replace the PRODUCT-* goal with the build goal that it refers to.
# Note that this will ensure that it appears in the same relative
# position, in case it matters.
@@ -172,6 +163,14 @@
$(unbundled_goals): $(MAKECMDGOALS)
endif # unbundled_goals
+# Default to building dalvikvm on hosts that support it...
+ifeq ($(HOST_OS),linux)
+# ... or if the if the option is already set
+ifeq ($(WITH_HOST_DALVIK),)
+ WITH_HOST_DALVIK := true
+endif
+endif
+
# ---------------------------------------------------------------
# Include the product definitions.
# We need to do this to translate TARGET_PRODUCT into its
@@ -226,22 +225,23 @@
extra_locales :=
endif
+# Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG
+PRODUCT_AAPT_CONFIG := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_CONFIG))
+PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) $(PRODUCT_AAPT_CONFIG)
+
# Default to medium-density assets.
-# (Can be overridden in the device config, e.g.: PRODUCT_LOCALES += hdpi)
-PRODUCT_LOCALES := $(strip \
- $(PRODUCT_LOCALES) \
- $(if $(filter %dpi,$(PRODUCT_LOCALES)),,mdpi))
+# (Can be overridden in the device config, e.g.: PRODUCT_AAPT_CONFIG += hdpi)
+PRODUCT_AAPT_CONFIG := $(strip \
+ $(PRODUCT_AAPT_CONFIG) \
+ $(if $(filter %dpi,$(PRODUCT_AAPT_CONFIG)),,mdpi))
# Everyone gets nodpi assets which are density-independent.
-PRODUCT_LOCALES += nodpi
-
-# Assemble the list of options.
-PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES)
+PRODUCT_AAPT_CONFIG += nodpi
# Convert spaces to commas.
comma := ,
PRODUCT_AAPT_CONFIG := \
- $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG)))
+ $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG)))
PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))
@@ -251,7 +251,7 @@
endif
PRODUCT_MANUFACTURER := \
- $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER))
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER))
ifndef PRODUCT_MANUFACTURER
PRODUCT_MANUFACTURER := unknown
endif
@@ -263,7 +263,16 @@
endif
PRODUCT_DEFAULT_WIFI_CHANNELS := \
- $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_WIFI_CHANNELS))
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_WIFI_CHANNELS))
+
+PRODUCT_DEFAULT_DEV_CERTIFICATE := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_DEV_CERTIFICATE))
+ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
+ifneq (1,$(words $(PRODUCT_DEFAULT_DEV_CERTIFICATE)))
+ $(error PRODUCT_DEFAULT_DEV_CERTIFICATE='$(PRODUCT_DEFAULT_DEV_CERTIFICATE)', \
+ only 1 certificate is allowed.)
+endif
+endif
# A list of words like <source path>:<destination path>. The file at
# the source path should be copied to the destination path when building
@@ -271,20 +280,26 @@
# it should look like, e.g., "system/etc/file.xml". The rules
# for these copy steps are defined in config/Makefile.
PRODUCT_COPY_FILES := \
- $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES))
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES))
# The HTML file containing the contributors to the project.
PRODUCT_CONTRIBUTORS_FILE := \
- $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CONTRIBUTORS_FILE))
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CONTRIBUTORS_FILE))
# A list of property assignments, like "key = value", with zero or more
# whitespace characters on either side of the '='.
PRODUCT_PROPERTY_OVERRIDES := \
- $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
+
+# A list of property assignments, like "key = value", with zero or more
+# whitespace characters on either side of the '='.
+# used for adding properties to default.prop
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
# Should we use the default resources or add any product specific overlays
PRODUCT_PACKAGE_OVERLAYS := \
- $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
DEVICE_PACKAGE_OVERLAYS := \
$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS))
@@ -293,8 +308,8 @@
# Add the product-defined properties to the build properties.
ADDITIONAL_BUILD_PROPERTIES := \
- $(ADDITIONAL_BUILD_PROPERTIES) \
- $(PRODUCT_PROPERTY_OVERRIDES)
+ $(ADDITIONAL_BUILD_PROPERTIES) \
+ $(PRODUCT_PROPERTY_OVERRIDES)
# The OTA key(s) specified by the product config, if any. The names
# of these keys are stored in the target-files zip so that post-build
@@ -305,14 +320,3 @@
PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))
-
-
-# ---------------------------------------------------------------
-# Simulator overrides
-ifeq ($(TARGET_PRODUCT),sim)
- # Tell the build system to turn on some special cases
- # to deal with the simulator product.
- TARGET_SIMULATOR := true
- # dexpreopt doesn't work when building the simulator
- DISABLE_DEXPREOPT := true
-endif
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 940fe61..ca639eb 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
@@ -34,8 +31,12 @@
my_target_crtbegin_so_o := $(TARGET_CRTBEGIN_SO_O)
my_target_crtend_so_o := $(TARGET_CRTEND_SO_O)
ifdef LOCAL_NDK_VERSION
-my_target_global_ld_dirs += $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
- $(my_ndk_version_root)/usr/lib)
+# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
+# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
+my_target_global_ld_dirs := \
+ $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
+ $(my_ndk_version_root)/usr/lib) \
+ $(my_target_global_ld_dirs)
my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
my_target_crtbegin_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_so.o)
my_target_crtend_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtend_so.o)
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
index 99a3227..96e0f44 100644
--- a/core/tasks/apicheck.mk
+++ b/core/tasks/apicheck.mk
@@ -19,24 +19,20 @@
ifneq ($(BUILD_TINY_ANDROID), true)
-APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
-APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
-APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
-
.PHONY: checkapi
# eval this to define a rule that runs apicheck.
#
# Args:
# $(1) target
-# $(2) stable api xml file
-# $(3) api xml file to be tested
+# $(2) stable api file
+# $(3) api file to be tested
# $(4) arguments for apicheck
# $(5) command to run if apicheck failed
define check-api
$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK)
@echo "Checking API:" $(1)
- $(hide) ( $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)" $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
+ $(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
$(hide) mkdir -p $$(dir $$@)
$(hide) touch $$@
checkapi: $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
@@ -45,10 +41,11 @@
# Run the checkapi rules by default.
droidcore: checkapi
-last_released_sdk_version := $(lastword $(call numerically_sort,\
- $(patsubst $(SRC_API_DIR)/%.xml,%, \
- $(filter-out $(SRC_API_DIR)/current.xml, \
- $(wildcard $(SRC_API_DIR)/*.xml)))))
+last_released_sdk_version := $(lastword $(call numerically_sort, \
+ $(filter-out $(SRC_API_DIR)/current, \
+ $(patsubst $(SRC_API_DIR)/%.txt,%, $(wildcard $(SRC_API_DIR)/*.txt)) \
+ )\
+ ))
# INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
@@ -56,7 +53,7 @@
# SDK version.
$(eval $(call check-api, \
checkapi-last, \
- $(SRC_API_DIR)/$(last_released_sdk_version).xml, \
+ $(SRC_API_DIR)/$(last_released_sdk_version).txt, \
$(INTERNAL_PLATFORM_API_FILE), \
-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \
-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
@@ -68,7 +65,7 @@
# SDK version.
$(eval $(call check-api, \
checkapi-current, \
- $(SRC_API_DIR)/current.xml, \
+ $(SRC_API_DIR)/current.txt, \
$(INTERNAL_PLATFORM_API_FILE), \
-error 2 -error 3 -error 4 -error 5 -error 6 \
-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
@@ -79,7 +76,7 @@
.PHONY: update-api
update-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
- @echo Copying current.xml
- $(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.xml
+ @echo Copying current.txt
+ $(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.txt
endif
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 8d7667b..af20da8 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -34,12 +34,12 @@
CTS_TF_README_PATH := $(cts_tools_src_dir)/tradefed-host/README
CTS_CORE_CASE_LIST := \
- android.core.tests.dom \
- android.core.tests.luni.io \
- android.core.tests.luni.lang \
- android.core.tests.luni.net \
- android.core.tests.luni.util \
- android.core.tests.xml \
+ android.core.tests.libcore.package.dalvik \
+ android.core.tests.libcore.package.com \
+ android.core.tests.libcore.package.sun \
+ android.core.tests.libcore.package.tests \
+ android.core.tests.libcore.package.org \
+ android.core.tests.libcore.package.libcore \
android.core.tests.runner
-include cts/CtsTestCaseList.mk
@@ -72,58 +72,62 @@
# Parameters:
# $1 : The output file where the description should be written (without the '.xml' extension)
# $2 : The AndroidManifest.xml corresponding to the test package
-# $3 : The name of the TestSuite generator class to use
-# $4 : The directory containing vogar expectations files
-# $5 : The Android.mk corresponding to the test package (required for host-side tests only)
+# $3 : The jar file name on PRIVATE_CLASSPATH containing junit tests to search for
+# $4 : The package prefix of classes to include, possible empty
+# $5 : The directory containing vogar expectations files
+# $6 : The Android.mk corresponding to the test package (required for host-side tests only)
define generate-core-test-description
@echo "Generate core-test description ("$(notdir $(1))")"
-$(hide) java $(PRIVATE_JAVAOPTS) \
- -classpath $(PRIVATE_CLASSPATH) \
- $(PRIVATE_PARAMS) CollectAllTests $(1) \
- $(2) $(3) $(4) $(5)
+$(hide) java -Xmx256M \
+ -classpath $(PRIVATE_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR) \
+ $(PRIVATE_PARAMS) CollectAllTests $(1) $(2) $(3) "$(4)" $(5) $(6)
endef
CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
+BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
+APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
+SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
-RUNNER_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junitrunner,,COMMON)
-SUPPORT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-support,,COMMON)
-DOM_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-dom,,COMMON)
-XML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-xml,,COMMON)
-TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
-GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(RUNNER_INTERMEDIATES)/classes.jar:$(SUPPORT_INTERMEDIATES)/classes.jar:$(DOM_INTERMEDIATES)/classes.jar:$(XML_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/javalib.jar:$(JUNIT_INTERMEDIATES)/javalib.jar:$(RUNNER_INTERMEDIATES)/javalib.jar:$(SUPPORT_INTERMEDIATES)/javalib.jar:$(DOM_INTERMEDIATES)/javalib.jar:$(XML_INTERMEDIATES)/javalib.jar:$(TESTS_INTERMEDIATES)/javalib.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR)
+CORETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
+
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar
$(cts_dir)/all_cts_core_files_stamp: PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
-$(cts_dir)/all_cts_core_files_stamp: PRIVATE_JAVAOPTS:=-Xmx256M
-$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true
-$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true
# Why does this depend on javalib.jar instead of classes.jar? Because
# even though the tool will operate on the classes.jar files, the
# build system requires that dependencies use javalib.jar. If
# javalib.jar is up-to-date, then classes.jar is as well. Depending
# on classes.jar will build the files incorrectly.
-$(cts_dir)/all_cts_core_files_stamp: $(CTS_CORE_CASE_LIST) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(RUNNER_INTERMEDIATES)/javalib.jar $(SUPPORT_INTERMEDIATES)/javalib.jar $(DOM_INTERMEDIATES)/javalib.jar $(XML_INTERMEDIATES)/javalib.jar $(TESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp | $(ACP)
- $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.dom,\
- cts/tests/core/dom/AndroidManifest.xml,\
- tests.dom.AllTests, libcore/expectations)
- $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.io,\
- cts/tests/core/luni-io/AndroidManifest.xml,\
- tests.luni.AllTestsIo, libcore/expectations)
- $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.lang,\
- cts/tests/core/luni-lang/AndroidManifest.xml,\
- tests.luni.AllTestsLang, libcore/expectations)
- $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.net,\
- cts/tests/core/luni-net/AndroidManifest.xml,\
- tests.luni.AllTestsNet, libcore/expectations)
- $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.util,\
- cts/tests/core/luni-util/AndroidManifest.xml,\
- tests.luni.AllTestsUtil, libcore/expectations)
- $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.xml,\
- cts/tests/core/xml/AndroidManifest.xml,\
- tests.xml.AllTests, libcore/expectations)
+$(cts_dir)/all_cts_core_files_stamp: $(CTS_CORE_CASE_LIST) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp | $(ACP)
+ $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.dalvik,\
+ cts/tests/core/libcore/dalvik/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,dalvik,\
+ libcore/expectations)
+ $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.com,\
+ cts/tests/core/libcore/com/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,com,\
+ libcore/expectations)
+ $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.sun,\
+ cts/tests/core/libcore/sun/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,sun,\
+ libcore/expectations)
+ $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.tests,\
+ cts/tests/core/libcore/tests/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,tests,\
+ libcore/expectations)
+ $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.org,\
+ cts/tests/core/libcore/org/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org,\
+ libcore/expectations)
+ $(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.libcore,\
+ cts/tests/core/libcore/libcore/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,libcore,\
+ libcore/expectations)
$(hide) touch $@
# ----- Generate the test descriptions for the vm-tests -----
+# TODO: remove this section once cts-tf replaces cts.
#
CORE_VM_TEST_DESC := $(cts_dir)/$(cts_name)/repository/testcases/android.core.vm-tests
@@ -131,22 +135,41 @@
# core tests only needed to get hold of junit-framework-classes
CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
-RUNNER_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junitrunner,,COMMON)
-TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
-GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(RUNNER_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOSTTESTLIB_JAR):$(DDMLIB_JAR):$(HOST_JDK_TOOLS_JAR)
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar:$(HOSTTESTLIB_JAR):$(DDMLIB_JAR)
$(CORE_VM_TEST_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
-$(CORE_VM_TEST_DESC): PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true
-$(CORE_VM_TEST_DESC): PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true
-$(CORE_VM_TEST_DESC): PRIVATE_JAVAOPTS:=-Xmx256M
# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
-$(CORE_VM_TEST_DESC): vm-tests $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(RUNNER_INTERMEDIATES)/javalib.jar $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(TESTS_INTERMEDIATES)/javalib.jar $(HOSTTESTLIB_JAR) $(DDMLIB_JAR) $(cts_dir)/all_cts_files_stamp | $(ACP)
+$(CORE_VM_TEST_DESC): vm-tests $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(HOSTTESTLIB_JAR) $(DDMLIB_JAR) $(cts_dir)/all_cts_files_stamp | $(ACP)
$(call generate-core-test-description,$(CORE_VM_TEST_DESC),\
cts/tests/vm-tests/AndroidManifest.xml,\
- dot.junit.AllJunitHostTests, libcore/expectations, cts/tools/vm-tests/Android.mk)
+ $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar,"",\
+ libcore/expectations,\
+ cts/tools/vm-tests/Android.mk)
$(ACP) -fv $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(PRIVATE_DIR)/repository/testcases/android.core.vm-tests.jar
+# ----- Generate the test descriptions for the vm-tests-tf -----
+#
+CORE_VM_TEST_TF_DESC := $(cts_dir)/$(cts_name)/repository/testcases/android.core.vm-tests-tf
+
+VMTESTSTF_INTERMEDIATES :=$(call intermediates-dir-for,EXECUTABLES,vm-tests-tf,1,)
+# core tests only needed to get hold of junit-framework-classes
+CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
+JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
+
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar:$(DDMLIB_JAR):$(TF_JAR)
+
+$(CORE_VM_TEST_TF_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
+# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
+$(CORE_VM_TEST_TF_DESC): $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar $(DDMLIB_JAR) $(cts_dir)/all_cts_files_stamp | $(ACP)
+ $(call generate-core-test-description,$(CORE_VM_TEST_TF_DESC),\
+ cts/tests/vm-tests-tf/AndroidManifest.xml,\
+ $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar,"",\
+ libcore/expectations,\
+ cts/tools/vm-tests-tf/Android.mk)
+ $(ACP) -fv $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar $(PRIVATE_DIR)/repository/testcases/android.core.vm-tests-tf.jar
+
+
# Move app security host-side tests to the repository
APP_SECURITY_LIB := $(cts_dir)/$(cts_name)/repository/testcases/CtsAppSecurityTests.jar
@@ -155,7 +178,7 @@
# Generate the default test plan for User.
# Usage: buildCts.py <testRoot> <ctsOutputDir> <tempDir> <androidRootDir> <docletPath>
-$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_dir)/all_cts_core_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(CORE_VM_TEST_DESC) $(APP_SECURITY_LIB) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
+$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_dir)/all_cts_core_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(CORE_VM_TEST_TF_DESC) $(CORE_VM_TEST_DESC) $(APP_SECURITY_LIB) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
$(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \
$(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk
index afcda23..f3aec65 100644
--- a/core/tasks/sdk-addon.mk
+++ b/core/tasks/sdk-addon.mk
@@ -55,10 +55,11 @@
# All SDK add-ons have these files
files_to_copy += \
- $(BUILT_SYSTEMIMAGE):images/system.img \
- $(BUILT_USERDATAIMAGE_TARGET):images/userdata.img \
- $(BUILT_RAMDISK_TARGET):images/ramdisk.img \
- $(target_notice_file_txt):images/NOTICE.txt
+ $(BUILT_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \
+ $(BUILT_USERDATAIMAGE_TARGET):images/$(TARGET_CPU_ABI)/userdata.img \
+ $(BUILT_RAMDISK_TARGET):images/$(TARGET_CPU_ABI)/ramdisk.img \
+ $(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \
+ $(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt
# Generate rules to copy the requested files
$(foreach cf,$(files_to_copy), \
@@ -110,4 +111,3 @@
$(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one)
endif
endif # addon_name
-
diff --git a/core/user_tags.mk b/core/user_tags.mk
index 120a502..d09a2cd 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 \
@@ -70,7 +69,6 @@
check_stack \
check_trace \
cmu2nuance \
- com.android.inputmethod.pinyin.lib \
com.android.phone.common \
com.android.vcard \
commons-compress-1.0 \
@@ -154,8 +152,6 @@
init \
input \
ip \
- iself \
- isprelinked \
jarjar \
javax.obex \
jcommon-1.0.12 \
@@ -220,7 +216,6 @@
libeffects \
libEGL \
libelf \
- libelfcopy \
libESR_Portable \
libESR_Shared \
libETC1 \
@@ -258,7 +253,6 @@
libiptc \
libjnigraphics \
libjni_latinime \
- libjni_pinyinime \
libjpeg \
libjs \
liblinenoise \
@@ -479,8 +473,6 @@
signapk \
signature-tools \
simg2img \
- simulator \
- soslim \
spec-progress \
sqlite3 \
stack_dump \
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index ef85f84..6773635 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -41,7 +41,7 @@
# which is the version that we reveal to the end user.
# Update this value when the platform version changes (rather
# than overriding it somewhere else). Can be an arbitrary string.
- PLATFORM_VERSION := 3.2.2
+ PLATFORM_VERSION := 4.0.1
endif
ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -53,7 +53,7 @@
# intermediate builds). During development, this number remains at the
# SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
# the code-name of the new development work.
- PLATFORM_SDK_VERSION := 13
+ PLATFORM_SDK_VERSION := 14
endif
ifeq "" "$(PLATFORM_VERSION_CODENAME)"
diff --git a/envsetup.sh b/envsetup.sh
index 24c4386..bab2d25 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -54,8 +54,9 @@
return
fi
CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
- TARGET_PRODUCT=$1 TARGET_BUILD_VARIANT= \
- TARGET_SIMULATOR= TARGET_BUILD_TYPE= \
+ TARGET_PRODUCT=$1 \
+ TARGET_BUILD_VARIANT= \
+ TARGET_BUILD_TYPE= \
TARGET_BUILD_APPS= \
get_build_var TARGET_DEVICE > /dev/null
# hide successful answers, but allow the errors to show
@@ -95,31 +96,47 @@
# #
##################################################################
+ # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
+ # due to "C:\Program Files" being in the path.
+
# out with the old
- if [ -n $ANDROID_BUILD_PATHS ] ; then
+ if [ -n "$ANDROID_BUILD_PATHS" ] ; then
export PATH=${PATH/$ANDROID_BUILD_PATHS/}
fi
- if [ -n $ANDROID_PRE_BUILD_PATHS ] ; then
+ if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
+ # strip trailing ':', if any
+ export PATH=${PATH/%:/}
fi
# and in with the new
CODE_REVIEWS=
prebuiltdir=$(getprebuilt)
- export ANDROID_EABI_TOOLCHAIN=$prebuiltdir/toolchain/arm-linux-androideabi-4.4.x/bin
- export ARM_EABI_TOOLCHAIN=$prebuiltdir/toolchain/arm-eabi-4.4.3/bin
+
+ # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
+ export ANDROID_EABI_TOOLCHAIN=
+ toolchaindir=toolchain/arm-linux-androideabi-4.4.x/bin
+ if [ -d "$prebuiltdir/$toolchaindir" ]; then
+ export ANDROID_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
+ fi
+
+ export ARM_EABI_TOOLCHAIN=
+ toolchaindir=toolchain/arm-eabi-4.4.3/bin
+ if [ -d "$prebuiltdir/$toolchaindir" ]; then
+ export ARM_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
+ fi
+
export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN
export ANDROID_QTOOLS=$T/development/emulator/qtools
export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN:$ARM_EABI_TOOLCHAIN$CODE_REVIEWS
export PATH=$PATH$ANDROID_BUILD_PATHS
unset ANDROID_JAVA_TOOLCHAIN
+ unset ANDROID_PRE_BUILD_PATHS
if [ -n "$JAVA_HOME" ]; then
export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
- fi
- export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN
- if [ -n "$ANDROID_PRE_BUILD_PATHS" ]; then
- export PATH=$ANDROID_PRE_BUILD_PATHS:$PATH
+ export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
+ export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
fi
unset ANDROID_PRODUCT_OUT
@@ -132,9 +149,6 @@
# needed for building linux on MacOS
# TODO: fix the path
#export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
-
- # needed for OProfile to post-process collected samples
- export OPROFILE_EVENTS_DIR=$prebuiltdir/oprofile
}
function printconfig()
@@ -176,73 +190,28 @@
fi
}
-case `uname -s` in
- Linux)
- function choosesim()
- {
- echo "Build for the simulator or the device?"
- echo " 1. Device"
- echo " 2. Simulator"
- echo
+function addcompletions()
+{
+ local T dir f
- export TARGET_SIMULATOR=
- local ANSWER
- while [ -z $TARGET_SIMULATOR ]
- do
- echo -n "Which would you like? [1] "
- if [ -z "$1" ] ; then
- read ANSWER
- else
- echo $1
- ANSWER=$1
- fi
- case $ANSWER in
- "")
- export TARGET_SIMULATOR=false
- ;;
- 1)
- export TARGET_SIMULATOR=false
- ;;
- Device)
- export TARGET_SIMULATOR=false
- ;;
- 2)
- export TARGET_SIMULATOR=true
- ;;
- Simulator)
- export TARGET_SIMULATOR=true
- ;;
- *)
- echo
- echo "I didn't understand your response. Please try again."
- echo
- ;;
- esac
- if [ -n "$1" ] ; then
- break
- fi
- done
+ # Keep us from trying to run in something that isn't bash.
+ if [ -z "${BASH_VERSION}" ]; then
+ return
+ fi
- set_stuff_for_environment
- }
- ;;
- *)
- function choosesim()
- {
- echo "Only device builds are supported for" `uname -s`
- echo " Forcing TARGET_SIMULATOR=false"
- echo
- if [ -z "$1" ]
- then
- echo -n "Press enter: "
- read
- fi
+ # Keep us from trying to run in bash that's too old.
+ if [ ${BASH_VERSINFO[0]} -lt 3 ]; then
+ return
+ fi
- export TARGET_SIMULATOR=false
- set_stuff_for_environment
- }
- ;;
-esac
+ dir="sdk/bash_completion"
+ if [ -d ${dir} ]; then
+ for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
+ echo "including $f"
+ . $f
+ done
+ fi
+}
function choosetype()
{
@@ -252,13 +221,8 @@
echo
local DEFAULT_NUM DEFAULT_VALUE
- if [ $TARGET_SIMULATOR = "false" ] ; then
- DEFAULT_NUM=1
- DEFAULT_VALUE=release
- else
- DEFAULT_NUM=2
- DEFAULT_VALUE=debug
- fi
+ DEFAULT_NUM=1
+ DEFAULT_VALUE=release
export TARGET_BUILD_TYPE=
local ANSWER
@@ -312,11 +276,7 @@
if [ "x$TARGET_PRODUCT" != x ] ; then
default_value=$TARGET_PRODUCT
else
- if [ "$TARGET_SIMULATOR" = true ] ; then
- default_value=sim
- else
- default_value=full
- fi
+ default_value=full
fi
export TARGET_PRODUCT=
@@ -398,19 +358,15 @@
function choosecombo()
{
- choosesim $1
+ choosetype $1
echo
echo
- choosetype $2
+ chooseproduct $2
echo
echo
- chooseproduct $3
-
- echo
- echo
- choosevariant $4
+ choosevariant $3
echo
set_stuff_for_environment
@@ -435,12 +391,7 @@
# add the default one here
add_lunch_combo full-eng
add_lunch_combo full_x86-eng
-
-# if we're on linux, add the simulator. There is a special case
-# in lunch to deal with the simulator
-if [ "$(uname)" = "Linux" ] ; then
- add_lunch_combo simulator
-fi
+add_lunch_combo vbox_x86-eng
function print_lunch_menu()
{
@@ -478,9 +429,6 @@
if [ -z "$answer" ]
then
selection=full-eng
- elif [ "$answer" = "simulator" ]
- then
- selection=simulator
elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
then
if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
@@ -501,45 +449,35 @@
export TARGET_BUILD_APPS=
- # special case the simulator
- if [ "$selection" = "simulator" ]
+ local product=$(echo -n $selection | sed -e "s/-.*$//")
+ check_product $product
+ if [ $? -ne 0 ]
then
- export TARGET_PRODUCT=sim
- export TARGET_BUILD_VARIANT=eng
- export TARGET_SIMULATOR=true
- export TARGET_BUILD_TYPE=debug
- else
- local product=$(echo -n $selection | sed -e "s/-.*$//")
- check_product $product
- if [ $? -ne 0 ]
- then
- echo
- echo "** Don't have a product spec for: '$product'"
- echo "** Do you have the right repo manifest?"
- product=
- fi
+ echo
+ echo "** Don't have a product spec for: '$product'"
+ echo "** Do you have the right repo manifest?"
+ product=
+ fi
- local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
- check_variant $variant
- if [ $? -ne 0 ]
- then
- echo
- echo "** Invalid variant: '$variant'"
- echo "** Must be one of ${VARIANT_CHOICES[@]}"
- variant=
- fi
+ local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
+ check_variant $variant
+ if [ $? -ne 0 ]
+ then
+ echo
+ echo "** Invalid variant: '$variant'"
+ echo "** Must be one of ${VARIANT_CHOICES[@]}"
+ variant=
+ fi
- if [ -z "$product" -o -z "$variant" ]
- then
- echo
- return 1
- fi
+ if [ -z "$product" -o -z "$variant" ]
+ then
+ echo
+ return 1
+ fi
- export TARGET_PRODUCT=$product
- export TARGET_BUILD_VARIANT=$variant
- export TARGET_SIMULATOR=false
- export TARGET_BUILD_TYPE=release
- fi # !simulator
+ export TARGET_PRODUCT=$product
+ export TARGET_BUILD_VARIANT=$variant
+ export TARGET_BUILD_TYPE=release
echo
@@ -580,7 +518,6 @@
export TARGET_PRODUCT=full
export TARGET_BUILD_VARIANT=$variant
- export TARGET_SIMULATOR=false
export TARGET_BUILD_TYPE=release
export TARGET_BUILD_APPS=$apps
@@ -785,7 +722,11 @@
local PID
local PROG="$3"
if [ "$PROG" ] ; then
- PID=`pid $3`
+ if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
+ PID="$3"
+ else
+ PID=`pid $3`
+ fi
adb forward "tcp$PORT" "tcp$PORT"
adb shell gdbserver $PORT --attach $PID &
sleep 2
@@ -814,55 +755,55 @@
Darwin)
function sgrep()
{
- find -E . -type f -iregex '.*\.(c|h|cpp|S|java|xml|sh|mk)' -print0 | xargs -0 grep --color -n "$@"
+ find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml|sh|mk)' -print0 | xargs -0 grep --color -n "$@"
}
;;
*)
function sgrep()
{
- find . -type f -iregex '.*\.\(c\|h\|cpp\|S\|java\|xml\|sh\|mk\)' -print0 | xargs -0 grep --color -n "$@"
+ find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cpp\|S\|java\|xml\|sh\|mk\)' -print0 | xargs -0 grep --color -n "$@"
}
;;
esac
function jgrep()
{
- find . -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
+ find . -name .repo -prune -o -name .git -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
}
function cgrep()
{
- find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
+ find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
}
function resgrep()
{
- for dir in `find . -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
+ for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
}
case `uname -s` in
Darwin)
function mgrep()
{
- find -E . -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
+ find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
}
function treegrep()
{
- find -E . -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
+ find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
}
;;
*)
function mgrep()
{
- find . -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
+ find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
}
function treegrep()
{
- find . -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
+ find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
}
;;
@@ -1066,7 +1007,7 @@
echo ""
fi
local lines
- lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
+ lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
if [[ ${#lines[@]} = 0 ]]; then
echo "Not found"
return
@@ -1079,7 +1020,7 @@
local line
for line in ${lines[@]}; do
printf "%6s %s\n" "[$index]" $line
- index=$(($index + 1))
+ index=$(($index + 1))
done
echo
echo -n "Select one: "
@@ -1111,13 +1052,15 @@
fi
}
-case `ps -o command -p $$` in
- *bash*)
- ;;
- *)
- echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
- ;;
-esac
+if [ "x$SHELL" != "x/bin/bash" ]; then
+ case `ps -o command -p $$` in
+ *bash*)
+ ;;
+ *)
+ echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
+ ;;
+ esac
+fi
# Execute the contents of any vendorsetup.sh files we can find.
for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`
@@ -1126,3 +1069,5 @@
. $f
done
unset f
+
+addcompletions
diff --git a/target/board/Android.mk b/target/board/Android.mk
index 54ee9e7..58164f6 100644
--- a/target/board/Android.mk
+++ b/target/board/Android.mk
@@ -27,10 +27,14 @@
# with everything else.
#
# If the file "board-info.txt" appears in $(TARGET_DEVICE_DIR),
-# it will be appended to the output file.
+# it will be used; otherwise TARGET_BOARD_INFO_FILE is used, which
+# can be set in BoardConfig.mk.
#
INSTALLED_ANDROID_INFO_TXT_TARGET := $(PRODUCT_OUT)/android-info.txt
board_info_txt := $(wildcard $(TARGET_DEVICE_DIR)/board-info.txt)
+ifndef board_info_txt
+board_info_txt := $(TARGET_BOARD_INFO_FILE)
+endif
$(INSTALLED_ANDROID_INFO_TXT_TARGET): $(board_info_txt)
$(call pretty,"Generated: ($@)")
ifdef board_info_txt
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 26bf6ab..229ea9c 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -6,12 +6,36 @@
# The generic product target doesn't have any hardware-specific pieces.
TARGET_NO_BOOTLOADER := true
TARGET_NO_KERNEL := true
-TARGET_CPU_ABI := armeabi
+
+# Note: we build the platform images for ARMv7-A _without_ NEON.
+#
+# Technically, the emulator supports ARMv7-A _and_ NEON instructions, but
+# emulated NEON code paths typically ends up 2x slower than the normal C code
+# it is supposed to replace (unlike on real devices where it is 2x to 3x
+# faster).
+#
+# What this means is that the platform image will not use NEON code paths
+# that are slower to emulate. On the other hand, it is possible to emulate
+# application code generated with the NDK that uses NEON in the emulator.
+#
+TARGET_ARCH_VARIANT := armv7-a
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+
HAVE_HTC_AUDIO_DRIVER := true
BOARD_USES_GENERIC_AUDIO := true
# no hardware camera
USE_CAMERA_STUB := true
-# Set /system/bin/sh to mksh, not ash, to test the transition.
-TARGET_SHELL := mksh
+# Set /system/bin/sh to ash, not mksh, to make sure we can switch back.
+TARGET_SHELL := ash
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+WITH_DEXPREOPT := true
+endif
+
+# Build OpenGLES emulation guest and host libraries
+BUILD_EMULATOR_OPENGL := true
diff --git a/target/board/generic/device.mk b/target/board/generic/device.mk
index 0b4dc27..8b187d5 100644
--- a/target/board/generic/device.mk
+++ b/target/board/generic/device.mk
@@ -23,4 +23,8 @@
PRODUCT_COPY_FILES := \
development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
- development/data/etc/vold.conf:system/etc/vold.conf
+ development/data/etc/vold.conf:system/etc/vold.conf \
+ development/tools/emulator/system/camera/media_profiles.xml:system/etc/media_profiles.xml \
+
+PRODUCT_PACKAGES := \
+ audio.primary.goldfish
diff --git a/target/board/generic_armv5/AndroidBoard.mk b/target/board/generic_armv5/AndroidBoard.mk
new file mode 100644
index 0000000..7daff27
--- /dev/null
+++ b/target/board/generic_armv5/AndroidBoard.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+-include build/target/board/generic/AndroidBoard.mk
diff --git a/target/board/generic_armv5/BoardConfig.mk b/target/board/generic_armv5/BoardConfig.mk
new file mode 100644
index 0000000..d8fa2fe
--- /dev/null
+++ b/target/board/generic_armv5/BoardConfig.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include build/target/board/generic/BoardConfig.mk
+
+TARGET_ARCH_VARIANT :=
+TARGET_CPU_ABI := armeabi
+TARGET_CPU_ABI2 :=
+
+WITH_DEXPREOPT := false
diff --git a/target/board/generic_armv5/README.txt b/target/board/generic_armv5/README.txt
new file mode 100644
index 0000000..25d590a
--- /dev/null
+++ b/target/board/generic_armv5/README.txt
@@ -0,0 +1,5 @@
+The "generic_armv5" product defines a non-hardware-specific target
+without a kernel or bootloader.
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_armv5/device.mk b/target/board/generic_armv5/device.mk
new file mode 100644
index 0000000..7c4aaf2
--- /dev/null
+++ b/target/board/generic_armv5/device.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include build/target/board/generic/device.mk
diff --git a/target/board/generic_armv5/system.prop b/target/board/generic_armv5/system.prop
new file mode 100644
index 0000000..137a0f9
--- /dev/null
+++ b/target/board/generic_armv5/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index 83a8c3e..1a1bc80 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -1,31 +1,31 @@
-TARGET_ARCH=x86
-DISABLE_DEXPREOPT := true
-TARGET_COMPRESS_MODULE_SYMBOLS := false
-TARGET_PRELINK_MODULE := false
-TARGET_NO_RECOVERY := true
-TARGET_HARDWARE_3D := false
-BOARD_USES_GENERIC_AUDIO := true
-USE_CAMERA_STUB := true
-TARGET_PROVIDES_INIT_RC := true
-USE_CUSTOM_RUNTIME_HEAP_MAX := "32M"
+# config.mk
+#
+# Product-specific compile-time definitions.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
TARGET_CPU_ABI := x86
-TARGET_USERIMAGES_USE_EXT4 := true
-TARGET_BOOTIMAGE_USE_EXT2 := true
+TARGET_ARCH := x86
+TARGET_ARCH_VARIANT := x86-atom
+TARGET_PRELINK_MODULE := false
-# For VirtualBox and likely other emulators
-BOARD_INSTALLER_CMDLINE := init=/init console=ttyS0 console=tty0 androidboot.hardware=generic_x86 vga=788 androidboot.console=tty0 verbose
-BOARD_KERNEL_CMDLINE := init=/init console=tty0 console=ttyS0 androidboot.hardware=generic_x86 vga=788 androidboot.console=tty0 verbose
-TARGET_USE_DISKINSTALLER := true
-TARGET_DISK_LAYOUT_CONFIG := build/target/board/generic_x86/disk_layout.conf
-BOARD_BOOTIMAGE_MAX_SIZE := 8388608
-BOARD_SYSLOADER_MAX_SIZE := 7340032
-BOARD_FLASH_BLOCK_SIZE := 512
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 157286400
-BOARD_USERDATAIMAGE_PARTITION_SIZE := 52428800
-BOARD_INSTALLERIMAGE_PARTITION_SIZE := 524288000
-TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+# The IA emulator (qemu) uses the Goldfish devices
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+# no hardware camera
+USE_CAMERA_STUB := true
-# The eth0 device should be started with dhcp on boot.
-# Useful for emulators that don't provide a wifi connection.
-NET_ETH0_STARTONBOOT := true
+# Set /system/bin/sh to ash, not mksh, to make sure we can switch back.
+TARGET_SHELL := ash
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+WITH_DEXPREOPT := true
+endif
+
+# Build OpenGLES emulation host and guest libraries
+BUILD_EMULATOR_OPENGL := true
diff --git a/target/board/generic_x86/README.txt b/target/board/generic_x86/README.txt
index 585a373..938d982 100644
--- a/target/board/generic_x86/README.txt
+++ b/target/board/generic_x86/README.txt
@@ -1,29 +1,8 @@
-The generic_x86 board target provides basic services on very basic
-hardware (really for an emulation). To build with generic_x86, you will
-need an appropriate kernel for your emulation (or device).
+The "generic_x86" product defines a non-hardware-specific IA target
+without a kernel or bootloader.
-A1. Create a new top level directory and pull the AOSP repository
- mkdir $HOME/AOSP
- cd $HOME/AOSP
- repo init -u git://android.git.kernel.org/platform/manifest.git
- repo sync
+It can be used to build the entire user-level system, and
+will work with the IA version of the emulator,
-A2. Copy in the kernel
- cd $HOME/AOSP
- cp ~/bzImage.your_device $HOME/AOSP/prebuilt/android-x86/kernel/kernel
-
-A3. Build
- cd $HOME/AOSP
- source build/envsetup.sh
- lunch generic_x86-eng
- make -j8
-
-The build will generate some image files whose format may or may not be correct for your
-device. You can build an installer image disk for the VirtualBox emulator using the command:
-
-A4. Build a VirtualBox installer image
- cd $HOME/AOSP
- source build/envsetup.sh
- lunch generic_x86-eng
- make -j8 installer_vdi
-
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_x86/device.mk b/target/board/generic_x86/device.mk
index bbdc8f4..1055cba 100644
--- a/target/board/generic_x86/device.mk
+++ b/target/board/generic_x86/device.mk
@@ -1,9 +1,27 @@
-ifeq ($(TARGET_PREBUILT_KERNEL),)
-LOCAL_KERNEL := prebuilt/android-x86/kernel/kernel
-else
-LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
-endif
+#
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
-PRODUCT_COPY_FILES += \
- $(LOCAL_KERNEL):kernel \
- build/target/board/generic_x86/init.rc:root/init.rc
+# This is a build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10
+
+PRODUCT_COPY_FILES := \
+ development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ development/data/etc/vold.conf:system/etc/vold.conf \
+ development/tools/emulator/system/camera/media_profiles.xml:system/etc/media_profiles.xml \
diff --git a/target/board/generic_x86/disk_layout.conf b/target/board/generic_x86/disk_layout.conf
deleted file mode 100644
index 7b073ee..0000000
--- a/target/board/generic_x86/disk_layout.conf
+++ /dev/null
@@ -1,54 +0,0 @@
-device {
- path /dev/block/sda
-
- scheme mbr
-
- # bytes in a disk sector (== 1 LBA), must be a power of 2!
- sector_size 512
-
- # What LBA should the partitions start at?
- start_lba 2048
-
- # Autodetect disk size if == 0
- num_lba 0
-
- partitions {
- sysloader {
- active y
- type linux
- len 7M
- }
-
- recovery {
- active y
- type linux
- len 16M
- }
-
- boot {
- active y
- type linux
- len 8M
- }
-
- cache {
- type linux
- len 512M
- }
-
- system {
- type linux
- len 512M
- }
-
- third_party {
- type linux
- len 512M
- }
-
- data {
- type linux
- len -1
- }
- }
-}
diff --git a/target/board/generic_x86/system.prop b/target/board/generic_x86/system.prop
new file mode 100644
index 0000000..137a0f9
--- /dev/null
+++ b/target/board/generic_x86/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/sim/AndroidBoard.mk b/target/board/sim/AndroidBoard.mk
deleted file mode 100644
index e69de29..0000000
--- a/target/board/sim/AndroidBoard.mk
+++ /dev/null
diff --git a/target/board/sim/BoardConfig.mk b/target/board/sim/BoardConfig.mk
deleted file mode 100644
index ba25c18..0000000
--- a/target/board/sim/BoardConfig.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# config.mk
-#
-# Product-specific compile-time definitions.
-#
-
-# Don't try prelinking or compressing the shared libraries
-# used by the simulator. The host OS won't know what to do
-# with them, and they may not even be ELF files.
-#
-# These definitions override the defaults in config/config.make.
-TARGET_COMPRESS_MODULE_SYMBOLS := false
-TARGET_PRELINK_MODULE := false
-
-# Don't try to build a bootloader.
-TARGET_NO_BOOTLOADER := true
-
-# Don't bother with a kernel
-TARGET_NO_KERNEL := true
-
-# The simulator does not support native code at all
-TARGET_CPU_ABI := none
-
-# But it is very likely SMP.
-TARGET_CPU_SMP := true
-
-#the simulator partially emulates the original HTC /dev/eac audio interface
-HAVE_HTC_AUDIO_DRIVER := true
-BOARD_USES_GENERIC_AUDIO := true
-
-# no hardware camera
-USE_CAMERA_STUB := true
diff --git a/target/board/vbox_x86/AndroidBoard.mk b/target/board/vbox_x86/AndroidBoard.mk
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/target/board/vbox_x86/AndroidBoard.mk
@@ -0,0 +1 @@
+
diff --git a/target/board/vbox_x86/BoardConfig.mk b/target/board/vbox_x86/BoardConfig.mk
new file mode 100644
index 0000000..94df57c
--- /dev/null
+++ b/target/board/vbox_x86/BoardConfig.mk
@@ -0,0 +1,38 @@
+#
+# IA target for VitualBox
+#
+
+TARGET_ARCH=x86
+DISABLE_DEXPREOPT := true
+TARGET_COMPRESS_MODULE_SYMBOLS := false
+TARGET_NO_RECOVERY := true
+TARGET_HARDWARE_3D := false
+BOARD_USES_GENERIC_AUDIO := true
+USE_CAMERA_STUB := true
+TARGET_PROVIDES_INIT_RC := true
+USE_CUSTOM_RUNTIME_HEAP_MAX := "32M"
+TARGET_CPU_ABI := x86
+TARGET_USERIMAGES_USE_EXT4 := true
+TARGET_BOOTIMAGE_USE_EXT2 := true
+
+# For VirtualBox and likely other emulators
+BOARD_INSTALLER_CMDLINE := init=/init console=ttyS0 console=tty0 vga=788 verbose
+BOARD_KERNEL_CMDLINE := init=/init qemu=1 console=ttyS0 console=tty0 vga=788 verbose androidboot.hardware=vbox_x86 androidboot.console=ttyS0 android.qemud=ttyS1
+TARGET_USE_DISKINSTALLER := true
+
+TARGET_DISK_LAYOUT_CONFIG := build/target/board/vbox_x86/disk_layout.conf
+BOARD_BOOTIMAGE_MAX_SIZE := 8388608
+BOARD_SYSLOADER_MAX_SIZE := 7340032
+BOARD_FLASH_BLOCK_SIZE := 512
+# 50M
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 52428800
+# 500M
+BOARD_INSTALLERIMAGE_PARTITION_SIZE := 524288000
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+# Reserve 265M for the system partition
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 268435456
+
+
+# The eth0 device should be started with dhcp on boot.
+# Useful for emulators that don't provide a wifi connection.
+NET_ETH0_STARTONBOOT := true
diff --git a/target/board/vbox_x86/README.txt b/target/board/vbox_x86/README.txt
new file mode 100644
index 0000000..568dc5f
--- /dev/null
+++ b/target/board/vbox_x86/README.txt
@@ -0,0 +1,9 @@
+The "vbox_x86" product defines a non-hardware-specific target intended
+to run on the VirtualBox emulator.
+
+Most of the Android devices (networking, phones, sound, etc) do not work.
+
+ADB via ethernet works with this target. You can use 'adb install' to
+test applications that do not require network, phone or sound support.
+This emulation is useful because VirtualBox runs much faster then does the
+QEMU emulators (at least until a KVM enabled QEMU emulator is available).
diff --git a/target/board/vbox_x86/device.mk b/target/board/vbox_x86/device.mk
new file mode 100644
index 0000000..a76d8fa
--- /dev/null
+++ b/target/board/vbox_x86/device.mk
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a build configuration for the product aspects that
+# are specific to the emulator.
+
+LOCAL_PATH := $(call my-dir)
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10
+
+LOCAL_KERNEL := prebuilt/android-x86/kernel/kernel-vbox
+
+PRODUCT_COPY_FILES := \
+ development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ development/data/etc/vold.conf:system/etc/vold.conf \
+ development/tools/emulator/system/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ build/target/board/vbox_x86/init.rc:root/init.rc \
+ build/target/board/vbox_x86/init.vbox_x86.rc:root/init.vbox_x86.rc \
+ $(LOCAL_KERNEL):kernel
diff --git a/target/board/vbox_x86/disk_layout.conf b/target/board/vbox_x86/disk_layout.conf
new file mode 100644
index 0000000..12241ab
--- /dev/null
+++ b/target/board/vbox_x86/disk_layout.conf
@@ -0,0 +1,76 @@
+# Best to align all partion start/ends on a cylinder boundary (fdisk prefers it)
+# 512 bytes/sector
+# 63 sectors/track
+# 32 tracks/cylinder
+
+# LBAs are in 'k', so...
+# 1008 blocks (1k each) (1032192 bytes) / cylinder
+
+device {
+
+ path /dev/block/sda
+
+ scheme mbr
+
+ # bytes in a disk sector (== 1 LBA), must be a power of 2!
+ sector_size 512
+
+ # Start_lba should be on a cylindar boundary.
+ start_lba 63
+
+ # Autodetect disk size if == 0
+ num_lba 0
+
+ partitions {
+ # /dev/sdX1
+ sysloader {
+ active y
+ type linux
+ # 8 cyls in length... about 8M
+ len 8064
+ }
+
+ # /dev/sdX2
+ recovery {
+ active y
+ type linux
+ # 8 cyls in length... about 8M
+ len 8064
+ }
+
+ # /dev/sdX3
+ boot {
+ active y
+ type linux
+ # 8 cyls in length... about 8M
+ len 8064
+ }
+
+ # /dev/sdX4
+ # (extended partion begins)
+
+ # /dev/sdX5
+ cache {
+ type linux
+ len 512M
+ }
+
+ # /dev/sdX6
+ system {
+ type linux
+ len 512M
+ }
+
+ # /dev/sdX7
+ third_party {
+ type linux
+ len 512M
+ }
+
+ # /dev/sdX8
+ data {
+ type linux
+ len -1
+ }
+ }
+}
diff --git a/target/board/generic_x86/init.rc b/target/board/vbox_x86/init.rc
similarity index 98%
rename from target/board/generic_x86/init.rc
rename to target/board/vbox_x86/init.rc
index 8f6be28..100cc09 100644
--- a/target/board/generic_x86/init.rc
+++ b/target/board/vbox_x86/init.rc
@@ -90,11 +90,11 @@
write /dev/cpuctl/bg_non_interactive/cpu.shares 52
on fs
-# mount mtd partitions
- mount ext4 /dev/block/sda6 /system rw
- mkdir /system/vendor
- mount ext4 /dev/block/sda8 /data nosuid nodev
- mount ext4 /dev/block/sda7 /cache nosuid nodev
+# mount sda partitions
+ mount ext4 /dev/block/sda6 /system
+ mount ext4 /dev/block/sda6 /system ro remount
+ mount ext4 /dev/block/sda7 /data nosuid nodev
+ mount ext4 /dev/block/sda8 /cache nosuid nodev
on post-fs
# once everything is setup, no need to modify /
@@ -293,11 +293,6 @@
on property:ro.secure=0
start console
-# Enable networking so that adb can connect
-service netcfg /system/bin/netcfg eth0 dhcp
- setprop property:ro.kernel.qemu 1
- oneshot
-
# adbd is controlled by the persist.service.adb.enable system property
service adbd /sbin/adbd
disabled
@@ -425,3 +420,7 @@
socket dumpstate stream 0660 shell log
disabled
oneshot
+
+# Enable networking so that adb can connect
+service netcfg /system/bin/netcfg eth0 dhcp
+ oneshot
diff --git a/target/board/vbox_x86/init.vbox_x86.rc b/target/board/vbox_x86/init.vbox_x86.rc
new file mode 100644
index 0000000..4c5d55c
--- /dev/null
+++ b/target/board/vbox_x86/init.vbox_x86.rc
@@ -0,0 +1,52 @@
+on boot
+ setprop ARGH ARGH
+ setprop net.eth0.dns1 10.0.2.3
+ setprop net.gprs.local-ip 10.0.2.15
+ setprop ro.radio.use-ppp no
+ setprop ro.build.product generic
+ setprop ro.product.device generic
+
+# fake some battery state
+ setprop status.battery.state Slow
+ setprop status.battery.level 5
+ setprop status.battery.level_raw 50
+ setprop status.battery.level_scale 9
+
+# disable some daemons the emulator doesn't want
+ stop dund
+ stop akmd
+
+ setprop ro.setupwizard.mode EMULATOR
+
+# enable Google-specific location features,
+# like NetworkLocationProvider and LocationCollector
+ setprop ro.com.google.locationfeatures 1
+
+# For the emulator, which bypasses Setup Wizard, you can specify
+# account info for the device via these two properties. Google
+# Login Service will insert these accounts into the database when
+# it is created (ie, after a data wipe).
+#
+# setprop ro.config.hosted_account username@hosteddomain.org:password
+# setprop ro.config.google_account username@gmail.com:password
+#
+# You MUST have a Google account on the device, and you MAY
+# additionally have a hosted account. No other configuration is
+# supported, and arbitrary breakage may result if you specify
+# something else.
+
+service goldfish-setup /system/etc/init.goldfish.sh
+ oneshot
+
+service qemud /system/bin/qemud
+ socket qemud stream 666
+ oneshot
+
+# -Q is a special logcat option that forces the
+# program to check wether it runs on the emulator
+# if it does, it redirects its output to the device
+# named by the androidboot.console kernel option
+# if not, is simply exit immediately
+
+service goldfish-logcat /system/bin/logcat -Q
+ oneshot
diff --git a/target/board/vbox_x86/system.prop b/target/board/vbox_x86/system.prop
new file mode 100644
index 0000000..137a0f9
--- /dev/null
+++ b/target/board/vbox_x86/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
index b27721a..e77c783 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -35,10 +35,12 @@
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/core.mk \
$(LOCAL_DIR)/generic.mk \
+ $(LOCAL_DIR)/generic_armv5.mk \
$(LOCAL_DIR)/generic_x86.mk \
$(LOCAL_DIR)/full.mk \
$(LOCAL_DIR)/full_x86.mk \
+ $(LOCAL_DIR)/vbox_x86.mk \
$(LOCAL_DIR)/sdk.mk \
- $(LOCAL_DIR)/sim.mk \
+ $(LOCAL_DIR)/sdk_x86.mk \
$(LOCAL_DIR)/large_emu_hw.mk
endif
diff --git a/target/product/core.mk b/target/product/core.mk
index fb46516..ca5858f 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -24,6 +24,7 @@
PRODUCT_PACKAGES := \
ApplicationsProvider \
+ BackupRestoreConfirmation \
Browser \
Bugreport \
Contacts \
@@ -33,16 +34,21 @@
DownloadProviderUi \
HTMLViewer \
Home \
+ KeyChain \
MediaProvider \
PackageInstaller \
PicoTts \
SettingsProvider \
+ SharedStorageBackup \
TelephonyProvider \
TtsService \
UserDictionaryProvider \
VpnServices \
apache-xml \
+ bluetooth-health \
bouncycastle \
+ bu \
+ cacerts \
com.android.location.provider \
com.android.location.provider.xml \
core \
@@ -55,7 +61,9 @@
dmtracedump \
dx \
ext \
+ filterfw \
framework-res \
+ hostapd \
hprof-conv \
icu.dat \
installd \
@@ -65,27 +73,45 @@
iptables \
libOpenMAXAL \
libOpenSLES \
+ libaudiopreprocessing \
libcrypto \
libdex \
libdvm \
libexpat \
+ libfilterfw \
+ libfilterpack_imageproc \
+ libgabi++ \
libicui18n \
libicuuc \
libjavacore \
libnativehelper \
libnfc_ndef \
+ libpowermanager \
+ libspeexresampler \
libsqlite_jni \
libssl \
+ libstagefright_soft_aacdec \
+ libstagefright_soft_amrdec \
+ libstagefright_soft_avcdec \
+ libstagefright_soft_g711dec \
+ libstagefright_soft_mp3dec \
+ libstagefright_soft_mpeg4dec \
+ libstagefright_soft_vorbisdec \
+ libstagefright_soft_vpxdec \
+ libvariablespeed \
+ libwebrtc_audio_preprocessing \
libwilhelm \
libz \
screencap \
- sqlite-jdbc \
+ sensorservice \
wpa_supplicant.conf
# host-only dependencies
ifeq ($(WITH_HOST_DALVIK),true)
PRODUCT_PACKAGES += \
+ apache-xml-hostdex \
bouncycastle-hostdex \
core-hostdex \
- libjavacore-host
+ libjavacore-host \
+ dalvik
endif
diff --git a/target/product/full.mk b/target/product/full.mk
index 8231e99..0f1956b 100644
--- a/target/product/full.mk
+++ b/target/product/full.mk
@@ -19,6 +19,9 @@
# build quite specifically for the emulator, and might not be
# entirely appropriate to inherit from for on-device configurations.
+PRODUCT_PACKAGES := \
+ Camera
+
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/board/generic/device.mk)
diff --git a/target/product/full_base.mk b/target/product/full_base.mk
index 19f94ee..a8a32fe 100644
--- a/target/product/full_base.mk
+++ b/target/product/full_base.mk
@@ -20,12 +20,17 @@
# in inherited configurations.
PRODUCT_PACKAGES := \
+ drmserver \
+ libdrmframework \
+ libdrmframework_jni \
+ libfwdlockengine \
OpenWnn \
+ PhotoEditor \
PinyinIME \
- VoiceDialer \
libWnnEngDic \
libWnnJpnDic \
libwnndict \
+ VideoEditor \
WAPPushManager
# Additional settings used in all AOSP builds
diff --git a/target/product/full_base_telephony.mk b/target/product/full_base_telephony.mk
index 932ba95..c376314 100644
--- a/target/product/full_base_telephony.mk
+++ b/target/product/full_base_telephony.mk
@@ -19,6 +19,9 @@
# build quite specifically for the emulator, and might not be
# entirely appropriate to inherit from for on-device configurations.
+PRODUCT_PACKAGES := \
+ VoiceDialer
+
PRODUCT_PROPERTY_OVERRIDES := \
keyguard.no_require_sim=true \
ro.com.android.dataroaming=true
diff --git a/target/product/full_x86.mk b/target/product/full_x86.mk
index 9e22bc5..c7a4cfb 100644
--- a/target/product/full_x86.mk
+++ b/target/product/full_x86.mk
@@ -16,8 +16,8 @@
# This is a build configuration for a full-featured build of the
# Open-Source part of the tree. It's geared toward a US-centric
-# x86 build, but all those aspects can be overridden
-# in inherited configurations.
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
# If running on an emulator or some other device that has a LAN connection
# that isn't a wifi connection. This will instruct init.rc to enable the
@@ -26,11 +26,19 @@
PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
endif
+PRODUCT_PACKAGES := \
+ Camera
+
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86/device.mk)
+# Ensure we package the BIOS files too.
+PRODUCT_PACKAGES += \
+ bios.bin \
+ vgabios-cirrus.bin \
+
# Overrides
PRODUCT_NAME := full_x86
PRODUCT_DEVICE := generic_x86
PRODUCT_BRAND := Android
-PRODUCT_MODEL := Full Android x86
+PRODUCT_MODEL := Full Android on x86 Emulator
diff --git a/target/product/generic_armv5.mk b/target/product/generic_armv5.mk
new file mode 100644
index 0000000..d419e70
--- /dev/null
+++ b/target/product/generic_armv5.mk
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a generic product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
+
+# Overrides
+PRODUCT_BRAND := generic_armv5
+PRODUCT_DEVICE := generic_armv5
+PRODUCT_NAME := generic_armv5
diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
index 2a3aae7..a1cce72 100644
--- a/target/product/generic_no_telephony.mk
+++ b/target/product/generic_no_telephony.mk
@@ -26,15 +26,15 @@
Bluetooth \
Calculator \
Calendar \
- Camera \
CertInstaller \
DrmProvider \
Email \
Exchange \
- Gallery3D \
+ Gallery2 \
LatinIME \
Launcher2 \
Music \
+ MusicFX \
Provision \
Phone \
QuickSearchBox \
@@ -44,7 +44,7 @@
Updater \
CalendarProvider \
SyncProvider \
- CryptKeeper
+ VpnDialogs
PRODUCT_PACKAGES += \
icu.dat
@@ -55,16 +55,20 @@
libvideoeditorplayer \
libvideoeditor_core
+PRODUCT_PACKAGES += \
+ audio.primary.default \
+ audio_policy.default
PRODUCT_COPY_FILES := \
system/bluetooth/data/audio.conf:system/etc/bluetooth/audio.conf \
system/bluetooth/data/auto_pairing.conf:system/etc/bluetooth/auto_pairing.conf \
system/bluetooth/data/blacklist.conf:system/etc/bluetooth/blacklist.conf \
system/bluetooth/data/input.conf:system/etc/bluetooth/input.conf \
- system/bluetooth/data/main.nonsmartphone.conf:system/etc/bluetooth/main.conf \
- system/bluetooth/data/network.conf:system/etc/bluetooth/network.conf
+ system/bluetooth/data/network.conf:system/etc/bluetooth/network.conf \
+ frameworks/base/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf
$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
+$(call inherit-product-if-exists, external/lohit-fonts/fonts.mk)
$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
diff --git a/target/product/generic_x86.mk b/target/product/generic_x86.mk
index 345a79a..7e77a27 100644
--- a/target/product/generic_x86.mk
+++ b/target/product/generic_x86.mk
@@ -1,34 +1,26 @@
+#
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
# This is a generic product that isn't specialized for a specific device.
-# It includes the base Android platform. If you need Google-specific features,
-# you should derive from generic_with_google.mk
+# It includes the base Android platform.
-PRODUCT_PACKAGES := \
- DeskClock \
- AlarmProvider \
- Calendar \
- Camera \
- DrmProvider \
- LatinIME \
- Mms \
- Music \
- Settings \
- Sync \
- Updater \
- CalendarProvider \
- SubscribedFeedsProvider \
- SyncProvider
-
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
# Overrides
PRODUCT_BRAND := generic_x86
PRODUCT_DEVICE := generic_x86
PRODUCT_NAME := generic_x86
-PRODUCT_POLICY := android.policy_phone
-
-# If running on an emulator or some other device that has a LAN connection
-# that isn't a wifi connection. This will instruct init.rc to enable the
-# network connection so that you can use it with ADB
-ifdef NET_ETH0_STARTONBOOT
- PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
-endif
diff --git a/target/product/languages_full.mk b/target/product/languages_full.mk
index 236dfa2..b18f78f 100644
--- a/target/product/languages_full.mk
+++ b/target/product/languages_full.mk
@@ -21,7 +21,5 @@
# Those are all the locales that have translations and are displayable
# by TextView in this branch.
-PRODUCT_LOCALES := en_US fr_FR it_IT es_ES de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR rm_CH sv_SE bg_BG ca_ES en_GB fi_FI hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH
-
-# Not currently usable:
-# ar, fa, th
+PRODUCT_LOCALES := en_US fr_FR it_IT es_ES de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR rm_CH sv_SE bg_BG ca_ES en_GB fi_FI hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH ar_EG fa_IR th_TH sw_TZ ms_MY af_ZA zu_ZA
+# We don't have the fonts to display am_ET yet
diff --git a/target/product/large_emu_hw.mk b/target/product/large_emu_hw.mk
index 139a9da..9224130 100644
--- a/target/product/large_emu_hw.mk
+++ b/target/product/large_emu_hw.mk
@@ -32,7 +32,7 @@
DrmProvider \
Email \
Exchange \
- Gallery3D \
+ Gallery2 \
LatinIME \
Launcher2 \
Music \
diff --git a/target/product/locales_full.mk b/target/product/locales_full.mk
index cf10392..cab2b91 100644
--- a/target/product/locales_full.mk
+++ b/target/product/locales_full.mk
@@ -1,5 +1,3 @@
-# The locales from the ICU "-large.dat" data set.
-# See external/icu4c/stubdata.
-# This is distinct from "languages_full.mk", which contains those locales for
-# which we have translations. If you like, this file is i18n rather than l18n.
PRODUCT_LOCALES := cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_NZ en_SG en_US es_ES fr_CA fr_CH fr_BE fr_FR it_CH it_IT ja_JP ko_KR nb_NO nl_BE nl_NL pl_PL pt_PT ru_RU sv_SE tr_TR zh_CN zh_HK zh_TW
+
+$(call inherit-product, build/target/product/languages_full.mk)
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index 1dffb60..f0142fa 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -30,7 +30,7 @@
libWnnEngDic \
libWnnJpnDic \
libwnndict \
- Phone \
+ Phone \
PinyinIME \
Protips \
SoftKeyboard \
@@ -59,7 +59,11 @@
jsr305lib \
jython \
jsilver \
- librs_jni
+ librs_jni \
+ ConnectivityTest \
+ GpsLocationTest \
+ CalendarProvider \
+ Calendar
# Host tools that are parts of the SDK.
@@ -100,6 +104,8 @@
sdklib \
sdkuilib \
sdkmanager \
+ swtmenubar \
+ swing-worker-1.1 \
groovy-all-1.7.0 \
commons-compress-1.0 \
emmalib \
@@ -119,7 +125,13 @@
ninepatch-tests \
common-tests \
sdklib-tests \
- sdkuilib-tests
+ sdkuilib-tests \
+ layoutlib-tests
+
+# audio libraries.
+PRODUCT_PACKAGES += \
+ audio.primary.goldfish \
+ audio_policy.default
PRODUCT_PACKAGE_OVERLAYS := development/sdk_overlay
@@ -141,10 +153,11 @@
# locale + densities. en_US is both first and in alphabetical order to
# ensure this is the default locale.
PRODUCT_LOCALES = \
+ en_US \
ldpi \
hdpi \
mdpi \
- en_US \
+ xhdpi \
ar_EG \
ar_IL \
bg_BG \
diff --git a/target/product/sdk_x86.mk b/target/product/sdk_x86.mk
new file mode 100644
index 0000000..6c5e746
--- /dev/null
+++ b/target/product/sdk_x86.mk
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk.mk)
+
+# Overrides
+PRODUCT_BRAND := generic_x86
+PRODUCT_NAME := sdk_x86
+PRODUCT_DEVICE := generic_x86
+PRODUCT_MODEL := Android SDK built for x86
diff --git a/target/product/sim.mk b/target/product/sim.mk
deleted file mode 100644
index 09722d6..0000000
--- a/target/product/sim.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/locales_full.mk)
-
-# Overrides
-PRODUCT_NAME := sim
-PRODUCT_DEVICE := sim
diff --git a/target/product/telephony.mk b/target/product/telephony.mk
index d557887..a0220de 100644
--- a/target/product/telephony.mk
+++ b/target/product/telephony.mk
@@ -21,4 +21,3 @@
Mms
PRODUCT_COPY_FILES := \
- system/bluetooth/data/main.conf:system/etc/bluetooth/main.conf
diff --git a/target/product/vbox_x86.mk b/target/product/vbox_x86.mk
new file mode 100644
index 0000000..f0d4232
--- /dev/null
+++ b/target/product/vbox_x86.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+ifdef NET_ETH0_STARTONBOOT
+ PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
+endif
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/vbox_x86/device.mk)
+
+PRODUCT_NAME := vbox_x86
+PRODUCT_DEVICE := vbox_x86
+PRODUCT_MODEL := Full Android on x86 VirtualBox
diff --git a/tools/Android.mk b/tools/Android.mk
index fa9d0b7..92603f5 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -14,7 +14,7 @@
# limitations under the License.
#
-LOCAL_PATH := $(my-dir)
+LOCAL_PATH := $(call my-dir)
# If we're building only unbundled apps, this is the only tool we need.
ifneq ($(TARGET_BUILD_APPS),)
diff --git a/tools/apriori/Android.mk b/tools/apriori/Android.mk
deleted file mode 100644
index 79ecf7f..0000000
--- a/tools/apriori/Android.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for apriori
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifneq ($(TARGET_SIMULATOR),true)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DDEBUG
-LOCAL_CFLAGS += -DADJUST_ELF=1
-
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DBIG_ENDIAN=1
-endif
-
-ifeq ($(HOST_OS),darwin)
-LOCAL_CFLAGS += -DFSCANF_IS_BROKEN
-endif
-ifeq ($(HOST_OS),windows)
-LOCAL_CFLAGS += -DFSCANF_IS_BROKEN
-LOCAL_LDLIBS += -lintl
-endif
-
-
-
-LOCAL_SRC_FILES := \
- apriori.c \
- cmdline.c \
- debug.c \
- hash.c \
- main.c \
- prelink_info.c \
- rangesort.c \
- source.c \
- prelinkmap.c
-
-LOCAL_C_INCLUDES:= \
- $(LOCAL_PATH)/ \
- external/elfutils/lib/ \
- external/elfutils/libelf/ \
- external/elfutils/libebl/ \
- external/elfcopy/
-
-LOCAL_STATIC_LIBRARIES := libelfcopy libelf libebl #dl
-
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_STATIC_LIBRARIES += libebl_arm
-endif
-
-LOCAL_MODULE := apriori
-
-include $(BUILD_HOST_EXECUTABLE)
-endif # TARGET_SIMULATOR != true
diff --git a/tools/apriori/apriori.c b/tools/apriori/apriori.c
deleted file mode 100644
index b827375..0000000
--- a/tools/apriori/apriori.c
+++ /dev/null
@@ -1,2775 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#ifdef ARM_SPECIFIC_HACKS
- #include <libebl_arm.h>
-#endif/*ARM_SPECIFIC_HACKS*/
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <hash.h>
-#include <apriori.h>
-#include <source.h>
-#include <tweak.h>
-#include <rangesort.h>
-#include <prelink_info.h>
-#include <prelinkmap.h>
-#include <libgen.h>
-
-#ifndef ADJUST_ELF
-#error "ADJUST_ELF must be defined!"
-#endif
-
-/* When this macro is defined, apriori sets to ZERO those relocation values for
- which it canot find the appropriate referent.
-*/
-#define PERMISSIVE
-#define COPY_SECTION_DATA_BUFFER (0)
-/* When this macro is set to a nonzero value, we replace calls to elf_strptr()
- on the target ELF handle with code that extracts the strings directly from
- the data buffers of that ELF handle. In this case, elf_strptr() does not
- work as expected, as it tries to read the data buffer of the associated
- string section directly from the file, and that buffer does not exist yet
- in the file, since we haven't committed our changes yet.
-*/
-#define ELF_STRPTR_IS_BROKEN (1)
-
-/* When the macro below is defined, apriori does not mark for removal those
- relocation sections that it fully handles. Instead, apriori just sets their
- sizes to zero. This is more for debugging than of any actual use.
-
- This macro is meaningful only when ADJUST_ELF!=0
-*/
-#define REMOVE_HANDLED_SECTIONS
-
-extern int verbose_flag;
-
-static source_t *sources = NULL;
-
-/* Retouch data is a very concise representation of the resolved relocations.
- This data is used to randomize the location of prelinked libraries at
- update time, on the device.
- */
-
-// We will store retouch entries into this buffer, then dump them at the
-// end of the .so file before setup_prelink_info().
-#define RETOUCH_MAX_SIZE 600000
-static char *retouch_buf;
-static unsigned int retouch_byte_cnt;
-// Compression state.
-static int32_t offs_prev;
-static uint32_t cont_prev;
-
-#define false 0
-#define true 1
-
-void retouch_init(void) {
- offs_prev = 0;
- cont_prev = 0;
- retouch_byte_cnt = 0;
- retouch_buf = malloc(RETOUCH_MAX_SIZE+12);
- FAILIF(retouch_buf == NULL,
- "Could not allocate %d bytes.\n", RETOUCH_MAX_SIZE+12);
-}
-
-//
-// We use three encoding schemes; this takes care of much of the redundancy
-// inherent in lists of relocations:
-//
-// * two bytes, leading 1, 2b for d_offset ("s"), 13b for d_contents ("c")
-//
-// 76543210 76543210
-// 1ssccccc cccccccc
-//
-// * three bytes, leading 01, 2b for delta offset, 20b for delta contents
-//
-// 76543210 76543210 76543210
-// 01sscccc cccccccc cccccccc
-//
-// * eigth bytes, leading 00, 30b for offset, 32b for contents
-//
-// 76543210 76543210 76543210 76543210
-// 00ssssss ssssssss ssssssss ssssssss + 4 bytes contents
-//
-// NOTE 1: All deltas are w.r.t. the previous line in the list.
-// NOTE 2: Two-bit ("ss") offsets mean: "00"=4, "01"=8, "10"=12, and "11"=16.
-// NOTE 3: Delta contents are signed. To map back to a int32 we refill with 1s.
-// NOTE 4: Special encoding for -1 offset. Extended back to 32b when decoded.
-//
-
-void retouch_encode(int32_t offset, uint32_t contents) {
- int64_t d_offs = offset-offs_prev;
- int64_t d_cont = (int64_t)contents-(int64_t)cont_prev;
-
- uint8_t output[8];
- uint32_t output_size;
-
- if ((d_offs > 3) &&
- (d_offs % 4) == 0 &&
- (d_offs / 4) < 5 &&
- (d_cont < 4000) &&
- (d_cont > -4000)) {
- // we can fit in 2 bytes
- output[0] =
- 0x80 |
- (((d_offs/4)-1) << 5) |
- (((uint64_t)d_cont & 0x1f00) >> 8);
- output[1] =
- ((uint64_t)d_cont & 0xff);
- output_size = 2;
- } else if ((d_offs > 3) &&
- (d_offs % 4) == 0 &&
- (d_offs / 4) < 5 &&
- (d_cont < 510000) &&
- (d_cont > -510000)) {
- // fit in 3 bytes
- output[0] =
- 0x40 |
- (((d_offs/4)-1) << 4) |
- (((uint64_t)d_cont & 0xf0000) >> 16);
- output[1] =
- ((uint64_t)d_cont & 0xff00) >> 8;
- output[2] =
- ((uint64_t)d_cont & 0xff);
- output_size = 3;
- } else {
- // fit in 8 bytes; we can't support files bigger than (1GB-1)
- // with this encoding: no library is that big anyway..
- FAILIF(offset < -1 || offset > 0x3ffffffe, "Offset out of range.\n");
- output[0] = (offset & 0x3f000000) >> 24;
- output[1] = (offset & 0xff0000) >> 16;
- output[2] = (offset & 0xff00) >> 8;
- output[3] = (offset & 0xff);
- output[4] = (contents & 0xff000000) >> 24;
- output[5] = (contents & 0xff0000) >> 16;
- output[6] = (contents & 0xff00) >> 8;
- output[7] = (contents & 0xff);
- output_size = 8;
- }
-
- // If this happens, the retouch buffer size can be bumped up.
- // Currently, the largest case is libwebcore, at about 250K.
- FAILIF((retouch_byte_cnt+output_size) > RETOUCH_MAX_SIZE,
- "About to overflow retouch buffer.\n");
-
- memcpy(retouch_buf+retouch_byte_cnt, output, output_size);
- retouch_byte_cnt += output_size;
-
- offs_prev = offset;
- cont_prev = contents;
-}
-
-void retouch_dump(const char *fname, int elf_little,
- unsigned int retouch_byte_cnt, char *retouch_buf) {
- int fd = open(fname, O_WRONLY);
- FAILIF(fd < 0,
- "open(%s, O_WRONLY): %s (%d)\n" ,
- fname, strerror(errno), errno);
- off_t sz = lseek(fd, 0, SEEK_END);
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- // The retouch blob ends with "RETOUCH XXXX", where XXXX is the 4-byte
- // size of the retouch blob, in target endianness.
- strncpy(retouch_buf+retouch_byte_cnt, "RETOUCH ", 8);
- if (elf_little ^ is_host_little()) {
- *(unsigned int *)(retouch_buf+retouch_byte_cnt+8) =
- switch_endianness(retouch_byte_cnt);
- } else {
- *(unsigned int *)(retouch_buf+retouch_byte_cnt+8) =
- retouch_byte_cnt;
- }
-
- int num_written = write(fd, retouch_buf, retouch_byte_cnt+12);
- FAILIF(num_written < 0,
- "write(%d, &info, sizeof(info)): %s (%d)\n",
- fd, strerror(errno), errno);
- FAILIF((retouch_byte_cnt+12) != num_written,
- "Could not write %d bytes as expected (wrote %d bytes instead)!\n",
- retouch_byte_cnt, num_written);
- FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-}
-
-/* End of retouch code.
- */
-
-#if defined(DEBUG) && 0
-
-static void print_shdr(source_t *source, Elf_Scn *scn)
-{
- GElf_Shdr shdr_mem, *shdr;
- shdr = gelf_getshdr(scn, &shdr_mem);
- Elf_Data *data = elf_getdata(scn, NULL);
- INFO("\t%02d: data = %p, hdr = { offset = %8lld, size = %lld }, "
- "data->d_buf = %p data->d_off = %lld, data->d_size = %d\n",
- elf_ndxscn(scn),
- data,
- shdr->sh_offset, shdr->sh_size,
- data->d_buf, data->d_off, data->d_size);
-}
-
-static void print_shdr_idx(source_t *source, Elf *elf, int idx)
-{
- print_shdr(source, elf_getscn(elf, idx));
-}
-
-static void print_shdrs(source_t *source) {
- Elf_Scn *scn = NULL;
- INFO("section offset dump for new ELF\n");
- while ((scn = elf_nextscn (source->elf, scn)) != NULL)
- print_shdr(source, scn);
-
- INFO("\nsection offset dump for original ELF\n");
- while ((scn = elf_nextscn (source->oldelf, scn)) != NULL)
- print_shdr(source, scn);
-
-#if 0
- {
- INFO("section offset dump for new ELF\n");
- int i = 0;
- for (i = 0; i < source->shnum; i++) {
- scn = elf_getscn(source->elf, i);
- print_shdr(source, scn);
- }
- }
-#endif
-}
-
-#endif /* DEBUG */
-
-static char * find_file(const char *libname,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs);
-
-static inline source_t* find_source(const char *name,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs) {
- char *full = find_file(name, lib_lookup_dirs, num_lib_lookup_dirs);
- if (full) {
- source_t *trav = sources;
- while (trav) {
- if (!strcmp(trav->name, full))
- break;
- trav = trav->next;
- }
- free(full);
- return trav;
- }
- return NULL;
-}
-
-static inline void add_to_sources(source_t *src) {
- src->next = sources;
- sources = src;
-}
-
-static void handle_range_error(range_error_t err,
- range_t *left, range_t *right) {
- switch (err) {
- case ERROR_CONTAINS:
- ERROR("ERROR: section (%lld, %lld bytes) contains "
- "section (%lld, %lld bytes)\n",
- left->start, left->length,
- right->start, right->length);
- break;
- case ERROR_OVERLAPS:
- ERROR("ERROR: Section (%lld, %lld bytes) intersects "
- "section (%lld, %lld bytes)\n",
- left->start, left->length,
- right->start, right->length);
- break;
- default:
- ASSERT(!"Unknown range error code!");
- }
-
- FAILIF(1, "Range error.\n");
-}
-
-static void create_elf_sections(source_t *source, Elf *elf)
-{
- INFO("Creating new ELF sections.\n");
- ASSERT(elf == NULL || source->elf == NULL || source->elf == elf);
- if (elf == NULL) {
- ASSERT(source->elf != NULL);
- elf = source->elf;
- }
-
- int cnt = 1;
- Elf_Scn *oldscn = NULL, *scn;
- while ((oldscn = elf_nextscn (source->oldelf, oldscn)) != NULL) {
- GElf_Shdr *oldshdr, oldshdr_mem;
-
- scn = elf_newscn(elf);
- FAILIF_LIBELF(NULL == scn, elf_newscn);
-
- oldshdr = gelf_getshdr(oldscn, &oldshdr_mem);
- FAILIF_LIBELF(NULL == oldshdr, gelf_getshdr);
- /* Set the section header of the new section to be the same as the
- headset of the old section by default. */
- gelf_update_shdr(scn, oldshdr);
-
- /* Copy the section data */
- Elf_Data *olddata = elf_getdata(oldscn, NULL);
- FAILIF_LIBELF(NULL == olddata, elf_getdata);
-
- Elf_Data *data = elf_newdata(scn);
- FAILIF_LIBELF(NULL == data, elf_newdata);
- *data = *olddata;
-#if COPY_SECTION_DATA_BUFFER
- if (olddata->d_buf != NULL) {
- data->d_buf = MALLOC(data->d_size);
- memcpy(data->d_buf, olddata->d_buf, olddata->d_size);
- }
-#endif
-
- INFO("\tsection %02d: [%-30s] created\n",
- cnt,
- elf_strptr(source->oldelf,
- source->shstrndx,
- oldshdr->sh_name));
-
- if (ADJUST_ELF) {
- ASSERT(source->shdr_info != NULL);
- /* Create a new section. */
- source->shdr_info[cnt].idx = cnt;
- source->shdr_info[cnt].newscn = scn;
- source->shdr_info[cnt].data = data;
- source->shdr_info[cnt].
- use_old_shdr_for_relocation_calculations = 1;
- INFO("\tsection [%s] (old offset %lld, old size %lld) "
- "will have index %d (was %d).\n",
- source->shdr_info[cnt].name,
- source->shdr_info[cnt].old_shdr.sh_offset,
- source->shdr_info[cnt].old_shdr.sh_size,
- source->shdr_info[cnt].idx,
- elf_ndxscn(source->shdr_info[cnt].scn));
- /* Same as the next assert */
- ASSERT(elf_ndxscn (source->shdr_info[cnt].newscn) ==
- source->shdr_info[cnt].idx);
- }
-
- ASSERT(elf_ndxscn(scn) == (size_t)cnt);
- cnt++;
- }
-}
-
-/* This function sets up the shdr_info[] array of a source_t. We call it only
- when ADJUST_ELF is non-zero (i.e., support for adjusting an ELF file for
- changes in sizes and numbers of relocation sections is compiled in. Note
- that setup_shdr_info() depends only on the information in source->oldelf,
- not on source->elf.
-*/
-
-static void setup_shdr_info(source_t *source)
-{
- if (ADJUST_ELF)
- {
- /* Allocate the section-header-info buffer. */
- INFO("Allocating section-header info structure (%d) bytes...\n",
- source->shnum * sizeof (shdr_info_t));
-
- source->shdr_info = (shdr_info_t *)CALLOC(source->shnum,
- sizeof (shdr_info_t));
-
- /* Mark the SHT_NULL section as handled. */
- source->shdr_info[0].idx = 2;
-
- int cnt = 1;
- Elf_Scn *oldscn = NULL;
- while ((oldscn = elf_nextscn (source->oldelf, oldscn)) != NULL) {
- /* Copy the section header */
- ASSERT(elf_ndxscn(oldscn) == (size_t)cnt);
-
- /* Initialized the corresponding shdr_info entry */
- {
- /* Mark the section with a non-zero index. Later, when we
- decide to drop a section, we will set its idx to zero, and
- assign section numbers to the remaining sections.
- */
- source->shdr_info[cnt].idx = 1;
-
- source->shdr_info[cnt].scn = oldscn;
-
- /* NOTE: Here we pupulate the section-headset struct with the
- same values as the original section's. After the
- first run of prelink(), we will update the sh_size
- fields of those sections that need resizing.
- */
- FAILIF_LIBELF(NULL ==
- gelf_getshdr(oldscn,
- &source->shdr_info[cnt].shdr),
- gelf_getshdr);
-
- /* Get the name of the section. */
- source->shdr_info[cnt].name =
- elf_strptr (source->oldelf, source->shstrndx,
- source->shdr_info[cnt].shdr.sh_name);
-
- INFO("\tname: %s\n", source->shdr_info[cnt].name);
- FAILIF(source->shdr_info[cnt].name == NULL,
- "Malformed file: section %d name is null\n",
- cnt);
-
- /* Remember the shdr.sh_link value. We need to remember this
- value for those sections that refer to other sections. For
- example, we need to remember it for relocation-entry
- sections, because if we modify the symbol table that a
- relocation-entry section is relative to, then we need to
- patch the relocation section. By the time we get to
- deciding whether we need to patch the relocation section, we
- will have overwritten its header's sh_link field with a new
- value.
- */
- source->shdr_info[cnt].old_shdr = source->shdr_info[cnt].shdr;
- INFO("\t\toriginal sh_link: %08d\n",
- source->shdr_info[cnt].old_shdr.sh_link);
- INFO("\t\toriginal sh_addr: %lld\n",
- source->shdr_info[cnt].old_shdr.sh_addr);
- INFO("\t\toriginal sh_offset: %lld\n",
- source->shdr_info[cnt].old_shdr.sh_offset);
- INFO("\t\toriginal sh_size: %lld\n",
- source->shdr_info[cnt].old_shdr.sh_size);
-
- FAILIF(source->shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX,
- "Cannot handle sh_type SHT_SYMTAB_SHNDX!\n");
- FAILIF(source->shdr_info[cnt].shdr.sh_type == SHT_GROUP,
- "Cannot handle sh_type SHT_GROUP!\n");
- FAILIF(source->shdr_info[cnt].shdr.sh_type == SHT_GNU_versym,
- "Cannot handle sh_type SHT_GNU_versym!\n");
- }
-
- cnt++;
- } /* for each section */
- } /* if (ADJUST_ELF) */
-}
-
-static Elf * init_elf(source_t *source, bool create_new_sections)
-{
- Elf *elf;
- if (source->output != NULL) {
- if (source->output_is_dir) {
- source->output_is_dir++;
- char *dir = source->output;
- int dirlen = strlen(dir);
- /* The main() function maintains a pointer to source->output; it
- frees the buffer after apriori() returns.
- */
- source->output = MALLOC(dirlen +
- 1 + /* slash */
- strlen(source->name) +
- 1); /* null terminator */
- strcpy(source->output, dir);
- source->output[dirlen] = '/';
- strcpy(source->output + dirlen + 1,
- basename(source->name));
- }
-
- /* Save some of the info; needed for retouching (ASLR). */
- retouch_init();
-
- source->newelf_fd = open(source->output,
- O_RDWR | O_CREAT,
- 0666);
- FAILIF(source->newelf_fd < 0, "open(%s): %s (%d)\n",
- source->output,
- strerror(errno),
- errno);
- elf = elf_begin(source->newelf_fd, ELF_C_WRITE, NULL);
- FAILIF_LIBELF(elf == NULL, elf_begin);
- } else {
- elf = elf_clone(source->oldelf, ELF_C_EMPTY);
- FAILIF_LIBELF(elf == NULL, elf_clone);
- }
-
- GElf_Ehdr *oldehdr = gelf_getehdr(source->oldelf, &source->old_ehdr_mem);
- FAILIF_LIBELF(NULL == oldehdr, gelf_getehdr);
-
- /* Create new ELF and program headers for the elf file */
- INFO("Creating empty ELF and program headers...\n");
- FAILIF_LIBELF(gelf_newehdr (elf, gelf_getclass (source->oldelf)) == 0,
- gelf_newehdr);
- FAILIF_LIBELF(oldehdr->e_type != ET_REL
- && gelf_newphdr (elf,
- oldehdr->e_phnum) == 0,
- gelf_newphdr);
-
- /* Copy the elf header */
- INFO("Copying ELF header...\n");
- GElf_Ehdr *ehdr = gelf_getehdr(elf, &source->ehdr_mem);
- FAILIF_LIBELF(NULL == ehdr, gelf_getehdr);
- memcpy(ehdr, oldehdr, sizeof(GElf_Ehdr));
- FAILIF_LIBELF(!gelf_update_ehdr(elf, ehdr), gelf_update_ehdr);
-
- /* Copy out the old program header: notice that if the ELF file does not
- have a program header, this loop won't execute.
- */
- INFO("Copying ELF program header...\n");
- {
- int cnt;
- source->phdr_info = (GElf_Phdr *)CALLOC(ehdr->e_phnum,
- sizeof(GElf_Phdr));
- for (cnt = 0; cnt < ehdr->e_phnum; ++cnt) {
- INFO("\tRetrieving entry %d\n", cnt);
- FAILIF_LIBELF(NULL ==
- gelf_getphdr(source->oldelf, cnt,
- source->phdr_info + cnt),
- gelf_getphdr);
- FAILIF_LIBELF(gelf_update_phdr (elf, cnt,
- source->phdr_info + cnt) == 0,
- gelf_update_phdr);
- }
- }
-
- /* Copy the sections and the section headers. */
- if (create_new_sections)
- {
- create_elf_sections(source, elf);
- }
-
- /* The ELF library better follows our layout when this is not a
- relocatable object file. */
- elf_flagelf (elf, ELF_C_SET, (ehdr->e_type != ET_REL ? ELF_F_LAYOUT : 0));
-
- return elf;
-}
-
-static shdr_info_t *lookup_shdr_info_by_new_section(
- source_t *source,
- const char *sname,
- Elf_Scn *newscn)
-{
- if (source->shdr_info == NULL) return NULL;
- int cnt;
- for (cnt = 0; cnt < source->shnum; cnt++) {
- if (source->shdr_info[cnt].newscn == newscn) {
- INFO("\t\tnew section at %p matches shdr_info[%d], "
- "section [%s]!\n",
- newscn,
- cnt,
- source->shdr_info[cnt].name);
- FAILIF(strcmp(sname, source->shdr_info[cnt].name),
- "Matched section's name [%s] does not match "
- "looked-up section's name [%s]!\n",
- source->shdr_info[cnt].name,
- sname);
- return source->shdr_info + cnt;
- }
- }
- return NULL;
-}
-
-static bool do_init_source(source_t *source, unsigned base)
-{
- /* Find various sections. */
- size_t scnidx;
- Elf_Scn *scn;
- GElf_Shdr *shdr, shdr_mem;
- source->sorted_sections = init_range_list();
- INFO("Processing [%s]'s sections...\n", source->name);
- for (scnidx = 1; scnidx < (size_t)source->shnum; scnidx++) {
- INFO("\tGetting section index %d...\n", scnidx);
- scn = elf_getscn(source->elf, scnidx);
- if (NULL == scn) {
- /* If we get an error from elf_getscn(), it means that a section
- at the requested index does not exist. This may happen when
- we remove sections. Since we do not update source->shnum
- (we can't, since we need to know the original number of sections
- to know source->shdr_info[]'s length), we will attempt to
- retrieve a section for an index that no longer exists in the
- new ELF file. */
- INFO("\tThere is no section at index %d anymore, continuing.\n",
- scnidx);
- continue;
- }
- shdr = gelf_getshdr(scn, &shdr_mem);
- FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
-
- /* We haven't modified the shstrtab section, and so shdr->sh_name
- has the same value as before. Thus we look up the name based
- on the old ELF handle. We cannot use shstrndx on the new ELF
- handle because the index of the shstrtab section may have
- changed (and calling elf_getshstrndx() returns the same section
- index, so libelf can't handle thise ither).
- */
- const char *sname =
- elf_strptr(source->oldelf, source->shstrndx, shdr->sh_name);
- ASSERT(sname);
-
- INFO("\tAdding [%s] (%lld, %lld)...\n",
- sname,
- shdr->sh_addr,
- shdr->sh_addr + shdr->sh_size);
- if ((shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) {
- add_unique_range_nosort(source->sorted_sections,
- shdr->sh_addr,
- shdr->sh_size,
- scn,
- handle_range_error,
- NULL); /* no user-data destructor */
- }
-
- if (shdr->sh_type == SHT_DYNSYM) {
- source->symtab.scn = scn;
- source->symtab.data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == source->symtab.data, elf_getdata);
- memcpy(&source->symtab.shdr, shdr, sizeof(GElf_Shdr));
- source->symtab.info = lookup_shdr_info_by_new_section(
- source, sname, scn);
- ASSERT(source->shdr_info == NULL || source->symtab.info != NULL);
-
- /* The sh_link field of the section header of the symbol table
- contains the index of the associated strings table. */
- source->strtab.scn = elf_getscn(source->elf,
- source->symtab.shdr.sh_link);
- FAILIF_LIBELF(NULL == source->strtab.scn, elf_getscn);
- FAILIF_LIBELF(NULL == gelf_getshdr(source->strtab.scn,
- &source->strtab.shdr),
- gelf_getshdr);
- source->strtab.data = elf_getdata(source->strtab.scn, NULL);
- FAILIF_LIBELF(NULL == source->strtab.data, elf_getdata);
- source->strtab.info = lookup_shdr_info_by_new_section(
- source,
- elf_strptr(source->oldelf, source->shstrndx,
- source->strtab.shdr.sh_name),
- source->strtab.scn);
- ASSERT(source->shdr_info == NULL || source->strtab.info != NULL);
- } else if (shdr->sh_type == SHT_DYNAMIC) {
- source->dynamic.scn = scn;
- source->dynamic.data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == source->dynamic.data, elf_getdata);
- memcpy(&source->dynamic.shdr, shdr, sizeof(GElf_Shdr));
- source->dynamic.info = lookup_shdr_info_by_new_section(
- source, sname, scn);
- ASSERT(source->shdr_info == NULL || source->dynamic.info != NULL);
- } else if (shdr->sh_type == SHT_HASH) {
- source->hash.scn = scn;
- source->hash.data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == source->hash.data, elf_getdata);
- memcpy(&source->hash.shdr, shdr, sizeof(GElf_Shdr));
- source->hash.info = lookup_shdr_info_by_new_section(
- source, sname, scn);
- ASSERT(source->shdr_info == NULL || source->hash.info != NULL);
- } else if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) {
- if (source->num_relocation_sections ==
- source->relocation_sections_size) {
- source->relocation_sections_size += 5;
- source->relocation_sections =
- (section_info_t *)REALLOC(source->relocation_sections,
- source->relocation_sections_size *
- sizeof(section_info_t));
- }
- section_info_t *reloc =
- source->relocation_sections + source->num_relocation_sections;
- reloc->scn = scn;
- reloc->info = lookup_shdr_info_by_new_section(source, sname, scn);
- ASSERT(source->shdr_info == NULL || reloc->info != NULL);
- reloc->data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == reloc->data, elf_getdata);
- memcpy(&reloc->shdr, shdr, sizeof(GElf_Shdr));
- source->num_relocation_sections++;
- } else if (!strcmp(sname, ".bss")) {
- source->bss.scn = scn;
- source->bss.data = elf_getdata(scn, NULL);
- source->bss.info = lookup_shdr_info_by_new_section(
- source, sname, scn);
- ASSERT(source->shdr_info == NULL || source->bss.info != NULL);
- /* The BSS section occupies no space in the ELF file. */
- FAILIF_LIBELF(NULL == source->bss.data, elf_getdata)
- FAILIF(NULL != source->bss.data->d_buf,
- "Enexpected: section [%s] has data!",
- sname);
- memcpy(&source->bss.shdr, shdr, sizeof(GElf_Shdr));
- }
- }
- sort_ranges(source->sorted_sections);
-
- source->unfinished =
- (unfinished_relocation_t *)CALLOC(source->num_relocation_sections,
- sizeof(unfinished_relocation_t));
-
- if (source->dynamic.scn == NULL) {
- INFO("File [%s] does not have a dynamic section!\n", source->name);
- /* If this is a static executable, we won't update anything. */
- source->dry_run = 1;
- return false;
- }
-
- FAILIF(source->symtab.scn == NULL,
- "File [%s] does not have a dynamic symbol table!\n",
- source->name);
- FAILIF(source->hash.scn == NULL,
- "File [%s] does not have a hash table!\n",
- source->name);
- FAILIF(source->hash.shdr.sh_link != elf_ndxscn(source->symtab.scn),
- "Hash points to section %d, not to %d as expected!\n",
- source->hash.shdr.sh_link,
- elf_ndxscn(source->symtab.scn));
-
- /* Now, find out how many symbols we have and allocate the array of
- satisfied symbols.
-
- NOTE: We don't count the number of undefined symbols here; we will
- iterate over the symbol table later, and count them then, when it is
- more convenient.
- */
- size_t symsize = gelf_fsize (source->elf,
- ELF_T_SYM,
- 1, source->elf_hdr.e_version);
- ASSERT(symsize);
-
- source->num_syms = source->symtab.data->d_size / symsize;
- source->base = (source->oldelf_hdr.e_type == ET_DYN) ? base : 0;
- INFO("Relink base for [%s]: 0x%lx\n", source->name, source->base);
- FAILIF(source->base == -1,
- "Can't prelink [%s]: it's a shared library and you did not "
- "provide a prelink address!\n",
- source->name);
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- FAILIF(source->prelinked && source->base != source->prelink_base,
- "ERROR: file [%s] has already been prelinked for 0x%08lx. "
- "Cannot change to 0x%08lx!\n",
- source->name,
- source->prelink_base,
- source->base);
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-
- return true;
-}
-
-static source_t* init_source(const char *full_path,
- const char *output, int is_file,
- int base, int dry_run)
-{
- source_t *source = (source_t *)CALLOC(1, sizeof(source_t));
-
- ASSERT(full_path);
- source->name = full_path;
- source->output = output;
- source->output_is_dir = !is_file;
-
- source->newelf_fd = -1;
- source->elf_fd = -1;
- INFO("Opening %s...\n", full_path);
- source->elf_fd =
- open(full_path, ((dry_run || output != NULL) ? O_RDONLY : O_RDWR));
- FAILIF(source->elf_fd < 0, "open(%s): %s (%d)\n",
- full_path,
- strerror(errno),
- errno);
-
- FAILIF(fstat(source->elf_fd, &source->elf_file_info) < 0,
- "fstat(%s(fd %d)): %s (%d)\n",
- source->name,
- source->elf_fd,
- strerror(errno),
- errno);
- INFO("File [%s]'s size is %lld bytes!\n",
- source->name,
- source->elf_file_info.st_size);
-
- INFO("Calling elf_begin(%s)...\n", full_path);
-
- source->oldelf =
- elf_begin(source->elf_fd,
- (dry_run || output != NULL) ? ELF_C_READ : ELF_C_RDWR,
- NULL);
- FAILIF_LIBELF(source->oldelf == NULL, elf_begin);
-
- /* libelf can recognize COFF and A.OUT formats, but we handle only ELF. */
- if(elf_kind(source->oldelf) != ELF_K_ELF) {
- ERROR("Input file %s is not in ELF format!\n", full_path);
- return NULL;
- }
-
- /* Make sure this is a shared library or an executable. */
- {
- INFO("Making sure %s is a shared library or an executable...\n",
- full_path);
- FAILIF_LIBELF(0 == gelf_getehdr(source->oldelf, &source->oldelf_hdr),
- gelf_getehdr);
- FAILIF(source->oldelf_hdr.e_type != ET_DYN &&
- source->oldelf_hdr.e_type != ET_EXEC,
- "%s must be a shared library (elf type is %d, expecting %d).\n",
- full_path,
- source->oldelf_hdr.e_type,
- ET_DYN);
- }
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- /* First, check to see if the file has been prelinked. */
- source->prelinked =
- check_prelinked(source->name,
- source->oldelf_hdr.e_ident[EI_DATA] == ELFDATA2LSB,
- &source->prelink_base);
- /* Note that in the INFO() below we need to use oldelf_hdr because we
- haven't cloned the ELF file yet, and source->elf_hdr is not defined. */
- if (source->prelinked) {
- PRINT("%s [%s] is already prelinked at 0x%08lx!\n",
- (source->oldelf_hdr.e_type == ET_EXEC ?
- "Executable" : "Shared library"),
- source->name,
- source->prelink_base);
- /* Force a dry run when the file has already been prelinked */
- source->dry_run = dry_run = 1;
- }
- else {
- INFO("%s [%s] is not prelinked!\n",
- (source->oldelf_hdr.e_type == ET_EXEC ?
- "Executable" : "Shared library"),
- source->name);
- source->dry_run = dry_run;
- }
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-
- /* Get the index of the section-header-strings-table section. */
- FAILIF_LIBELF(elf_getshstrndx (source->oldelf, &source->shstrndx) < 0,
- elf_getshstrndx);
-
- FAILIF_LIBELF(elf_getshnum (source->oldelf, (size_t *)&source->shnum) < 0,
- elf_getshnum);
-
- /* When we have a dry run, or when ADJUST_ELF is enabled, we use
- source->oldelf for source->elf, because the former is mmapped privately,
- so changes to it have no effect. With ADJUST_ELF, the first run of
- prelink() is a dry run. We will reopen the elf file for write access
- after that dry run, before we call adjust_elf. */
-
- source->elf = (ADJUST_ELF || source->dry_run) ?
- source->oldelf : init_elf(source, ADJUST_ELF == 0);
-
- FAILIF_LIBELF(0 == gelf_getehdr(source->elf, &source->elf_hdr),
- gelf_getehdr);
-#ifdef DEBUG
- ASSERT(!memcmp(&source->oldelf_hdr,
- &source->elf_hdr,
- sizeof(source->elf_hdr)));
-#endif
-
- /* Get the EBL handling. The -g option is currently the only reason
- we need EBL so dont open the backend unless necessary. */
- source->ebl = ebl_openbackend (source->elf);
- FAILIF_LIBELF(NULL == source->ebl, ebl_openbackend);
-#ifdef ARM_SPECIFIC_HACKS
- FAILIF_LIBELF(0 != arm_init(source->elf, source->elf_hdr.e_machine,
- source->ebl, sizeof(Ebl)),
- arm_init);
-#endif/*ARM_SPECIFIC_HACKS*/
-
- add_to_sources(source);
- if (do_init_source(source, base) == false) return NULL;
- return source;
-}
-
-/* complements do_init_source() */
-static void do_destroy_source(source_t *source)
-{
- int cnt;
- destroy_range_list(source->sorted_sections);
- source->sorted_sections = NULL;
- for (cnt = 0; cnt < source->num_relocation_sections; cnt++) {
- FREEIF(source->unfinished[cnt].rels);
- source->unfinished[cnt].rels = NULL;
- source->unfinished[cnt].num_rels = 0;
- source->unfinished[cnt].rels_size = 0;
- }
- if (source->jmprel.sections != NULL) {
- destroy_range_list(source->jmprel.sections);
- source->jmprel.sections = NULL;
- }
- if (source->rel.sections != NULL) {
- destroy_range_list(source->rel.sections);
- source->rel.sections = NULL;
- }
- FREE(source->unfinished); /* do_init_source() */
- source->unfinished = NULL;
- FREE(source->relocation_sections); /* do_init_source() */
- source->relocation_sections = NULL;
- source->num_relocation_sections = source->relocation_sections_size = 0;
-}
-
-static void destroy_source(source_t *source)
-{
- /* Is this a little-endian ELF file? */
- if (source->oldelf != source->elf) {
- /* If it's a dynamic executable, this must not be a dry run. */
- if (!source->dry_run && source->dynamic.scn != NULL)
- {
- FAILIF_LIBELF(elf_update(source->elf, ELF_C_WRITE) == -1,
- elf_update);
- }
- FAILIF_LIBELF(elf_end(source->oldelf), elf_end);
- }
- ebl_closebackend(source->ebl);
- FAILIF_LIBELF(elf_end(source->elf), elf_end);
- FAILIF(close(source->elf_fd) < 0, "Could not close file %s: %s (%d)!\n",
- source->name, strerror(errno), errno);
- FAILIF((source->newelf_fd >= 0) && (close(source->newelf_fd) < 0),
- "Could not close output file: %s (%d)!\n", strerror(errno), errno);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- if (!source->dry_run) {
- if (source->dynamic.scn != NULL &&
- source->elf_hdr.e_type != ET_EXEC)
- {
- /* For some reason, trying to write directly to source->elf_fd
- causes a "bad file descriptor" error because of something libelf
- does. We just close the file descriptor and open a new one in
- function setup_prelink_info() below. */
- INFO("%s: setting up prelink tag at end of file.\n",
- source->output ? source->output : source->name);
- retouch_encode(-1, source->base);
- retouch_dump(source->output ? source->output : source->name,
- source->elf_hdr.e_ident[EI_DATA] == ELFDATA2LSB,
- retouch_byte_cnt,
- retouch_buf);
- setup_prelink_info(source->output ? source->output : source->name,
- source->elf_hdr.e_ident[EI_DATA] == ELFDATA2LSB,
- source->base);
- }
- else INFO("%s: executable, NOT setting up prelink tag.\n",
- source->name);
- }
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-
- do_destroy_source(source);
- if (retouch_buf != NULL) { free(retouch_buf); retouch_buf = NULL; }
-
- if (source->shstrtab_data != NULL)
- FREEIF(source->shstrtab_data->d_buf); /* adjust_elf */
-
- FREE(source->lib_deps); /* list of library dependencies (process_file()) */
- FREEIF(source->shdr_info); /* setup_shdr_info() */
- FREEIF(source->phdr_info); /* init_elf() */
- FREE(source->name); /* assigned to by init_source() */
- /* If the output is a directory, in init_elf() we allocate a buffer where
- we copy the directory, a slash, and the file name. Here we free that
- buffer.
- */
- if (source->output_is_dir > 1) {
- FREE(source->output);
- }
- FREE(source); /* init_source() */
-}
-
-static void reinit_source(source_t *source)
-{
- do_destroy_source(source);
- do_init_source(source, source->base);
-
- {
- /* We've gathered all the DT_DYNAMIC entries; now we need to figure
- out which relocation sections fit in which range as described by
- the entries. Before we do so, however, we will populate the
- jmprel and rel members of source, as well as their sizes.
- */
-
- size_t dynidx, numdyn;
- GElf_Dyn *dyn, dyn_mem;
-
- numdyn = source->dynamic.shdr.sh_size /
- source->dynamic.shdr.sh_entsize;
-
- source->rel.idx = source->rel.sz_idx = -1;
- source->jmprel.idx = source->jmprel.sz_idx = -1;
- for (dynidx = 0; dynidx < numdyn; dynidx++) {
- dyn = gelf_getdyn (source->dynamic.data,
- dynidx,
- &dyn_mem);
- FAILIF_LIBELF(NULL == dyn, gelf_getdyn);
- switch (dyn->d_tag)
- {
- case DT_NEEDED:
- break;
- case DT_JMPREL:
- INFO("reinit_source: DT_JMPREL is at index %d, 0x%08llx.\n",
- dynidx, dyn->d_un.d_ptr);
- source->jmprel.idx = dynidx;
- source->jmprel.addr = dyn->d_un.d_ptr;
- break;
- case DT_PLTRELSZ:
- INFO("reinit_source: DT_PLTRELSZ is at index %d, 0x%08llx.\n",
- dynidx, dyn->d_un.d_val);
- source->jmprel.sz_idx = dynidx;
- source->jmprel.size = dyn->d_un.d_val;
- break;
- case DT_REL:
- INFO("reinit_source: DT_REL is at index %d, 0x%08llx.\n",
- dynidx, dyn->d_un.d_ptr);
- source->rel.idx = dynidx;
- source->rel.addr = dyn->d_un.d_ptr;
- break;
- case DT_RELSZ:
- INFO("reinit_source: DT_RELSZ is at index %d, 0x%08llx.\n",
- dynidx, dyn->d_un.d_val);
- source->rel.sz_idx = dynidx;
- source->rel.size = dyn->d_un.d_val;
- break;
- case DT_RELA:
- case DT_RELASZ:
- FAILIF(1, "Can't handle DT_RELA and DT_RELASZ entries!\n");
- break;
- } /* switch */
- } /* for each dynamic entry... */
- }
-}
-
-static GElf_Sym *hash_lookup_global_or_weak_symbol(source_t *lib,
- const char *symname,
- GElf_Sym *lib_sym_mem)
-{
- int lib_symidx = hash_lookup(lib->elf,
- lib->hash.data,
- lib->symtab.data,
- lib->strtab.data,
- symname);
-
- GElf_Sym sym_mem;
- if (SHN_UNDEF != lib_symidx) {
- /* We found the symbol--now check to see if it is global
- or weak. If this is the case, then the symbol satisfies
- the dependency. */
- GElf_Sym *lib_sym = gelf_getsymshndx(lib->symtab.data,
- NULL,
- lib_symidx,
- &sym_mem,
- NULL);
- FAILIF_LIBELF(NULL == lib_sym, gelf_getsymshndx);
-#if ELF_STRPTR_IS_BROKEN
- ASSERT(!strcmp(
- symname,
- ((char *)elf_getdata(elf_getscn(lib->elf,
- lib->symtab.shdr.sh_link),
- NULL)->d_buf) +
- lib_sym->st_name));
-#else
- ASSERT(!strcmp(
- symname,
- elf_strptr(lib->elf, lib->symtab.shdr.sh_link,
- lib_sym->st_name)));
-#endif
- if (lib_sym->st_shndx != SHN_UNDEF &&
- (GELF_ST_BIND(lib_sym->st_info) == STB_GLOBAL ||
- GELF_ST_BIND(lib_sym->st_info) == STB_WEAK)) {
- memcpy(lib_sym_mem, &sym_mem, sizeof(GElf_Sym));
- return lib_sym;
- }
- }
-
- return NULL;
-}
-
-static source_t *lookup_symbol_in_dependencies(source_t *source,
- const char *symname,
- GElf_Sym *found_sym)
-{
- source_t *sym_source = NULL; /* return value */
-
- /* This is an undefined symbol. Go over the list of libraries
- and look it up. */
- size_t libidx;
- int found = 0;
- source_t *last_found = NULL;
- for (libidx = 0; libidx < (size_t)source->num_lib_deps; libidx++) {
- source_t *lib = source->lib_deps[libidx];
- if (hash_lookup_global_or_weak_symbol(lib, symname, found_sym) != NULL)
- {
- sym_source = lib;
- if (found) {
- if (found == 1) {
- found++;
- ERROR("ERROR: multiple definitions found for [%s:%s]!\n",
- source->name, symname);
- ERROR("\tthis definition [%s]\n", lib->name);
- }
- ERROR("\tprevious definition [%s]\n", last_found->name);
- }
- last_found = lib;
- if (!found) found = 1;
- }
- }
-
-#if ELF_STRPTR_IS_BROKEN
- ASSERT(!sym_source ||
- !strcmp(symname,
- (char *)(elf_getdata(elf_getscn(
- sym_source->elf,
- sym_source->symtab.shdr.sh_link),
- NULL)->d_buf) +
- found_sym->st_name));
-#else
- ASSERT(!sym_source ||
- !strcmp(symname,
- elf_strptr(sym_source->elf,
- sym_source->symtab.shdr.sh_link,
- found_sym->st_name)));
-#endif
-
- return sym_source;
-}
-
-static int do_prelink(source_t *source,
- Elf_Data *reloc_scn_data,
- int reloc_scn_entry_size,
- unfinished_relocation_t *unfinished,
- int locals_only,
- bool dry_run,
- char **lib_lookup_dirs, int num_lib_lookup_dirs,
- char **default_libs, int num_default_libs,
- int *num_unfinished_relocs)
-{
- int num_relocations = 0;
-
- size_t num_rels;
- num_rels = reloc_scn_data->d_size / reloc_scn_entry_size;
-
- INFO("\tThere are %d relocations.\n", num_rels);
-
- int rel_idx;
- for (rel_idx = 0; rel_idx < (size_t)num_rels; rel_idx++) {
- GElf_Rel *rel, rel_mem;
-
- //INFO("\tHandling relocation %d/%d\n", rel_idx, num_rels);
-
- rel = gelf_getrel(reloc_scn_data, rel_idx, &rel_mem);
- FAILIF_LIBELF(rel == NULL, gelf_getrel);
- GElf_Sym *sym = NULL, sym_mem;
- unsigned sym_idx = GELF_R_SYM(rel->r_info);
- source_t *sym_source = NULL;
- /* found_sym points to found_sym_mem, when sym_source != NULL, and
- to sym, when the sybmol is locally defined. If the symbol is
- not locally defined and sym_source == NULL, then sym is not
- defined either. */
- GElf_Sym *found_sym = NULL, found_sym_mem;
- const char *symname = NULL;
- int sym_is_local = 1;
- if (sym_idx) {
- sym = gelf_getsymshndx(source->symtab.data,
- NULL,
- sym_idx,
- &sym_mem,
- NULL);
- FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
-#if ELF_STRPTR_IS_BROKEN
- symname =
- ((char *)source->strtab.data->d_buf) +
- sym->st_name;
-#else
- symname = elf_strptr(source->elf,
- elf_ndxscn(source->strtab.scn),
- sym->st_name);
-#endif
-
- /* If the symbol is defined and is either not in the BSS
- section, or if it is in the BSS then the relocation is
- not a copy relocation, then the symbol's source is this
- library (i.e., it is locally-defined). Otherwise, the
- symbol is imported.
- */
-
- sym_is_local = 0;
- if (sym->st_shndx != SHN_UNDEF &&
- (source->bss.scn == NULL ||
- sym->st_shndx != elf_ndxscn(source->bss.scn) ||
-#ifdef ARM_SPECIFIC_HACKS
- GELF_R_TYPE(rel->r_info) != R_ARM_COPY
-#else
- 1
-#endif
- ))
- {
- sym_is_local = 1;
- }
-
- if (sym_is_local) {
- INFO("\t\tSymbol [%s:%s] is defined locally.\n",
- source->name,
- symname);
- sym_source = source;
- found_sym = sym;
- }
- else if (!locals_only) {
- sym_source = lookup_symbol_in_dependencies(source,
- symname,
- &found_sym_mem);
-
- /* The symbol was not in the list of dependencies, which by
- itself is an error: it means either that the symbol does
- not exist anywhere, or that the library which has the symbol
- has not been listed as a dependency in this library or
- executable. It could also mean (for a library) that the
- symbol is defined in the executable that links agsinst it,
- which is obviously not a good thing. These are bad things,
- but they do happen, which is why we have the ability to
- provide a list of default dependencies, including
- executables. Here we check to see if the symbol has been
- defined in any of them.
- */
- if (NULL == sym_source) {
- INFO("\t\tChecking default dependencies...\n");
- int i;
- source_t *lib, *old_sym_source = NULL;
- int printed_initial_error = 0;
- for (i = 0; i < num_default_libs; i++) {
- INFO("\tChecking in [%s].\n", default_libs[i]);
- lib = find_source(default_libs[i],
- lib_lookup_dirs,
- num_lib_lookup_dirs);
- FAILIF(NULL == lib,
- "Can't find default library [%s]!\n",
- default_libs[i]);
- if (hash_lookup_global_or_weak_symbol(lib,
- symname,
- &found_sym_mem)) {
- found_sym = &found_sym_mem;
- sym_source = lib;
-#if ELF_STRPTR_IS_BROKEN
- ASSERT(!strcmp(symname,
- (char *)(elf_getdata(
- elf_getscn(
- sym_source->elf,
- sym_source->symtab.
- shdr.sh_link),
- NULL)->d_buf) +
- found_sym->st_name));
-#else
- ASSERT(!strcmp(symname,
- elf_strptr(sym_source->elf,
- sym_source->symtab.shdr.sh_link,
- found_sym->st_name)));
-
-#endif
- INFO("\tFound symbol [%s] in [%s]!\n",
- symname, lib->name);
- if (old_sym_source) {
- if (printed_initial_error == 0) {
- printed_initial_error = 1;
- ERROR("Multiple definition of [%s]:\n"
- "\t[%s]\n",
- symname,
- old_sym_source->name);
- }
- ERROR("\t[%s]\n", sym_source->name);
- }
- old_sym_source = sym_source;
- } else {
- INFO("\tCould not find symbol [%s] in default "
- "lib [%s]!\n", symname, lib->name);
- }
- }
- if (sym_source) {
- ERROR("ERROR: Could not find [%s:%s] in dependent "
- "libraries (but found in default [%s])!\n",
- source->name,
- symname,
- sym_source->name);
- }
- } else {
- found_sym = &found_sym_mem;
- /* We found the symbol in a dependency library. */
- INFO("\t\tSymbol [%s:%s, value %lld] is imported from [%s]\n",
- source->name,
- symname,
- found_sym->st_value,
- sym_source->name);
- }
- } /* if symbol is defined in this library... */
-
- if (!locals_only) {
- /* If a symbol is weak and we haven't found it, then report
- an error. We really need to find a way to set its value
- to zero. The problem is that it needs to refer to some
- section. */
-
- FAILIF(NULL == sym_source &&
- GELF_ST_BIND(sym->st_info) == STB_WEAK,
- "Cannot handle weak symbols yet (%s:%s <- %s).\n",
- source->name,
- symname,
- sym_source->name);
-#ifdef PERMISSIVE
- if (GELF_ST_BIND(sym->st_info) != STB_WEAK &&
- NULL == sym_source) {
- ERROR("ERROR: Can't find symbol [%s:%s] in dependent or "
- "default libraries!\n", source->name, symname);
- }
-#else
- FAILIF(GELF_ST_BIND(sym->st_info) != STB_WEAK &&
- NULL == sym_source,
- "Can't find symbol [%s:%s] in dependent or default "
- "libraries!\n",
- source->name,
- symname);
-#endif
- } /* if (!locals_only) */
- }
-#if 0 // too chatty
- else
- INFO("\t\tno symbol is associated with this relocation\n");
-#endif
-
-
- // We prelink only local symbols when locals_only == 1.
-
- bool can_relocate = true;
- if (!sym_is_local &&
- (symname[0] == 'd' && symname[1] == 'l' && symname[2] != '\0' &&
- (!strcmp(symname + 2, "open") ||
- !strcmp(symname + 2, "close") ||
- !strcmp(symname + 2, "sym") ||
- !strcmp(symname + 2, "error")))) {
- INFO("********* NOT RELOCATING LIBDL SYMBOL [%s]\n", symname);
- can_relocate = false;
- }
-
- if (can_relocate && (sym_is_local || !locals_only))
- {
- GElf_Shdr shdr_mem; Elf_Scn *scn; Elf_Data *data;
- find_section(source, rel->r_offset, &scn, &shdr_mem, &data);
- unsigned *dest =
- (unsigned*)(((char *)data->d_buf) +
- (rel->r_offset - shdr_mem.sh_addr));
- unsigned rel_type = GELF_R_TYPE(rel->r_info);
- char buf[64];
- INFO("\t\t%-15s ",
- ebl_reloc_type_name(source->ebl,
- GELF_R_TYPE(rel->r_info),
- buf,
- sizeof(buf)));
-
- /* Section-name offsets do not change, so we use oldelf to get the
- strings. This makes a difference in the second pass of the
- perlinker, after the call to adjust_elf, because
- source->shstrndx no longer contains the index of the
- section-header-strings table.
- */
- const char *sname = elf_strptr(
- source->oldelf, source->shstrndx, shdr_mem.sh_name);
-
- switch (rel_type) {
- case R_ARM_JUMP_SLOT:
- case R_ARM_GLOB_DAT:
- case R_ARM_ABS32:
- ASSERT(data->d_buf != NULL);
- ASSERT(data->d_size >= rel->r_offset - shdr_mem.sh_addr);
-#ifdef PERMISSIVE
- if (sym_source == NULL) {
- ERROR("ERROR: Permissive relocation "
- "[%-15s] [%s:%s]: [0x%llx] = ZERO\n",
- ebl_reloc_type_name(source->ebl,
- GELF_R_TYPE(rel->r_info),
- buf,
- sizeof(buf)),
- sname,
- symname,
- rel->r_offset);
- if (!dry_run)
- *dest = 0;
- } else
-#endif
- {
- ASSERT(sym_source);
- INFO("[%s:%s]: [0x%llx] = 0x%llx + 0x%lx\n",
- sname,
- symname,
- rel->r_offset,
- found_sym->st_value,
- sym_source->base);
- if (!dry_run) {
- PRINT("WARNING: Relocation type not supported "
- "for retouching!");
- *dest = found_sym->st_value + sym_source->base;
- }
- }
- num_relocations++;
- break;
- case R_ARM_RELATIVE:
- ASSERT(data->d_buf != NULL);
- ASSERT(data->d_size >= rel->r_offset - shdr_mem.sh_addr);
- FAILIF(sym != NULL,
- "Unsupported RELATIVE form (symbol != 0)...\n");
- INFO("[%s:%s]: [0x%llx] = 0x%x + 0x%lx\n",
- sname,
- symname ?: "(symbol has no name)",
- rel->r_offset, *dest, source->base);
- if (!dry_run) {
- *dest += source->base;
-
- /* Output an entry for the ASLR touch-up process. */
- retouch_encode(rel->r_offset
- -shdr_mem.sh_addr
- +shdr_mem.sh_offset,
- *dest);
- }
- num_relocations++;
- break;
- case R_ARM_COPY:
-#ifdef PERMISSIVE
- if (sym_source == NULL) {
- ERROR("ERROR: Permissive relocation "
- "[%-15s] [%s:%s]: NOT PERFORMING\n",
- ebl_reloc_type_name(source->ebl,
- GELF_R_TYPE(rel->r_info),
- buf,
- sizeof(buf)),
- sname,
- symname);
- } else
-#endif
- {
- ASSERT(sym);
- ASSERT(sym_source);
- GElf_Shdr src_shdr_mem;
- Elf_Scn *src_scn;
- Elf_Data *src_data;
- find_section(sym_source, found_sym->st_value,
- &src_scn,
- &src_shdr_mem,
- &src_data);
- INFO("Found [%s:%s (%lld)] in section [%s] .\n",
- sym_source->name,
- symname,
- found_sym->st_value,
-#if ELF_STRPTR_IS_BROKEN
- (((char *)elf_getdata(
- elf_getscn(sym_source->elf,
- sym_source->shstrndx),
- NULL)->d_buf) + src_shdr_mem.sh_name)
-#else
- elf_strptr(sym_source->elf,
- sym_source->shstrndx,
- src_shdr_mem.sh_name)
-#endif
- );
-
- unsigned *src = NULL;
- if (src_data->d_buf == NULL)
- {
-#ifdef PERMISSIVE
- if (sym_source->bss.scn == NULL ||
- elf_ndxscn(src_scn) !=
- elf_ndxscn(sym_source->bss.scn)) {
- ERROR("ERROR: Permissive relocation (NULL source "
- "not from .bss) [%-15s] [%s:%s]: "
- "NOT PERFORMING\n",
- ebl_reloc_type_name(source->ebl,
- GELF_R_TYPE(rel->r_info),
- buf,
- sizeof(buf)),
- sname,
- symname);
- }
-#endif
- }
- else {
- ASSERT(src_data->d_size >=
- found_sym->st_value - src_shdr_mem.sh_addr);
- src = (unsigned*)(((char *)src_data->d_buf) +
- (found_sym->st_value -
- src_shdr_mem.sh_addr));
- }
- ASSERT(symname);
- INFO("[%s:%s]: [0x%llx] <- [0x%llx] size %lld\n",
- sname,
- symname, rel->r_offset,
- found_sym->st_value,
- found_sym->st_size);
-
-#ifdef PERMISSIVE
- if (src_data->d_buf != NULL ||
- (sym_source->bss.scn != NULL &&
- elf_ndxscn(src_scn) ==
- elf_ndxscn(sym_source->bss.scn)))
-#endif/*PERMISSIVE*/
- {
- if (data->d_buf == NULL) {
- INFO("Incomplete relocation [%-15s] of [%s:%s].\n",
- ebl_reloc_type_name(source->ebl,
- GELF_R_TYPE(rel->r_info),
- buf,
- sizeof(buf)),
- sname,
- symname);
- FAILIF(unfinished == NULL,
- "You passed unfinished as NULL expecting "
- "to handle all relocations, "
- "but at least one cannot be handled!\n");
- if (unfinished->num_rels == unfinished->rels_size) {
- unfinished->rels_size += 10;
- unfinished->rels = (GElf_Rel *)REALLOC(
- unfinished->rels,
- unfinished->rels_size *
- sizeof(GElf_Rel));
- }
- unfinished->rels[unfinished->num_rels++] = *rel;
- num_relocations--;
- (*num_unfinished_relocs)++;
- }
- else {
- if (src_data->d_buf != NULL)
- {
- ASSERT(data->d_buf != NULL);
- ASSERT(data->d_size >= rel->r_offset -
- shdr_mem.sh_addr);
- if (!dry_run) {
- PRINT("WARNING: Relocation type not supported "
- "for retouching!");
- memcpy(dest, src, found_sym->st_size);
- }
- }
- else {
- ASSERT(src == NULL);
- ASSERT(elf_ndxscn(src_scn) ==
- elf_ndxscn(sym_source->bss.scn));
- if (!dry_run) {
- PRINT("WARNING: Relocation type not supported "
- "for retouching!");
- memset(dest, 0, found_sym->st_size);
- }
- }
- }
- }
- num_relocations++;
- }
- break;
- default:
- FAILIF(1, "Unknown relocation type %d!\n", rel_type);
- } // switch
- } // relocate
- else {
- INFO("\t\tNot relocating symbol [%s]%s\n",
- symname,
- (can_relocate ? ", relocating only locals" :
- ", which is a libdl symbol"));
- FAILIF(unfinished == NULL,
- "You passed unfinished as NULL expecting to handle all "
- "relocations, but at least one cannot be handled!\n");
- if (unfinished->num_rels == unfinished->rels_size) {
- unfinished->rels_size += 10;
- unfinished->rels = (GElf_Rel *)REALLOC(
- unfinished->rels,
- unfinished->rels_size *
- sizeof(GElf_Rel));
- }
- unfinished->rels[unfinished->num_rels++] = *rel;
- (*num_unfinished_relocs)++;
- }
- } // for each relocation entry
-
- return num_relocations;
-}
-
-static int prelink(source_t *source,
- int locals_only,
- bool dry_run,
- char **lib_lookup_dirs, int num_lib_lookup_dirs,
- char **default_libs, int num_default_libs,
- int *num_unfinished_relocs)
-{
- INFO("Prelinking [%s] (number of relocation sections: %d)%s...\n",
- source->name, source->num_relocation_sections,
- (dry_run ? " (dry run)" : ""));
- int num_relocations = 0;
- int rel_scn_idx;
- for (rel_scn_idx = 0; rel_scn_idx < source->num_relocation_sections;
- rel_scn_idx++)
- {
- section_info_t *reloc_scn = source->relocation_sections + rel_scn_idx;
- unfinished_relocation_t *unfinished = source->unfinished + rel_scn_idx;
-
- /* We haven't modified the shstrtab section, and so shdr->sh_name has
- the same value as before. Thus we look up the name based on the old
- ELF handle. We cannot use shstrndx on the new ELF handle because
- the index of the shstrtab section may have changed (and calling
- elf_getshstrndx() returns the same section index, so libelf can't
- handle thise ither).
-
- If reloc_scn->info is available, we can assert that the
- section-name has not changed. If this assertion fails,
- then we cannot use the elf_strptr() trick below to get
- the section name. One solution would be to save it in
- the section_info_t structure.
- */
- ASSERT(reloc_scn->info == NULL ||
- reloc_scn->shdr.sh_name == reloc_scn->info->old_shdr.sh_name);
- const char *sname =
- elf_strptr(source->oldelf,
- source->shstrndx,
- reloc_scn->shdr.sh_name);
- ASSERT(sname != NULL);
-
- INFO("\n\tIterating relocation section [%s]...\n", sname);
-
- /* In general, the new size of the section differs from the original
- size of the section, because we can handle some of the relocations.
- This was communicated to adjust_elf, which modified the ELF file
- according to the new section sizes. Now, when prelink() does the
- actual work of prelinking, it needs to know the original size of the
- relocation section so that it can see all of the original relocation
- entries!
- */
- size_t d_size = reloc_scn->data->d_size;
- if (reloc_scn->info != NULL &&
- reloc_scn->data->d_size != reloc_scn->info->old_shdr.sh_size)
- {
- INFO("Setting size of section [%s] to from new size %d to old "
- "size %lld temporarily (so prelinker can see all "
- "relocations).\n",
- reloc_scn->info->name,
- d_size,
- reloc_scn->info->old_shdr.sh_size);
- reloc_scn->data->d_size = reloc_scn->info->old_shdr.sh_size;
- }
-
- num_relocations +=
- do_prelink(source,
- reloc_scn->data, reloc_scn->shdr.sh_entsize,
- unfinished,
- locals_only, dry_run,
- lib_lookup_dirs, num_lib_lookup_dirs,
- default_libs, num_default_libs,
- num_unfinished_relocs);
-
- if (reloc_scn->data->d_size != d_size)
- {
- ASSERT(reloc_scn->info != NULL);
- INFO("Resetting size of section [%s] to %d\n",
- reloc_scn->info->name,
- d_size);
- reloc_scn->data->d_size = d_size;
- }
- }
-
- /* Now prelink those relocation sections which were fully handled, and
- therefore removed. They are not a part of the
- source->relocation_sections[] array anymore, but we can find them by
- scanning source->shdr_info[] and looking for sections with idx == 0.
- */
-
- if (ADJUST_ELF && source->shdr_info != NULL) {
- /* Walk over the shdr_info[] array to see if we've removed any
- relocation sections. prelink() those sections as well.
- */
- int i;
- for (i = 0; i < source->shnum; i++) {
- shdr_info_t *info = source->shdr_info + i;
- if (info->idx == 0 &&
- (info->shdr.sh_type == SHT_REL ||
- info->shdr.sh_type == SHT_RELA)) {
-
- Elf_Data *data = elf_getdata(info->scn, NULL);
- ASSERT(data->d_size == 0);
- data->d_size = info->old_shdr.sh_size;
-
- INFO("\n\tIterating relocation section [%s], which was "
- "discarded (size %d, entry size %lld).\n",
- info->name,
- data->d_size,
- info->old_shdr.sh_entsize);
-
- num_relocations +=
- do_prelink(source,
- data, info->old_shdr.sh_entsize,
- NULL, /* the section was fully handled */
- locals_only, dry_run,
- lib_lookup_dirs, num_lib_lookup_dirs,
- default_libs, num_default_libs,
- num_unfinished_relocs);
-
- data->d_size = 0;
- }
- }
- }
- return num_relocations;
-}
-
-static char * find_file(const char *libname,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs) {
- if (libname[0] == '/') {
- /* This is an absolute path name--just return it. */
- /* INFO("ABSOLUTE PATH: [%s].\n", libname); */
- return strdup(libname);
- } else {
- /* First try the working directory. */
- int fd;
- if ((fd = open(libname, O_RDONLY)) > 0) {
- close(fd);
- /* INFO("FOUND IN CURRENT DIR: [%s].\n", libname); */
- return strdup(libname);
- } else {
- /* Iterate over all library paths. For each path, append the file
- name and see if there is a file at that place. If that fails,
- bail out. */
-
- char *name;
- while (num_lib_lookup_dirs--) {
- size_t lib_len = strlen(*lib_lookup_dirs);
- /* one extra character for the slash, and another for the
- terminating NULL. */
- name = (char *)MALLOC(lib_len + strlen(libname) + 2);
- strcpy(name, *lib_lookup_dirs);
- name[lib_len] = '/';
- strcpy(name + lib_len + 1, libname);
- if ((fd = open(name, O_RDONLY)) > 0) {
- close(fd);
- /* INFO("FOUND: [%s] in [%s].\n", libname, name); */
- return name;
- }
- INFO("NOT FOUND: [%s] in [%s].\n", libname, name);
- free(name);
- }
- }
- }
- return NULL;
-}
-
-static void adjust_dynamic_segment_entry_size(source_t *source,
- dt_rel_info_t *dyn)
-{
- /* Update the size entry in the DT_DYNAMIC segment. */
- GElf_Dyn *dyn_entry, dyn_entry_mem;
- dyn_entry = gelf_getdyn(source->dynamic.data,
- dyn->sz_idx,
- &dyn_entry_mem);
- FAILIF_LIBELF(NULL == dyn_entry, gelf_getdyn);
- /* If we are calling this function to adjust the size of the dynamic entry,
- then there should be some unfinished relocations remaining. If there
- are none, then we should remove the entry from the dynamic section
- altogether.
- */
- ASSERT(dyn->num_unfinished_relocs);
-
- size_t relsize = gelf_fsize(source->elf,
- ELF_T_REL,
- 1,
- source->elf_hdr.e_version);
-
- if (unlikely(verbose_flag)) {
- char buf[64];
- INFO("Updating entry %d: [%-10s], %08llx --> %08x\n",
- dyn->sz_idx,
- ebl_dynamic_tag_name (source->ebl, dyn_entry->d_tag,
- buf, sizeof (buf)),
- dyn_entry->d_un.d_val,
- dyn->num_unfinished_relocs * relsize);
- }
-
- dyn_entry->d_un.d_val = dyn->num_unfinished_relocs * relsize;
-
- FAILIF_LIBELF(!gelf_update_dyn(source->dynamic.data,
- dyn->sz_idx,
- dyn_entry),
- gelf_update_dyn);
-}
-
-static void adjust_dynamic_segment_entries(source_t *source)
-{
- /* This function many remove entries from the dynamic segment, but it won't
- resize the relevant section. It'll just fill the remainted with empty
- DT entries.
-
- FIXME: This is not guaranteed right now. If a dynamic segment does not
- end with null DT entries, I think this will break.
- */
- FAILIF(source->rel.processed,
- "More than one section matches DT_REL entry in dynamic segment!\n");
- FAILIF(source->jmprel.processed,
- "More than one section matches DT_JMPREL entry in "
- "dynamic segment!\n");
- source->rel.processed =
- source->jmprel.processed = 1;
-
- if (source->rel.num_unfinished_relocs > 0)
- adjust_dynamic_segment_entry_size(source, &source->rel);
-
- if (source->jmprel.num_unfinished_relocs > 0)
- adjust_dynamic_segment_entry_size(source, &source->jmprel);
-
- /* If at least one of the entries is empty, then we need to remove it. We
- have already adjusted the size of the other.
- */
- if (source->rel.num_unfinished_relocs == 0 ||
- source->jmprel.num_unfinished_relocs == 0)
- {
- /* We need to delete the DT_REL/DT_RELSZ and DT_PLTREL/DT_PLTRELSZ
- entries from the dynamic segment. */
-
- GElf_Dyn *dyn_entry, dyn_entry_mem;
- size_t dynidx, updateidx;
-
- size_t numdyn =
- source->dynamic.shdr.sh_size /
- source->dynamic.shdr.sh_entsize;
-
- for (updateidx = dynidx = 0; dynidx < numdyn; dynidx++)
- {
- dyn_entry = gelf_getdyn(source->dynamic.data,
- dynidx,
- &dyn_entry_mem);
- FAILIF_LIBELF(NULL == dyn_entry, gelf_getdyn);
- if ((source->rel.num_unfinished_relocs == 0 &&
- (dynidx == source->rel.idx ||
- dynidx == source->rel.sz_idx)) ||
- (source->jmprel.num_unfinished_relocs == 0 &&
- (dynidx == source->jmprel.idx ||
- dynidx == source->jmprel.sz_idx)))
- {
- if (unlikely(verbose_flag)) {
- char buf[64];
- INFO("\t(!)\tRemoving entry %02d: [%-10s], %08llx\n",
- dynidx,
- ebl_dynamic_tag_name (source->ebl, dyn_entry->d_tag,
- buf, sizeof (buf)),
- dyn_entry->d_un.d_val);
- }
- continue;
- }
-
- if (unlikely(verbose_flag)) {
- char buf[64];
- INFO("\t\tKeeping entry %02d: [%-10s], %08llx\n",
- dynidx,
- ebl_dynamic_tag_name (source->ebl, dyn_entry->d_tag,
- buf, sizeof (buf)),
- dyn_entry->d_un.d_val);
- }
-
- gelf_update_dyn(source->dynamic.data,
- updateidx,
- &dyn_entry_mem);
- updateidx++;
- }
- }
-} /* adjust_dynamic_segment_entries */
-
-static bool adjust_dynamic_segment_for(source_t *source,
- dt_rel_info_t *dyn,
- bool adjust_section_size_only)
-{
- bool dropped_sections = false;
-
- /* Go over the sections that belong to this dynamic range. */
- dyn->num_unfinished_relocs = 0;
- if (dyn->sections) {
- int num_scns, idx;
- range_t *scns = get_sorted_ranges(dyn->sections, &num_scns);
-
- INFO("\tdynamic range %s:[%lld, %lld) contains %d sections.\n",
- source->name,
- dyn->addr,
- dyn->addr + dyn->size,
- num_scns);
-
- ASSERT(scns);
- int next_idx = 0, next_rel_off = 0;
- /* The total number of unfinished relocations for this dynamic
- * entry. */
- section_info_t *next = (section_info_t *)scns[next_idx].user;
- section_info_t *first = next;
- ASSERT(first);
- for (idx = 0; idx < num_scns; idx++) {
- section_info_t *reloc_scn = (section_info_t *)scns[idx].user;
- size_t rel_scn_idx = reloc_scn - source->relocation_sections;
- ASSERT(rel_scn_idx < (size_t)source->num_relocation_sections);
- unfinished_relocation_t *unfinished =
- &source->unfinished[rel_scn_idx];
- int unf_idx;
-
- ASSERT(reloc_scn->info == NULL ||
- reloc_scn->shdr.sh_name ==
- reloc_scn->info->old_shdr.sh_name);
- const char *sname =
- elf_strptr(source->oldelf,
- source->shstrndx,
- reloc_scn->shdr.sh_name);
-
- INFO("\tsection [%s] contains %d unfinished relocs.\n",
- sname,
- unfinished->num_rels);
-
- for (unf_idx = 0; unf_idx < unfinished->num_rels; unf_idx++)
- {
- /* There are unfinished relocations. Copy them forward to the
- lowest section we can. */
-
- while (next_rel_off ==
- (int)(next->shdr.sh_size/next->shdr.sh_entsize))
- {
- INFO("\tsection [%s] has filled up with %d unfinished "
- "relocs.\n",
- sname,
- next_rel_off);
-
- next_idx++;
- ASSERT(next_idx <= idx);
- next = (section_info_t *)scns[next_idx].user;
- next_rel_off = 0;
- }
-
- if (!adjust_section_size_only) {
- INFO("\t\tmoving unfinished relocation %2d to [%s:%d]\n",
- unf_idx,
- sname,
- next_rel_off);
- FAILIF_LIBELF(0 ==
- gelf_update_rel(next->data,
- next_rel_off,
- &unfinished->rels[unf_idx]),
- gelf_update_rel);
- }
-
- next_rel_off++;
- dyn->num_unfinished_relocs++;
- }
- } /* for */
-
- /* Set the size of the last section, and mark all subsequent
- sections for removal. At this point, next is the section
- to which we last wrote data, next_rel_off is the offset before
- which we wrote the last relocation, and so next_rel_off *
- relsize is the new size of the section.
- */
-
- bool adjust_file = ADJUST_ELF && source->elf_hdr.e_type != ET_EXEC;
- if (adjust_file && !source->dry_run)
- {
- size_t relsize = gelf_fsize(source->elf,
- ELF_T_REL,
- 1,
- source->elf_hdr.e_version);
-
- ASSERT(next->info == NULL ||
- next->shdr.sh_name == next->info->old_shdr.sh_name);
- const char *sname =
- elf_strptr(source->oldelf,
- source->shstrndx,
- next->shdr.sh_name);
-
- INFO("\tsection [%s] (index %d) has %d unfinished relocs, "
- "changing its size to %ld bytes (from %ld bytes).\n",
- sname,
- elf_ndxscn(next->scn),
- next_rel_off,
- (long)(next_rel_off * relsize),
- (long)(next->shdr.sh_size));
-
- /* source->shdr_info[] must be allocated prior to calling this
- function. This is in fact done in process_file(), by calling
- setup_shdr_info() just before we call adjust_dynamic_segment().
- */
- ASSERT(source->shdr_info != NULL);
-
- /* We do not update the data field of shdr_info[], because it does
- not exist yet (with ADJUST_ELF != 0). We create the new section
- and section data after the first call to prelink(). For now, we
- save the results of our analysis by modifying the sh_size field
- of the section header. When we create the new sections' data,
- we set the size of the data from the sh_size fields of the
- section headers.
-
- NOTE: The assertion applies only to the first call of
- adjust_dynamic_segment (which calls this function). By
- the second call, we've already created the data for the
- new sections. The only sections for which we haven't
- created data are the relocation sections we are removing.
- */
-#ifdef DEBUG
- ASSERT((!adjust_section_size_only &&
- (source->shdr_info[elf_ndxscn(next->scn)].idx > 0)) ||
- source->shdr_info[elf_ndxscn(next->scn)].data == NULL);
-#endif
-
- //FIXME: what else do we need to do here? Do we need to update
- // another copy of the shdr so that it's picked up when we
- // commit the file?
- next->shdr.sh_size = next_rel_off * relsize;
- source->shdr_info[elf_ndxscn(next->scn)].shdr.sh_size =
- next->shdr.sh_size;
- if (next_rel_off * relsize == 0) {
-#ifdef REMOVE_HANDLED_SECTIONS
- INFO("\tsection [%s] (index %d) is now empty, marking for "
- "removal.\n",
- sname,
- elf_ndxscn(next->scn));
- source->shdr_info[elf_ndxscn(next->scn)].idx = 0;
- dropped_sections = true;
-#endif
- }
-
- while (++next_idx < num_scns) {
- next = (section_info_t *)scns[next_idx].user;
-#ifdef REMOVE_HANDLED_SECTIONS
- ASSERT(next->info == NULL ||
- next->shdr.sh_name == next->info->old_shdr.sh_name);
- const char *sname =
- elf_strptr(source->oldelf,
- source->shstrndx,
- next->shdr.sh_name);
- INFO("\tsection [%s] (index %d) is now empty, marking for "
- "removal.\n",
- sname,
- elf_ndxscn(next->scn));
- /* mark for removal */
- source->shdr_info[elf_ndxscn(next->scn)].idx = 0;
- dropped_sections = true;
-#endif
- }
- }
-
- } /* if (dyn->sections) */
- else {
- /* The dynamic entry won't have any sections when it itself doesn't
- exist. This could happen when we remove all relocation sections
- from a dynamic entry because we have managed to handle all
- relocations in them.
- */
- INFO("\tNo section for dynamic entry!\n");
- }
-
- return dropped_sections;
-}
-
-static bool adjust_dynamic_segment(source_t *source,
- bool adjust_section_size_only)
-{
- bool dropped_section;
- INFO("Adjusting dynamic segment%s.\n",
- (adjust_section_size_only ? " (section sizes only)" : ""));
- INFO("\tadjusting dynamic segment REL.\n");
- dropped_section =
- adjust_dynamic_segment_for(source, &source->rel,
- adjust_section_size_only);
- INFO("\tadjusting dynamic segment JMPREL.\n");
- dropped_section =
- adjust_dynamic_segment_for(source, &source->jmprel,
- adjust_section_size_only) ||
- dropped_section;
- if (!adjust_section_size_only)
- adjust_dynamic_segment_entries(source);
- return dropped_section;
-}
-
-static void match_relocation_sections_to_dynamic_ranges(source_t *source)
-{
- /* We've gathered all the DT_DYNAMIC entries; now we need to figure out
- which relocation sections fit in which range as described by the
- entries.
- */
-
- int relidx;
- for (relidx = 0; relidx < source->num_relocation_sections; relidx++) {
- section_info_t *reloc_scn = &source->relocation_sections[relidx];
-
- int index = elf_ndxscn(reloc_scn->scn);
-
- ASSERT(reloc_scn->info == NULL ||
- reloc_scn->shdr.sh_name == reloc_scn->info->old_shdr.sh_name);
- const char *sname =
- elf_strptr(source->oldelf,
- source->shstrndx,
- reloc_scn->shdr.sh_name);
-
- INFO("Checking section [%s], index %d, for match to dynamic ranges\n",
- sname, index);
- if (source->shdr_info == NULL || reloc_scn->info->idx > 0) {
- if (source->rel.addr &&
- source->rel.addr <= reloc_scn->shdr.sh_addr &&
- reloc_scn->shdr.sh_addr < source->rel.addr + source->rel.size)
- {
- /* The entire section must fit in the dynamic range. */
- if((reloc_scn->shdr.sh_addr + reloc_scn->shdr.sh_size) >
- (source->rel.addr + source->rel.size))
- {
- PRINT("WARNING: In [%s], section %s:[%lld,%lld) "
- "is not fully contained in dynamic range "
- "[%lld,%lld)!\n",
- source->name,
- sname,
- reloc_scn->shdr.sh_addr,
- reloc_scn->shdr.sh_addr +
- reloc_scn->shdr.sh_size,
- source->rel.addr,
- source->rel.addr + source->rel.size);
- }
-
- if (NULL == source->rel.sections) {
- source->rel.sections = init_range_list();
- ASSERT(source->rel.sections);
- }
- add_unique_range_nosort(source->rel.sections,
- reloc_scn->shdr.sh_addr,
- reloc_scn->shdr.sh_size,
- reloc_scn,
- NULL,
- NULL);
- INFO("\tSection [%s] matches dynamic range REL.\n",
- sname);
- }
- else if (source->jmprel.addr &&
- source->jmprel.addr <= reloc_scn->shdr.sh_addr &&
- reloc_scn->shdr.sh_addr <= source->jmprel.addr +
- source->jmprel.size)
- {
- if((reloc_scn->shdr.sh_addr + reloc_scn->shdr.sh_size) >
- (source->jmprel.addr + source->jmprel.size))
- {
- PRINT("WARNING: In [%s], section %s:[%lld,%lld) "
- "is not fully "
- "contained in dynamic range [%lld,%lld)!\n",
- source->name,
- sname,
- reloc_scn->shdr.sh_addr,
- reloc_scn->shdr.sh_addr +
- reloc_scn->shdr.sh_size,
- source->jmprel.addr,
- source->jmprel.addr + source->jmprel.size);
- }
-
- if (NULL == source->jmprel.sections) {
- source->jmprel.sections = init_range_list();
- ASSERT(source->jmprel.sections);
- }
- add_unique_range_nosort(source->jmprel.sections,
- reloc_scn->shdr.sh_addr,
- reloc_scn->shdr.sh_size,
- reloc_scn,
- NULL,
- NULL);
- INFO("\tSection [%s] matches dynamic range JMPREL.\n",
- sname);
- }
- else
- PRINT("WARNING: Relocation section [%s:%s] does not match "
- "any DT_ entry.\n",
- source->name,
- sname);
- }
- else {
- INFO("Section [%s] was removed, not matching it to dynamic "
- "ranges.\n",
- sname);
- }
- } /* for ... */
-
- if (source->rel.sections) sort_ranges(source->rel.sections);
- if (source->jmprel.sections) sort_ranges(source->jmprel.sections);
-}
-
-static void drop_sections(source_t *source)
-{
- INFO("We are dropping some sections from [%s]--creating section entries "
- "only for remaining sections.\n",
- source->name);
- /* Renumber the sections. The numbers for the sections after those we are
- dropping will be shifted back by the number of dropped sections. */
- int cnt, idx;
- for (cnt = idx = 1; cnt < source->shnum; ++cnt) {
- if (source->shdr_info[cnt].idx > 0) {
- source->shdr_info[cnt].idx = idx++;
-
- /* Create a new section. */
- FAILIF_LIBELF((source->shdr_info[cnt].newscn =
- elf_newscn(source->elf)) == NULL, elf_newscn);
- ASSERT(elf_ndxscn (source->shdr_info[cnt].newscn) ==
- source->shdr_info[cnt].idx);
-
- /* Copy the section data */
- Elf_Data *olddata =
- elf_getdata(source->shdr_info[cnt].scn, // old section
- NULL);
- FAILIF_LIBELF(NULL == olddata, elf_getdata);
- Elf_Data *data =
- elf_newdata(source->shdr_info[cnt].newscn);
- FAILIF_LIBELF(NULL == data, elf_newdata);
- *data = *olddata;
-#if COPY_SECTION_DATA_BUFFER
- if (olddata->d_buf != NULL) {
- data->d_buf = MALLOC(data->d_size);
- memcpy(data->d_buf, olddata->d_buf, olddata->d_size);
- }
-#endif
- source->shdr_info[cnt].data = data;
-
- if (data->d_size !=
- source->shdr_info[cnt].shdr.sh_size) {
- INFO("Trimming new-section data from %d to %lld bytes "
- "(as calculated by adjust_dynamic_segment()).\n",
- data->d_size,
- source->shdr_info[cnt].shdr.sh_size);
- data->d_size =
- source->shdr_info[cnt].shdr.sh_size;
- }
-
- INFO("\tsection [%s] (old offset %lld, old size %lld) "
- "will have index %d (was %d), new size %d\n",
- source->shdr_info[cnt].name,
- source->shdr_info[cnt].old_shdr.sh_offset,
- source->shdr_info[cnt].old_shdr.sh_size,
- source->shdr_info[cnt].idx,
- elf_ndxscn(source->shdr_info[cnt].scn),
- data->d_size);
- } else {
- INFO("\tIgnoring section [%s] (offset %lld, size %lld, index %d), "
- "it will be discarded.\n",
- source->shdr_info[cnt].name,
- source->shdr_info[cnt].shdr.sh_offset,
- source->shdr_info[cnt].shdr.sh_size,
- elf_ndxscn(source->shdr_info[cnt].scn));
- }
-
- /* NOTE: We mark use_old_shdr_for_relocation_calculations even for the
- sections we are removing. adjust_elf has an assertion that makes
- sure that if the values for the size of a section according to its
- header and its data structure differ, then we are using explicitly
- the old section header for calculations, and that the section in
- question is a relocation section.
- */
- source->shdr_info[cnt].use_old_shdr_for_relocation_calculations = true;
- } /* for */
-}
-
-static source_t* process_file(const char *filename,
- const char *output, int is_file,
- void (*report_library_size_in_memory)(
- const char *name, off_t fsize),
- unsigned (*get_next_link_address)(
- const char *name),
- int locals_only,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs,
- char **default_libs,
- int num_default_libs,
- int dry_run,
- int *total_num_handled_relocs,
- int *total_num_unhandled_relocs)
-{
- /* Look up the file in the list of already-handles files, which are
- represented by source_t structs. If we do not find the file, then we
- haven't prelinked it yet. If we find it, then we have, so we do
- nothing. Keep in mind that apriori operates on an entire collection
- of files, and if application A used library L, and so does application
- B, if we process A first, then by the time we get to B we will have
- prelinked L already; that's why we check first to see if a library has
- been prelinked.
- */
- source_t *source =
- find_source(filename, lib_lookup_dirs, num_lib_lookup_dirs);
- if (NULL == source) {
- /* If we could not find the source, then it hasn't been processed yet,
- so we go ahead and process it! */
- INFO("Processing [%s].\n", filename);
- char *full = find_file(filename, lib_lookup_dirs, num_lib_lookup_dirs);
- FAILIF(NULL == full,
- "Could not find [%s] in the current directory or in any of "
- "the search paths!\n", filename);
-
- unsigned base = get_next_link_address(full);
-
- source = init_source(full, output, is_file, base, dry_run);
-
- if (source == NULL) {
- INFO("File [%s] is a static executable.\n", filename);
- return NULL;
- }
- ASSERT(source->dynamic.scn != NULL);
-
- /* We need to increment the next prelink address only when the file we
- are currently handing is a shared library. Executables do not need
- to be prelinked at a different address, they are always at address
- zero.
-
- Also, if we are prelinking locals only, then we are handling a
- single file per invokation of apriori, so there is no need to
- increment the prelink address unless there is a global prelink map,
- in which case we do need to check to see if the library isn't
- running into its neighbouts in the prelink map.
- */
- if (source->oldelf_hdr.e_type != ET_EXEC &&
- (!locals_only ||
- report_library_size_in_memory ==
- pm_report_library_size_in_memory)) {
- /* This sets the next link address only if an increment was not
- specified by the user. If an address increment was specified,
- then we just check to make sure that the file size is less than
- the increment.
-
- NOTE: The file size is the absolute highest number of bytes that
- the file may occupy in memory, if the entire file is loaded, but
- this is almost next the case. A file will often have sections
- which are not loaded, which could add a lot of size. That's why
- we start off with the file size and then subtract the size of
- the biggest sections that will not get loaded, which are the
- varios DWARF sections, all of which of which are named starting
- with ".debug_".
-
- We could do better than this (by caculating exactly how many
- bytes from that file will be loaded), but that's an overkill.
- Unless the prelink-address increment becomes too small, the file
- size after subtracting the sizes of the DWARF section will be a
- good-enough upper bound.
- */
-
- unsigned long fsize = source->elf_file_info.st_size;
- INFO("Calculating loadable file size for next link address. "
- "Starting with %ld.\n", fsize);
- if (true) {
- Elf_Scn *scn = NULL;
- GElf_Shdr shdr_mem, *shdr;
- const char *scn_name;
- while ((scn = elf_nextscn (source->oldelf, scn)) != NULL) {
- shdr = gelf_getshdr(scn, &shdr_mem);
- FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
- scn_name = elf_strptr (source->oldelf,
- source->shstrndx, shdr->sh_name);
- ASSERT(scn_name != NULL);
-
- if (!(shdr->sh_flags & SHF_ALLOC)) {
- INFO("\tDecrementing by %lld on account of section "
- "[%s].\n",
- shdr->sh_size,
- scn_name);
- fsize -= shdr->sh_size;
- }
- }
- }
- INFO("Done calculating loadable file size for next link address: "
- "Final value is %ld.\n", fsize);
- report_library_size_in_memory(source->name, fsize);
- }
-
- /* Identify the dynamic segment and process it. Specifically, we find
- out what dependencies, if any, this file has. Whenever we encounter
- such a dependency, we process it recursively; we find out where the
- various relocation information sections are stored. */
-
- size_t dynidx;
- GElf_Dyn *dyn, dyn_mem;
- size_t numdyn =
- source->dynamic.shdr.sh_size /
- source->dynamic.shdr.sh_entsize;
- ASSERT(source->dynamic.shdr.sh_size == source->dynamic.data->d_size);
-
- source->rel.idx = source->rel.sz_idx = -1;
- source->jmprel.idx = source->jmprel.sz_idx = -1;
-
- for (dynidx = 0; dynidx < numdyn; dynidx++) {
- dyn = gelf_getdyn (source->dynamic.data,
- dynidx,
- &dyn_mem);
- FAILIF_LIBELF(NULL == dyn, gelf_getdyn);
- /* When we are processing only the local relocations in a file,
- we don't need to handle any of the dependencies. It won't
- hurt if we do, but we will be doing unnecessary work.
- */
- switch (dyn->d_tag)
- {
- case DT_NEEDED:
- if (!locals_only) {
- /* Process the needed library recursively.
- */
- const char *dep_lib =
-#if ELF_STRPTR_IS_BROKEN
- (((char *)elf_getdata(
- elf_getscn(source->elf,
- source->dynamic.shdr.sh_link),
- NULL)->d_buf) + dyn->d_un.d_val);
-#else
- elf_strptr (source->elf,
- source->dynamic.shdr.sh_link,
- dyn->d_un.d_val);
-#endif
- ASSERT(dep_lib != NULL);
- INFO("[%s] depends on [%s].\n", filename, dep_lib);
- ASSERT(output == NULL || is_file == 0);
- source_t *dep = process_file(dep_lib,
- output, is_file,
- report_library_size_in_memory,
- get_next_link_address,
- locals_only,
- lib_lookup_dirs,
- num_lib_lookup_dirs,
- default_libs,
- num_default_libs,
- dry_run,
- total_num_handled_relocs,
- total_num_unhandled_relocs);
-
- /* Add the library to the dependency list. */
- if (source->num_lib_deps == source->lib_deps_size) {
- source->lib_deps_size += 10;
- source->lib_deps = REALLOC(source->lib_deps,
- source->lib_deps_size *
- sizeof(source_t *));
- }
- source->lib_deps[source->num_lib_deps++] = dep;
- }
- break;
- case DT_JMPREL:
- source->jmprel.idx = dynidx;
- source->jmprel.addr = dyn->d_un.d_ptr;
- break;
- case DT_PLTRELSZ:
- source->jmprel.sz_idx = dynidx;
- source->jmprel.size = dyn->d_un.d_val;
- break;
- case DT_REL:
- source->rel.idx = dynidx;
- source->rel.addr = dyn->d_un.d_ptr;
- break;
- case DT_RELSZ:
- source->rel.sz_idx = dynidx;
- source->rel.size = dyn->d_un.d_val;
- break;
- case DT_RELA:
- case DT_RELASZ:
- FAILIF(1, "Can't handle DT_RELA and DT_RELASZ entries!\n");
- break;
- } /* switch */
- } /* for each dynamic entry... */
-
- INFO("Handling [%s].\n", filename);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- if (!source->prelinked)
-#endif
- {
- /* When ADJUST_ELF is defined, this call to prelink is a dry run
- intended to calculate the number of relocations that could not
- be handled. This, in turn, allows us to calculate the amount by
- which we can shrink the various relocation sections before we
- call adjust_elf. After we've adjusted the sections, we will
- call prelink() one more time to do the actual work.
-
- NOTE: Even when ADJUST_ELF != 0, we cannot adjust an ELF file
- that is an executabe, because an executable is not PIC.
- */
-
- int num_unfinished_relocs = 0;
- bool adjust_file = ADJUST_ELF && source->elf_hdr.e_type != ET_EXEC;
- INFO("\n\n\tPRELINKING %s\n\n",
- adjust_file ?
- "(CALCULATE NUMBER OF HANDLED RELOCATIONS)" :
- "(ACTUAL)");
- int num_relocs = prelink(source, locals_only,
- adjust_file || dry_run,
- lib_lookup_dirs, num_lib_lookup_dirs,
- default_libs, num_default_libs,
- &num_unfinished_relocs);
- INFO("[%s]: (calculate changes) handled %d, could not handle %d "
- "relocations.\n",
- source->name,
- num_relocs,
- num_unfinished_relocs);
-
- if (adjust_file && !dry_run)
- {
- /* Find out the new section sizes of the relocation sections,
- but do not move any relocations around, because adjust_elf
- needs to know about all relocations in order to adjust the
- file correctly.
- */
- match_relocation_sections_to_dynamic_ranges(source);
-
- /* We haven't set up source->shdr_info[] yet, so we do it now.
-
- NOTE: setup_shdr_info() depends only on source->oldelf, not
- on source->elf! source->elf is not even defined yet. We
- initialize source->shdr_info[] based on the section
- information of the unmodified ELF file, and then make our
- modifications in the call to adjust_dynamic_segment() based
- on this information. adjust_dynamic_segment() will
- rearrange the unhandled relocations in the beginning of
- their relocation sections, and adjust the size of those
- relocation sections. In the case when a relocation section
- is completely handled, adjust_dynamic_segment() will mark it
- for removal by function adjust_elf.
- */
-
- ASSERT(source->elf == source->oldelf);
- ASSERT(source->shdr_info == NULL);
- setup_shdr_info(source);
- ASSERT(source->shdr_info != NULL);
-
- INFO("\n\n\tADJUSTING DYNAMIC SEGMENT "
- "(CALCULATE CHANGES)\n\n");
- bool drop_some_sections = adjust_dynamic_segment(source, true);
-
- /* Reopen the elf file! Note that we are not doing a dry run
- (the if statement above makes sure of that.)
-
- NOTE: We call init_elf() after we called
- adjust_dynamic_segment() in order to have
- adjust_dynamic_segment() refer to source->oldelf when
- it refers to source->elf. Since
- adjust_dynamic_segment doesn't actually write to the
- ELF file, this is OK. adjust_dynamic_segment()
- updates the sh_size fields of saved section headers
- and optionally marks sections for removal.
-
- Having adjust_dynamic_segment() refer to
- source->oldelf means that we'll have access to
- section-name strings so we can print them out in our
- logging and debug output.
- */
- source->elf = init_elf(source, false);
-
- /* This is the same code as in init_source() after the call to
- * init_elf(). */
- ASSERT(source->elf != source->oldelf);
- ebl_closebackend(source->ebl);
- source->ebl = ebl_openbackend (source->elf);
- FAILIF_LIBELF(NULL == source->ebl, ebl_openbackend);
-#ifdef ARM_SPECIFIC_HACKS
- FAILIF_LIBELF(0 != arm_init(source->elf,
- source->elf_hdr.e_machine,
- source->ebl, sizeof(Ebl)),
- arm_init);
-#endif/*ARM_SPECIFIC_HACKS*/
-
- if (drop_some_sections)
- drop_sections(source);
- else {
- INFO("All sections remain in [%s]--we are changing at "
- "most section sizes.\n", source->name);
- create_elf_sections(source, NULL);
- int cnt, idx;
- for (cnt = idx = 1; cnt < source->shnum; ++cnt) {
- Elf_Data *data = elf_getdata(
- source->shdr_info[cnt].newscn, // new section
- NULL);
- if (data->d_size !=
- source->shdr_info[cnt].shdr.sh_size) {
- INFO("Trimming new-section data from %d to %lld "
- "bytes (as calculated by "
- "adjust_dynamic_segment()).\n",
- data->d_size,
- source->shdr_info[cnt].shdr.sh_size);
- data->d_size = source->shdr_info[cnt].shdr.sh_size;
- }
- }
- }
-
- /* Shrink it! */
- INFO("\n\n\tADJUSTING ELF\n\n");
- adjust_elf(
- source->oldelf, source->name,
- source->elf, source->name,
- source->ebl,
- &source->old_ehdr_mem,
- NULL, 0, // no symbol filter
- source->shdr_info, // information on how to adjust the ELF
- source->shnum, // length of source->shdr_info[]
- source->phdr_info, // program-header info
- source->shnum, // irrelevant--we're not rebuilding shstrtab
- source->shnum, // number of sections in file
- source->shstrndx, // index of shstrtab (both in
- // shdr_info[] and as a section index)
- NULL, // irrelevant, since we are not rebuilding shstrtab
- drop_some_sections, // some sections are being dropped
- elf_ndxscn(source->dynamic.scn), // index of .dynamic
- elf_ndxscn(source->symtab.scn), // index of .dynsym
- 1, // allow shady business
- &source->shstrtab_data,
- true,
- false); // do not rebuild shstrtab
-
- INFO("\n\n\tREINITIALIZING STRUCTURES "
- "(TO CONTAIN ADJUSTMENTS)\n\n");
- reinit_source(source);
-
- INFO("\n\n\tPRELINKING (ACTUAL)\n\n");
-#ifdef DEBUG
- int old_num_unfinished_relocs = num_unfinished_relocs;
-#endif
- num_unfinished_relocs = 0;
-#ifdef DEBUG
- int num_relocs_take_two =
-#endif
- prelink(source, locals_only,
- false, /* not a dry run */
- lib_lookup_dirs, num_lib_lookup_dirs,
- default_libs, num_default_libs,
- &num_unfinished_relocs);
-
- /* The numbers for the total number of relocations and the
- number of unhandled relocations between the first and second
- invokationof prelink() must be the same! The first time we
- ran prelink() just to calculate the numbers so that we could
- calculate the adjustments to pass to adjust_elf, and the
- second time we actually carry out the prelinking; the
- numbers must stay the same!
- */
- ASSERT(num_relocs == num_relocs_take_two);
- ASSERT(old_num_unfinished_relocs == num_unfinished_relocs);
-
- INFO("[%s]: (actual prelink) handled %d, could not "
- "handle %d relocations.\n",
- source->name,
- num_relocs,
- num_unfinished_relocs);
- } /* if (adjust_elf && !dry_run) */
-
- *total_num_handled_relocs += num_relocs;
- *total_num_unhandled_relocs += num_unfinished_relocs;
-
- if(num_unfinished_relocs != 0 &&
- source->elf_hdr.e_type != ET_EXEC &&
- !locals_only)
- {
- /* One reason you could have unfinished relocations in an
- executable file is if this file used dlopen() and friends.
- We do not adjust relocation entries to those symbols,
- because libdl is a dummy only--the real functions are
- provided for by the dynamic linker itsef.
-
- NOTE FIXME HACK: This is specific to the Android dynamic
- linker, and may not be true in other cases.
- */
- PRINT("WARNING: Expecting to have unhandled relocations only "
- "for executables (%s is not an executable)!\n",
- source->name);
- }
-
- match_relocation_sections_to_dynamic_ranges(source);
-
- /* Now, for each relocation section, check to see if its address
- matches one of the DT_DYNAMIC relocation pointers. If so, then
- if the section has no unhandled relocations, simply set the
- associated DT_DYNAMIC entry's size to zero. If the section does
- have unhandled entries, then lump them all together at the front
- of the respective section and update the size of the respective
- DT_DYNAMIC entry to the new size of the section. A better
- approach would be do delete a relocation section if it has been
- fully relocated and to remove its entry from the DT_DYNAMIC
- array, and for relocation entries that still have some
- relocations in them, we should shrink the section if that won't
- violate relative offsets. This is more work, however, and for
- the speed improvement we expect from a prelinker, just patching
- up DT_DYNAMIC will suffice.
-
- Note: adjust_dynamic_segment() will modify source->shdr_info[]
- to denote any change in a relocation section's size. This
- will be picked up by adjust_elf, which will rearrange the
- file to eliminate the gap created by the decrease in size
- of the relocation section. We do not need to do this, but
- the relocation section could be large, and reduced
- drastically by the prelinking process, so it pays to
- adjust the file.
- */
-
- INFO("\n\n\tADJUSTING DYNAMIC SEGMENT (ACTUAL)\n\n");
- adjust_dynamic_segment(source, false);
- }
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- else INFO("[%s] is already prelinked at 0x%08lx.\n",
- filename,
- source->prelink_base);
-#endif
- } else INFO("[%s] has been processed already.\n", filename);
-
- return source;
-}
-
-void apriori(char **execs, int num_execs,
- char *output,
- void (*report_library_size_in_memory)(
- const char *name, off_t fsize),
- int (*get_next_link_address)(const char *name),
- int locals_only,
- int dry_run,
- char **lib_lookup_dirs, int num_lib_lookup_dirs,
- char **default_libs, int num_default_libs,
- char *mapfile)
-{
- source_t *source; /* for general usage */
- int input_idx;
-
- ASSERT(report_library_size_in_memory != NULL);
- ASSERT(get_next_link_address != NULL);
-
- /* Process and prelink each executable and object file. Function
- process_file() is called for each executable in the loop below.
- It calls itself recursively for each library. We prelink each library
- after prelinking its dependencies. */
- int total_num_handled_relocs = 0, total_num_unhandled_relocs = 0;
- for (input_idx = 0; input_idx < num_execs; input_idx++) {
- INFO("executable: [%s]\n", execs[input_idx]);
- /* Here process_file() is actually processing the top-level
- executable files. */
- process_file(execs[input_idx], output, num_execs == 1,
- report_library_size_in_memory,
- get_next_link_address, /* executables get a link address
- of zero, regardless of this
- value */
- locals_only,
- lib_lookup_dirs, num_lib_lookup_dirs,
- default_libs, num_default_libs,
- dry_run,
- &total_num_handled_relocs,
- &total_num_unhandled_relocs);
- /* if source is NULL, then the respective executable is static */
- /* Mark the source as an executable */
- } /* for each input executable... */
-
- PRINT("Handled %d relocations.\n", total_num_handled_relocs);
- PRINT("Could not handle %d relocations.\n", total_num_unhandled_relocs);
-
- /* We are done! Since the end result of our calculations is a set of
- symbols for each library that other libraries or executables link
- against, we iterate over the set of libraries one last time, and for
- each symbol that is marked as satisfying some dependence, we emit
- a line with the symbol's name to a text file derived from the library's
- name by appending the suffix .syms to it. */
-
- if (mapfile != NULL) {
- const char *mapfile_name = mapfile;
- FILE *fp;
- if (*mapfile == '+') {
- mapfile_name = mapfile + 1;
- INFO("Opening map file %s for append/write.\n",
- mapfile_name);
- fp = fopen(mapfile_name, "a");
- }
- else fp = fopen(mapfile_name, "w");
-
- FAILIF(fp == NULL, "Cannot open file [%s]: %s (%d)!\n",
- mapfile_name,
- strerror(errno),
- errno);
- source = sources;
- while (source) {
- /* If it's a library, print the results. */
- if (source->elf_hdr.e_type == ET_DYN) {
- /* Add to the memory map file. */
- fprintf(fp, "%s 0x%08lx %lld\n",
- basename(source->name),
- source->base,
- source->elf_file_info.st_size);
- }
- source = source->next;
- }
- fclose(fp);
- }
-
- /* Free the resources--you can't do it in the loop above because function
- print_symbol_references() accesses nodes other than the one being
- iterated over.
- */
- source = sources;
- while (source) {
- source_t *old = source;
- source = source->next;
- /* Destroy the evidence. */
- destroy_source(old);
- }
-}
diff --git a/tools/apriori/apriori.h b/tools/apriori/apriori.h
deleted file mode 100644
index 5e396fd..0000000
--- a/tools/apriori/apriori.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LSD_H
-#define LSD_H
-
-void apriori(char **execs, int num_execs,
- char *output,
- void (*set_next_link_address)(const char *name, off_t fsize),
- int (*get_next_link_address)(const char *name),
- int locals_only,
- int dry_run,
- char **lib_lookup_dirs, int num_lib_lookup_dirs,
- char **default_libs, int num_default_libs,
- char *mapfile);
-
-#endif
diff --git a/tools/apriori/cmdline.c b/tools/apriori/cmdline.c
deleted file mode 100644
index 95f112a..0000000
--- a/tools/apriori/cmdline.c
+++ /dev/null
@@ -1,186 +0,0 @@
-#include <debug.h>
-#include <cmdline.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <ctype.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-static struct option long_options[] = {
- {"start-address", required_argument, 0, 's'},
- {"inc-address", required_argument, 0, 'i'},
- {"locals-only", no_argument, 0, 'l'},
- {"quiet", no_argument, 0, 'Q'},
- {"noupdate", no_argument, 0, 'n'},
- {"lookup", required_argument, 0, 'L'},
- {"default", required_argument, 0, 'D'},
- {"verbose", no_argument, 0, 'V'},
- {"help", no_argument, 0, 'h'},
- {"mapfile", required_argument, 0, 'M'},
- {"output", required_argument, 0, 'o'},
- {"prelinkmap", required_argument, 0, 'p'},
- {0, 0, 0, 0},
-};
-
-/* This array must parallel long_options[] */
-static const char *descriptions[] = {
- "start address to prelink libraries to",
- "address increment for each library",
- "prelink local relocations only",
- "suppress informational and non-fatal error messages",
- "do a dry run--calculate the prelink info but do not update any files",
- "provide a directory for library lookup",
- "provide a default library or executable for symbol lookup",
- "print verbose output",
- "print help screen",
- "print a list of prelink addresses to file (prefix filename with + to append instead of overwrite)",
- "specify an output directory (if multiple inputs) or file (is single input)",
- "specify a file with prelink addresses instead of a --start-address/--inc-address combination",
-};
-
-void print_help(const char *name) {
- fprintf(stdout,
- "invokation:\n"
- "\t%s file1 [file2 file3 ...] -Ldir1 [-Ldir2 ...] -saddr -iinc [-Vqn] [-M<logfile>]\n"
- "\t%s -l file [-Vqn] [-M<logfile>]\n"
- "\t%s -h\n\n", name, name, name);
- fprintf(stdout, "options:\n");
- struct option *opt = long_options;
- const char **desc = descriptions;
- while (opt->name) {
- fprintf(stdout, "\t-%c/--%s%s: %s\n",
- opt->val,
- opt->name,
- (opt->has_arg ? " (argument)" : ""),
- *desc);
- opt++;
- desc++;
- }
-}
-
-int get_options(int argc, char **argv,
- int *start_addr,
- int *inc_addr,
- int *locals_only,
- int *quiet,
- int *dry_run,
- char ***dirs,
- int *num_dirs,
- char ***defaults,
- int *num_defaults,
- int *verbose,
- char **mapfile,
- char **output,
- char **prelinkmap) {
- int c;
-
- ASSERT(dry_run); *dry_run = 0;
- ASSERT(quiet); *quiet = 0;
- ASSERT(verbose); *verbose = 0;
- ASSERT(dirs); *dirs = NULL;
- ASSERT(num_dirs); *num_dirs = 0;
- ASSERT(defaults); *defaults = NULL;
- ASSERT(num_defaults); *num_defaults = 0;
- ASSERT(start_addr); *start_addr = -1;
- ASSERT(inc_addr); *inc_addr = -1;
- ASSERT(locals_only); *locals_only = 0;
- ASSERT(mapfile); *mapfile = NULL;
- ASSERT(output); *output = NULL;
- ASSERT(prelinkmap); *prelinkmap = NULL;
- int dirs_size = 0;
- int defaults_size = 0;
-
- while (1) {
- /* getopt_long stores the option index here. */
- int option_index = 0;
-
- c = getopt_long (argc, argv,
- "VhnQlL:D:s:i:M:o:p:",
- long_options,
- &option_index);
- /* Detect the end of the options. */
- if (c == -1) break;
-
- if (isgraph(c)) {
- INFO ("option -%c with value `%s'\n", c, (optarg ?: "(null)"));
- }
-
-#define SET_STRING_OPTION(name) do { \
- ASSERT(optarg); \
- (*name) = strdup(optarg); \
-} while(0)
-
-#define SET_REPEATED_STRING_OPTION(arr, num, size) do { \
- if (*num == size) { \
- size += 10; \
- *arr = (char **)REALLOC(*arr, size * sizeof(char *)); \
- } \
- SET_STRING_OPTION(((*arr) + *num)); \
- (*num)++; \
-} while(0)
-
-#define SET_INT_OPTION(val) do { \
- ASSERT(optarg); \
- if (strlen(optarg) >= 2 && optarg[0] == '0' && optarg[1] == 'x') { \
- FAILIF(1 != sscanf(optarg+2, "%x", val), \
- "Expecting a hexadecimal argument!\n"); \
- } else { \
- FAILIF(1 != sscanf(optarg, "%d", val), \
- "Expecting a decimal argument!\n"); \
- } \
-} while(0)
-
- switch (c) {
- case 0:
- /* If this option set a flag, do nothing else now. */
- if (long_options[option_index].flag != 0)
- break;
- INFO ("option %s", long_options[option_index].name);
- if (optarg)
- INFO (" with arg %s", optarg);
- INFO ("\n");
- break;
- case 'Q': *quiet = 1; break;
- case 'n': *dry_run = 1; break;
- case 'M':
- SET_STRING_OPTION(mapfile);
- break;
- case 'o':
- SET_STRING_OPTION(output);
- break;
- case 'p':
- SET_STRING_OPTION(prelinkmap);
- break;
- case 's':
- SET_INT_OPTION(start_addr);
- break;
- case 'i':
- SET_INT_OPTION(inc_addr);
- break;
- case 'L':
- SET_REPEATED_STRING_OPTION(dirs, num_dirs, dirs_size);
- break;
- case 'D':
- SET_REPEATED_STRING_OPTION(defaults, num_defaults, defaults_size);
- break;
- case 'l': *locals_only = 1; break;
- case 'h': print_help(argv[0]); exit(1); break;
- case 'V': *verbose = 1; break;
- case '?':
- /* getopt_long already printed an error message. */
- break;
-
-#undef SET_STRING_OPTION
-#undef SET_REPEATED_STRING_OPTION
-#undef SET_INT_OPTION
-
- default:
- FAILIF(1, "Unknown option");
- }
- }
-
- return optind;
-}
diff --git a/tools/apriori/cmdline.h b/tools/apriori/cmdline.h
deleted file mode 100644
index 8f7f394..0000000
--- a/tools/apriori/cmdline.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-void print_help(const char *executable_name);
-
-int get_options(int argc, char **argv,
- int *start_addr,
- int *addr_increment,
- int *locals_only,
- int *quiet,
- int *dry_run,
- char ***dirs,
- int *num_dirs,
- char ***defaults,
- int *num_defaults,
- int *verbose,
- char **mapfile,
- char **output,
- char **prelinkmap);
-
-#endif/*CMDLINE_H*/
diff --git a/tools/apriori/common.h b/tools/apriori/common.h
deleted file mode 100644
index f5d9d2e..0000000
--- a/tools/apriori/common.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr) __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-static inline int is_host_little(void)
-{
- short val = 0x10;
- return ((char *)&val)[0] != 0;
-}
-
-static inline long switch_endianness(long val)
-{
- long newval;
- ((char *)&newval)[3] = ((char *)&val)[0];
- ((char *)&newval)[2] = ((char *)&val)[1];
- ((char *)&newval)[1] = ((char *)&val)[2];
- ((char *)&newval)[0] = ((char *)&val)[3];
- return newval;
-}
-
-#endif/*COMMON_H*/
diff --git a/tools/apriori/debug.c b/tools/apriori/debug.c
deleted file mode 100644
index 263e09f..0000000
--- a/tools/apriori/debug.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define NUM_COLS (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize) {
- int num_nonprintable = 0;
- int i, last;
- char *pchr = (char *)b;
- fputc('\n', s);
- fprintf(s, "%p: ", b);
- for (i = last = 0; i < len; i++) {
- if (!elsize) {
- if (i && !(i % 4)) fprintf(s, " ");
- if (i && !(i % 8)) fprintf(s, " ");
- } else {
- if (i && !(i % elsize)) fprintf(s, " ");
- }
-
- if (i && !(i % NUM_COLS)) {
- while (last < i) {
- if (isprint(pchr[last]))
- fputc(pchr[last], s);
- else {
- fputc('.', s);
- num_nonprintable++;
- }
- last++;
- }
- fprintf(s, " (%d)\n%p: ", i, b);
- }
- fprintf(s, "%02x", (unsigned char)pchr[i]);
- }
- if (i && (i % NUM_COLS)) fputs("\n", s);
- return num_nonprintable;
-}
-
diff --git a/tools/apriori/debug.h b/tools/apriori/debug.h
deleted file mode 100644
index 3996898..0000000
--- a/tools/apriori/debug.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* Debug enabled */
- #define ASSERT(x) do { \
- if (unlikely(!(x))) { \
- fprintf(stderr, \
- "ASSERTION FAILURE %s:%d: [%s]\n", \
- __FILE__, __LINE__, #x); \
- exit(1); \
- } \
-} while(0)
-
-#else
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* No debug */
- #define ASSERT(x) do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
- FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
- void *m = malloc(size);
- FAILIF(NULL == m, "malloc(%d) failed!\n", size);
- return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
- void *m = calloc(num_entries, entry_size);
- FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
- return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
- void *m = realloc(ptr, size);
- FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
- return m;
-}
-
-static inline void FREE(void *ptr) {
- free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
- if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...) do { \
- extern int quiet_flag; \
- if(likely(!quiet_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-#define ERROR PRINT
-
-#define INFO(x...) do { \
- extern int verbose_flag; \
- if(unlikely(verbose_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/apriori/hash.c b/tools/apriori/hash.c
deleted file mode 100644
index 9f1a614..0000000
--- a/tools/apriori/hash.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <hash.h>
-#include <string.h>
-
-int hash_lookup(Elf *elf,
- Elf_Data *hash,
- Elf_Data *symtab,
- Elf_Data *symstr,
- const char *symname) {
- Elf32_Word *hash_data = (Elf32_Word *)hash->d_buf;
- Elf32_Word index;
- Elf32_Word nbuckets = *hash_data++;
- Elf32_Word *buckets = ++hash_data;
- Elf32_Word *chains = hash_data + nbuckets;
-
- index = buckets[elf_hash(symname) % nbuckets];
- while (index != STN_UNDEF &&
- strcmp((char *)symstr->d_buf +
- ((Elf32_Sym *)symtab->d_buf)[index].st_name,
- symname)) {
- index = chains[index];
- }
-
- return index;
-}
diff --git a/tools/apriori/hash.h b/tools/apriori/hash.h
deleted file mode 100644
index af29b9e..0000000
--- a/tools/apriori/hash.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef HASH_H
-#define HASH_H
-
-#include <common.h>
-#include <libelf.h>
-#include <gelf.h>
-
-int hash_lookup(Elf *elf,
- Elf_Data *hash,
- Elf_Data *symtab,
- Elf_Data *symstr,
- const char *symname);
-
-#endif/*HASH_H*/
diff --git a/tools/apriori/main.c b/tools/apriori/main.c
deleted file mode 100644
index 552392a..0000000
--- a/tools/apriori/main.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/* TODO:
- 1. check the ARM EABI version--this works for versions 1 and 2.
- 2. use a more-intelligent approach to finding the symbol table,
- symbol-string table, and the .dynamic section.
- 3. fix the determination of the host and ELF-file endianness
- 4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <elf.h>
-#include <gelf.h>
-#include <cmdline.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <apriori.h>
-#include <prelinkmap.h>
-
-/* Flag set by --verbose. This variable is global as it is accessed by the
- macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet. This variable is global as it is accessed by the
- macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-static void print_dynamic_symbols(Elf *elf, const char *symtab_name);
-
-static unsigned s_next_link_addr;
-static off_t s_addr_increment;
-
-static void report_library_size_in_memory(const char *name, off_t fsize)
-{
- ASSERT(s_next_link_addr != -1UL);
- INFO("Setting next link address (current is at 0x%08x):\n",
- s_next_link_addr);
- if (s_addr_increment) {
- FAILIF(s_addr_increment < fsize,
- "Command-line-specified address increment of 0x%08llx (%lld) "
- "less than file [%s]'s size of %lld bytes!\n",
- s_addr_increment, s_addr_increment, name, fsize);
- FAILIF(s_next_link_addr % 4096,
- "User-provided address increment 0x%08lx "
- "is not page-aligned!\n",
- s_addr_increment);
- INFO("\tignoring file size, adjusting by address increment.\n");
- s_next_link_addr += s_addr_increment;
- }
- else {
- INFO("\tuser address increment is zero, adjusting by file size.\n");
- s_next_link_addr += fsize;
- s_next_link_addr &= ~(4096 - 1);
- }
- INFO("\t[%s] file size 0x%08lx\n",
- name,
- fsize);
- INFO("\tnext prelink address: 0x%08x\n", s_next_link_addr);
- ASSERT(!(s_next_link_addr % 4096)); /* New address must be page-aligned */
-}
-
-static unsigned get_next_link_address(const char *name) {
- return s_next_link_addr;
-}
-
-int main(int argc, char **argv) {
- /* Do not issue INFO() statements before you call get_options() to set
- the verbose flag as necessary.
- */
-
- char **lookup_dirs, **default_libs;
- char *mapfile, *output, *prelinkmap;
- int start_addr, inc_addr, locals_only, num_lookup_dirs,
- num_default_libs, dry_run;
- int first = get_options(argc, argv,
- &start_addr, &inc_addr, &locals_only,
- &quiet_flag,
- &dry_run,
- &lookup_dirs, &num_lookup_dirs,
- &default_libs, &num_default_libs,
- &verbose_flag,
- &mapfile,
- &output,
- &prelinkmap);
-
- /* Perform some command-line-parameter checks. */
- int cmdline_err = 0;
- if (first == argc) {
- ERROR("You must specify at least one input ELF file!\n");
- cmdline_err++;
- }
- /* We complain when the user does not specify a start address for
- prelinking when the user does not pass the locals_only switch. The
- reason is that we will have a collection of executables, which we always
- prelink to zero, and shared libraries, which we prelink at the specified
- prelink address. When the user passes the locals_only switch, we do not
- fail if the user does not specify start_addr, because the file to
- prelink may be an executable, and not a shared library. At this moment,
- we do not know what the case is. We find that out when we call function
- init_source().
- */
- if (!locals_only && start_addr == -1) {
- ERROR("You must specify --start-addr!\n");
- cmdline_err++;
- }
- if (start_addr == -1 && inc_addr != -1) {
- ERROR("You must provide a start address if you provide an "
- "address increment!\n");
- cmdline_err++;
- }
- if (prelinkmap != NULL && start_addr != -1) {
- ERROR("You may not provide a prelink-map file (-p) and use -s/-i "
- "at the same time!\n");
- cmdline_err++;
- }
- if (inc_addr == 0) {
- ERROR("You may not specify a link-address increment of zero!\n");
- cmdline_err++;
- }
- if (locals_only) {
- if (argc - first == 1) {
- if (inc_addr != -1) {
- ERROR("You are prelinking a single file; there is no point in "
- "specifying a prelink-address increment!\n");
- /* This is nonfatal error, but paranoia is healthy. */
- cmdline_err++;
- }
- }
- if (lookup_dirs != NULL || default_libs != NULL) {
- ERROR("You are prelinking local relocations only; there is "
- "no point in specifying lookup directories!\n");
- /* This is nonfatal error, but paranoia is healthy. */
- cmdline_err++;
- }
- }
-
- /* If there is an output option, then that must specify a file, if there is
- a single input file, or a directory, if there are multiple input
- files. */
- if (output != NULL) {
- struct stat output_st;
- FAILIF(stat(output, &output_st) < 0 && errno != ENOENT,
- "stat(%s): %s (%d)\n",
- output,
- strerror(errno),
- errno);
-
- if (argc - first == 1) {
- FAILIF(!errno && !S_ISREG(output_st.st_mode),
- "you have a single input file: -o must specify a "
- "file name!\n");
- }
- else {
- FAILIF(errno == ENOENT,
- "you have multiple input files: -o must specify a "
- "directory name, but %s does not exist!\n",
- output);
- FAILIF(!S_ISDIR(output_st.st_mode),
- "you have multiple input files: -o must specify a "
- "directory name, but %s is not a directory!\n",
- output);
- }
- }
-
- if (cmdline_err) {
- print_help(argv[0]);
- FAILIF(1, "There are command-line-option errors.\n");
- }
-
- /* Check to see whether the ELF library is current. */
- FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
- if (inc_addr < 0) {
- if (!locals_only)
- PRINT("User has not provided an increment address, "
- "will use library size to calculate successive "
- "prelink addresses.\n");
- inc_addr = 0;
- }
-
- void (*func_report_library_size_in_memory)(const char *name, off_t fsize);
- unsigned (*func_get_next_link_address)(const char *name);
-
- if (prelinkmap != NULL) {
- INFO("Reading prelink addresses from prelink-map file [%s].\n",
- prelinkmap);
- pm_init(prelinkmap);
- func_report_library_size_in_memory = pm_report_library_size_in_memory;
- func_get_next_link_address = pm_get_next_link_address;
- }
- else {
- INFO("Start address: 0x%x\n", start_addr);
- INFO("Increment address: 0x%x\n", inc_addr);
- s_next_link_addr = start_addr;
- s_addr_increment = inc_addr;
- func_report_library_size_in_memory = report_library_size_in_memory;
- func_get_next_link_address = get_next_link_address;
- }
-
- /* Prelink... */
- apriori(&argv[first], argc - first, output,
- func_report_library_size_in_memory, func_get_next_link_address,
- locals_only,
- dry_run,
- lookup_dirs, num_lookup_dirs,
- default_libs, num_default_libs,
- mapfile);
-
- FREEIF(mapfile);
- FREEIF(output);
- if (lookup_dirs) {
- ASSERT(num_lookup_dirs);
- while (num_lookup_dirs--)
- FREE(lookup_dirs[num_lookup_dirs]);
- FREE(lookup_dirs);
- }
- if (default_libs) {
- ASSERT(num_default_libs);
- while (num_default_libs--)
- FREE(default_libs[num_default_libs]);
- FREE(default_libs);
- }
-
- return 0;
-}
diff --git a/tools/apriori/prelink_info.c b/tools/apriori/prelink_info.c
deleted file mode 100644
index da7ca05..0000000
--- a/tools/apriori/prelink_info.c
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <prelink_info.h>
-#include <debug.h>
-#include <common.h>
-
-typedef struct {
- int32_t mmap_addr;
- char tag[4]; /* 'P', 'R', 'E', ' ' */
-} prelink_info_t __attribute__((packed));
-
-static inline void set_prelink(long *prelink_addr,
- int elf_little,
- prelink_info_t *info)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
- if (prelink_addr) {
- if (!(elf_little ^ is_host_little())) {
- /* Same endianness */
- *prelink_addr = info->mmap_addr;
- }
- else {
- /* Different endianness */
- *prelink_addr = switch_endianness(info->mmap_addr);
- }
- }
-}
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
- int fd = open(fname, O_RDONLY);
- FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
- fname, strerror(errno), errno);
- off_t end = lseek(fd, 0, SEEK_END);
-
- int nr = sizeof(prelink_info_t);
-
- off_t sz = lseek(fd, -nr, SEEK_CUR);
- ASSERT((long)(end - sz) == (long)nr);
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- prelink_info_t info;
- int num_read = read(fd, &info, nr);
- FAILIF(num_read < 0,
- "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
- fd, strerror(errno), errno);
- FAILIF(num_read != sizeof(info),
- "read(%d, &info, sizeof(prelink_info_t)): did not read %d bytes as "
- "expected (read %d)!\n",
- fd, sizeof(info), num_read);
-
- int prelinked = 0;
- if (!strncmp(info.tag, "PRE ", 4)) {
- set_prelink(prelink_addr, elf_little, &info);
- prelinked = 1;
- }
- FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
- return prelinked;
-}
-
-void setup_prelink_info(const char *fname, int elf_little, long base)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
- int fd = open(fname, O_WRONLY);
- FAILIF(fd < 0,
- "open(%s, O_WRONLY): %s (%d)\n" ,
- fname, strerror(errno), errno);
- prelink_info_t info;
- off_t sz = lseek(fd, 0, SEEK_END);
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- if (!(elf_little ^ is_host_little())) {
- /* Same endianness */
- INFO("Host and ELF file [%s] have same endianness.\n", fname);
- info.mmap_addr = base;
- }
- else {
- /* Different endianness */
- INFO("Host and ELF file [%s] have different endianness.\n", fname);
- info.mmap_addr = switch_endianness(base);
- }
- strncpy(info.tag, "PRE ", 4);
-
- int num_written = write(fd, &info, sizeof(info));
- FAILIF(num_written < 0,
- "write(%d, &info, sizeof(info)): %s (%d)\n",
- fd, strerror(errno), errno);
- FAILIF(sizeof(info) != num_written,
- "Could not write %d bytes (wrote only %d bytes) as expected!\n",
- sizeof(info), num_written);
- FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-}
-
-#endif /*SUPPORT_ANDROID_PRELINK_TAGS*/
diff --git a/tools/apriori/prelink_info.h b/tools/apriori/prelink_info.h
deleted file mode 100644
index e2787cb..0000000
--- a/tools/apriori/prelink_info.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef PRELINK_INFO_H
-#define PRELINK_INFO_H
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr);
-void setup_prelink_info(const char *fname, int elf_little, long base);
-
-#endif
-#endif/*PRELINK_INFO_H*/
diff --git a/tools/apriori/prelinkmap.c b/tools/apriori/prelinkmap.c
deleted file mode 100644
index 9fb00e4..0000000
--- a/tools/apriori/prelinkmap.c
+++ /dev/null
@@ -1,170 +0,0 @@
-#include <prelinkmap.h>
-#include <debug.h>
-#include <errno.h>
-#include <string.h>
-#include <libgen.h>
-#include <ctype.h>
-
-typedef struct mapentry mapentry;
-
-#define MAX_ALIASES 10
-
-struct mapentry
-{
- mapentry *next;
- unsigned base;
- char *names[MAX_ALIASES];
- int num_names;
-};
-
-static mapentry *maplist = 0;
-
-/* These values limit the address range within which we prelinked libraries
- reside. The limit is not set in stone, but should be observed in the
- prelink map, or the prelink step will fail.
-*/
-
-#define PRELINK_MIN 0x90000000
-#define PRELINK_MAX 0xBFFFFFFF
-
-void pm_init(const char *file)
-{
- unsigned line = 0;
- char buf[256];
- char *x;
- FILE *fp;
- mapentry *me;
- unsigned last = -1UL;
-
- fp = fopen(file, "r");
- FAILIF(fp == NULL, "Error opening file %s: %s (%d)\n",
- file, strerror(errno), errno);
-
- while(fgets(buf, 256, fp)){
- x = buf;
- line++;
-
- /* eat leading whitespace */
- while(isspace(*x)) x++;
-
- /* comment or blank line? skip! */
- if(*x == '#') continue;
- if(*x == 0) continue;
-
- /* skip name */
- while(*x && !isspace(*x)) x++;
-
- if(*x) {
- *x++ = 0;
- /* skip space before address */
- while(*x && isspace(*x)) x++;
- }
-
- /* no address? complain. */
- if(*x == 0) {
- fprintf(stderr,"warning: %s:%d no base address specified\n",
- file, line);
- continue;
- }
-
- if (isalpha(*x)) {
- /* Assume that this is an alias, and look through the list of
- already-installed libraries.
- */
- me = maplist;
- while(me) {
- /* The strlen() call ignores the newline at the end of x */
- if (!strncmp(me->names[0], x, strlen(me->names[0]))) {
- PRINT("Aliasing library %s to %s at %08x\n",
- buf, x, me->base);
- break;
- }
- me = me->next;
- }
- FAILIF(!me, "Nonexistent alias %s -> %s\n", buf, x);
- }
- else {
- unsigned n = strtoul(x, 0, 16);
- /* Note that this is not the only bounds check. If a library's
- size exceeds its slot as defined in the prelink map, the
- prelinker will exit with an error. See
- pm_report_library_size_in_memory().
- */
- FAILIF((n < PRELINK_MIN) || (n > PRELINK_MAX),
- "%s:%d base 0x%08x out of range.\n",
- file, line, n);
-
- me = malloc(sizeof(mapentry));
- FAILIF(me == NULL, "Out of memory parsing %s\n", file);
-
- FAILIF(last <= n, "The prelink map is not in descending order "
- "at entry %s (%08x)!\n", buf, n);
- last = n;
-
- me->base = n;
- me->next = maplist;
- me->num_names = 0;
- maplist = me;
- }
-
- FAILIF(me->num_names >= MAX_ALIASES,
- "Too many aliases for library %s, maximum is %d.\n",
- me->names[0],
- MAX_ALIASES);
- me->names[me->num_names] = strdup(buf);
- me->num_names++;
- }
-
- fclose(fp);
-}
-
-/* apriori() calls this function when it determine the size of a library
- in memory. pm_report_library_size_in_memory() makes sure that the library
- fits in the slot provided by the prelink map.
-*/
-void pm_report_library_size_in_memory(const char *name,
- off_t fsize)
-{
- char *x;
- mapentry *me;
- int n;
-
- x = strrchr(name,'/');
- if(x) name = x+1;
-
- for(me = maplist; me; me = me->next){
- for (n = 0; n < me->num_names; n++) {
- if(!strcmp(name, me->names[n])) {
- off_t slot = me->next ? me->next->base : PRELINK_MAX;
- slot -= me->base;
- FAILIF(fsize > slot,
- "prelink map error: library %s@0x%08x is too big "
- "at %lld bytes, it runs %lld bytes into "
- "library %s@0x%08x!\n",
- me->names[0], me->base, fsize, fsize - slot,
- me->next->names[0], me->next->base);
- return;
- }
- }
- }
-
- FAILIF(1, "library '%s' not in prelink map\n", name);
-}
-
-unsigned pm_get_next_link_address(const char *lookup_name)
-{
- char *x;
- mapentry *me;
- int n;
-
- x = strrchr(lookup_name,'/');
- if(x) lookup_name = x+1;
-
- for(me = maplist; me; me = me->next)
- for (n = 0; n < me->num_names; n++)
- if(!strcmp(lookup_name, me->names[n]))
- return me->base;
-
- FAILIF(1, "library '%s' not in prelink map\n", lookup_name);
- return 0;
-}
diff --git a/tools/apriori/prelinkmap.h b/tools/apriori/prelinkmap.h
deleted file mode 100644
index 17f7660..0000000
--- a/tools/apriori/prelinkmap.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef PRELINKMAP_H
-#define PRELINKMAP_H
-
-#include <sys/types.h>
-
-extern void pm_init(const char *file);
-extern void pm_report_library_size_in_memory(const char *name, off_t fsize);
-extern unsigned pm_get_next_link_address(const char *name);
-
-#endif/*PRELINKMAP_H*/
diff --git a/tools/apriori/rangesort.c b/tools/apriori/rangesort.c
deleted file mode 100644
index b0295e8..0000000
--- a/tools/apriori/rangesort.c
+++ /dev/null
@@ -1,317 +0,0 @@
-#include <common.h>
-#include <debug.h>
-#include <rangesort.h>
-
-#define PARALLEL_ARRAY_SIZE (5)
-
-struct range_list_t {
- range_t *array;
-#ifdef DEBUG
- int is_sorted;
-#endif
- int array_length;
- int num_ranges;
-};
-
-range_list_t* init_range_list(void) {
- range_list_t *ranges = (range_list_t *)MALLOC(sizeof(range_list_t));
-
- ranges->array = (range_t *)MALLOC(PARALLEL_ARRAY_SIZE*sizeof(range_t));
- ranges->array_length = PARALLEL_ARRAY_SIZE;
- ranges->num_ranges = 0;
-#ifdef DEBUG
- ranges->is_sorted = 0;
-#endif
- return ranges;
-}
-
-void destroy_range_list(range_list_t *ranges) {
- int idx;
- for (idx = 0; idx < ranges->num_ranges; idx++) {
- if (ranges->array[idx].user_dtor) {
- ASSERT(ranges->array[idx].user);
- ranges->array[idx].user_dtor(ranges->array[idx].user);
- }
- }
- FREE(ranges->array);
- FREE(ranges);
-}
-
-static inline int CONTAINS(range_t *container, range_t *contained) {
- return container->start <= contained->start && contained->length &&
- (container->start + container->length >
- contained->start + contained->length);
-}
-
-static inline int IN_RANGE(range_t *range, GElf_Off point) {
- return
- range->start <= point &&
- point < (range->start + range->length);
-}
-
-static inline int INTERSECT(range_t *left, range_t *right) {
- return
- (IN_RANGE(left, right->start) &&
- IN_RANGE(right, left->start + left->length)) ||
- (IN_RANGE(right, left->start) &&
- IN_RANGE(left, right->start + right->length));
-}
-
-static int range_cmp_for_search(const void *l, const void *r) {
- range_t *left = (range_t *)l, *right = (range_t *)r;
- if (INTERSECT(left, right) ||
- CONTAINS(left, right) ||
- CONTAINS(right, left)) {
- return 0;
- }
- return left->start - right->start;
-}
-
-static inline void run_checks(const void *l, const void *r) {
- range_t *left = (range_t *)l, *right = (range_t *)r;
- if (CONTAINS(left, right)) {
- if (left->err_fn)
- left->err_fn(ERROR_CONTAINS, left, right);
- FAILIF(1, "Range sorting error: [%lld, %lld) contains [%lld, %lld)!\n",
- left->start, left->start + left->length,
- right->start, right->start + right->length);
- }
- if (CONTAINS(right, left)) {
- if (right->err_fn)
- right->err_fn(ERROR_CONTAINS, left, right);
- FAILIF(1, "Range sorting error: [%lld, %lld) contains [%lld, %lld)!\n",
- right->start, right->start + right->length,
- left->start, left->start + left->length);
- }
- if (INTERSECT(left, right)) {
- if (left->err_fn)
- left->err_fn(ERROR_OVERLAPS, left, right);
- FAILIF(1, "Range sorting error: [%lld, %lld)and [%lld, %lld) intersect!\n",
- left->start, left->start + left->length,
- right->start, right->start + right->length);
- }
-}
-
-static int range_cmp(const void *l, const void *r) {
- run_checks(l, r);
- range_t *left = (range_t *)l, *right = (range_t *)r;
- return left->start - right->start;
-}
-
-void add_unique_range_nosort(
- range_list_t *ranges,
- GElf_Off start,
- GElf_Off length,
- void *user,
- void (*err_fn)(range_error_t, range_t *, range_t *),
- void (*user_dtor)(void * ))
-{
- if (ranges->num_ranges == ranges->array_length) {
- ranges->array_length += PARALLEL_ARRAY_SIZE;
- ranges->array = REALLOC(ranges->array,
- ranges->array_length*sizeof(range_t));
- }
- ranges->array[ranges->num_ranges].start = start;
- ranges->array[ranges->num_ranges].length = length;
- ranges->array[ranges->num_ranges].user = user;
- ranges->array[ranges->num_ranges].err_fn = err_fn;
- ranges->array[ranges->num_ranges].user_dtor = user_dtor;
- ranges->num_ranges++;
-}
-
-range_list_t *sort_ranges(range_list_t *ranges) {
- if (ranges->num_ranges > 1)
- qsort(ranges->array, ranges->num_ranges, sizeof(range_t), range_cmp);
- ranges->is_sorted = 1;
- return ranges;
-}
-
-range_t *find_range(range_list_t *ranges, GElf_Off value) {
-#if 1
- int i;
- for (i = 0; i < ranges->num_ranges; i++) {
- if (ranges->array[i].start <= value &&
- value < ranges->array[i].start + ranges->array[i].length)
- return ranges->array + i;
- }
- return NULL;
-#else
- ASSERT(ranges->is_sorted); /* The range list must be sorted */
- range_t lookup;
- lookup.start = value;
- lookup.length = 0;
- return
- (range_t *)bsearch(&lookup,
- ranges->array, ranges->num_ranges, sizeof(range_t),
- range_cmp_for_search);
-#endif
-}
-
-int get_num_ranges(const range_list_t *ranges)
-{
- return ranges->num_ranges;
-}
-
-range_t *get_sorted_ranges(const range_list_t *ranges, int *num_ranges) {
- ASSERT(ranges->is_sorted); /* The range list must be sorted */
- if (num_ranges) {
- *num_ranges = ranges->num_ranges;
- }
- return ranges->array;
-}
-
-GElf_Off get_last_address(const range_list_t *ranges) {
- ASSERT(ranges->num_ranges);
- return
- ranges->array[ranges->num_ranges-1].start +
- ranges->array[ranges->num_ranges-1].length;
-}
-
-static void handle_range_error(range_error_t err,
- range_t *left, range_t *right) {
- switch (err) {
- case ERROR_CONTAINS:
- ERROR("ERROR: section (%lld, %lld bytes) contains "
- "section (%lld, %lld bytes)\n",
- left->start, left->length,
- right->start, right->length);
- break;
- case ERROR_OVERLAPS:
- ERROR("ERROR: Section (%lld, %lld bytes) intersects "
- "section (%lld, %lld bytes)\n",
- left->start, left->length,
- right->start, right->length);
- break;
- default:
- ASSERT(!"Unknown range error code!");
- }
-
- FAILIF(1, "Range error.\n");
-}
-
-static void destroy_contiguous_range_info(void *user) {
- contiguous_range_info_t *info = (contiguous_range_info_t *)user;
- FREE(info->ranges);
- FREE(info);
-}
-
-static void handle_contiguous_range_error(range_error_t err,
- range_t *left,
- range_t *right)
-{
- contiguous_range_info_t *left_data =
- (contiguous_range_info_t *)left->user;
- ASSERT(left_data);
- contiguous_range_info_t *right_data =
- (contiguous_range_info_t *)right->user;
- ASSERT(right_data);
-
- PRINT("Contiguous-range overlap error. Printing contained ranges:\n");
- int cnt;
- PRINT("\tLeft ranges:\n");
- for (cnt = 0; cnt < left_data->num_ranges; cnt++) {
- PRINT("\t\t[%lld, %lld)\n",
- left_data->ranges[cnt].start,
- left_data->ranges[cnt].start + left_data->ranges[cnt].length);
- }
- PRINT("\tRight ranges:\n");
- for (cnt = 0; cnt < right_data->num_ranges; cnt++) {
- PRINT("\t\t[%lld, %lld)\n",
- right_data->ranges[cnt].start,
- right_data->ranges[cnt].start + right_data->ranges[cnt].length);
- }
-
- handle_range_error(err, left, right);
-}
-
-range_list_t* get_contiguous_ranges(const range_list_t *input)
-{
- ASSERT(input);
- FAILIF(!input->is_sorted,
- "get_contiguous_ranges(): input range list is not sorted!\n");
-
- range_list_t* ret = init_range_list();
- int num_ranges;
- range_t *ranges = get_sorted_ranges(input, &num_ranges);
-
- int end_idx = 0;
- while (end_idx < num_ranges) {
- int start_idx = end_idx++;
- int old_end_idx = start_idx;
- int total_length = ranges[start_idx].length;
- while (end_idx < num_ranges) {
- if (ranges[old_end_idx].start + ranges[old_end_idx].length !=
- ranges[end_idx].start)
- break;
- old_end_idx = end_idx++;
- total_length += ranges[old_end_idx].length;
- }
-
- contiguous_range_info_t *user =
- (contiguous_range_info_t *)MALLOC(sizeof(contiguous_range_info_t));
- user->num_ranges = end_idx - start_idx;
- user->ranges = (range_t *)MALLOC(user->num_ranges * sizeof(range_t));
- int i;
- for (i = 0; i < end_idx - start_idx; i++)
- user->ranges[i] = ranges[start_idx + i];
- add_unique_range_nosort(ret,
- ranges[start_idx].start,
- total_length,
- user,
- handle_contiguous_range_error,
- destroy_contiguous_range_info);
- }
-
- return ret;
-}
-
-range_list_t* subtract_ranges(const range_list_t *r, const range_list_t *s)
-{
- ASSERT(r); ASSERT(r->is_sorted);
- ASSERT(s); ASSERT(s->is_sorted);
-
- range_list_t *result = init_range_list();
-
- int r_num_ranges, r_idx;
- range_t *r_ranges = get_sorted_ranges(r, &r_num_ranges);
- ASSERT(r_ranges);
-
- int s_num_ranges, s_idx;
- range_t *s_ranges = get_sorted_ranges(s, &s_num_ranges);
- ASSERT(s_ranges);
-
- s_idx = 0;
- for (r_idx = 0; r_idx < r_num_ranges; r_idx++) {
- GElf_Off last_start = r_ranges[r_idx].start;
- for (; s_idx < s_num_ranges; s_idx++) {
- if (CONTAINS(&r_ranges[r_idx], &s_ranges[s_idx])) {
- if (last_start ==
- r_ranges[r_idx].start + r_ranges[r_idx].length) {
- break;
- }
- if (last_start == s_ranges[s_idx].start) {
- last_start += s_ranges[s_idx].length;
- continue;
- }
- INFO("Adding subtracted range [%lld, %lld)\n",
- last_start,
- s_ranges[s_idx].start);
- add_unique_range_nosort(
- result,
- last_start,
- s_ranges[s_idx].start - last_start,
- NULL,
- NULL,
- NULL);
- last_start = s_ranges[s_idx].start + s_ranges[s_idx].length;
- } else {
- ASSERT(!INTERSECT(&r_ranges[r_idx], &s_ranges[s_idx]));
- break;
- }
- } /* while (s_idx < s_num_ranges) */
- } /* for (r_idx = 0; r_idx < r_num_ranges; r_idx++) */
-
- return result;
-}
-
-
diff --git a/tools/apriori/rangesort.h b/tools/apriori/rangesort.h
deleted file mode 100644
index 21db357..0000000
--- a/tools/apriori/rangesort.h
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifndef RANGESORT_H
-#define RANGESORT_H
-
-/* This implements a simple sorted list of non-overlapping ranges. */
-
-#include <debug.h>
-#include <common.h>
-#include <gelf.h>
-
-typedef enum range_error_t {
- ERROR_CONTAINS,
- ERROR_OVERLAPS
-} range_error_t;
-
-typedef struct range_t range_t;
-struct range_t {
- GElf_Off start;
- GElf_Off length;
- void *user;
- void (*err_fn)(range_error_t, range_t *, range_t *);
- void (*user_dtor)(void *);
-};
-
-typedef struct range_list_t range_list_t;
-
-range_list_t* init_range_list();
-void destroy_range_list(range_list_t *);
-
-/* Just adds a range to the list. We won't detect whether the range overlaps
- other ranges or contains them, or is contained by them, till we call
- sort_ranges(). */
-void add_unique_range_nosort(range_list_t *ranges,
- GElf_Off start, GElf_Off length,
- void *user,
- void (*err_fn)(range_error_t, range_t *, range_t *),
- void (*user_dtor)(void * ));
-
-/* Sorts the ranges. If there are overlapping ranges or ranges that contain
- other ranges, it will cause the program to exit with a FAIL. */
-range_list_t* sort_ranges(range_list_t *ranges);
-/* Find which range value falls in. Return that range or NULL if value does
- not fall within any range. */
-range_t *find_range(range_list_t *ranges, GElf_Off value);
-int get_num_ranges(const range_list_t *ranges);
-range_t *get_sorted_ranges(const range_list_t *ranges, int *num_ranges);
-GElf_Off get_last_address(const range_list_t *ranges);
-
-/* This returns a range_list_t handle that contains ranges composed of the
- adjacent ranges of the input range list. The user data of each range in
- the range list is a structure of the type contiguous_range_info_t.
- This structure contains an array of pointers to copies of the original
- range_t structures comprising each new contiguous range, as well as the
- length of that array.
-
- NOTE: The input range must be sorted!
-
- NOTE: destroy_range_list() will take care of releasing the data that it
- allocates as a result of calling get_contiguous_ranges(). Do not free that
- data yourself.
-
- NOTE: the user data of the original range_t structures is simply copied, so
- be careful handling it. You can destroy the range_list_t with
- destroy_range_list() as usual. On error, the function does not return--the
- program terminates.
-
- NOTE: The returned range is not sorted. You must call sort_ranges() if you
- need to.
-*/
-
-typedef struct {
- int num_ranges;
- range_t *ranges;
-} contiguous_range_info_t;
-
-range_list_t* get_contiguous_ranges(const range_list_t *);
-
-/* The function below takes in two range lists: r and s, and subtracts the
- ranges in s from those in r. For example, if r and s are as follows:
-
- r = { [0, 10) }
- s = { [3, 5), [7, 9) }
-
- Then r - s is { [0, 3), [5, 7), [9, 10) }
-
- NOTE: Both range lists must be sorted on input. This is guarded by an
- assertion.
-
- NOTE: Range s must contain ranges, which are fully contained by the span of
- range r (the span being the interval between the start of the lowest
- range in r, inclusive, and the end of the highest range in r,
- exclusive).
-
- NOTE: In addition to the requirement above, range s must contain ranges,
- each of which is a subrange of one of the ranges of r.
-
- NOTE: There is no user info associated with the resulting range.
-
- NOTE: The resulting range is not sorted.
-
- Ther returned list must be destroyed with destroy_range_list().
-*/
-
-range_list_t* subtract_ranges(const range_list_t *r, const range_list_t *s);
-
-#endif/*RANGESORT_H*/
diff --git a/tools/apriori/source.c b/tools/apriori/source.c
deleted file mode 100644
index 69c57c7..0000000
--- a/tools/apriori/source.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <source.h>
-
-void find_section(source_t *source, Elf64_Addr address,
- Elf_Scn **scn,
- GElf_Shdr *shdr,
- Elf_Data **data)
-{
- range_t *range = find_range(source->sorted_sections, address);
- FAILIF(NULL == range,
- "Cannot match address %lld to any range in [%s]!\n",
- address,
- source->name);
- *scn = (Elf_Scn *)range->user;
- ASSERT(*scn);
- FAILIF_LIBELF(NULL == gelf_getshdr(*scn, shdr), gelf_getshdr);
- *data = elf_getdata(*scn, NULL);
- FAILIF_LIBELF(NULL == *data, elf_getdata);
-}
diff --git a/tools/apriori/source.h b/tools/apriori/source.h
deleted file mode 100644
index 5381a29..0000000
--- a/tools/apriori/source.h
+++ /dev/null
@@ -1,122 +0,0 @@
-#ifndef SOURCE_H
-#define SOURCE_H
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libelf.h>
-#include <libebl.h>
-#ifdef ARM_SPECIFIC_HACKS
- #include <libebl_arm.h>
-#endif/*ARM_SPECIFIC_HACKS*/
-#include <elf.h>
-#include <gelf.h>
-#include <rangesort.h>
-#include <elfcopy.h>
-
-typedef struct source_t source_t;
-
-typedef struct {
- Elf_Scn *scn;
- GElf_Shdr shdr;
- Elf_Data *data;
- shdr_info_t *info;
-} section_info_t;
-
-typedef struct {
- GElf_Rel *rels;
- int num_rels; /* number of relocations that were not finished */
- int rels_size; /* this is the size of rels[], NOT the number of rels! */
-} unfinished_relocation_t;
-
-typedef struct {
- int processed;
- size_t idx; /* index of DT entry in the .dynamic section, if entry has a ptr value */
- Elf64_Addr addr; /* if DT entry's value is an address, we save it here */
- size_t sz_idx; /* index of DT entry in the .dynamic section, if entry has a size value */
- Elf64_Xword size; /* if DT entry's value is a size, we save it here */
-
- range_list_t *sections; /* list of sections corresponding to this entry */
- int num_unfinished_relocs; /* this variables is populated by adjust_dynamic_segment_for()
- during the second pass of the prelinker */
-} dt_rel_info_t;
-
-struct source_t {
- source_t *next;
-
- char *name; /* full path name of this executable file */
- char *output; /* name of the output file or directory */
- int output_is_dir; /* nonzero if output is a directory, 0 if output is a file */
- /* ELF-related information: */
- Elf *oldelf;
- Elf *elf;
- /* info[] is an array of structures describing the sections of the new ELF
- file. We populate the info[] array in clone_elf(), and use it to
- adjust the size of the ELF file when we modify the relocation-entry
- section.
- */
- shdr_info_t *shdr_info;
- GElf_Ehdr old_ehdr_mem; /* store ELF header of original library */
- GElf_Ehdr ehdr_mem; /* store ELF header of new library */
- GElf_Phdr *phdr_info;
- Ebl *ebl;
- Elf_Data *shstrtab_data;
- int elf_fd;
- int newelf_fd; /* fd of output file, -1 if output == NULL */
- int newelf_relo_fd; /* fd of relocaion output file */
- struct stat elf_file_info;
- GElf_Ehdr elf_hdr, oldelf_hdr;
- size_t shstrndx;
- int shnum; /* number of sections */
- int dry_run; /* 0 if we do not update the files, 1 (default) otherwise */
-
- section_info_t symtab;
- section_info_t strtab;
- section_info_t dynamic;
- section_info_t hash;
- section_info_t bss;
-
- range_list_t *sorted_sections;
-
- section_info_t *relocation_sections; /* relocation sections in file */
- int num_relocation_sections; /* number of relocation sections (<= relocation_sections_size) */
- int relocation_sections_size; /* sice of array -- NOT number of relocs! */
-
- /* relocation sections that contain relocations that could not be handled.
- This array is parallel to relocation_sections, and for each entry
- in that array, it contains a list of relocations that could not be
- handled.
- */
- unfinished_relocation_t *unfinished;
-
- /* The sections field of these two structuer contains a list of elements
- of the member variable relocations. */
- dt_rel_info_t rel;
- dt_rel_info_t jmprel;
-
- int num_syms; /* number of symbols in symbol table. This is the length of
- both exports[] and satisfied[] arrays. */
-
- /* This is an array that contains one element for each library dependency
- listed in the executable or shared library. */
- source_t **lib_deps; /* list of library dependencies */
- int num_lib_deps; /* actual number of library dependencies */
- int lib_deps_size; /* size of lib_deps array--NOT actual number of deps! */
-
- /* This is zero for executables. For shared libraries, it is the address
- at which the library was prelinked. */
- unsigned base;
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- /* When we read in a file, if it has the prelinked tag, we set prelinked
- to 1 and the prelink address in the tag to prelink_base. This address
- must match the value of base that we choose. */
- int prelinked;
- long prelink_base; /* valid if prelinked != 0 */
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-};
-
-extern void find_section(source_t *source, Elf64_Addr address,
- Elf_Scn **scn,
- GElf_Shdr *shdr,
- Elf_Data **data);
-
-#endif/*SOURCE_H*/
diff --git a/tools/apriori/tweak.h b/tools/apriori/tweak.h
deleted file mode 100755
index 3afedee..0000000
--- a/tools/apriori/tweak.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef TWEAK_H
-#define TWEAK_H
-
-#include <source.h>
-
-/* This function will break up the .bss section into multiple subsegments,
- depending on whether the .bss segment contains copy-relocated symbols. This
- will produce a nonstandard ELF file (with multiple .bss sections), tht the
- linker will need to know how to handle. The return value is the number of
- segments that the .bss segment was broken into (zero if the .bss segment was
- not modified. */
-
-int tweak_bss_if_necessary(source_t *source);
-
-#endif/*TWEAK_H*/
diff --git a/tools/atree/atree.cpp b/tools/atree/atree.cpp
index aee2b3c..2ba284f 100644
--- a/tools/atree/atree.cpp
+++ b/tools/atree/atree.cpp
@@ -1,6 +1,8 @@
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stdarg.h>
#include "options.h"
#include "files.h"
#include "fs.h"
@@ -10,7 +12,7 @@
using namespace std;
-bool g_debug = false;
+bool g_debug = getenv("ATREE_DEBUG") != NULL;
vector<string> g_listFiles;
vector<string> g_inputBases;
map<string, string> g_variables;
@@ -33,6 +35,7 @@
" -m DEPENDENCY Output a make-formatted file containing the list.\n"
" of files included. It sets the variable ATREE_FILES.\n"
" -v VAR=VAL Replaces ${VAR} by VAL when reading input files.\n"
+" -d Verbose debug mode.\n"
"\n"
"FILELIST file format:\n"
" The FILELIST files contain the list of files that will end up\n"
@@ -42,11 +45,13 @@
" In a FILELIST file, comment lines start with a #. Other lines\n"
" are of the format:\n"
"\n"
-" DEST\n"
-" SRC DEST\n"
+" [rm|strip] DEST\n"
+" SRC [strip] DEST\n"
" -SRCPATTERN\n"
"\n"
" DEST should be path relative to the output directory.\n"
+" 'rm DEST' removes the destination file and fails if it's missing.\n"
+" 'strip DEST' strips the binary destination file.\n"
" If SRC is supplied, the file names can be different.\n"
" SRCPATTERN is a pattern for the filenames.\n"
"\n";
@@ -72,13 +77,26 @@
return true;
}
+static void
+debug_printf(const char* format, ...)
+{
+ if (g_debug) {
+ fflush(stderr);
+ va_list ap;
+ va_start(ap, format);
+ vprintf(format, ap);
+ va_end(ap);
+ fflush(stdout);
+ }
+}
+
int
main(int argc, char* const* argv)
{
int err;
bool done = false;
while (!done) {
- int opt = getopt(argc, argv, "f:I:o:hlm:v:");
+ int opt = getopt(argc, argv, "f:I:o:hlm:v:d");
switch (opt)
{
case -1:
@@ -117,6 +135,9 @@
return usage();
}
break;
+ case 'd':
+ g_debug = true;
+ break;
default:
case '?':
case 'h':
@@ -169,7 +190,7 @@
// read file lists
for (vector<string>::iterator it=g_listFiles.begin();
- it!=g_listFiles.end(); it++) {
+ it!=g_listFiles.end(); it++) {
err = read_list_file(*it, g_variables, &files, &excludes);
if (err != 0) {
return err;
@@ -181,9 +202,8 @@
for (vector<FileRecord>::iterator it=files.begin();
it!=files.end(); it++) {
err |= locate(&(*it), g_inputBases);
-
}
-
+
// expand the directories that we should copy into a list of files
for (vector<FileRecord>::iterator it=files.begin();
it!=files.end(); it++) {
@@ -219,8 +239,8 @@
}
}
- // gather files that should become directores and directories that should
- // become files
+ // gather files that should become directores
+ // and directories that should become files
for (vector<FileRecord>::iterator it=files.begin();
it!=files.end(); it++) {
if (it->outMod != 0 && it->sourceIsDir != it->outIsDir) {
@@ -231,48 +251,66 @@
// delete files
for (set<string>::iterator it=deleted.begin();
it!=deleted.end(); it++) {
- if (g_debug) {
- printf("deleting %s\n", it->c_str());
- }
+ debug_printf("deleting %s\n", it->c_str());
err = remove_recursively(*it);
if (err != 0) {
return err;
}
}
+ // remove all files or directories as requested from the input atree file.
+ // must be done before create new directories.
+ for (vector<FileRecord>::iterator it=files.begin();
+ it!=files.end(); it++) {
+ if (!it->sourceIsDir) {
+ if (it->fileOp == FILE_OP_REMOVE &&
+ deleted.count(it->outPath) == 0) {
+ debug_printf("remove %s\n", it->outPath.c_str());
+ err = remove_recursively(it->outPath);
+ if (err != 0) {
+ return err;
+ }
+ }
+ }
+ }
+
// make directories
for (set<string>::iterator it=directories.begin();
it!=directories.end(); it++) {
- if (g_debug) {
- printf("mkdir %s\n", it->c_str());
- }
+ debug_printf("mkdir %s\n", it->c_str());
err = mkdir_recursively(*it);
if (err != 0) {
return err;
}
}
- // copy (or link) files
+ // copy (or link) files that are newer or of different size
for (vector<FileRecord>::iterator it=files.begin();
it!=files.end(); it++) {
if (!it->sourceIsDir) {
- if (g_debug) {
- printf("copy %s(%ld) ==> %s(%ld)", it->sourcePath.c_str(),
- it->sourceMod, it->outPath.c_str(), it->outMod);
- fflush(stdout);
+ if (it->fileOp == FILE_OP_REMOVE) {
+ continue;
}
- if (it->outMod < it->sourceMod) {
+ debug_printf("copy %s(%ld) ==> %s(%ld)",
+ it->sourcePath.c_str(), it->sourceMod,
+ it->outPath.c_str(), it->outMod);
+
+ if (it->outSize != it->sourceSize || it->outMod < it->sourceMod) {
err = copy_file(it->sourcePath, it->outPath);
- if (g_debug) {
- printf(" done.\n");
- }
+ debug_printf(" done.\n");
if (err != 0) {
return err;
}
} else {
- if (g_debug) {
- printf(" skipping.\n");
+ debug_printf(" skipping.\n");
+ }
+
+ if (it->fileOp == FILE_OP_STRIP) {
+ debug_printf("strip %s\n", it->outPath.c_str());
+ err = strip_file(it->outPath);
+ if (err != 0) {
+ return err;
}
}
}
diff --git a/tools/atree/files.cpp b/tools/atree/files.cpp
index d4866d4..df3e987 100644
--- a/tools/atree/files.cpp
+++ b/tools/atree/files.cpp
@@ -62,7 +62,7 @@
split_line(const char* p, vector<string>* out)
{
const char* q = p;
- enum { WHITE, TEXT } state = WHITE;
+ enum { WHITE, TEXT, IN_QUOTE } state = WHITE;
while (*p) {
if (*p == '#') {
break;
@@ -73,13 +73,25 @@
case WHITE:
if (!isspace(*p)) {
q = p;
- state = TEXT;
+ state = (*p == '"') ? IN_QUOTE : TEXT;
}
break;
+ case IN_QUOTE:
+ if (*p == '"') {
+ state = TEXT;
+ break;
+ }
+ // otherwise fall-through to TEXT case
case TEXT:
- if (isspace(*p)) {
+ if (state != IN_QUOTE && isspace(*p)) {
if (q != p) {
- out->push_back(string(q, p-q));
+ const char* start = q;
+ size_t len = p-q;
+ if (len > 2 && *start == '"' && start[len - 1] == '"') {
+ start++;
+ len -= 2;
+ }
+ out->push_back(string(start, len));
}
state = WHITE;
}
@@ -88,17 +100,25 @@
p++;
}
if (state == TEXT) {
- out->push_back(string(q, p-q));
+ const char* start = q;
+ size_t len = p-q;
+ if (len > 2 && *start == '"' && start[len - 1] == '"') {
+ start++;
+ len -= 2;
+ }
+ out->push_back(string(start, len));
}
}
static void
-add_file(vector<FileRecord>* files, const string& listFile, int listLine,
+add_file(vector<FileRecord>* files, const FileOpType fileOp,
+ const string& listFile, int listLine,
const string& sourceName, const string& outName)
{
FileRecord rec;
rec.listFile = listFile;
rec.listLine = listLine;
+ rec.fileOp = fileOp;
rec.sourceName = sourceName;
rec.outName = outName;
files->push_back(rec);
@@ -182,7 +202,7 @@
err = errno;
goto cleanup;
}
-
+
size = ftell(f);
err = fseek(f, 0, SEEK_SET);
@@ -245,35 +265,52 @@
}
printf("]\n");
#endif
-
- if (words.size() == 1) {
- // pattern: DEST
- bool error = false;
- string w0 = replace_variables(words[0], variables, &error);
- if (error) {
- err = 1;
- goto cleanup;
+ FileOpType op = FILE_OP_COPY;
+ string paths[2];
+ int pcount = 0;
+ string errstr;
+ for (vector<string>::iterator it = words.begin(); it != words.end(); ++it) {
+ const string& word = *it;
+ if (word == "rm") {
+ if (op != FILE_OP_COPY) {
+ errstr = "Error: you can only specifiy 'rm' or 'strip' once per line.";
+ break;
+ }
+ op = FILE_OP_REMOVE;
+ } else if (word == "strip") {
+ if (op != FILE_OP_COPY) {
+ errstr = "Error: you can only specifiy 'rm' or 'strip' once per line.";
+ break;
+ }
+ op = FILE_OP_STRIP;
+ } else if (pcount < 2) {
+ bool error = false;
+ paths[pcount++] = replace_variables(word, variables, &error);
+ if (error) {
+ err = 1;
+ goto cleanup;
+ }
+ } else {
+ errstr = "Error: More than 2 paths per line.";
+ break;
}
- add_file(files, filename, i+1, w0, w0);
}
- else if (words.size() == 2) {
- // pattern: SRC DEST
- bool error = false;
- string w0, w1;
- w0 = replace_variables(words[0], variables, &error);
- if (!error) {
- w1 = replace_variables(words[1], variables, &error);
- }
- if (error) {
- err = 1;
- goto cleanup;
- }
- add_file(files, filename, i+1, w0, w1);
+
+ if (pcount == 0 && !errstr.empty()) {
+ errstr = "Error: No path found on line.";
}
- else {
- fprintf(stderr, "%s:%d: bad format: %s\n", filename.c_str(),
- i+1, p);
+
+ if (!errstr.empty()) {
+ fprintf(stderr, "%s:%d: bad format: %s\n%s\nExpected: [SRC] [rm|strip] DEST\n",
+ filename.c_str(), i+1, p, errstr.c_str());
err = 1;
+ } else {
+ if (pcount == 1) {
+ // pattern: [rm|strip] DEST
+ paths[1] = paths[0];
+ }
+
+ add_file(files, op, filename, i+1, paths[0], paths[1]);
}
}
p = q;
@@ -293,6 +330,14 @@
int
locate(FileRecord* rec, const vector<string>& search)
{
+ if (rec->fileOp == FILE_OP_REMOVE) {
+ // Don't touch source files when removing a destination.
+ rec->sourceMod = 0;
+ rec->sourceSize = 0;
+ rec->sourceIsDir = false;
+ return 0;
+ }
+
int err;
for (vector<string>::const_iterator it=search.begin();
@@ -304,6 +349,7 @@
rec->sourceBase = *it;
rec->sourcePath = full;
rec->sourceMod = st.st_mtime;
+ rec->sourceSize = st.st_size;
rec->sourceIsDir = S_ISDIR(st.st_mode);
return 0;
}
@@ -324,9 +370,11 @@
err = stat(rec->outPath.c_str(), &st);
if (err == 0) {
rec->outMod = st.st_mtime;
+ rec->outSize = st.st_size;
rec->outIsDir = S_ISDIR(st.st_mode);
} else {
rec->outMod = 0;
+ rec->outSize = 0;
rec->outIsDir = false;
}
}
@@ -427,3 +475,8 @@
{
return list_dir("", rec, excludes, files);
}
+
+FileRecord::FileRecord() {
+ fileOp = FILE_OP_COPY;
+}
+
diff --git a/tools/atree/files.h b/tools/atree/files.h
index 6480c98..f6bf8a6 100644
--- a/tools/atree/files.h
+++ b/tools/atree/files.h
@@ -8,8 +8,16 @@
using namespace std;
+enum FileOpType {
+ FILE_OP_COPY = 0,
+ FILE_OP_REMOVE,
+ FILE_OP_STRIP
+};
+
struct FileRecord
{
+ FileRecord();
+
string listFile;
int listLine;
@@ -18,9 +26,12 @@
string sourcePath;
bool sourceIsDir;
time_t sourceMod;
+ off_t sourceSize;
+ FileOpType fileOp;
string outName;
string outPath;
+ off_t outSize;
time_t outMod;
bool outIsDir;
unsigned int mode;
diff --git a/tools/atree/fs.cpp b/tools/atree/fs.cpp
index 9971879..b648394 100644
--- a/tools/atree/fs.cpp
+++ b/tools/atree/fs.cpp
@@ -1,7 +1,9 @@
#include "fs.h"
#include "files.h"
#include <unistd.h>
+#include <stdlib.h>
#include <sys/types.h>
+#include <sys/wait.h>
#include <dirent.h>
#include <string>
#include <vector>
@@ -64,10 +66,10 @@
#ifdef HAVE_DIRENT_D_TYPE
bool is_directory = (ent->d_type == DT_DIR);
#else
- // If dirent.d_type is missing, then use stat instead
- struct stat stat_buf;
- stat(full.c_str(), &stat_buf);
- bool is_directory = S_ISDIR(stat_buf.st_mode);
+ // If dirent.d_type is missing, then use stat instead
+ struct stat stat_buf;
+ stat(full.c_str(), &stat_buf);
+ bool is_directory = S_ISDIR(stat_buf.st_mode);
#endif
if (is_directory) {
dirs.push_back(full);
@@ -146,3 +148,27 @@
COPY_NO_DEREFERENCE | COPY_FORCE | COPY_PERMISSIONS);
return err;
}
+
+int
+strip_file(const string& path)
+{
+ // Default strip command to run is "strip" unless overridden by the STRIP env var.
+ const char* strip_cmd = getenv("STRIP");
+ if (!strip_cmd || !strip_cmd[0]) {
+ strip_cmd = "strip";
+ }
+ pid_t pid = fork();
+ if (pid == -1) {
+ // Fork failed. errno should be set.
+ return -1;
+ } else if (pid == 0) {
+ // Exec in the child. Only returns if execve failed.
+ return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL);
+ } else {
+ // Wait for child pid and return its exit code.
+ int status;
+ waitpid(pid, &status, 0);
+ return status;
+ }
+}
+
diff --git a/tools/atree/fs.h b/tools/atree/fs.h
index 4080880..fd4ae3e 100644
--- a/tools/atree/fs.h
+++ b/tools/atree/fs.h
@@ -8,5 +8,6 @@
int remove_recursively(const string& path);
int mkdir_recursively(const string& path);
int copy_file(const string& src, const string& dst);
+int strip_file(const string& path);
#endif // FS_H
diff --git a/tools/check_prereq/Android.mk b/tools/check_prereq/Android.mk
index abedff6..4329aff 100644
--- a/tools/check_prereq/Android.mk
+++ b/tools/check_prereq/Android.mk
@@ -15,8 +15,6 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-ifneq ($(TARGET_SIMULATOR),true)
-
LOCAL_SRC_FILES := check_prereq.c
LOCAL_MODULE := check_prereq
LOCAL_FORCE_STATIC_EXECUTABLE := true
@@ -25,6 +23,3 @@
LOCAL_STATIC_LIBRARIES += libcutils libc
include $(BUILD_EXECUTABLE)
-
-endif # !TARGET_SIMULATOR
-
diff --git a/tools/droiddoc/templates-sdk/assets/android-developer-core.css b/tools/droiddoc/templates-sdk/assets/android-developer-core.css
index 565f173..f548a6c 100644
--- a/tools/droiddoc/templates-sdk/assets/android-developer-core.css
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-core.css
@@ -649,6 +649,7 @@
#doc-content .gsc-tabHeader {
padding: 3px 6px;
position:relative;
+ width:auto;
}
#doc-content .gsc-tabHeader.gsc-tabhActive {
diff --git a/tools/droiddoc/templates-sdk/assets/android-developer-docs.css b/tools/droiddoc/templates-sdk/assets/android-developer-docs.css
index 22d010a..20871b9 100644
--- a/tools/droiddoc/templates-sdk/assets/android-developer-docs.css
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-docs.css
@@ -718,6 +718,17 @@
padding:0;
}
+#jd-content div.special.reference h2,
+#jd-content div.special.reference h3,
+#jd-content div.special.reference h4 {
+ color:#000;
+ font-size:1em;
+ border:none;
+ font-weight:bold;
+ margin:.5em 0;
+ padding:0;
+}
+
p.note, div.note,
p.caution, div.caution,
p.warning, div.warning {
@@ -1005,6 +1016,82 @@
/* End sidebox sidebar element styles */
+/* BEGIN developer training bar styles */
+
+div#tb-wrapper {
+ float: right;
+ width:480px; /* +25px padding = 505 */
+ background-color:#fff;
+ margin:-48px 0 2px 0;
+ padding:0 0 20px 25px;
+}
+
+div#tb {
+ margin:0;
+ padding:15px;
+ width:450px; /* +15px padding = 480 */
+ font-size:.9em;
+ background:#e9e9e9;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+}
+
+div#tb h2 {
+ font-size:1.3em;
+ font-weight:bold;
+ margin:12px 0 .25em 0;
+ padding:10px 0;
+ background-color:transparent;
+ border:none;
+}
+
+div.download-box a.button {
+ color:#eee;
+ font-weight:bold;
+ font-size:1.1em;
+ text-decoration:none;
+ height:40px;
+ line-height:40px;
+ padding:5px 10px;
+ border:2px solid #99be27;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ /* thanks http://www.colorzilla.com/gradient-editor/ */
+ background: #aed33c; /* Old browsers */
+ background: -moz-linear-gradient(top, #aed33c 20%, #a1c730 80%); /* FF3.6+ */
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(20%,#aed33c), color-stop(80%,#a1c730)); /* Chrome,Safari4+ */
+ background: -webkit-linear-gradient(top, #aed33c 20%,#a1c730 80%); /* Chrome10+,Safari5.1+ */
+ background: -o-linear-gradient(top, #aed33c 20%,#a1c730 80%); /* Opera11.10+ */
+ background: -ms-linear-gradient(top, #aed33c 20%,#a1c730 80%); /* IE10+ */
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#AED33C', endColorstr='#A1C730',GradientType=0 ); /* IE6-9 */
+ background: linear-gradient(top, #aed33c 20%,#a1c730 80%); /* W3C */
+}
+
+div.download-box a.button:hover {
+ border:2px solid #b2d841;
+}
+
+div.download-box a.button:active {
+ background: #a1c730; /* Old browsers */
+ background: -moz-linear-gradient(top, #a1c730 15%, #aed33c 70%); /* FF3.6+ */
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(15%,#a1c730), color-stop(70%,#aed33c)); /* Chrome,Safari4+ */
+ background: -webkit-linear-gradient(top, #a1c730 15%,#aed33c 70%); /* Chrome10+,Safari5.1+ */
+ background: -o-linear-gradient(top, #a1c730 15%,#aed33c 70%); /* Opera11.10+ */
+ background: -ms-linear-gradient(top, #a1c730 15%,#aed33c 70%); /* IE10+ */
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a1c730', endColorstr='#aed33c',GradientType=0 ); /* IE6-9 */
+ background: linear-gradient(top, #a1c730 15%,#aed33c 70%); /* W3C */
+}
+
+div.download-box p.filename {
+ font-size:0.8em;
+ color:#888;
+ margin:0 0 0 12px;
+}
+
+/* End developer training bar */
+
/* BEGIN image and caption styles (originally for UI Guidelines docs) */
table.image-caption {
diff --git a/tools/droiddoc/templates-sdk/assets/android-developer-docs.js b/tools/droiddoc/templates-sdk/assets/android-developer-docs.js
index e353236..0cac2fc 100644
--- a/tools/droiddoc/templates-sdk/assets/android-developer-docs.js
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-docs.js
@@ -143,7 +143,8 @@
cookiePath = "guide_";
} else if (location.href.indexOf("/sdk/") != -1) {
cookiePath = "sdk_";
- } else if (location.href.indexOf("/resources/") != -1) {
+ } else if ((location.href.indexOf("/resources/") != -1) ||
+ (location.href.indexOf("/training/") != -1)) {
cookiePath = "resources_";
}
@@ -231,6 +232,9 @@
if (tags[j] == 'new') {
listItemNode.get(0).innerHTML += ' <span class="new">new!</span>';
break;
+ } else if (tags[j] == 'updated') {
+ listItemNode.get(0).innerHTML += ' <span class="new">updated!</span>';
+ break;
}
}
listNode.append(listItemNode);
@@ -251,6 +255,8 @@
firstSlashPos = fullPageName.indexOf("/sdk/");
} else if (fullPageName.indexOf("/resources/") != -1) {
firstSlashPos = fullPageName.indexOf("/resources/");
+ } else if (fullPageName.indexOf("/training/") != -1) {
+ firstSlashPos = fullPageName.indexOf("/training/");
}
if (lastSlashPos == (fullPageName.length - 1)) { // if the url ends in slash (add 'index.html')
fullPageName = fullPageName + "index.html";
diff --git a/tools/droiddoc/templates-sdk/assets/android-developer-reference.js b/tools/droiddoc/templates-sdk/assets/android-developer-reference.js
index 31a702b..ba47d4d 100644
--- a/tools/droiddoc/templates-sdk/assets/android-developer-reference.js
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-reference.js
@@ -5,6 +5,7 @@
var API_LEVEL_ENABLED_COOKIE = "api_level_enabled";
var API_LEVEL_COOKIE = "api_level";
var minLevel = 1;
+var maxLevel = 1;
function toggleApiLevelSelector(checkbox) {
var date = new Date();
@@ -23,9 +24,9 @@
}
function buildApiLevelSelector() {
- var maxLevel = SINCE_DATA.length;
+ maxLevel = SINCE_DATA.length;
var userApiLevelEnabled = readCookie(API_LEVEL_ENABLED_COOKIE);
- var userApiLevel = readCookie(API_LEVEL_COOKIE);
+ var userApiLevel = parseInt(readCookie(API_LEVEL_COOKIE));
userApiLevel = userApiLevel == 0 ? maxLevel : userApiLevel; // If there's no cookie (zero), use the max by default
if (userApiLevelEnabled == 0) {
@@ -34,41 +35,47 @@
$("#apiLevelCheckbox").attr("checked","checked");
$("#api-level-toggle label").removeClass("disabled");
}
-
- minLevel = $("body").attr("class");
+
+ minLevel = parseInt($("body").attr("class"));
+ // Handle provisional api levels; the provisional level will always be the highest possible level
+ // Provisional api levels will also have a length; other stuff that's just missing a level won't,
+ // so leave those kinds of entities at the default level of 1 (for example, the R.styleable class)
+ if (isNaN(minLevel) && minLevel.length) {
+ minLevel = maxLevel;
+ }
var select = $("#apiLevelSelector").html("").change(changeApiLevel);
for (var i = maxLevel-1; i >= 0; i--) {
var option = $("<option />").attr("value",""+SINCE_DATA[i]).append(""+SINCE_DATA[i]);
// if (SINCE_DATA[i] < minLevel) option.addClass("absent"); // always false for strings (codenames)
select.append(option);
}
-
+
// get the DOM element and use setAttribute cuz IE6 fails when using jquery .attr('selected',true)
var selectedLevelItem = $("#apiLevelSelector option[value='"+userApiLevel+"']").get(0);
selectedLevelItem.setAttribute('selected',true);
}
function changeApiLevel() {
- var maxLevel = SINCE_DATA.length;
+ maxLevel = SINCE_DATA.length;
var userApiLevelEnabled = readCookie(API_LEVEL_ENABLED_COOKIE);
var selectedLevel = maxLevel;
-
+
if (userApiLevelEnabled == 0) {
toggleVisisbleApis(selectedLevel, "body");
} else {
selectedLevel = parseInt($("#apiLevelSelector option:selected").val());
toggleVisisbleApis(selectedLevel, "body");
-
+
var date = new Date();
date.setTime(date.getTime()+(10*365*24*60*60*1000)); // keep this for 10 years
var expiration = date.toGMTString();
writeCookie(API_LEVEL_COOKIE, selectedLevel, null, expiration);
}
-
+
if (selectedLevel < minLevel) {
var thing = ($("#jd-header").html().indexOf("package") != -1) ? "package" : "class";
$("#naMessage").show().html("<div><p><strong>This " + thing + " is not available with API Level " + selectedLevel + ".</strong></p>"
- + "<p>To use this " + thing + ", your application must specify API Level " + minLevel + " or higher in its manifest "
+ + "<p>To use this " + thing + ", your application must specify API Level \"" + $("body").attr("class") + "\" or higher in its manifest "
+ "and be compiled against a version of the Android library that supports an equal or higher API Level. To reveal this "
+ "document, change the value of the API Level filter above.</p>"
+ "<p><a href='" +toRoot+ "guide/appendix/api-levels.html'>What is the API Level?</a></p></div>");
@@ -86,7 +93,21 @@
var apiLevelEndIndex = className.indexOf(" ", apiLevelIndex);
apiLevelEndIndex = apiLevelEndIndex != -1 ? apiLevelEndIndex : className.length;
var apiLevel = className.substring(apiLevelIndex, apiLevelEndIndex);
- if (apiLevel > selectedLevel) obj.addClass("absent").attr("title","Requires API Level "+apiLevel+" or higher");
+ if (apiLevel.length == 0) { // for odd cases when the since data is actually missing, just bail
+ return;
+ }
+ apiLevel = parseInt(apiLevel);
+
+ // Handle provisional api levels; if this item's level is the provisional one, set it to the max
+ var selectedLevelNum = parseInt(selectedLevel)
+ var apiLevelNum = parseInt(apiLevel);
+ if (isNaN(apiLevelNum)) {
+ apiLevelNum = maxLevel;
+ }
+
+ // Grey things out that aren't available and give a tooltip title
+ if (apiLevelNum > selectedLevelNum) obj.addClass("absent").attr("title","Requires API Level \""
+ + apiLevel + "\" or higher");
else obj.removeClass("absent").removeAttr("title");
});
}
@@ -184,7 +205,7 @@
}
node.plus_img.src = me.toroot + "assets/images/triangle-opened-small.png";
node.expanded = true;
-
+
// perform api level toggling because new nodes are new to the DOM
var selectedLevel = $("#apiLevelSelector option:selected").val();
toggleVisisbleApis(selectedLevel, "#side-nav");
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/ics-android.png b/tools/droiddoc/templates-sdk/assets/images/home/ics-android.png
new file mode 100644
index 0000000..be62ca8
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/home/ics-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg
index cb1ff0b..0fbb197 100644
--- a/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg
+++ b/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg
Binary files differ
diff --git a/tools/fileslist.py b/tools/fileslist.py
index ae1b4b6..a11efaa 100755
--- a/tools/fileslist.py
+++ b/tools/fileslist.py
@@ -15,7 +15,7 @@
# limitations under the License.
#
-import os, sys
+import operator, os, sys
def get_file_size(path):
st = os.lstat(path)
@@ -37,9 +37,9 @@
output.append(row)
except os.error:
pass
+ output.sort(key=operator.itemgetter(0), reverse=True)
for row in output:
print "%12d %s" % row
if __name__ == '__main__':
main(sys.argv)
-
diff --git a/tools/findleaves.py b/tools/findleaves.py
index 0adf188..52c4d9f 100755
--- a/tools/findleaves.py
+++ b/tools/findleaves.py
@@ -89,9 +89,9 @@
usage()
dirlist = argv[i:-1]
filename = argv[-1]
- results = perform_find(mindepth, prune, dirlist, filename)
+ results = list(set(perform_find(mindepth, prune, dirlist, filename)))
results.sort()
- for r in set(results):
+ for r in results:
print r
if __name__ == "__main__":
diff --git a/tools/fs_config/Android.mk b/tools/fs_config/Android.mk
index 3f2ed95..5486bc2 100644
--- a/tools/fs_config/Android.mk
+++ b/tools/fs_config/Android.mk
@@ -15,13 +15,9 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-ifneq ($(TARGET_SIMULATOR),true)
-
LOCAL_SRC_FILES := fs_config.c
LOCAL_MODULE := fs_config
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_TAGS := eng
include $(BUILD_HOST_EXECUTABLE)
-
-endif # !TARGET_SIMULATOR
diff --git a/tools/iself/Android.mk b/tools/iself/Android.mk
deleted file mode 100755
index 49fabff..0000000
--- a/tools/iself/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for iself
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DDEBUG
-
-LOCAL_C_INCLUDES:= \
- $(LOCAL_PATH)/
-
-LOCAL_SRC_FILES := \
- iself.c
-
-LOCAL_MODULE := iself
-
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/iself/debug.h b/tools/iself/debug.h
deleted file mode 100644
index 9bbf47f..0000000
--- a/tools/iself/debug.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr) __builtin_expect (expr, 1)
-
-#ifdef DEBUG
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* Debug enabled */
- #define ASSERT(x) do { \
- if (unlikely(!(x))) { \
- fprintf(stderr, \
- "ASSERTION FAILURE %s:%d: [%s]\n", \
- __FILE__, __LINE__, #x); \
- exit(1); \
- } \
-} while(0)
-
-#else
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* No debug */
- #define ASSERT(x) do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
- FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
- void *m = malloc(size);
- FAILIF(NULL == m, "malloc(%d) failed!\n", size);
- return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
- void *m = calloc(num_entries, entry_size);
- FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
- return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
- void *m = realloc(ptr, size);
- FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
- return m;
-}
-
-static inline void FREE(void *ptr) {
- free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
- if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...) do { \
- extern int quiet_flag; \
- if(likely(!quiet_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-#define ERROR PRINT
-
-#define INFO(x...) do { \
- extern int verbose_flag; \
- if(unlikely(verbose_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/iself/iself.c b/tools/iself/iself.c
deleted file mode 100644
index e634a22..0000000
--- a/tools/iself/iself.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <debug.h>
-#include <unistd.h>
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-
-int
-main(int argc, char **argv)
-{
- char *fname;
- int fd;
- char magic[4];
-
- argc--, argv++;
- FAILIF(argc != 1, "Expecting a file name!\n");
- fname = *argv;
-
- fd = open(fname, O_RDONLY);
- FAILIF(fd < 0, "Error opening %s for reading: %s (%d)!\n",
- fname, strerror(errno), errno);
-
- FAILIF(4 != read(fd, magic, 4),
- "Could not read first 4 bytes from %s: %s (%d)!\n",
- fname, strerror(errno), errno);
-
- if (magic[0] != 0x7f) return 1;
- if (magic[1] != 'E') return 1;
- if (magic[2] != 'L') return 1;
- if (magic[3] != 'F') return 1;
-
- return 0;
-}
diff --git a/tools/isprelinked/Android.mk b/tools/isprelinked/Android.mk
deleted file mode 100755
index e085f29..0000000
--- a/tools/isprelinked/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for apriori
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifeq ($(TARGET_ARCH),arm)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DDEBUG
-
-ifeq ($(HOST_OS),windows)
-LOCAL_LDLIBS += -lintl
-endif
-
-LOCAL_SRC_FILES := \
- isprelinked.c \
- debug.c \
- prelink_info.c
-
-LOCAL_C_INCLUDES:= \
- $(LOCAL_PATH)/ \
- external/elfutils/lib/ \
- external/elfutils/libelf/ \
- external/elfutils/libebl/ \
- external/elfcopy/
-
-LOCAL_STATIC_LIBRARIES := libelfcopy libelf libebl libebl_arm #dl
-
-LOCAL_MODULE := isprelinked
-
-include $(BUILD_HOST_EXECUTABLE)
-endif #TARGET_ARCH==arm
diff --git a/tools/isprelinked/common.h b/tools/isprelinked/common.h
deleted file mode 100644
index f5d9d2e..0000000
--- a/tools/isprelinked/common.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr) __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-static inline int is_host_little(void)
-{
- short val = 0x10;
- return ((char *)&val)[0] != 0;
-}
-
-static inline long switch_endianness(long val)
-{
- long newval;
- ((char *)&newval)[3] = ((char *)&val)[0];
- ((char *)&newval)[2] = ((char *)&val)[1];
- ((char *)&newval)[1] = ((char *)&val)[2];
- ((char *)&newval)[0] = ((char *)&val)[3];
- return newval;
-}
-
-#endif/*COMMON_H*/
diff --git a/tools/isprelinked/debug.c b/tools/isprelinked/debug.c
deleted file mode 100644
index 6066543..0000000
--- a/tools/isprelinked/debug.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define NUM_COLS (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize) {
- int num_nonprintable = 0;
- int i, last;
- char *pchr = (char *)b;
- fputc('\n', s);
- for (i = last = 0; i < len; i++) {
- if (!elsize) {
- if (i && !(i % 4)) fprintf(s, " ");
- if (i && !(i % 8)) fprintf(s, " ");
- } else {
- if (i && !(i % elsize)) fprintf(s, " ");
- }
-
- if (i && !(i % NUM_COLS)) {
- while (last < i) {
- if (isprint(pchr[last]))
- fputc(pchr[last], s);
- else {
- fputc('.', s);
- num_nonprintable++;
- }
- last++;
- }
- fprintf(s, " (%d)\n", i);
- }
- fprintf(s, "%02x", (unsigned char)pchr[i]);
- }
- if (i && (i % NUM_COLS)) fputs("\n", s);
- return num_nonprintable;
-}
-
diff --git a/tools/isprelinked/debug.h b/tools/isprelinked/debug.h
deleted file mode 100644
index 3996898..0000000
--- a/tools/isprelinked/debug.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* Debug enabled */
- #define ASSERT(x) do { \
- if (unlikely(!(x))) { \
- fprintf(stderr, \
- "ASSERTION FAILURE %s:%d: [%s]\n", \
- __FILE__, __LINE__, #x); \
- exit(1); \
- } \
-} while(0)
-
-#else
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* No debug */
- #define ASSERT(x) do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
- FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
- void *m = malloc(size);
- FAILIF(NULL == m, "malloc(%d) failed!\n", size);
- return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
- void *m = calloc(num_entries, entry_size);
- FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
- return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
- void *m = realloc(ptr, size);
- FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
- return m;
-}
-
-static inline void FREE(void *ptr) {
- free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
- if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...) do { \
- extern int quiet_flag; \
- if(likely(!quiet_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-#define ERROR PRINT
-
-#define INFO(x...) do { \
- extern int verbose_flag; \
- if(unlikely(verbose_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/isprelinked/isprelinked.c b/tools/isprelinked/isprelinked.c
deleted file mode 100644
index c677e39..0000000
--- a/tools/isprelinked/isprelinked.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* TODO:
- 1. check the ARM EABI version--this works for versions 1 and 2.
- 2. use a more-intelligent approach to finding the symbol table, symbol-string
- table, and the .dynamic section.
- 3. fix the determination of the host and ELF-file endianness
- 4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#ifdef ARM_SPECIFIC_HACKS
- #include <libebl_arm.h>
-#endif/*ARM_SPECIFIC_HACKS*/
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <rangesort.h>
-#include <prelink_info.h>
-#include <libgen.h>
-
-
-/* Flag set by --verbose. This variable is global as it is accessed by the
- macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet. This variable is global as it is accessed by the
- macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-
-int main(int argc, char **argv) {
-
- argc--, argv++;
- if (!argc)
- return 0;
-
- /* Check to see whether the ELF library is current. */
- FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
- const char *filename;
- for (; argc; argc--) {
- filename = *argv++;
-
- Elf *elf;
- GElf_Ehdr elf_hdr;
- int fd;
- int prelinked;
- long prelink_addr = 0;
-
- INFO("Processing file [%s]\n", filename);
-
- fd = open(filename, O_RDONLY);
- FAILIF(fd < 0, "open(%d): %s (%d).\n",
- filename,
- strerror(errno),
- errno);
-
- elf = elf_begin(fd, ELF_C_READ_MMAP_PRIVATE, NULL);
- FAILIF_LIBELF(elf == NULL, elf_begin);
-
- FAILIF_LIBELF(0 == gelf_getehdr(elf, &elf_hdr),
- gelf_getehdr);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- prelinked = check_prelinked(filename, elf_hdr.e_ident[EI_DATA] == ELFDATA2LSB,
- &prelink_addr);
-#else
- #error 'SUPPORT_ANDROID_PRELINK_TAGS is not defined!'
-#endif
-
- if (prelinked)
- PRINT("%s: 0x%08x\n", filename, prelink_addr);
- else
- PRINT("%s: not prelinked\n", filename);
-
- FAILIF_LIBELF(elf_end(elf), elf_end);
- close(fd);
- }
-
- return 0;
-}
-
diff --git a/tools/isprelinked/prelink_info.c b/tools/isprelinked/prelink_info.c
deleted file mode 100644
index 21b1519..0000000
--- a/tools/isprelinked/prelink_info.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <prelink_info.h>
-#include <debug.h>
-#include <common.h>
-
-typedef struct {
- long mmap_addr;
- char tag[4]; /* 'P', 'R', 'E', ' ' */
-} prelink_info_t __attribute__((packed));
-
-static inline void set_prelink(long *prelink_addr,
- int elf_little,
- prelink_info_t *info)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
- if (prelink_addr) {
- if (!(elf_little ^ is_host_little())) {
- /* Same endianness */
- *prelink_addr = info->mmap_addr;
- }
- else {
- /* Different endianness */
- *prelink_addr = switch_endianness(info->mmap_addr);
- }
- }
-}
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
- int fd = open(fname, O_RDONLY);
- FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
- fname, strerror(errno), errno);
- off_t end = lseek(fd, 0, SEEK_END);
-
- int nr = sizeof(prelink_info_t);
-
- off_t sz = lseek(fd, -nr, SEEK_CUR);
- ASSERT((long)(end - sz) == (long)nr);
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- prelink_info_t info;
- int num_read = read(fd, &info, nr);
- FAILIF(num_read < 0,
- "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
- fd, strerror(errno), errno);
- FAILIF(num_read != sizeof(info),
- "read(%d, &info, sizeof(prelink_info_t)): did not read %d bytes as "
- "expected (read %d)!\n",
- fd, sizeof(info), num_read);
-
- int prelinked = 0;
- if (!strncmp(info.tag, "PRE ", 4)) {
- set_prelink(prelink_addr, elf_little, &info);
- prelinked = 1;
- }
- FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
- return prelinked;
-}
-
-#endif /*SUPPORT_ANDROID_PRELINK_TAGS*/
diff --git a/tools/isprelinked/prelink_info.h b/tools/isprelinked/prelink_info.h
deleted file mode 100644
index afc03e9..0000000
--- a/tools/isprelinked/prelink_info.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef PRELINK_INFO_H
-#define PRELINK_INFO_H
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr);
-
-#endif
-#endif/*PRELINK_INFO_H*/
diff --git a/tools/lsd/Android.mk b/tools/lsd/Android.mk
deleted file mode 100644
index a224741..0000000
--- a/tools/lsd/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for lsd
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifeq ($(TARGET_ARCH),arm)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DBIG_ENDIAN=1
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DDEBUG
-
-ifeq ($(HOST_OS),windows)
-LOCAL_LDLIBS += -lintl
-endif
-
-LOCAL_SRC_FILES := \
- cmdline.c \
- debug.c \
- hash.c \
- lsd.c \
- main.c
-
-LOCAL_C_INCLUDES:= \
- $(LOCAL_PATH)/ \
- external/elfutils/lib/ \
- external/elfutils/libelf/ \
- external/elfutils/libebl/
-
-LOCAL_STATIC_LIBRARIES := libelf libebl libebl_arm #dl
-
-LOCAL_MODULE := lsd
-
-include $(BUILD_HOST_EXECUTABLE)
-endif #TARGET_ARCH==arm
-
diff --git a/tools/lsd/cmdline.c b/tools/lsd/cmdline.c
deleted file mode 100644
index a3445cd..0000000
--- a/tools/lsd/cmdline.c
+++ /dev/null
@@ -1,130 +0,0 @@
-#include <debug.h>
-#include <cmdline.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <ctype.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-static struct option long_options[] = {
- {"verbose", no_argument, 0, 'V'},
- {"help", no_argument, 0, 'h'},
- {"print-info", no_argument, 0, 'p'},
- {"list-needed-libs", no_argument, 0, 'n'},
- {"lookup", required_argument, 0, 'L'},
- {0, 0, 0, 0},
-};
-
-/* This array must parallel long_options[] */
-static const char *descriptions[] = {
- "print verbose output",
- "print help screen",
- "for each file, generate a listing of all dependencies that each symbol "
- "satisfies",
- "print out a list of needed libraries",
- "provide a directory for library lookup"
-};
-
-void print_help(void)
-{
- fprintf(stdout,
- "invokation:\n"
- "\tlsd file1 [file2 file3 ... fileN] [-Ldir1 -Ldir2 ... -LdirN] "
- "[-Vpn]\n"
- "or\n"
- "\tlsd -h\n\n");
- fprintf(stdout, "options:\n");
- struct option *opt = long_options;
- const char **desc = descriptions;
- while (opt->name) {
- fprintf(stdout, "\t-%c\n"
- "\t--%-15s: %s\n",
- opt->val,
- opt->name,
- *desc);
- opt++;
- desc++;
- }
-}
-
-int get_options(int argc, char **argv,
- int *list_needed_libs,
- int *info,
- char ***dirs,
- int *num_dirs,
- int *verbose)
-{
- int c;
-
- ASSERT(list_needed_libs);
- *list_needed_libs = 0;
- ASSERT(info);
- *info = 0;
- ASSERT(verbose);
- *verbose = 0;
- ASSERT(dirs);
- *dirs = NULL;
- ASSERT(num_dirs);
- int size = 0;
- *num_dirs = 0;
-
- while (1) {
- /* getopt_long stores the option index here. */
- int option_index = 0;
-
- c = getopt_long (argc, argv,
- "VhpnL:",
- long_options,
- &option_index);
- /* Detect the end of the options. */
- if (c == -1) break;
-
- if (isgraph(c)) {
- INFO ("option -%c with value `%s'\n", c, (optarg ?: "(null)"));
- }
-
-#define SET_STRING_OPTION(name) do { \
- ASSERT(optarg); \
- (*name) = strdup(optarg); \
-} while(0)
-
- switch (c) {
- case 0:
- /* If this option set a flag, do nothing else now. */
- if (long_options[option_index].flag != 0)
- break;
- INFO ("option %s", long_options[option_index].name);
- if (optarg)
- INFO (" with arg %s", optarg);
- INFO ("\n");
- break;
- case 'h': print_help(); exit(1); break;
- case 'V': *verbose = 1; break;
- case 'p': *info = 1; break;
- case 'n': *list_needed_libs = 1; break;
- case 'L':
- {
- if (*num_dirs == size) {
- size += 10;
- *dirs = (char **)REALLOC(*dirs, size * sizeof(char *));
- }
- SET_STRING_OPTION(((*dirs) + *num_dirs));
- (*num_dirs)++;
- }
- break;
- case '?':
- /* getopt_long already printed an error message. */
- break;
-
-#undef SET_STRING_OPTION
-
- default:
- FAILIF(1, "Unknown option");
- }
- }
-
- return optind;
-}
diff --git a/tools/lsd/cmdline.h b/tools/lsd/cmdline.h
deleted file mode 100644
index fc3be3e..0000000
--- a/tools/lsd/cmdline.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-void print_help(void);
-
-int get_options(int argc, char **argv,
- int *list_needed_libs,
- int *info,
- char ***dirs,
- int *num_dirs,
- int *verbose);
-
-#endif/*CMDLINE_H*/
diff --git a/tools/lsd/common.h b/tools/lsd/common.h
deleted file mode 100644
index 6447b10..0000000
--- a/tools/lsd/common.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr) __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-#endif/*COMMON_H*/
diff --git a/tools/lsd/debug.c b/tools/lsd/debug.c
deleted file mode 100644
index 54b18df..0000000
--- a/tools/lsd/debug.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define NUM_COLS (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize)
-{
- int num_nonprintable = 0;
- int i, last;
- char *pchr = (char *)b;
- fputc('\n', s);
- for (i = last = 0; i < len; i++) {
- if (!elsize) {
- if (i && !(i % 4)) fprintf(s, " ");
- if (i && !(i % 8)) fprintf(s, " ");
- }
- else {
- if (i && !(i % elsize)) fprintf(s, " ");
- }
-
- if (i && !(i % NUM_COLS)) {
- while (last < i) {
- if (isprint(pchr[last]))
- fputc(pchr[last], s);
- else {
- fputc('.', s);
- num_nonprintable++;
- }
- last++;
- }
- fprintf(s, " (%d)\n", i);
- }
- fprintf(s, "%02x", (unsigned char)pchr[i]);
- }
- if (i && (i % NUM_COLS)) fputs("\n", s);
- return num_nonprintable;
-}
-
diff --git a/tools/lsd/debug.h b/tools/lsd/debug.h
deleted file mode 100644
index f7842f8..0000000
--- a/tools/lsd/debug.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
-#define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* Debug enabled */
-#define ASSERT(x) do { \
- if (unlikely(!(x))) { \
- fprintf(stderr, \
- "ASSERTION FAILURE %s:%d: [%s]\n", \
- __FILE__, __LINE__, #x); \
- exit(1); \
- } \
-} while(0)
-
-#else
-
-#define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* No debug */
-#define ASSERT(x) do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
- FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size)
-{
- void *m = malloc(size);
- FAILIF(NULL == m, "malloc(%d) failed!\n", size);
- return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size)
-{
- void *m = calloc(num_entries, entry_size);
- FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
- return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size)
-{
- void *m = realloc(ptr, size);
- FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
- return m;
-}
-
-static inline void FREE(void *ptr)
-{
- free(ptr);
-}
-
-static inline void FREEIF(void *ptr)
-{
- if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...) do { \
- extern int quiet_flag; \
- if(likely(!quiet_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-#define ERROR(x...) fprintf(stderr, ##x)
-
-#define INFO(x...) do { \
- extern int verbose_flag; \
- if(unlikely(verbose_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/lsd/hash.c b/tools/lsd/hash.c
deleted file mode 100644
index bbac675..0000000
--- a/tools/lsd/hash.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <hash.h>
-#include <string.h>
-
-int hash_lookup(Elf *elf,
- Elf_Data *hash,
- Elf_Data *symtab,
- Elf_Data *symstr,
- const char *symname)
-{
- Elf32_Word *hash_data = (Elf32_Word *)hash->d_buf;
- Elf32_Word index;
- Elf32_Word nbuckets = *hash_data++;
- Elf32_Word *buckets = ++hash_data;
- Elf32_Word *chains = hash_data + nbuckets;
-
- index = buckets[elf_hash(symname) % nbuckets];
- while(index != STN_UNDEF &&
- strcmp((char *)symstr->d_buf +
- ((Elf32_Sym *)symtab->d_buf)[index].st_name,
- symname))
- {
- index = chains[index];
- }
-
- return index;
-}
diff --git a/tools/lsd/hash.h b/tools/lsd/hash.h
deleted file mode 100644
index af29b9e..0000000
--- a/tools/lsd/hash.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef HASH_H
-#define HASH_H
-
-#include <common.h>
-#include <libelf.h>
-#include <gelf.h>
-
-int hash_lookup(Elf *elf,
- Elf_Data *hash,
- Elf_Data *symtab,
- Elf_Data *symstr,
- const char *symname);
-
-#endif/*HASH_H*/
diff --git a/tools/lsd/lsd.c b/tools/lsd/lsd.c
deleted file mode 100644
index 03c235b..0000000
--- a/tools/lsd/lsd.c
+++ /dev/null
@@ -1,777 +0,0 @@
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <hash.h>
-#include <lsd.h>
-
-extern int verbose_flag;
-
-typedef struct source_t source_t;
-
-typedef struct {
- Elf_Scn *scn;
- GElf_Shdr shdr;
- Elf_Data *data;
-} section_info_t;
-
-typedef struct next_export_t {
- source_t *source;
- int next_idx;
-} next_export_t;
-
-struct source_t {
- source_t *next;
- int visited;
-
- char *name; /* full path name of this executable file */
- /* ELF-related information: */
- Elf *elf;
- int elf_fd;
- GElf_Ehdr elf_hdr;
- size_t shstrndx;
- int shnum; /* number of sections */
-
- section_info_t symtab;
- section_info_t strtab;
- section_info_t dynamic;
- section_info_t hash;
-
- section_info_t *relocations;
- int num_relocations; /* number of relocs (<= relocations_size) */
- int relocations_size; /* sice of array -- NOT number of relocs! */
-
- /* satisfied_execs: array containing pointers to the libraries or
- executables that this executable satisfies symbol references for. */
- source_t **satisfied_execs;
- int num_satisfied_execs;
- int satisfied_execs_size;
-
- /* satisfied: array is parallel to symbol table; for each undefined symbol
- in that array, we maintain a flag stating whether that symbol has been
- satisfied, and if so, by which library. This applies both to executable
- files and libraries.
- */
- source_t **satisfied;
-
- /* exports: array is parallel to symbol table; for each global symbol
- in that array, we maintain a flag stating whether that symbol satisfies
- a dependency in some other file. num_syms is the length of the exports
- array, as well as the satisfied array. This applied to libraries only.
-
- next_exports: this is a bit tricky. We use this field to maintain a
- linked list of source_t for each global symbol of a shared library.
- For a shared library's global symbol at index N has the property that
- exports[N] is the head of a linked list (threaded through next_export)
- of all source_t that this symbol resolves a reference to. For example,
- if symbol printf has index 1000 in libc.so, and an executable A and
- library L use printf, then the source_t entry corresponding to libc.so
- will have exports[1000] be a linked list that contains the nodes for
- application A and library L.
- */
-
- next_export_t *exports;
- /* num_exported is the number of symbols in this file actually used by
- somebody else; it's not the size of the exports array. */
- int num_exported;
- next_export_t *next_export;
- int num_next_export;
- int next_export_size;
-
- int num_syms; /* number of symbols in symbol table. This is the length of
- both exports[] and satisfied[] arrays. */
-
- /* This is an array that contains one element for each library dependency
- listed in the executable or shared library. */
- source_t **lib_deps; /* list of library dependencies */
- int num_lib_deps; /* actual number of library dependencies */
- int lib_deps_size; /* size of lib_deps array--NOT actual number of deps! */
-
-};
-
-static source_t *sources = NULL;
-
-static char * find_file(const char *libname,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs);
-
-static inline source_t* find_source(const char *name,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs) {
- source_t *trav = sources;
- char *full = find_file(name, lib_lookup_dirs, num_lib_lookup_dirs);
- FAILIF(full == NULL, "Cannot construct full path for file [%s]!\n", name);
- while (trav) {
- if (!strcmp(trav->name, full))
- break;
- trav = trav->next;
- }
- free(full);
- return trav;
-}
-
-static inline void add_to_sources(source_t *src) {
- src->next = sources;
- sources = src;
-}
-
-static source_t* init_source(char *full_path) {
- source_t *source = (source_t *)CALLOC(1, sizeof(source_t));
-
- ASSERT(full_path);
- source->name = full_path;
- source->elf_fd = -1;
-
- INFO("Opening %s...\n", full_path);
- source->elf_fd = open(full_path, O_RDONLY);
- FAILIF(source->elf_fd < 0, "open(%s): %s (%d)\n",
- full_path,
- strerror(errno),
- errno);
- INFO("Calling elf_begin(%s)...\n", full_path);
- source->elf = elf_begin(source->elf_fd, ELF_C_READ, NULL);
- FAILIF_LIBELF(source->elf == NULL, elf_begin);
-
- /* libelf can recognize COFF and A.OUT formats, but we handle only ELF. */
- if (elf_kind(source->elf) != ELF_K_ELF) {
- ERROR("Input file %s is not in ELF format!\n", full_path);
- return NULL;
- }
-
- /* Make sure this is a shared library or an executable. */
- {
- INFO("Making sure %s is a shared library or an executable...\n",
- full_path);
- FAILIF_LIBELF(0 == gelf_getehdr(source->elf, &source->elf_hdr), gelf_getehdr);
- FAILIF(source->elf_hdr.e_type != ET_DYN &&
- source->elf_hdr.e_type != ET_EXEC,
- "%s must be a shared library (elf type is %d, expecting %d).\n",
- full_path,
- source->elf_hdr.e_type,
- ET_DYN);
- }
-
- /* Get the index of the section-header-strings-table section. */
- FAILIF_LIBELF(elf_getshstrndx (source->elf, &source->shstrndx) < 0,
- elf_getshstrndx);
-
- FAILIF_LIBELF(elf_getshnum (source->elf, &source->shnum) < 0, elf_getshnum);
-
- /* Find various sections. */
- size_t scnidx;
- Elf_Scn *scn;
- GElf_Shdr *shdr, shdr_mem;
- INFO("Locating %d sections in %s...\n", source->shnum, full_path);
- for (scnidx = 1; scnidx < source->shnum; scnidx++) {
- scn = elf_getscn(source->elf, scnidx);
- FAILIF_LIBELF(NULL == scn, elf_getscn);
- shdr = gelf_getshdr(scn, &shdr_mem);
- FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
- INFO("\tfound section [%s]...\n", elf_strptr(source->elf, source->shstrndx, shdr->sh_name));
- if (shdr->sh_type == SHT_DYNSYM) {
- source->symtab.scn = scn;
- source->symtab.data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == source->symtab.data, elf_getdata);
- memcpy(&source->symtab.shdr, shdr, sizeof(GElf_Shdr));
-
- /* The sh_link field of the section header of the symbol table
- contains the index of the associated strings table. */
- source->strtab.scn = elf_getscn(source->elf,
- source->symtab.shdr.sh_link);
- FAILIF_LIBELF(NULL == source->strtab.scn, elf_getscn);
- FAILIF_LIBELF(NULL == gelf_getshdr(scn, &source->strtab.shdr),
- gelf_getshdr);
- source->strtab.data = elf_getdata(source->strtab.scn, NULL);
- FAILIF_LIBELF(NULL == source->strtab.data, elf_getdata);
- }
- else if (shdr->sh_type == SHT_DYNAMIC) {
- source->dynamic.scn = scn;
- source->dynamic.data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == source->symtab.data, elf_getdata);
- memcpy(&source->dynamic.shdr, shdr, sizeof(GElf_Shdr));
- }
- else if (shdr->sh_type == SHT_HASH) {
- source->hash.scn = scn;
- source->hash.data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == source->hash.data, elf_getdata);
- memcpy(&source->hash.shdr, shdr, sizeof(GElf_Shdr));
- }
- else if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) {
- if (source->num_relocations == source->relocations_size) {
- source->relocations_size += 5;
- source->relocations =
- (section_info_t *)REALLOC(source->relocations,
- source->relocations_size *
- sizeof(section_info_t));
- }
- section_info_t *reloc =
- source->relocations + source->num_relocations;
- reloc->scn = scn;
- reloc->data = elf_getdata(scn, NULL);
- FAILIF_LIBELF(NULL == reloc->data, elf_getdata);
- memcpy(&reloc->shdr, shdr, sizeof(GElf_Shdr));
- source->num_relocations++;
- }
- }
-
- if (source->dynamic.scn == NULL) {
- INFO("File [%s] does not have a dynamic section!\n", full_path);
- return 0;
- }
-
- FAILIF(source->symtab.scn == NULL,
- "File [%s] does not have a dynamic symbol table!\n",
- full_path);
-
- FAILIF(source->hash.scn == NULL,
- "File [%s] does not have a hash table!\n",
- full_path);
- FAILIF(source->hash.shdr.sh_link != elf_ndxscn(source->symtab.scn),
- "Hash points to section %d, not to %d as expected!\n",
- source->hash.shdr.sh_link,
- elf_ndxscn(scn));
-
- /* Now, find out how many symbols we have and allocate the array of
- satisfied symbols.
-
- NOTE: We don't count the number of undefined symbols here; we will
- iterate over the symbol table later, and count them then, when it is
- more convenient.
- */
- size_t symsize = gelf_fsize (source->elf,
- ELF_T_SYM,
- 1, source->elf_hdr.e_version);
- ASSERT(symsize);
-
- source->num_syms = source->symtab.data->d_size / symsize;
- source->satisfied = (source_t **)CALLOC(source->num_syms,
- sizeof(source_t *));
- source->exports = (source_t **)CALLOC(source->num_syms,
- sizeof(next_export_t));
-
- source->num_exported = 0;
- source->satisfied_execs = NULL;
- source->num_satisfied_execs = 0;
- source->satisfied_execs_size = 0;
-
- add_to_sources(source);
- return source;
-}
-
-static void destroy_source(source_t *source) {
- FREE(source->satisfied_execs);
- FREE(source->satisfied);
- FREE(source->exports);
- FREE(source->next_export);
- FREE(source->lib_deps); /* list of library dependencies */
- FAILIF_LIBELF(elf_end(source->elf), elf_end);
- FAILIF(close(source->elf_fd) < 0, "Could not close file %s: %s (%d)!\n",
- source->name, strerror(errno), errno);
- FREE(source->name);
- FREE(source);
-}
-
-static void print_needed_libs(source_t *source)
-{
- size_t idx;
- for (idx = 0; idx < source->num_lib_deps; idx++) {
- PRINT("%s:%s\n",
- source->name,
- source->lib_deps[idx]->name);
- }
-}
-
-static int is_symbol_imported(source_t *source,
- GElf_Sym *sym,
- size_t symidx)
-{
- const char *symname = elf_strptr(source->elf,
- elf_ndxscn(source->strtab.scn),
- sym->st_name);
-
- /* A symbol is imported by an executable or a library if it is undefined
- and is either global or weak. There is an additional case for
- executables that we will check below. */
- if (sym->st_shndx == SHN_UNDEF &&
- (GELF_ST_BIND(sym->st_info) == STB_GLOBAL ||
- GELF_ST_BIND(sym->st_info) == STB_WEAK)) {
- INFO("*** symbol [%s:%s] is imported (UNDEFIEND).\n",
- source->name,
- symname);
- return 1;
- }
-
-#ifdef ARM_SPECIFIC_HACKS
- /* A symbol is imported by an executable if is marked as an undefined
- symbol--this is standard to all ELF formats. Alternatively, according
- to the ARM specifications, a symbol in a BSS section that is also marked
- by an R_ARM_COPY relocation is also imported. */
-
- if (source->elf_hdr.e_type != ET_EXEC) {
- INFO("is_symbol_imported(): [%s] is a library, "
- "no further checks.\n", source->name);
- return 0;
- }
-
- /* Is the symbol in the BSS section, and is there a COPY relocation on
- that symbol? */
- INFO("*** [%s:%s] checking further to see if symbol is imported.\n",
- source->name, symname);
- if (sym->st_shndx < source->shnum) {
- /* Is it the .bss section? */
- Elf_Scn *scn = elf_getscn(source->elf, sym->st_shndx);
- FAILIF_LIBELF(NULL == scn, elf_getscn);
- GElf_Shdr *shdr, shdr_mem;
- shdr = gelf_getshdr(scn, &shdr_mem);
- FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
- if (!strcmp(".bss", elf_strptr(source->elf,
- source->shstrndx,
- shdr->sh_name)))
- {
- /* Is there an R_ARM_COPY relocation on this symbol? Iterate
- over the list of relocation sections and scan each section for
- an entry that matches the symbol. */
- size_t idx;
- for (idx = 0; idx < source->num_relocations; idx++) {
- section_info_t *reloc = source->relocations + idx;
- /* Does the relocation section refer to the symbol table in
- which this symbol resides, and does it relocate the .bss
- section? */
- if (reloc->shdr.sh_link == elf_ndxscn(source->symtab.scn) &&
- reloc->shdr.sh_info == sym->st_shndx)
- {
- /* Go over the relocations and see if any of them matches
- our symbol. */
- size_t nrels = reloc->shdr.sh_size / reloc->shdr.sh_entsize;
- size_t relidx, newidx;
- if (reloc->shdr.sh_type == SHT_REL) {
- for (newidx = relidx = 0; relidx < nrels; ++relidx) {
- GElf_Rel rel_mem;
- FAILIF_LIBELF(gelf_getrel (reloc->data,
- relidx,
- &rel_mem) == NULL,
- gelf_getrel);
- if (GELF_R_TYPE(rel_mem.r_info) == R_ARM_COPY &&
- GELF_R_SYM (rel_mem.r_info) == symidx)
- {
- INFO("*** symbol [%s:%s] is imported "
- "(DEFINED, REL-COPY-RELOCATED).\n",
- source->name,
- symname);
- return 1;
- }
- } /* for each rel entry... */
- } else {
- for (newidx = relidx = 0; relidx < nrels; ++relidx) {
- GElf_Rela rel_mem;
- FAILIF_LIBELF(gelf_getrela (reloc->data,
- relidx,
- &rel_mem) == NULL,
- gelf_getrela);
- if (GELF_R_TYPE(rel_mem.r_info) == R_ARM_COPY &&
- GELF_R_SYM (rel_mem.r_info) == symidx)
- {
- INFO("*** symbol [%s:%s] is imported "
- "(DEFINED, RELA-COPY-RELOCATED).\n",
- source->name,
- symname);
- return 1;
- }
- } /* for each rela entry... */
- } /* if rel else rela */
- }
- }
- }
- }
-#endif/*ARM_SPECIFIC_HACKS*/
-
- return 0;
-}
-
-static void resolve(source_t *source) {
- /* Iterate the symbol table. For each undefined symbol, scan the
- list of dependencies till we find a global symbol in one of them that
- satisfies the undefined reference. At this point, we update both the
- satisfied[] array of the sources entry, as well as the exports array of
- the dependency where we found the match.
- */
-
- GElf_Sym *sym, sym_mem;
- size_t symidx;
- for (symidx = 0; symidx < source->num_syms; symidx++) {
- sym = gelf_getsymshndx(source->symtab.data,
- NULL,
- symidx,
- &sym_mem,
- NULL);
- FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
- if (is_symbol_imported(source, sym, symidx))
- {
- /* This is an undefined symbol. Go over the list of libraries
- and look it up. */
- size_t libidx;
- int found = 0;
- source_t *last_found = NULL;
- const char *symname = elf_strptr(source->elf,
- elf_ndxscn(source->strtab.scn),
- sym->st_name);
- for (libidx = 0; libidx < source->num_lib_deps; libidx++) {
- source_t *lib = source->lib_deps[libidx];
- int lib_symidx = hash_lookup(lib->elf,
- lib->hash.data,
- lib->symtab.data,
- lib->strtab.data,
- symname);
- if (STN_UNDEF != lib_symidx)
- {
- /* We found the symbol--now check to see if it is global
- or weak. If this is the case, then the symbol satisfies
- the dependency. */
- GElf_Sym *lib_sym, lib_sym_mem;
- lib_sym = gelf_getsymshndx(lib->symtab.data,
- NULL,
- lib_symidx,
- &lib_sym_mem,
- NULL);
- FAILIF_LIBELF(NULL == lib_sym, gelf_getsymshndx);
-
- if(lib_sym->st_shndx != STN_UNDEF &&
- (GELF_ST_BIND(lib_sym->st_info) == STB_GLOBAL ||
- GELF_ST_BIND(lib_sym->st_info) == STB_WEAK))
- {
- /* We found the symbol! Update the satisfied array at this
- index location. */
- source->satisfied[symidx] = lib;
- /* Now, link this structure into the linked list
- corresponding to the found symbol in the library's
- global array. */
- if (source->num_next_export == source->next_export_size) {
- source->next_export_size += 30;
- source->next_export =
- (source_t **)REALLOC(source->next_export,
- source->next_export_size *
- sizeof(struct next_export_t));
- }
- source->next_export[source->num_next_export] = lib->exports[lib_symidx];
- lib->exports[lib_symidx].source = source;
- lib->exports[lib_symidx].next_idx = source->num_next_export;
-
- source->num_next_export++;
- lib->num_exported++;
-
- INFO("[%s:%s (index %d)] satisfied by [%s] (index %d)\n",
- source->name,
- symname,
- symidx,
- lib->name,
- lib_symidx);
- if (found) {
- if (found == 1) {
- found++;
- ERROR("ERROR: multiple definitions found for [%s:%s]!\n",
- source->name, symname);
- ERROR("\tthis definition [%s]\n", lib->name);
- }
- ERROR("\tprevious definition [%s]\n", last_found->name);
- }
-
- last_found = lib;
- if (!found) found = 1;
- }
- }
- }
- if(found == 0) {
- ERROR("ERROR: could not find match for %s:%s.\n",
- source->name,
- symname);
- }
- } /* if we found the symbol... */
- } /* for each symbol... */
-} /* resolve() */
-
-static void print_used_symbols(source_t *source) {
-
- int name_len = strlen(source->name);
- static const char ext[] = ".syms";
- char *filter = (char *)MALLOC(name_len + sizeof(ext));
- strcpy(filter, source->name);
- strcpy(filter + name_len, ext);
-
- FILE *fp = fopen(filter, "w+");
- FAILIF(NULL == fp,
- "Can't open %s: %s (%d)\n",
- filter,
- strerror(errno), errno);
-
- /* Is anybody using the symbols defined in source? */
-
- if (source->num_exported > 0) {
- INFO("[%s] exports %d symbols to %d libraries and executables.\n",
- source->name,
- source->num_exported,
- source->num_satisfied_execs);
- size_t symidx;
- for (symidx = 0; symidx < source->num_syms; symidx++) {
- if (source->exports[symidx].source != NULL) {
- GElf_Sym *sym, sym_mem;
- sym = gelf_getsymshndx(source->symtab.data,
- NULL,
- symidx,
- &sym_mem,
- NULL);
- FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
- fprintf(fp, "%s\n", elf_strptr(source->elf,
- elf_ndxscn(source->strtab.scn),
- sym->st_name));
- }
- }
- }
- else if (source->num_satisfied_execs > 0) {
-
- /* Is the source listed as a depenency on anyone? If so, then the source exports no symbols
- to anyone, but someone lists it as a dependency, which is unnecessary, so we print a warning.
- */
-
- ERROR("WARNING: [%s] is listed as a dependency in: ", source->name);
- int i;
- for (i = 0; i < source->num_satisfied_execs; i++) {
- ERROR(" [%s],", source->satisfied_execs[i]->name);
- }
- ERROR(" but none of its symbols are used!.\n");
- }
-#if 0 /* This is not really an error--a library's symbols may not be used anyone as specified in the ELF file,
- but someone may still open a library via dlopen().
- */
- else {
- ERROR("WARNING: None of [%s]'s symbols are used by any library or executable!\n", source->name);
- }
-#endif
-
- fclose(fp);
- FREE(filter);
-}
-
-static void print_symbol_references(source_t *source) {
-
- int name_len = strlen(source->name);
- static const char ext[] = ".info";
- char *filter = (char *)MALLOC(name_len + sizeof(ext));
- strcpy(filter, source->name);
- strcpy(filter + name_len, ext);
-
- FILE *fp = fopen(filter, "w+");
- FAILIF(NULL == fp,
- "Can't open %s: %s (%d)\n",
- filter,
- strerror(errno), errno);
-
- if (source->num_exported > 0) {
- size_t symidx;
- for (symidx = 0; symidx < source->num_syms; symidx++) {
- if (source->exports[symidx].source != NULL) {
- const char *symname;
- GElf_Sym *sym, sym_mem;
- sym = gelf_getsymshndx(source->symtab.data,
- NULL,
- symidx,
- &sym_mem,
- NULL);
- FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
- symname = elf_strptr(source->elf,
- elf_ndxscn(source->strtab.scn),
- sym->st_name);
- fprintf(fp, "%s\n", symname);
- next_export_t *export = &source->exports[symidx];
- while (export->source != NULL) {
- //fprintf(stderr, "%s:%s\n", symname, export->source->name);
- fprintf(fp, "\t%s\n", export->source->name);
- export = &export->source->next_export[export->next_idx];
- }
- }
- }
- }
-
- fclose(fp);
- FREE(filter);
-}
-
-static char * find_file(const char *libname,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs) {
- if (libname[0] == '/') {
- /* This is an absolute path name--just return it. */
- INFO("ABSOLUTE PATH: [%s].\n", libname);
- return strdup(libname);
- } else {
- /* First try the working directory. */
- int fd;
- if ((fd = open(libname, O_RDONLY)) > 0) {
- close(fd);
- INFO("FOUND IN CURRENT DIR: [%s].\n", libname);
- return strdup(libname);
- } else {
- /* Iterate over all library paths. For each path, append the file
- name and see if there is a file at that place. If that fails,
- bail out. */
-
- char *name;
- while (num_lib_lookup_dirs--) {
- size_t lib_len = strlen(*lib_lookup_dirs);
- /* one extra character for the slash, and another for the
- terminating NULL. */
- name = (char *)MALLOC(lib_len + strlen(libname) + 2);
- strcpy(name, *lib_lookup_dirs);
- name[lib_len] = '/';
- strcpy(name + lib_len + 1, libname);
- if ((fd = open(name, O_RDONLY)) > 0) {
- close(fd);
- INFO("FOUND: [%s] in [%s].\n", libname, name);
- return name;
- }
- INFO("NOT FOUND: [%s] in [%s].\n", libname, name);
- free(name);
- }
- }
- }
- return NULL;
-}
-
-static source_t* process_library(const char *libname,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs) {
- source_t *source = find_source(libname, lib_lookup_dirs, num_lib_lookup_dirs);
- if (NULL == source) {
- INFO("Processing [%s].\n", libname);
- char *full = find_file(libname, lib_lookup_dirs, num_lib_lookup_dirs);
- FAILIF(NULL == full,
- "Could not find [%s] in the current directory or in any of "
- "the search paths!\n", libname);
- source = init_source(full);
- if (source) {
- GElf_Dyn *dyn, dyn_mem;
- size_t dynidx;
- size_t numdyn =
- source->dynamic.shdr.sh_size /
- source->dynamic.shdr.sh_entsize;
-
- for (dynidx = 0; dynidx < numdyn; dynidx++) {
- dyn = gelf_getdyn (source->dynamic.data,
- dynidx,
- &dyn_mem);
- FAILIF_LIBELF(NULL == dyn, gelf_getdyn);
- if (dyn->d_tag == DT_NEEDED) {
- /* Process the needed library recursively. */
- const char *dep_lib =
- elf_strptr (source->elf,
- source->dynamic.shdr.sh_link,
- dyn->d_un.d_val);
- INFO("[%s] depends on [%s].\n", libname, dep_lib);
- source_t *dep = process_library(dep_lib,
- lib_lookup_dirs,
- num_lib_lookup_dirs);
-
- /* Tell dep that source depends on it. */
- if (dep->num_satisfied_execs == dep->satisfied_execs_size) {
- dep->satisfied_execs_size += 10;
- dep->satisfied_execs =
- REALLOC(dep->satisfied_execs,
- dep->satisfied_execs_size *
- sizeof(source_t *));
- }
- dep->satisfied_execs[dep->num_satisfied_execs++] = source;
-
- /* Add the library to the dependency list. */
- if (source->num_lib_deps == source->lib_deps_size) {
- source->lib_deps_size += 10;
- source->lib_deps = REALLOC(source->lib_deps,
- source->lib_deps_size *
- sizeof(source_t *));
- }
- source->lib_deps[source->num_lib_deps++] = dep;
- }
- } /* for each dynamic entry... */
- }
- } else INFO("[%s] has been processed already.\n", libname);
-
- return source;
-}
-
-void lsd(char **execs, int num_execs,
- int list_needed_libs,
- int print_info,
- char **lib_lookup_dirs, int num_lib_lookup_dirs) {
-
- source_t *source; /* for general usage */
- int input_idx;
-
- for (input_idx = 0; input_idx < num_execs; input_idx++) {
- INFO("executable: [%s]\n", execs[input_idx]);
- /* Here process library is actually processing the top-level executable
- files. */
- process_library(execs[input_idx], lib_lookup_dirs, num_lib_lookup_dirs);
- /* if source is NULL, then the respective executable is static */
- /* Mark the source as an executable */
- } /* for each input executable... */
-
- if (list_needed_libs) {
- source = sources;
- while (source) {
- print_needed_libs(source);
- source = source->next;
- }
- }
-
- /* Now, for each entry in the sources array, iterate its symbol table. For
- each undefined symbol, scan the list of dependencies till we find a
- global symbol in one of them that satisfies the undefined reference.
- At this point, we update both the satisfied[] array of the sources entry,
- as well as the exports array of the dependency where we found the match.
- */
-
- source = sources;
- while (source) {
- resolve(source);
- source = source->next;
- }
-
- /* We are done! Since the end result of our calculations is a set of
- symbols for each library that other libraries or executables link
- against, we iterate over the set of libraries one last time, and for
- each symbol that is marked as satisfying some dependence, we emit
- a line with the symbol's name to a text file derived from the library's
- name by appending the suffix .syms to it. */
-
- source = sources;
- while (source) {
- /* If it's a library, print the results. */
- if (source->elf_hdr.e_type == ET_DYN) {
- print_used_symbols(source);
- if (print_info)
- print_symbol_references(source);
- }
- source = source->next;
- }
-
- /* Free the resources--you can't do it in the loop above because function
- print_symbol_references() accesses nodes other than the one being
- iterated over.
- */
- source = sources;
- while (source) {
- source_t *old = source;
- source = source->next;
- /* Destroy the evidence. */
- destroy_source(old);
- }
-}
-
diff --git a/tools/lsd/lsd.h b/tools/lsd/lsd.h
deleted file mode 100644
index 883c423..0000000
--- a/tools/lsd/lsd.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef LSD_H
-#define LSD_H
-
-void lsd(char **execs, int num_execs,
- int list_needed_libs,
- int print_info,
- char **lib_lookup_dirs,
- int num_lib_lookup_dirs);
-
-#endif
diff --git a/tools/lsd/main.c b/tools/lsd/main.c
deleted file mode 100644
index f29157a..0000000
--- a/tools/lsd/main.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* TODO:
- 1. check the ARM EABI version--this works for versions 1 and 2.
- 2. use a more-intelligent approach to finding the symbol table, symbol-string
- table, and the .dynamic section.
- 3. fix the determination of the host and ELF-file endianness
- 4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <elf.h>
-#include <gelf.h>
-#include <cmdline.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <lsd.h>
-
-/* Flag set by --verbose. This variable is global as it is accessed by the
- macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet. This variable is global as it is accessed by the
- macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-
-int main(int argc, char **argv)
-{
- char **lookup_dirs = NULL;
- int num_lookup_dirs;
- int print_info;
- int list_needed_libs;
-
- /* Do not issue INFO() statements before you call get_options() to set
- the verbose flag as necessary.
- */
-
- int first = get_options(argc, argv,
- &list_needed_libs,
- &print_info,
- &lookup_dirs,
- &num_lookup_dirs,
- &verbose_flag);
-
- if (first == argc) {
- print_help();
- FAILIF(1, "You must specify at least one input ELF file!\n");
- }
-
- /* Check to see whether the ELF library is current. */
- FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
- /* List symbol dependencies... */
- lsd(&argv[first], argc - first,
- list_needed_libs, print_info,
- lookup_dirs, num_lookup_dirs);
-
- FREE(lookup_dirs);
-
- return 0;
-}
-
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
new file mode 100755
index 0000000..01f9128
--- /dev/null
+++ b/tools/post_process_props.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+
+# Put the modifications that you need to make into the /system/build.prop into this
+# function. The prop object has get(name) and put(name,value) methods.
+def mangle_build_prop(prop):
+ pass
+
+
+# Put the modifications that you need to make into the /system/build.prop into this
+# function. The prop object has get(name) and put(name,value) methods.
+def mangle_default_prop(prop):
+ # If ro.debuggable is 1, then enable adb on USB by default
+ # (this is for userdebug builds)
+ if prop.get("ro.debuggable") == "1":
+ val = prop.get("persist.sys.usb.config")
+ if val == "":
+ val = "adb"
+ else:
+ val = val + ",adb"
+ prop.put("persist.sys.usb.config", val)
+
+
+class PropFile:
+ def __init__(self, lines):
+ self.lines = [s[:-1] for s in lines]
+
+ def get(self, name):
+ key = name + "="
+ for line in self.lines:
+ if line.startswith(key):
+ return line[len(key):]
+ return ""
+
+ def put(self, name, value):
+ key = name + "="
+ for i in range(0,len(self.lines)):
+ if self.lines[i].startswith(key):
+ self.lines[i] = key + value
+ return
+ self.lines.append(key + value)
+
+ def write(self, f):
+ f.write("\n".join(self.lines))
+ f.write("\n")
+
+def main(argv):
+ filename = argv[1]
+ f = open(filename)
+ lines = f.readlines()
+ f.close()
+
+ properties = PropFile(lines)
+ if filename.endswith("/build.prop"):
+ mangle_build_prop(properties)
+ elif filename.endswith("/default.prop"):
+ mangle_default_prop(properties)
+ else:
+ sys.stderr.write("bad command line: " + str(argv) + "\n")
+ sys.exit(1)
+
+ f = open(filename, 'w+')
+ properties.write(f)
+ f.close()
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/tools/releasetools/check_target_files_signatures b/tools/releasetools/check_target_files_signatures
index 2c97e2e..4e83129 100755
--- a/tools/releasetools/check_target_files_signatures
+++ b/tools/releasetools/check_target_files_signatures
@@ -52,6 +52,11 @@
import tempfile
import zipfile
+try:
+ from hashlib import sha1 as sha1
+except ImportError:
+ from sha import sha as sha1
+
import common
# Work around a bug in python's zipfile module that prevents opening
@@ -182,7 +187,7 @@
class APK(object):
def __init__(self, full_filename, filename):
self.filename = filename
- self.cert = None
+ self.certs = set()
Push(filename+":")
try:
self.RecordCert(full_filename)
@@ -198,11 +203,10 @@
for info in apk.infolist():
if info.filename.startswith("META-INF/") and \
(info.filename.endswith(".DSA") or info.filename.endswith(".RSA")):
- if pkcs7 is not None:
- AddProblem("multiple certs")
pkcs7 = apk.read(info.filename)
- self.cert = CertFromPKCS7(pkcs7, info.filename)
- ALL_CERTS.Add(self.cert)
+ cert = CertFromPKCS7(pkcs7, info.filename)
+ self.certs.add(cert)
+ ALL_CERTS.Add(cert)
if not pkcs7:
AddProblem("no signature")
finally:
@@ -276,24 +280,19 @@
for uid in sorted(apks_by_uid.keys()):
apks = apks_by_uid[uid]
for apk in apks[1:]:
- if apk.cert != apks[0].cert:
+ if apk.certs != apks[0].certs:
break
else:
- # all the certs are the same; this uid is fine
+ # all packages have the same set of certs; this uid is fine.
continue
- AddProblem("uid %s shared across multiple certs" % (uid,))
+ AddProblem("different cert sets for packages with uid %s" % (uid,))
- print "uid %s is shared by packages with different certs:" % (uid,)
- x = [(i.cert, i.package, i) for i in apks]
- x.sort()
- lastcert = None
- for cert, _, apk in x:
- if cert != lastcert:
- lastcert = cert
- print " %s:" % (ALL_CERTS.Get(cert),)
- print " %-*s [%s]" % (self.max_pkg_len,
- apk.package, apk.filename)
+ print "uid %s is shared by packages with different cert sets:" % (uid,)
+ for apk in apks:
+ print "%-*s [%s]" % (self.max_pkg_len, apk.package, apk.filename)
+ for cert in apk.certs:
+ print " ", ALL_CERTS.Get(cert)
print
def CheckExternalSignatures(self):
@@ -314,7 +313,8 @@
"""Display a table of packages grouped by cert."""
by_cert = {}
for apk in self.apks.itervalues():
- by_cert.setdefault(apk.cert, []).append((apk.package, apk))
+ for cert in apk.certs:
+ by_cert.setdefault(cert, []).append((apk.package, apk))
order = [(-len(v), k) for (k, v) in by_cert.iteritems()]
order.sort()
@@ -347,10 +347,10 @@
for i in all:
if i in self.apks:
if i in other.apks:
- # in both; should have the same cert
- if self.apks[i].cert != other.apks[i].cert:
- by_certpair.setdefault((other.apks[i].cert,
- self.apks[i].cert), []).append(i)
+ # in both; should have at least one cert in common
+ if not (self.apks[i].cert & other.apks[i].cert):
+ by_certpair.setdefault((other.apks[i].certs,
+ self.apks[i].certs), []).append(i)
else:
print "%s [%s]: new APK (not in comparison target_files)" % (
i, self.apks[i].filename)
@@ -363,8 +363,16 @@
AddProblem("some APKs changed certs")
Banner("APK signing differences")
for (old, new), packages in sorted(by_certpair.items()):
- print "was", ALL_CERTS.Get(old)
- print "now", ALL_CERTS.Get(new)
+ for i, o in enumerate(old):
+ if i == 0:
+ print "was", ALL_CERTS.Get(o)
+ else:
+ print " ", ALL_CERTS.Get(o)
+ for i, n in enumerate(new):
+ if i == 0:
+ print "now", ALL_CERTS.Get(n)
+ else:
+ print " ", ALL_CERTS.Get(n)
for i in sorted(packages):
old_fn = other.apks[i].filename
new_fn = self.apks[i].filename
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index bcfacb2..2cb5680 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -29,11 +29,9 @@
import zipfile
try:
- import hashlib
- sha1 = hashlib.sha1
+ from hashlib import sha1 as sha1
except ImportError:
- import sha
- sha1 = sha.sha
+ from sha import sha as sha1
# missing in Python 2.4 and before
if not hasattr(os, "SEEK_SET"):
@@ -144,10 +142,6 @@
makeint("boot_size")
d["fstab"] = LoadRecoveryFSTab(zip)
- if not d["fstab"]:
- if "fs_type" not in d: d["fs_type"] = "yaffs2"
- if "partition_type" not in d: d["partition_type"] = "MTD"
-
return d
def LoadRecoveryFSTab(zip):
@@ -157,9 +151,7 @@
try:
data = zip.read("RECOVERY/RAMDISK/etc/recovery.fstab")
except KeyError:
- # older target-files that doesn't have a recovery.fstab; fall back
- # to the fs_type and partition_type keys.
- return
+ raise ValueError("Could not find RECOVERY/RAMDISK/etc/recovery.fstab")
d = {}
for line in data.split("\n"):
@@ -397,9 +389,6 @@
p = info_dict["fstab"][mount_point]
fs_type = p.fs_type
limit = info_dict.get(p.device + "_size", None)
- else:
- fs_type = info_dict.get("fs_type", None)
- limit = info_dict.get(target + "_size", None)
if not fs_type or not limit: return
if fs_type == "yaffs2":
@@ -830,9 +819,4 @@
if fstab:
return PARTITION_TYPES[fstab[mount_point].fs_type], fstab[mount_point].device
else:
- devices = {"/boot": "boot",
- "/recovery": "recovery",
- "/radio": "radio",
- "/data": "userdata",
- "/cache": "cache"}
- return info["partition_type"], info.get("partition_path", "") + devices[mount_point]
+ return None
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index c2b0056..d7b924b 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -140,13 +140,6 @@
(p.fs_type, common.PARTITION_TYPES[p.fs_type],
p.device, p.mount_point))
self.mounts.add(p.mount_point)
- else:
- what = mount_point.lstrip("/")
- what = self.info.get("partition_path", "") + what
- self.script.append('mount("%s", "%s", "%s", "%s");' %
- (self.info["fs_type"], self.info["partition_type"],
- what, mount_point))
- self.mounts.add(mount_point)
def UnpackPackageDir(self, src, dst):
"""Unpack a given directory from the OTA package into the given
@@ -175,12 +168,6 @@
self.script.append('format("%s", "%s", "%s", "%s");' %
(p.fs_type, common.PARTITION_TYPES[p.fs_type],
p.device, p.length))
- else:
- # older target-files without per-partition types
- partition = self.info.get("partition_path", "") + partition
- self.script.append('format("%s", "%s", "%s", "%s");' %
- (self.info["fs_type"], self.info["partition_type"],
- partition, reserve_size))
def DeleteFiles(self, file_list):
"""Delete all files in file_list."""
@@ -213,31 +200,13 @@
args = {'device': p.device, 'fn': fn}
if partition_type == "MTD":
self.script.append(
- ('assert(package_extract_file("%(fn)s", "/tmp/%(device)s.img"),\n'
- ' write_raw_image("/tmp/%(device)s.img", "%(device)s"),\n'
- ' delete("/tmp/%(device)s.img"));') % args)
+ 'write_raw_image(package_extract_file("%(fn)s"), "%(device)s");'
+ % args)
elif partition_type == "EMMC":
self.script.append(
'package_extract_file("%(fn)s", "%(device)s");' % args)
else:
raise ValueError("don't know how to write \"%s\" partitions" % (p.fs_type,))
- else:
- # backward compatibility with older target-files that lack recovery.fstab
- if self.info["partition_type"] == "MTD":
- self.script.append(
- ('assert(package_extract_file("%(fn)s", "/tmp/%(partition)s.img"),\n'
- ' write_raw_image("/tmp/%(partition)s.img", "%(partition)s"),\n'
- ' delete("/tmp/%(partition)s.img"));')
- % {'partition': partition, 'fn': fn})
- elif self.info["partition_type"] == "EMMC":
- self.script.append(
- ('package_extract_file("%(fn)s", "%(dir)s%(partition)s");')
- % {'partition': partition, 'fn': fn,
- 'dir': self.info.get("partition_path", ""),
- })
- else:
- raise ValueError("don't know how to write \"%s\" partitions" %
- (self.info["partition_type"],))
def SetPermissions(self, fn, uid, gid, mode):
"""Set file ownership and permissions."""
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 8f5c3fe..0a27a19 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -24,9 +24,14 @@
-b (--board_config) <file>
Deprecated.
- -k (--package_key) <key>
- Key to use to sign the package (default is
- "build/target/product/security/testkey").
+ -k (--package_key) <key> Key to use to sign the package (default is
+ the value of default_system_dev_certificate from the input
+ target-files's META/misc_info.txt, or
+ "build/target/product/security/testkey" if that value is not
+ specified).
+
+ For incremental OTAs, the default value is based on the source
+ target-file, not the target build.
-i (--incremental_from) <file>
Generate an incremental OTA using the given target-files zip as
@@ -63,11 +68,16 @@
import time
import zipfile
+try:
+ from hashlib import sha1 as sha1
+except ImportError:
+ from sha import sha as sha1
+
import common
import edify_generator
OPTIONS = common.OPTIONS
-OPTIONS.package_key = "build/target/product/security/testkey"
+OPTIONS.package_key = None
OPTIONS.incremental_source = None
OPTIONS.require_verbatim = set()
OPTIONS.prohibit_verbatim = set(("system/build.prop",))
@@ -608,7 +618,12 @@
so_far = 0
script.Print("Patching system files...")
- for fn, tf, sf, size, _ in patch_list:
+ deferred_patch_list = []
+ for item in patch_list:
+ fn, tf, sf, size, _ = item
+ if tf.name == "system/build.prop":
+ deferred_patch_list.append(item)
+ continue
script.ApplyPatch("/"+fn, "-", tf.size, tf.sha1, sf.sha1, "patch/"+fn+".p")
so_far += tf.size
script.SetProgress(so_far / total_patch_size)
@@ -710,6 +725,15 @@
if OPTIONS.extra_script is not None:
script.AppendExtra(OPTIONS.extra_script)
+ # Patch the build.prop file last, so if something fails but the
+ # device can still come up, it appears to be the old build and will
+ # get set the OTA package again to retry.
+ script.Print("Patching remaining system files...")
+ for item in deferred_patch_list:
+ fn, tf, sf, size, _ = item
+ script.ApplyPatch("/"+fn, "-", tf.size, tf.sha1, sf.sha1, "patch/"+fn+".p")
+ script.SetPermissions("/system/build.prop", 0, 0, 0644)
+
script.AddToZip(target_zip, output_zip)
WriteMetadata(metadata, output_zip)
@@ -775,30 +799,34 @@
OPTIONS.device_specific = os.path.normpath(OPTIONS.device_specific)
print "using device-specific extensions in", OPTIONS.device_specific
- if OPTIONS.package_key:
- temp_zip_file = tempfile.NamedTemporaryFile()
- output_zip = zipfile.ZipFile(temp_zip_file, "w",
- compression=zipfile.ZIP_DEFLATED)
- else:
- output_zip = zipfile.ZipFile(args[1], "w",
- compression=zipfile.ZIP_DEFLATED)
+ temp_zip_file = tempfile.NamedTemporaryFile()
+ output_zip = zipfile.ZipFile(temp_zip_file, "w",
+ compression=zipfile.ZIP_DEFLATED)
if OPTIONS.incremental_source is None:
WriteFullOTAPackage(input_zip, output_zip)
+ if OPTIONS.package_key is None:
+ OPTIONS.package_key = OPTIONS.info_dict.get(
+ "default_system_dev_certificate",
+ "build/target/product/security/testkey")
else:
print "unzipping source target-files..."
OPTIONS.source_tmp, source_zip = common.UnzipTemp(OPTIONS.incremental_source)
OPTIONS.target_info_dict = OPTIONS.info_dict
OPTIONS.source_info_dict = common.LoadInfoDict(source_zip)
+ if OPTIONS.package_key is None:
+ OPTIONS.package_key = OPTIONS.source_info_dict.get(
+ "default_system_dev_certificate",
+ "build/target/product/security/testkey")
if OPTIONS.verbose:
print "--- source info ---"
common.DumpInfoDict(OPTIONS.source_info_dict)
WriteIncrementalOTAPackage(input_zip, source_zip, output_zip)
output_zip.close()
- if OPTIONS.package_key:
- SignOutput(temp_zip_file.name, args[1])
- temp_zip_file.close()
+
+ SignOutput(temp_zip_file.name, args[1])
+ temp_zip_file.close()
common.Cleanup()
diff --git a/tools/releasetools/sign_target_files_apks b/tools/releasetools/sign_target_files_apks
index 5353063..eaad8a4 100755
--- a/tools/releasetools/sign_target_files_apks
+++ b/tools/releasetools/sign_target_files_apks
@@ -36,10 +36,16 @@
-d (--default_key_mappings) <dir>
Set up the following key mappings:
- build/target/product/security/testkey ==> $dir/releasekey
- build/target/product/security/media ==> $dir/media
- build/target/product/security/shared ==> $dir/shared
- build/target/product/security/platform ==> $dir/platform
+ $devkey/devkey ==> $dir/releasekey
+ $devkey/testkey ==> $dir/releasekey
+ $devkey/media ==> $dir/media
+ $devkey/shared ==> $dir/shared
+ $devkey/platform ==> $dir/platform
+
+ where $devkey is the directory part of the value of
+ default_system_dev_certificate from the input target-files's
+ META/misc_info.txt. (Defaulting to "build/target/product/security"
+ if the value is not present in misc_info.
-d and -k options are added to the set of mappings in the order
in which they appear on the command line.
@@ -55,7 +61,7 @@
the last component of the build fingerprint). Prefix each with
'+' or '-' to indicate whether that tag should be added or
removed. Changes are processed in the order they appear.
- Default value is "-test-keys,+release-keys".
+ Default value is "-test-keys,-dev-keys,+release-keys".
"""
@@ -80,7 +86,7 @@
OPTIONS.extra_apks = {}
OPTIONS.key_map = {}
OPTIONS.replace_ota_keys = False
-OPTIONS.tag_changes = ("-test-keys", "+release-keys")
+OPTIONS.tag_changes = ("-test-keys", "-dev-keys", "+release-keys")
def GetApkCerts(tf_zip):
certmap = common.ReadApkCerts(tf_zip)
@@ -198,14 +204,12 @@
return "\n".join(output) + "\n"
-def ReplaceOtaKeys(input_tf_zip, output_tf_zip):
+def ReplaceOtaKeys(input_tf_zip, output_tf_zip, misc_info):
try:
keylist = input_tf_zip.read("META/otakeys.txt").split()
except KeyError:
raise ExternalError("can't read META/otakeys.txt from input")
- misc_info = common.LoadInfoDict(input_tf_zip)
-
extra_recovery_keys = misc_info.get("extra_recovery_keys", None)
if extra_recovery_keys:
extra_recovery_keys = [OPTIONS.key_map.get(k, k) + ".x509.pem"
@@ -227,10 +231,10 @@
print "using:\n ", "\n ".join(mapped_keys)
print "for OTA package verification"
else:
+ devkey = misc_info.get("default_system_dev_certificate",
+ "build/target/product/security/testkey")
mapped_keys.append(
- OPTIONS.key_map.get("build/target/product/security/testkey",
- "build/target/product/security/testkey")
- + ".x509.pem")
+ OPTIONS.key_map.get(devkey, devkey) + ".x509.pem")
print "META/otakeys.txt has no keys; using", mapped_keys[0]
# recovery uses a version of the key that has been slightly
@@ -259,8 +263,28 @@
tempfile.getvalue())
+def BuildKeyMap(misc_info, key_mapping_options):
+ for s, d in key_mapping_options:
+ if s is None: # -d option
+ devkey = misc_info.get("default_system_dev_certificate",
+ "build/target/product/security/testkey")
+ devkeydir = os.path.dirname(devkey)
+
+ OPTIONS.key_map.update({
+ devkeydir + "/testkey": d + "/releasekey",
+ devkeydir + "/devkey": d + "/releasekey",
+ devkeydir + "/media": d + "/media",
+ devkeydir + "/shared": d + "/shared",
+ devkeydir + "/platform": d + "/platform",
+ })
+ else:
+ OPTIONS.key_map[s] = d
+
+
def main(argv):
+ key_mapping_options = []
+
def option_handler(o, a):
if o in ("-e", "--extra_apks"):
names, key = a.split("=")
@@ -268,15 +292,9 @@
for n in names:
OPTIONS.extra_apks[n] = key
elif o in ("-d", "--default_key_mappings"):
- OPTIONS.key_map.update({
- "build/target/product/security/testkey": "%s/releasekey" % (a,),
- "build/target/product/security/media": "%s/media" % (a,),
- "build/target/product/security/shared": "%s/shared" % (a,),
- "build/target/product/security/platform": "%s/platform" % (a,),
- })
+ key_mapping_options.append((None, a))
elif o in ("-k", "--key_mapping"):
- s, d = a.split("=")
- OPTIONS.key_map[s] = d
+ key_mapping_options.append(a.split("=", 1))
elif o in ("-o", "--replace_ota_keys"):
OPTIONS.replace_ota_keys = True
elif o in ("-t", "--tag_changes"):
@@ -307,6 +325,10 @@
input_zip = zipfile.ZipFile(args[0], "r")
output_zip = zipfile.ZipFile(args[1], "w")
+ misc_info = common.LoadInfoDict(input_zip)
+
+ BuildKeyMap(misc_info, key_mapping_options)
+
apk_key_map = GetApkCerts(input_zip)
CheckAllApksSigned(input_zip, apk_key_map)
@@ -314,7 +336,7 @@
SignApks(input_zip, output_zip, apk_key_map, key_passwords)
if OPTIONS.replace_ota_keys:
- ReplaceOtaKeys(input_zip, output_zip)
+ ReplaceOtaKeys(input_zip, output_zip, misc_info)
input_zip.close()
output_zip.close()
diff --git a/tools/soslim/Android.mk b/tools/soslim/Android.mk
deleted file mode 100644
index 60a860a..0000000
--- a/tools/soslim/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for soslim
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifeq ($(TARGET_ARCH),arm)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DBIG_ENDIAN=1
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DDEBUG
-LOCAL_CFLAGS += -DSTRIP_STATIC_SYMBOLS
-LOCAL_CFLAGS += -DMOVE_SECTIONS_IN_RANGES
-
-ifeq ($(HOST_OS),windows)
-# Cygwin stat does not support ACCESSPERMS bitmask
-LOCAL_CFLAGS += -DACCESSPERMS=0777
-LOCAL_LDLIBS += -lintl
-endif
-
-LOCAL_SRC_FILES := \
- cmdline.c \
- common.c \
- debug.c \
- soslim.c \
- main.c \
- prelink_info.c \
- symfilter.c
-
-LOCAL_C_INCLUDES:= \
- $(LOCAL_PATH)/ \
- external/elfutils/lib/ \
- external/elfutils/libelf/ \
- external/elfutils/libebl/ \
- external/elfcopy/
-
-LOCAL_STATIC_LIBRARIES := libelfcopy libelf libebl libebl_arm #dl
-
-LOCAL_MODULE := soslim
-
-include $(BUILD_HOST_EXECUTABLE)
-endif #TARGET_ARCH==arm
diff --git a/tools/soslim/cmdline.c b/tools/soslim/cmdline.c
deleted file mode 100644
index c2d5e71..0000000
--- a/tools/soslim/cmdline.c
+++ /dev/null
@@ -1,141 +0,0 @@
-#include <debug.h>
-#include <cmdline.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <ctype.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-static struct option long_options[] =
-{
- {"verbose", no_argument, 0, 'V'},
- {"quiet", no_argument, 0, 'Q'},
- {"shady", no_argument, 0, 'S'},
- {"print", no_argument, 0, 'p'},
- {"help", no_argument, 0, 'h'},
- {"outfile", required_argument, 0, 'o'},
- {"filter", required_argument, 0, 'f'},
- {"dry", no_argument, 0, 'n'},
- {"strip", no_argument, 0, 's'},
- {0, 0, 0, 0},
-};
-
-/* This array must parallel long_options[] */
-static
-const char *descriptions[sizeof(long_options)/sizeof(long_options[0])] = {
- "print verbose output",
- "suppress errors and warnings",
- "patch ABS symbols whose values coincide with section starts and ends",
- "print the symbol table (if specified, only -V is allowed)",
- "this help screen",
- "specify an output file (if not provided, input file is modified)",
- "specify a symbol-filter file",
- "dry run (perform all calculations but do not modify the ELF file)",
- "strip debug sections, if they are present"
-};
-
-void print_help(void)
-{
- fprintf(stdout,
- "invokation:\n"
- "\tsoslim file1 [file2 file3 ... fileN] [-Ldir1 -Ldir2 ... -LdirN] "
- "[-Vpn]\n"
- "or\n"
- "\tsoslim -h\n\n");
- fprintf(stdout, "options:\n");
- struct option *opt = long_options;
- const char **desc = descriptions;
- while (opt->name) {
- fprintf(stdout, "\t-%c/--%-15s %s\n",
- opt->val,
- opt->name,
- *desc);
- opt++;
- desc++;
- }
-}
-
-int get_options(int argc, char **argv,
- char **outfile,
- char **symsfile,
- int *print_symtab,
- int *verbose,
- int *quiet,
- int *shady,
- int *dry_run,
- int *strip_debug)
-{
- int c;
-
- ASSERT(outfile);
- *outfile = NULL;
- ASSERT(symsfile);
- *symsfile = NULL;
- ASSERT(print_symtab);
- *print_symtab = 0;
- ASSERT(verbose);
- *verbose = 0;
- ASSERT(quiet);
- *quiet = 0;
- ASSERT(shady);
- *shady = 0;
- ASSERT(dry_run);
- *dry_run = 0;
- ASSERT(strip_debug);
- *strip_debug = 0;
-
- while (1) {
- /* getopt_long stores the option index here. */
- int option_index = 0;
-
- c = getopt_long (argc, argv,
- "QVSphi:o:y:Y:f:ns",
- long_options,
- &option_index);
- /* Detect the end of the options. */
- if (c == -1) break;
-
- if (isgraph(c)) {
- INFO ("option -%c with value `%s'\n", c, (optarg ?: "(null)"));
- }
-
-#define SET_STRING_OPTION(name) do { \
- ASSERT(optarg); \
- *name = strdup(optarg); \
-} while(0)
-
- switch (c) {
- case 0:
- /* If this option set a flag, do nothing else now. */
- if (long_options[option_index].flag != 0)
- break;
- INFO ("option %s", long_options[option_index].name);
- if (optarg)
- INFO (" with arg %s", optarg);
- INFO ("\n");
- break;
- case 'p': *print_symtab = 1; break;
- case 'h': print_help(); exit(1); break;
- case 'V': *verbose = 1; break;
- case 'Q': *quiet = 1; break;
- case 'S': *shady = 1; break;
- case 'n': *dry_run = 1; break;
- case 's': *strip_debug = 1; break;
- case 'o': SET_STRING_OPTION(outfile); break;
- case 'f': SET_STRING_OPTION(symsfile); break;
- case '?':
- /* getopt_long already printed an error message. */
- break;
-
-#undef SET_STRING_OPTION
-
- default:
- FAILIF(1, "Unknown option");
- }
- }
-
- return optind;
-}
diff --git a/tools/soslim/cmdline.h b/tools/soslim/cmdline.h
deleted file mode 100644
index bfc431e..0000000
--- a/tools/soslim/cmdline.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-void print_help(void);
-
-int get_options(int argc, char **argv,
- char **outfile,
- char **symsfile,
- int *print_symtab,
- int *verbose,
- int *quiet,
- int *shady,
- int *dry_run,
- int *strip_debug);
-
-#endif/*CMDLINE_H*/
diff --git a/tools/soslim/common.c b/tools/soslim/common.c
deleted file mode 100644
index b90cf41..0000000
--- a/tools/soslim/common.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdlib.h>
-#include <common.h>
-#include <debug.h>
-
-void map_over_sections(Elf *elf,
- section_match_fn_t match,
- void *user_data)
-{
- Elf_Scn* section = NULL;
- while ((section = elf_nextscn(elf, section)) != NULL) {
- if (match(elf, section, user_data))
- return;
- }
-}
-
-void map_over_segments(Elf *elf,
- segment_match_fn_t match,
- void *user_data)
-{
- Elf32_Ehdr *ehdr;
- Elf32_Phdr *phdr;
- int index;
-
- ehdr = elf32_getehdr(elf);
- phdr = elf32_getphdr(elf);
-
- INFO("Scanning over %d program segments...\n",
- ehdr->e_phnum);
-
- for (index = ehdr->e_phnum; index; index--) {
- if (match(elf, phdr++, user_data))
- return;
- }
-}
-
diff --git a/tools/soslim/common.h b/tools/soslim/common.h
deleted file mode 100644
index dacf930..0000000
--- a/tools/soslim/common.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr) __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-typedef int (*section_match_fn_t)(Elf *, Elf_Scn *, void *);
-void map_over_sections(Elf *, section_match_fn_t, void *);
-
-typedef int (*segment_match_fn_t)(Elf *, Elf32_Phdr *, void *);
-void map_over_segments(Elf *, segment_match_fn_t, void *);
-
-typedef struct {
- Elf_Scn *sect;
- Elf32_Shdr *hdr;
- Elf_Data *data;
- size_t index;
-} section_info_t;
-
-static inline void get_section_info(Elf_Scn *sect, section_info_t *info)
-{
- info->sect = sect;
- info->data = elf_getdata(sect, 0);
- info->hdr = elf32_getshdr(sect);
- info->index = elf_ndxscn(sect);
-}
-
-static inline int is_host_little(void)
-{
- short val = 0x10;
- return ((char *)&val)[0] != 0;
-}
-
-static inline long switch_endianness(long val)
-{
- long newval;
- ((char *)&newval)[3] = ((char *)&val)[0];
- ((char *)&newval)[2] = ((char *)&val)[1];
- ((char *)&newval)[1] = ((char *)&val)[2];
- ((char *)&newval)[0] = ((char *)&val)[3];
- return newval;
-}
-
-#endif/*COMMON_H*/
diff --git a/tools/soslim/debug.c b/tools/soslim/debug.c
deleted file mode 100644
index b8365af..0000000
--- a/tools/soslim/debug.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#if 0
-
-#define NUM_COLS (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize) {
- int num_nonprintable = 0;
- int i, last;
- char *pchr = (char *)b;
- fputc('\n', s);
- for (i = last = 0; i < len; i++) {
- if (!elsize) {
- if (i && !(i % 4)) fprintf(s, " ");
- if (i && !(i % 8)) fprintf(s, " ");
- } else {
- if (i && !(i % elsize)) fprintf(s, " ");
- }
-
- if (i && !(i % NUM_COLS)) {
- while (last < i) {
- if (isprint(pchr[last]))
- fputc(pchr[last], s);
- else {
- fputc('.', s);
- num_nonprintable++;
- }
- last++;
- }
- fprintf(s, " (%d)\n", i);
- }
- fprintf(s, "%02x", (unsigned char)pchr[i]);
- }
- if (i && (i % NUM_COLS)) fputs("\n", s);
- return num_nonprintable;
-}
-
-#endif
diff --git a/tools/soslim/debug.h b/tools/soslim/debug.h
deleted file mode 100644
index e7a2f9a..0000000
--- a/tools/soslim/debug.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* Debug enabled */
- #define ASSERT(x) do { \
- if (unlikely(!(x))) { \
- fprintf(stderr, \
- "ASSERTION FAILURE %s:%d: [%s]\n", \
- __FILE__, __LINE__, #x); \
- exit(1); \
- } \
-} while(0)
-
-#else
-
- #define FAILIF(cond, msg...) do { \
- if (unlikely(cond)) { \
- fprintf(stderr, ##msg); \
- exit(1); \
- } \
-} while(0)
-
-/* No debug */
- #define ASSERT(x) do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
- FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
- void *m = malloc(size);
- FAILIF(NULL == m, "malloc(%d) failed!\n", size);
- return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
- void *m = calloc(num_entries, entry_size);
- FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
- return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
- void *m = realloc(ptr, size);
- FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
- return m;
-}
-
-static inline void FREE(void *ptr) {
- free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
- if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...) do { \
- extern int quiet_flag; \
- if(likely(!quiet_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-#define ERROR(x...) fprintf(stderr, ##x)
-
-#define INFO(x...) do { \
- extern int verbose_flag; \
- if(unlikely(verbose_flag)) \
- fprintf(stdout, ##x); \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/soslim/main.c b/tools/soslim/main.c
deleted file mode 100644
index df48484..0000000
--- a/tools/soslim/main.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/* TODO:
- 1. check the ARM EABI version--this works for versions 1 and 2.
- 2. use a more-intelligent approach to finding the symbol table, symbol-string
- table, and the .dynamic section.
- 3. fix the determination of the host and ELF-file endianness
- 4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <hash.h>
-#include <libelf.h>
-#include <elf.h>
-#include <gelf.h>
-#include <cmdline.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <soslim.h>
-#include <symfilter.h>
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-#include <prelink_info.h>
-#endif
-
-/* Flag set by --verbose. This variable is global as it is accessed by the
- macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet. This variable is global as it is accessed by the
- macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-static void print_dynamic_symbols(Elf *elf, const char *symtab_name);
-
-int main(int argc, char **argv)
-{
- int elf_fd = -1, newelf_fd = -1;
- Elf *elf = NULL, *newelf = NULL;
- char *infile = NULL;
- char *outfile = NULL;
- char *symsfile_name = NULL;
- int print_symtab = 0;
- int shady = 0;
- int dry_run = 0;
- int strip_debug = 0;
-
- /* Do not issue INFO() statements before you call get_options() to set
- the verbose flag as necessary.
- */
-
- int first = get_options(argc, argv,
- &outfile,
- &symsfile_name,
- &print_symtab,
- &verbose_flag,
- &quiet_flag,
- &shady,
- &dry_run,
- &strip_debug);
-
- if ((print_symtab && (first == argc)) ||
- (!print_symtab && first + 1 != argc)) {
- print_help();
- FAILIF(1, "You must specify an input ELF file!\n");
- }
- FAILIF(print_symtab && (outfile || symsfile_name || shady),
- "You cannot provide --print and --outfile, --filter options, or "
- "--shady simultaneously!\n");
- FAILIF(dry_run && outfile,
- "You cannot have a dry run and output a file at the same time.");
-
- /* Check to see whether the ELF library is current. */
- FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
- if (print_symtab) {
-
- while (first < argc) {
- infile = argv[first++];
-
- INFO("Opening %s...\n", infile);
- elf_fd = open(infile, O_RDONLY);
- FAILIF(elf_fd < 0, "open(%s): %s (%d)\n",
- infile,
- strerror(errno),
- errno);
- INFO("Calling elf_begin(%s)...\n", infile);
- elf = elf_begin(elf_fd, ELF_C_READ, NULL);
- FAILIF_LIBELF(elf == NULL, elf_begin);
-
- /* libelf can recognize COFF and A.OUT formats, but we handle only
- ELF. */
- FAILIF(elf_kind(elf) != ELF_K_ELF,
- "Input file %s is not in ELF format!\n",
- infile);
-
- /* Make sure this is a shared library or an executable. */
- {
- GElf_Ehdr elf_hdr;
- INFO("Making sure %s is a shared library or an executable.\n",
- infile);
- FAILIF_LIBELF(0 == gelf_getehdr(elf, &elf_hdr), gelf_getehdr);
- FAILIF(elf_hdr.e_type != ET_DYN &&
- elf_hdr.e_type != ET_EXEC,
- "%s must be a shared library or an executable "
- "(elf type is %d).\n",
- infile,
- elf_hdr.e_type);
- }
-
- print_dynamic_symbols(elf, infile);
-
- FAILIF_LIBELF(elf_end(elf), elf_end);
- FAILIF(close(elf_fd) < 0, "Could not close file %s: %s (%d)!\n",
- infile, strerror(errno), errno);
- }
- }
- else {
- int elf_fd = -1;
- Elf *elf = NULL;
- infile = argv[first];
-
- INFO("Opening %s...\n", infile);
- elf_fd = open(infile, ((outfile == NULL && dry_run == 0) ? O_RDWR : O_RDONLY));
- FAILIF(elf_fd < 0, "open(%s): %s (%d)\n",
- infile,
- strerror(errno),
- errno);
- INFO("Calling elf_begin(%s)...\n", infile);
- elf = elf_begin(elf_fd,
- ((outfile == NULL && dry_run == 0) ? ELF_C_RDWR : ELF_C_READ),
- NULL);
- FAILIF_LIBELF(elf == NULL, elf_begin);
-
- /* libelf can recognize COFF and A.OUT formats, but we handle only ELF. */
- FAILIF(elf_kind(elf) != ELF_K_ELF,
- "Input file %s is not in ELF format!\n",
- infile);
-
- /* We run a better check in adjust_elf() itself. It is permissible to call adjust_elf()
- on an executable if we are only stripping sections from the executable, not rearranging
- or moving sections.
- */
- if (0) {
- /* Make sure this is a shared library. */
- GElf_Ehdr elf_hdr;
- INFO("Making sure %s is a shared library...\n", infile);
- FAILIF_LIBELF(0 == gelf_getehdr(elf, &elf_hdr), gelf_getehdr);
- FAILIF(elf_hdr.e_type != ET_DYN,
- "%s must be a shared library (elf type is %d, expecting %d).\n",
- infile,
- elf_hdr.e_type,
- ET_DYN);
- }
-
- if (outfile != NULL) {
- ASSERT(!dry_run);
- struct stat st;
- FAILIF(fstat (elf_fd, &st) != 0,
- "Cannot stat input file %s: %s (%d)!\n",
- infile, strerror(errno), errno);
- newelf_fd = open (outfile, O_RDWR | O_CREAT | O_TRUNC,
- st.st_mode & ACCESSPERMS);
- FAILIF(newelf_fd < 0, "Cannot create file %s: %s (%d)!\n",
- outfile, strerror(errno), errno);
- INFO("Output file is [%s].\n", outfile);
- newelf = elf_begin(newelf_fd, ELF_C_WRITE_MMAP, NULL);
- } else {
- INFO("Modifying [%s] in-place.\n", infile);
- newelf = elf_clone(elf, ELF_C_EMPTY);
- }
-
- symfilter_t symfilter;
-
- symfilter.symbols_to_keep = NULL;
- symfilter.num_symbols_to_keep = 0;
- if (symsfile_name) {
- /* Make sure that the file is not empty. */
- struct stat s;
- FAILIF(stat(symsfile_name, &s) < 0,
- "Cannot stat file %s.\n", symsfile_name);
- if (s.st_size) {
- INFO("Building symbol filter.\n");
- build_symfilter(symsfile_name, elf, &symfilter, s.st_size);
- }
- else INFO("Not building symbol filter, filter file is empty.\n");
- }
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- int prelinked = 0, retouched = 0;
- int elf_little; /* valid if prelinked != 0 */
- long prelink_addr; /* valid if prelinked != 0 */
-#define RETOUCH_MAX_SIZE 600000
- /* _cnt valid if retouched != 0 */
- unsigned int retouch_byte_cnt = RETOUCH_MAX_SIZE;
- char retouch_buf[RETOUCH_MAX_SIZE]; /* valid if retouched != 0 */
-#endif
- clone_elf(elf, newelf,
- infile, outfile,
- symfilter.symbols_to_keep,
- symfilter.num_symbols_to_keep,
- shady
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- , &prelinked,
- &elf_little,
- &prelink_addr,
- &retouched,
- &retouch_byte_cnt,
- retouch_buf
-#endif
- ,
- true, /* rebuild the section-header-strings table */
- strip_debug,
- dry_run);
-
- if (symsfile_name && symfilter.symbols_to_keep != NULL) {
- destroy_symfilter(&symfilter);
- }
-
- if (outfile != NULL) INFO("Closing %s...\n", outfile);
- FAILIF_LIBELF(elf_end (newelf) != 0, elf_end);
- FAILIF(newelf_fd >= 0 && close(newelf_fd) < 0,
- "Could not close file %s: %s (%d)!\n",
- outfile, strerror(errno), errno);
-
- INFO("Closing %s...\n", infile);
- FAILIF_LIBELF(elf_end(elf), elf_end);
- FAILIF(close(elf_fd) < 0, "Could not close file %s: %s (%d)!\n",
- infile, strerror(errno), errno);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- if (retouched) {
- INFO("File has retouch data, putting it back in place.\n");
- retouch_dump(outfile != NULL ? outfile : infile,
- elf_little,
- retouch_byte_cnt,
- retouch_buf);
- }
- if (prelinked) {
- INFO("File is prelinked, putting prelink TAG back in place.\n");
- setup_prelink_info(outfile != NULL ? outfile : infile,
- elf_little,
- prelink_addr);
- }
-#endif
- }
-
- FREEIF(outfile);
- return 0;
-}
-
-static void print_dynamic_symbols(Elf *elf, const char *file)
-{
- Elf_Scn *scn = NULL;
- GElf_Shdr shdr;
-
- GElf_Ehdr ehdr;
- FAILIF_LIBELF(0 == gelf_getehdr(elf, &ehdr), gelf_getehdr);
- while ((scn = elf_nextscn (elf, scn)) != NULL) {
- FAILIF_LIBELF(NULL == gelf_getshdr(scn, &shdr), gelf_getshdr);
- if (SHT_DYNSYM == shdr.sh_type) {
- /* This failure is too restrictive. There is no reason why
- the symbol table couldn't be called something else, but
- there is a standard name, and chances are that if we don't
- see it, there's something wrong.
- */
- size_t shstrndx;
- FAILIF_LIBELF(elf_getshstrndx(elf, &shstrndx) < 0,
- elf_getshstrndx);
- /* Now print the symbols. */
- {
- Elf_Data *symdata;
- size_t elsize;
- symdata = elf_getdata (scn, NULL); /* get the symbol data */
- FAILIF_LIBELF(NULL == symdata, elf_getdata);
- /* Get the number of section. We need to compare agains this
- value for symbols that have special info in their section
- references */
- size_t shnum;
- FAILIF_LIBELF(elf_getshnum (elf, &shnum) < 0, elf_getshnum);
- /* Retrieve the size of a symbol entry */
- elsize = gelf_fsize(elf, ELF_T_SYM, 1, ehdr.e_version);
-
- size_t index;
- for (index = 0; index < symdata->d_size / elsize; index++) {
- GElf_Sym sym_mem;
- GElf_Sym *sym;
- /* Get the symbol. */
- sym = gelf_getsymshndx (symdata, NULL,
- index, &sym_mem, NULL);
- FAILIF_LIBELF(sym == NULL, gelf_getsymshndx);
- /* Print the symbol. */
- char bind = '?';
- switch(ELF32_ST_BIND(sym->st_info))
- {
- case STB_LOCAL: bind = 'l'; break;
- case STB_GLOBAL: bind = 'g'; break;
- case STB_WEAK: bind = 'w'; break;
- default: break;
- }
- char type = '?';
- switch(ELF32_ST_TYPE(sym->st_info))
- {
- case STT_NOTYPE: /* Symbol type is unspecified */
- type = '?';
- break;
- case STT_OBJECT: /* Symbol is a data object */
- type = 'o';
- break;
- case STT_FUNC: /* Symbol is a code object */
- type = 'f';
- break;
- case STT_SECTION:/* Symbol associated with a section */
- type = 's';
- break;
- case STT_FILE: /* Symbol's name is file name */
- type = 'f';
- break;
- case STT_COMMON: /* Symbol is a common data object */
- type = 'c';
- break;
- case STT_TLS: /* Symbol is thread-local data object*/
- type = 't';
- break;
- }
- {
- int till_lineno;
- int lineno;
- const char *section_name = "(unknown)";
- FAILIF(sym->st_shndx == SHN_XINDEX,
- "Can't handle symbol's st_shndx == SHN_XINDEX!\n");
- if (sym->st_shndx != SHN_UNDEF &&
- sym->st_shndx < shnum) {
- Elf_Scn *symscn = elf_getscn(elf, sym->st_shndx);
- FAILIF_LIBELF(NULL == symscn, elf_getscn);
- GElf_Shdr symscn_shdr;
- FAILIF_LIBELF(NULL == gelf_getshdr(symscn,
- &symscn_shdr),
- gelf_getshdr);
- section_name = elf_strptr(elf, shstrndx,
- symscn_shdr.sh_name);
- }
- else if (sym->st_shndx == SHN_ABS) {
- section_name = "SHN_ABS";
- }
- else if (sym->st_shndx == SHN_COMMON) {
- section_name = "SHN_COMMON";
- }
- else if (sym->st_shndx == SHN_UNDEF) {
- section_name = "(undefined)";
- }
- /* value size binding type section symname */
- PRINT("%-15s %8zd: %08llx %08llx %c%c %5d %n%s%n",
- file,
- index,
- sym->st_value, sym->st_size, bind, type,
- sym->st_shndx,
- &till_lineno,
- section_name,
- &lineno);
- lineno -= till_lineno;
- /* Create padding for section names of 15 chars.
- This limit is somewhat arbitratry. */
- while (lineno++ < 15) PRINT(" ");
- PRINT("(%d) %s\n",
- sym->st_name,
- elf_strptr(elf, shdr.sh_link, sym->st_name));
- }
- }
- }
- } /* if (shdr.sh_type = SHT_DYNSYM) */
- } /* while ((scn = elf_nextscn (elf, scn)) != NULL) */
-}
diff --git a/tools/soslim/prelink_info.c b/tools/soslim/prelink_info.c
deleted file mode 100644
index 2600ac7..0000000
--- a/tools/soslim/prelink_info.c
+++ /dev/null
@@ -1,204 +0,0 @@
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <prelink_info.h>
-#include <debug.h>
-#include <common.h>
-
-#define RETOUCH_SUFFIX_SIZE 12
-typedef struct {
- uint32_t mmap_addr;
- char tag[4]; /* 'P', 'R', 'E', ' ' */
-} __attribute__((packed)) prelink_info_t;
-
-static inline void set_prelink(long *prelink_addr,
- int elf_little,
- prelink_info_t *info)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
- if (prelink_addr) {
- if (!(elf_little ^ is_host_little())) {
- /* Same endianness */
- *prelink_addr = info->mmap_addr;
- }
- else {
- /* Different endianness */
- *prelink_addr = switch_endianness(info->mmap_addr);
- }
- }
-}
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
- int fd = open(fname, O_RDONLY);
- FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
- fname, strerror(errno), errno);
- off_t end = lseek(fd, 0, SEEK_END);
-#ifndef DEBUG
- (void)end;
-#endif
-
- int nr = sizeof(prelink_info_t);
-
- off_t sz = lseek(fd, -nr, SEEK_CUR);
- ASSERT((long)(end - sz) == (long)nr);
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- prelink_info_t info;
- ssize_t num_read = read(fd, &info, nr);
- FAILIF(num_read < 0,
- "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
- fd, strerror(errno), errno);
- FAILIF((size_t)num_read != sizeof(info),
- "read(%d, &info, sizeof(prelink_info_t)): did not read %zd bytes as "
- "expected (read %zd)!\n",
- fd, sizeof(info), (size_t)num_read);
-
- int prelinked = 0;
- if (!strncmp(info.tag, "PRE ", 4)) {
- set_prelink(prelink_addr, elf_little, &info);
- prelinked = 1;
- }
- FAILIF(close(fd) < 0,
- "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
- return prelinked;
-}
-
-int check_retouched(const char *fname, int elf_little,
- unsigned int *retouch_byte_cnt, char *retouch_buf) {
- FAILIF(sizeof(prelink_info_t) != 8,
- "Unexpected sizeof(prelink_info_t) == %d!\n",
- sizeof(prelink_info_t));
- int fd = open(fname, O_RDONLY);
- FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
- fname, strerror(errno), errno);
- off_t end = lseek(fd, 0, SEEK_END);
- int nr = sizeof(prelink_info_t);
- off_t sz = lseek(fd, -nr-RETOUCH_SUFFIX_SIZE, SEEK_CUR);
- ASSERT((long)(end - sz) == (long)(nr+RETOUCH_SUFFIX_SIZE));
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- char retouch_meta[RETOUCH_SUFFIX_SIZE];
- int num_read = read(fd, &retouch_meta, RETOUCH_SUFFIX_SIZE);
- FAILIF(num_read < 0,
- "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
- fd, strerror(errno), errno);
- FAILIF(num_read != RETOUCH_SUFFIX_SIZE,
- "read(%d, &info, sizeof(prelink_info_t)): did not read %d bytes as "
- "expected (read %d)!\n",
- fd, RETOUCH_SUFFIX_SIZE, num_read);
-
- int retouched = 0;
- if (!strncmp(retouch_meta, "RETOUCH ", 8)) {
- unsigned int retouch_byte_cnt_meta;
- if (!(elf_little ^ is_host_little()))
- retouch_byte_cnt_meta = *(unsigned int *)(retouch_meta+8);
- else
- retouch_byte_cnt_meta =
- switch_endianness(*(unsigned int *)(retouch_meta+8));
- FAILIF(*retouch_byte_cnt < retouch_byte_cnt_meta,
- "Retouch buffer too small at %d bytes (%d needed).",
- *retouch_byte_cnt, retouch_byte_cnt_meta);
- *retouch_byte_cnt = retouch_byte_cnt_meta;
- off_t sz = lseek(fd,
- -((long)*retouch_byte_cnt)-RETOUCH_SUFFIX_SIZE-nr,
- SEEK_END);
- ASSERT((long)(end - sz) ==
- (long)(*retouch_byte_cnt+RETOUCH_SUFFIX_SIZE+nr));
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
- num_read = read(fd, retouch_buf, *retouch_byte_cnt);
- FAILIF(num_read < 0,
- "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
- fd, strerror(errno), errno);
- FAILIF(num_read != *retouch_byte_cnt,
- "read(%d, retouch_buf, %u): did not read %d bytes as "
- "expected (read %d)!\n",
- fd, *retouch_byte_cnt, *retouch_byte_cnt, num_read);
-
- retouched = 1;
- }
- FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
- return retouched;
-}
-
-void retouch_dump(const char *fname, int elf_little,
- unsigned int retouch_byte_cnt, char *retouch_buf) {
- int fd = open(fname, O_WRONLY);
- FAILIF(fd < 0,
- "open(%s, O_WRONLY): %s (%d)\n",
- fname, strerror(errno), errno);
- off_t sz = lseek(fd, 0, SEEK_END);
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- // The retouch blob ends with "RETOUCH XXXX", where XXXX is the 4-byte
- // size of the retouch blob, in target endianness.
- strncpy(retouch_buf+retouch_byte_cnt, "RETOUCH ", 8);
- if (elf_little ^ is_host_little()) {
- *(unsigned int *)(retouch_buf+retouch_byte_cnt+8) =
- switch_endianness(retouch_byte_cnt);
- } else {
- *(unsigned int *)(retouch_buf+retouch_byte_cnt+8) =
- retouch_byte_cnt;
- }
-
- int num_written = write(fd, retouch_buf, retouch_byte_cnt+12);
- FAILIF(num_written < 0,
- "write(%d, &info, sizeof(info)): %s (%d)\n",
- fd, strerror(errno), errno);
- FAILIF((retouch_byte_cnt+12) != num_written,
- "Could not write %d bytes as expected (wrote %d bytes instead)!\n",
- retouch_byte_cnt, num_written);
- FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-}
-
-void setup_prelink_info(const char *fname, int elf_little, long base)
-{
- FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
- int fd = open(fname, O_WRONLY);
- FAILIF(fd < 0,
- "open(%s, O_WRONLY): %s (%d)\n" ,
- fname, strerror(errno), errno);
- prelink_info_t info;
- off_t sz = lseek(fd, 0, SEEK_END);
- FAILIF(sz == (off_t)-1,
- "lseek(%d, 0, SEEK_END): %s (%d)!\n",
- fd, strerror(errno), errno);
-
- if (!(elf_little ^ is_host_little())) {
- /* Same endianness */
- INFO("Host and ELF file [%s] have same endianness.\n", fname);
- info.mmap_addr = base;
- }
- else {
- /* Different endianness */
- INFO("Host and ELF file [%s] have different endianness.\n", fname);
- info.mmap_addr = switch_endianness(base);
- }
- strncpy(info.tag, "PRE ", 4);
-
- ssize_t num_written = write(fd, &info, sizeof(info));
- FAILIF(num_written < 0,
- "write(%d, &info, sizeof(info)): %s (%d)\n",
- fd, strerror(errno), errno);
- FAILIF(sizeof(info) != (size_t)num_written,
- "Could not write %zd bytes (wrote only %zd bytes) as expected!\n",
- sizeof(info), (size_t)num_written);
- FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-}
-
-#endif /*SUPPORT_ANDROID_PRELINK_TAGS*/
diff --git a/tools/soslim/prelink_info.h b/tools/soslim/prelink_info.h
deleted file mode 100644
index efa84fd..0000000
--- a/tools/soslim/prelink_info.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef PRELINK_INFO_H
-#define PRELINK_INFO_H
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr);
-int check_retouched(const char *fname, int elf_little,
- unsigned int *retouch_byte_cnt, char *retouch_buf);
-void retouch_dump(const char *fname, int elf_little,
- unsigned int retouch_byte_cnt, char *retouch_buf);
-void setup_prelink_info(const char *fname, int elf_little, long base);
-
-#endif
-#endif/*PRELINK_INFO_H*/
diff --git a/tools/soslim/soslim.c b/tools/soslim/soslim.c
deleted file mode 100644
index 33b1ee7..0000000
--- a/tools/soslim/soslim.c
+++ /dev/null
@@ -1,536 +0,0 @@
-#include <stdio.h>
-//#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#include <libebl_arm.h>
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-#include <prelink_info.h>
-#endif
-
-#include <elfcopy.h>
-
-void clone_elf(Elf *elf, Elf *newelf,
- const char *elf_name,
- const char *newelf_name,
- bool *sym_filter, int num_symbols,
- int shady
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- , int *prelinked,
- int *elf_little,
- long *prelink_addr,
- int *retouched,
- unsigned int *retouch_byte_cnt,
- char *retouch_buf
-#endif
- , bool rebuild_shstrtab,
- bool strip_debug,
- bool dry_run)
-{
- GElf_Ehdr ehdr_mem, *ehdr; /* store ELF header of original library */
- size_t shstrndx; /* section-strings-section index */
- size_t shnum; /* number of sections in the original file */
- /* string table for section headers in new file */
- struct Ebl_Strtab *shst = NULL;
- int dynamic_idx = -1; /* index in shdr_info[] of .dynamic section */
- int dynsym_idx = -1; /* index in shdr_info[] of dynamic symbol table
- section */
-
- unsigned int cnt; /* general-purpose counter */
- /* This flag is true when at least one section is dropped or when the
- relative order of sections has changed, so that section indices in
- the resulting file will be different from those in the original. */
- bool sections_dropped_or_rearranged;
- Elf_Scn *scn; /* general-purpose section */
- size_t idx; /* general-purporse section index */
-
- shdr_info_t *shdr_info = NULL;
- unsigned int shdr_info_len = 0;
- GElf_Phdr *phdr_info = NULL;
-
- /* Get the information from the old file. */
- ehdr = gelf_getehdr (elf, &ehdr_mem);
- FAILIF_LIBELF(NULL == ehdr, gelf_getehdr);
-
- /* Create new program header for the elf file */
- FAILIF(gelf_newehdr (newelf, gelf_getclass (elf)) == 0 ||
- (ehdr->e_type != ET_REL && gelf_newphdr (newelf,
- ehdr->e_phnum) == 0),
- "Cannot create new file: %s", elf_errmsg (-1));
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- ASSERT(prelinked);
- ASSERT(prelink_addr);
- ASSERT(elf_little);
- *elf_little = (ehdr->e_ident[EI_DATA] == ELFDATA2LSB);
- *prelinked = check_prelinked(elf_name, *elf_little, prelink_addr);
- ASSERT(retouched);
- ASSERT(retouch_byte_cnt);
- ASSERT(retouch_buf);
- *retouched = check_retouched(elf_name, *elf_little,
- retouch_byte_cnt, retouch_buf);
-#endif
-
- INFO("\n\nCALCULATING MODIFICATIONS\n\n");
-
- /* Copy out the old program header: notice that if the ELF file does not
- have a program header, this loop won't execute.
- */
- INFO("Copying ELF program header...\n");
- phdr_info = (GElf_Phdr *)CALLOC(ehdr->e_phnum, sizeof(GElf_Phdr));
- for (cnt = 0; cnt < ehdr->e_phnum; ++cnt) {
- INFO("\tRetrieving entry %d\n", cnt);
- FAILIF_LIBELF(NULL == gelf_getphdr(elf, cnt, phdr_info + cnt),
- gelf_getphdr);
- /* -- we update the header at the end
- FAILIF_LIBELF(gelf_update_phdr (newelf, cnt, phdr_info + cnt) == 0,
- gelf_update_phdr);
- */
- }
-
- /* Get the section-header strings section. This section contains the
- strings used to name the other sections. */
- FAILIF_LIBELF(elf_getshstrndx(elf, &shstrndx) < 0, elf_getshstrndx);
-
- /* Get the number of sections. */
- FAILIF_LIBELF(elf_getshnum (elf, &shnum) < 0, elf_getshnum);
- INFO("Original ELF file has %zd sections.\n", shnum);
-
- /* Allocate the section-header-info buffer. We allocate one more entry
- for the section-strings section because we regenerate that one and
- place it at the very end of the file. Note that just because we create
- an extra entry in the shdr_info array, it does not mean that we create
- one more section the header. We just mark the old section for removal
- and create one as the last section.
- */
- INFO("Allocating section-header info structure (%zd) bytes...\n",
- shnum*sizeof (shdr_info_t));
- shdr_info_len = rebuild_shstrtab ? shnum + 1 : shnum;
- shdr_info = (shdr_info_t *)CALLOC(shdr_info_len, sizeof (shdr_info_t));
-
- /* Iterate over all the sections and initialize the internal section-info
- array...
- */
- INFO("Initializing section-header info structure...\n");
- /* Gather information about the sections in this file. */
- scn = NULL;
- cnt = 1;
- while ((scn = elf_nextscn (elf, scn)) != NULL) {
- ASSERT(elf_ndxscn(scn) == cnt);
- shdr_info[cnt].scn = scn;
- FAILIF_LIBELF(NULL == gelf_getshdr(scn, &shdr_info[cnt].shdr),
- gelf_getshdr);
-
- /* Get the name of the section. */
- shdr_info[cnt].name = elf_strptr (elf, shstrndx,
- shdr_info[cnt].shdr.sh_name);
-
- INFO("\tname: %s\n", shdr_info[cnt].name);
- FAILIF(shdr_info[cnt].name == NULL,
- "Malformed file: section %d name is null\n",
- cnt);
-
- /* Mark them as present but not yet investigated. By "investigating"
- sections, we mean that we check to see if by stripping other
- sections, the sections under investigation will be compromised. For
- example, if we are removing a section of code, then we want to make
- sure that the symbol table does not contain symbols that refer to
- this code, so we investigate the symbol table. If we do find such
- symbols, we will not strip the code section.
- */
- shdr_info[cnt].idx = 1;
-
- /* Remember the shdr.sh_link value. We need to remember this value
- for those sections that refer to other sections. For example,
- we need to remember it for relocation-entry sections, because if
- we modify the symbol table that a relocation-entry section is
- relative to, then we need to patch the relocation section. By the
- time we get to deciding whether we need to patch the relocation
- section, we will have overwritten its header's sh_link field with
- a new value.
- */
- shdr_info[cnt].old_shdr = shdr_info[cnt].shdr;
- INFO("\t\toriginal sh_link: %08d\n", shdr_info[cnt].old_shdr.sh_link);
- INFO("\t\toriginal sh_addr: %lld\n", shdr_info[cnt].old_shdr.sh_addr);
- INFO("\t\toriginal sh_offset: %lld\n",
- shdr_info[cnt].old_shdr.sh_offset);
- INFO("\t\toriginal sh_size: %lld\n", shdr_info[cnt].old_shdr.sh_size);
-
- if (shdr_info[cnt].shdr.sh_type == SHT_DYNAMIC) {
- INFO("\t\tthis is the SHT_DYNAMIC section [%s] at index %d\n",
- shdr_info[cnt].name,
- cnt);
- dynamic_idx = cnt;
- }
- else if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM) {
- INFO("\t\tthis is the SHT_DYNSYM section [%s] at index %d\n",
- shdr_info[cnt].name,
- cnt);
- dynsym_idx = cnt;
- }
-
- FAILIF(shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX,
- "Cannot handle sh_type SHT_SYMTAB_SHNDX!\n");
- FAILIF(shdr_info[cnt].shdr.sh_type == SHT_GROUP,
- "Cannot handle sh_type SHT_GROUP!\n");
- FAILIF(shdr_info[cnt].shdr.sh_type == SHT_GNU_versym,
- "Cannot handle sh_type SHT_GNU_versym!\n");
-
- /* Increment the counter. */
- ++cnt;
- } /* while */
-
- /* Get the EBL handling. */
- Ebl *ebl = ebl_openbackend (elf);
- FAILIF_LIBELF(NULL == ebl, ebl_openbackend);
- FAILIF_LIBELF(0 != arm_init(elf, ehdr->e_machine, ebl, sizeof(Ebl)),
- arm_init);
-
- if (strip_debug) {
-
- /* This will actually strip more than just sections. It will strip
- anything not essential to running the image.
- */
-
- INFO("Finding debug sections to strip.\n");
-
- /* Now determine which sections can go away. The general rule is that
- all sections which are not used at runtime are stripped out. But
- there are a few exceptions:
-
- - special sections named ".comment" and ".note" are kept
- - OS or architecture specific sections are kept since we might not
- know how to handle them
- - if a section is referred to from a section which is not removed
- in the sh_link or sh_info element it cannot be removed either
- */
- for (cnt = 1; cnt < shnum; ++cnt) {
- /* Check whether the section can be removed. */
- if (SECTION_STRIP_P (ebl, elf, ehdr, &shdr_info[cnt].shdr,
- shdr_info[cnt].name,
- 1, /* remove .comment sections */
- 1 /* remove all debug sections */) ||
- /* The macro above is broken--check for .comment explicitly */
- !strcmp(".comment", shdr_info[cnt].name)
-#ifdef ARM_SPECIFIC_HACKS
- ||
- /* We ignore this section, that's why we can remove it. */
- !strcmp(".stack", shdr_info[cnt].name)
-#endif
- )
- {
- /* For now assume this section will be removed. */
- INFO("Section [%s] will be stripped from image.\n",
- shdr_info[cnt].name);
- shdr_info[cnt].idx = 0;
- }
-#ifdef STRIP_STATIC_SYMBOLS
- else if (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB) {
- /* Mark the static symbol table for removal */
- INFO("Section [%s] (static symbol table) will be stripped from image.\n",
- shdr_info[cnt].name);
- shdr_info[cnt].idx = 0;
- if (shdr_info[shdr_info[cnt].shdr.sh_link].shdr.sh_type ==
- SHT_STRTAB)
- {
- /* Mark the symbol table's string table for removal. */
- INFO("Section [%s] (static symbol-string table) will be stripped from image.\n",
- shdr_info[shdr_info[cnt].shdr.sh_link].name);
- shdr_info[shdr_info[cnt].shdr.sh_link].idx = 0;
- }
- else {
- ERROR("Expecting the sh_link field of a symbol table to point to"
- " associated symbol-strings table! This is not mandated by"
- " the standard, but is a common practice and the only way "
- " to know for sure which strings table corresponds to which"
- " symbol table!\n");
- }
- }
-#endif
- }
-
- /* Mark the SHT_NULL section as handled. */
- shdr_info[0].idx = 2;
-
- /* Handle exceptions: section groups and cross-references. We might have
- to repeat this a few times since the resetting of the flag might
- propagate.
- */
- int exceptions_pass = 0;
- bool changes;
- do {
- changes = false;
- INFO("\nHandling exceptions, pass %d\n\n", exceptions_pass++);
- for (cnt = 1; cnt < shnum; ++cnt) {
- if (shdr_info[cnt].idx == 0) {
- /* If a relocation section is marked as being removed but the
- section it is relocating is not, then do not remove the
- relocation section.
- */
- if ((shdr_info[cnt].shdr.sh_type == SHT_REL
- || shdr_info[cnt].shdr.sh_type == SHT_RELA)
- && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) {
- PRINT("\tSection [%s] will not be removed because the "
- "section it is relocating (%s) stays.\n",
- shdr_info[cnt].name,
- shdr_info[shdr_info[cnt].shdr.sh_info].name);
- }
- }
- if (shdr_info[cnt].idx == 1) {
- INFO("Processing section [%s]...\n", shdr_info[cnt].name);
-
- /* The content of symbol tables we don't remove must not
- reference any section which we do remove. Otherwise
- we cannot remove the referred section.
- */
- if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM ||
- shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)
- {
- Elf_Data *symdata;
- size_t elsize;
-
- INFO("\tSection [%s] is a symbol table that's not being"
- " removed.\n\tChecking to make sure that no symbols"
- " refer to sections that are being removed.\n",
- shdr_info[cnt].name);
-
- /* Make sure the data is loaded. */
- symdata = elf_getdata (shdr_info[cnt].scn, NULL);
- FAILIF_LIBELF(NULL == symdata, elf_getdata);
-
- /* Go through all symbols and make sure the section they
- reference is not removed. */
- elsize = gelf_fsize (elf, ELF_T_SYM, 1, ehdr->e_version);
-
- /* Check the length of the dynamic-symbol filter. */
- FAILIF(sym_filter != NULL &&
- (size_t)num_symbols != symdata->d_size / elsize,
- "Length of dynsym filter (%d) must equal the number"
- " of dynamic symbols (%zd)!\n",
- num_symbols,
- symdata->d_size / elsize);
-
- size_t inner;
- for (inner = 0;
- inner < symdata->d_size / elsize;
- ++inner)
- {
- GElf_Sym sym_mem;
- GElf_Sym *sym;
- size_t scnidx;
-
- sym = gelf_getsymshndx (symdata, NULL,
- inner, &sym_mem, NULL);
- FAILIF_LIBELF(sym == NULL, gelf_getsymshndx);
-
- scnidx = sym->st_shndx;
- FAILIF(scnidx == SHN_XINDEX,
- "Can't handle SHN_XINDEX!\n");
- if (scnidx == SHN_UNDEF ||
- scnidx >= shnum ||
- (scnidx >= SHN_LORESERVE &&
- scnidx <= SHN_HIRESERVE) ||
- GELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- continue;
- }
-
- /* If the symbol is going to be thrown and it is a
- global or weak symbol that is defined (not imported),
- then continue. Since the symbol is going away, we
- do not care whether it refers to a section that is
- also going away.
- */
- if (sym_filter && !sym_filter[inner])
- {
- bool global_or_weak =
- ELF32_ST_BIND(sym->st_info) == STB_GLOBAL ||
- ELF32_ST_BIND(sym->st_info) == STB_WEAK;
- if (!global_or_weak && sym->st_shndx != SHN_UNDEF)
- continue;
- }
-
- /* -- far too much output
- INFO("\t\t\tSymbol [%s] (%d)\n",
- elf_strptr(elf,
- shdr_info[cnt].shdr.sh_link,
- sym->st_name),
- shdr_info[cnt].shdr.sh_info);
- */
-
- if (shdr_info[scnidx].idx == 0)
- {
- PRINT("\t\t\tSymbol [%s] refers to section [%s], "
- "which is being removed. Will keep that "
- "section.\n",
- elf_strptr(elf,
- shdr_info[cnt].shdr.sh_link,
- sym->st_name),
- shdr_info[scnidx].name);
- /* Mark this section as used. */
- shdr_info[scnidx].idx = 1;
- changes |= scnidx < cnt;
- }
- } /* for each symbol */
- } /* section type is SHT_DYNSYM or SHT_SYMTAB */
- /* Cross referencing happens:
- - for the cases the ELF specification says. That are
- + SHT_DYNAMIC in sh_link to string table
- + SHT_HASH in sh_link to symbol table
- + SHT_REL and SHT_RELA in sh_link to symbol table
- + SHT_SYMTAB and SHT_DYNSYM in sh_link to string table
- + SHT_GROUP in sh_link to symbol table
- + SHT_SYMTAB_SHNDX in sh_link to symbol table
- Other (OS or architecture-specific) sections might as
- well use this field so we process it unconditionally.
- - references inside section groups
- - specially marked references in sh_info if the SHF_INFO_LINK
- flag is set
- */
-
- if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0) {
- shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1;
- changes |= shdr_info[cnt].shdr.sh_link < cnt;
- }
-
- /* Handle references through sh_info. */
- if (SH_INFO_LINK_P (&shdr_info[cnt].shdr) &&
- shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) {
- PRINT("\tSection [%s] links to section [%s], which was "
- "marked for removal--it will not be removed.\n",
- shdr_info[cnt].name,
- shdr_info[shdr_info[cnt].shdr.sh_info].name);
-
- shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
- changes |= shdr_info[cnt].shdr.sh_info < cnt;
- }
-
- /* Mark the section as investigated. */
- shdr_info[cnt].idx = 2;
- } /* if (shdr_info[cnt].idx == 1) */
- } /* for (cnt = 1; cnt < shnum; ++cnt) */
- } while (changes);
- }
- else {
- INFO("Not stripping sections.\n");
- /* Mark the SHT_NULL section as handled. */
- shdr_info[0].idx = 2;
- }
-
- /* Mark the section header string table as unused, we will create
- a new one as the very last section in the new ELF file.
- */
- shdr_info[shstrndx].idx = rebuild_shstrtab ? 0 : 2;
-
- /* We need a string table for the section headers. */
- FAILIF_LIBELF((shst = ebl_strtabinit (1 /* null-terminated */)) == NULL,
- ebl_strtabinit);
-
- /* Assign new section numbers. */
- INFO("Creating new sections...\n");
- //shdr_info[0].idx = 0;
- for (cnt = idx = 1; cnt < shnum; ++cnt) {
- if (shdr_info[cnt].idx > 0) {
- shdr_info[cnt].idx = idx++;
-
- /* Create a new section. */
- FAILIF_LIBELF((shdr_info[cnt].newscn =
- elf_newscn(newelf)) == NULL, elf_newscn);
- ASSERT(elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
-
- /* Add this name to the section header string table. */
- shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
-
- INFO("\tsection [%s] (old offset %lld, old size %lld) will have index %d "
- "(was %zd).\n",
- shdr_info[cnt].name,
- shdr_info[cnt].old_shdr.sh_offset,
- shdr_info[cnt].old_shdr.sh_size,
- shdr_info[cnt].idx,
- elf_ndxscn(shdr_info[cnt].scn));
- } else {
- INFO("\tIgnoring section [%s] (offset %lld, size %lld, index %zd), "
- "it will be discarded.\n",
- shdr_info[cnt].name,
- shdr_info[cnt].shdr.sh_offset,
- shdr_info[cnt].shdr.sh_size,
- elf_ndxscn(shdr_info[cnt].scn));
- }
- } /* for */
-
- sections_dropped_or_rearranged = idx != cnt;
-
- Elf_Data *shstrtab_data = NULL;
-
-#if 0
- /* Fail if sections are being dropped or rearranged (except for moving shstrtab) or the
- symbol filter is not empty, AND the file is an executable.
- */
- FAILIF(((idx != cnt && !(cnt - idx == 1 && rebuild_shstrtab)) || sym_filter != NULL) &&
- ehdr->e_type != ET_DYN,
- "You may not rearrange sections or strip symbols on an executable file!\n");
-#endif
-
- INFO("\n\nADJUSTING ELF FILE\n\n");
-
- adjust_elf(elf, elf_name,
- newelf, newelf_name,
- ebl,
- ehdr, /* store ELF header of original library */
- sym_filter, num_symbols,
- shdr_info, shdr_info_len,
- phdr_info,
- idx, /* highest_scn_num */
- shnum,
- shstrndx,
- shst,
- sections_dropped_or_rearranged,
- dynamic_idx, /* index in shdr_info[] of .dynamic section */
- dynsym_idx, /* index in shdr_info[] of dynamic symbol table */
- shady,
- &shstrtab_data,
- ehdr->e_type == ET_DYN, /* adjust section ofsets only when the file is a shared library */
- rebuild_shstrtab);
-
- /* We have everything from the old file. */
- FAILIF_LIBELF(elf_cntl(elf, ELF_C_FDDONE) != 0, elf_cntl);
-
- /* The ELF library better follows our layout when this is not a
- relocatable object file. */
- elf_flagelf (newelf,
- ELF_C_SET,
- (ehdr->e_type != ET_REL ? ELF_F_LAYOUT : 0));
-
- /* Finally write the file. */
- FAILIF_LIBELF(!dry_run && elf_update(newelf, ELF_C_WRITE) == -1, elf_update);
-
- if (shdr_info != NULL) {
- /* For some sections we might have created an table to map symbol
- table indices. */
- for (cnt = 1; cnt < shdr_info_len; ++cnt) {
- FREEIF(shdr_info[cnt].newsymidx);
- FREEIF(shdr_info[cnt].symse);
- if(shdr_info[cnt].dynsymst != NULL)
- ebl_strtabfree (shdr_info[cnt].dynsymst);
- }
- /* Free the memory. */
- FREE (shdr_info);
- }
- FREEIF(phdr_info);
-
- ebl_closebackend(ebl);
-
- /* Free other resources. */
- if (shst != NULL) ebl_strtabfree (shst);
- if (shstrtab_data != NULL)
- FREEIF(shstrtab_data->d_buf);
-}
diff --git a/tools/soslim/soslim.h b/tools/soslim/soslim.h
deleted file mode 100644
index 952c960..0000000
--- a/tools/soslim/soslim.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef ELFCOPY_H
-#define ELFCOPY_H
-
-#include <libelf.h>
-#include <libebl.h>
-#include <elf.h>
-#include <gelf.h>
-
-/*
-symbol_filter:
- On input: symbol_filter[i] indicates whether to keep a symbol (1) or to
- remove it from the symbol table.
- On output: symbol_filter[i] indicates whether a symbol was removed (0) or
- kept (1) in the symbol table.
-*/
-
-void clone_elf(Elf *elf, Elf *newelf,
- const char *elf_name,
- const char *newelf_name,
- bool *symbol_filter,
- int num_symbols,
- int shady
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
- , int *prelinked,
- int *elf_little,
- long *prelink_addr,
- int *retouched,
- unsigned int *retouch_byte_cnt,
- char *retouch_buf
-#endif
- , bool rebuild_shstrtab,
- bool strip_debug,
- bool dry_run);
-
-#endif/*ELFCOPY_H*/
diff --git a/tools/soslim/symfilter.c b/tools/soslim/symfilter.c
deleted file mode 100644
index b59e68a..0000000
--- a/tools/soslim/symfilter.c
+++ /dev/null
@@ -1,246 +0,0 @@
-#include <debug.h>
-#include <common.h>
-#include <symfilter.h>
-#include <hash.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <libelf.h>
-#include <gelf.h>
-#include <ctype.h>
-
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-static int match_hash_table_section(Elf *elf, Elf_Scn *sect, void *data);
-static int match_dynsym_section(Elf *elf, Elf_Scn *sect, void *data);
-
-void build_symfilter(const char *name, Elf *elf, symfilter_t *filter,
- off_t fsize)
-{
- char *line = NULL;
- symfilter_list_t *symbol;
-
- FAILIF(NULL == name,
- "You must provide a list of symbols to filter on!\n");
-
- filter->num_symbols = 0;
- filter->total_name_length = 0;
-
- /* Open the file. */
- INFO("Opening symbol-filter file %s...\n", name);
- filter->fd = open(name, O_RDONLY);
- FAILIF(filter->fd < 0, "open(%s): %s (%d)\n",
- name,
- strerror(errno),
- errno);
-
- INFO("Symbol-filter file %s is %zd bytes long...\n",
- name,
- (size_t)fsize);
- filter->fsize = fsize;
-
- /* mmap the symbols file */
- filter->mmap = mmap(NULL, fsize,
- PROT_READ | PROT_WRITE, MAP_PRIVATE,
- filter->fd, 0);
- FAILIF(MAP_FAILED == filter->mmap,
- "mmap(NULL, %zd, PROT_READ, MAP_PRIVATE, %d, 0): %s (%d)\n",
- (size_t)fsize,
- filter->fd,
- strerror(errno),
- errno);
- INFO("Memory-mapped symbol-filter file at %p\n", filter->mmap);
-
- /* Make sure that the ELF file has a hash table. We will use the hash
- table to look up symbols quickly. If the library does not have a hash-
- table section, we can still do a linear scan, but the code for that is
- not written, as practically every shared library has a hash table.
- */
-
- filter->symtab.sect = NULL;
- map_over_sections(elf, match_dynsym_section, filter);
- FAILIF(NULL == filter->symtab.sect,
- "There is no dynamic-symbol table in this library.\n");
- filter->hash.sect = NULL;
- map_over_sections(elf, match_hash_table_section, filter);
- FAILIF(NULL == filter->hash.sect,
- "There is no hash table in this library.\n");
- INFO("Hash table size 0x%lx, data size 0x%lx.\n",
- (unsigned long)filter->hash.hdr->sh_size,
- (unsigned long)filter->hash.data->d_size);
-
- INFO("Hash table file offset: 0x%x\n", filter->hash.hdr->sh_offset);
-
- GElf_Ehdr *ehdr, ehdr_mem;
- ehdr = gelf_getehdr(elf, &ehdr_mem);
- size_t symsize = gelf_fsize (elf, ELF_T_SYM, 1, ehdr->e_version);
- ASSERT(symsize);
- filter->num_symbols_to_keep = filter->symtab.data->d_size / symsize;
- filter->symbols_to_keep = (bool *)CALLOC(filter->num_symbols_to_keep,
- sizeof(bool));
-
- /* Build the symbol-name chain. */
- INFO("Building symbol list...\n");
-
- line = (char *)filter->mmap;
-
- filter->symbols = NULL;
-#define NOT_DONE ((off_t)(line - (char *)filter->mmap) < fsize)
- do {
- char *name = line;
-
- /* Advance to the next line. We seek out spaces or new lines. At the
- first space or newline character we find, we place a '\0', and
- continue till we've consumed the line. For new lines, we scan both
- '\r' and '\n'. For spaces, we look for ' ', '\t', and '\f'
- */
-
- while (NOT_DONE && !isspace(*line)) line++;
- if (likely(NOT_DONE)) {
- *line++ = '\0';
- if (line - name > 1) {
- /* Add the entry to the symbol-filter list */
- symbol = (symfilter_list_t *)MALLOC(sizeof(symfilter_list_t));
- symbol->next = filter->symbols;
- symbol->name = name;
- filter->symbols = symbol;
-
-#if 0
- /* SLOW! For debugging only! */
- {
- size_t idx;
- size_t elsize = gelf_fsize(elf, ELF_T_SYM, 1,
- ehdr->e_version);
- symbol->index = SHN_UNDEF;
- for (idx = 0; idx < filter->symtab.data->d_size / elsize;
- idx++) {
- GElf_Sym sym_mem;
- GElf_Sym *sym;
- const char *symname;
- sym = gelf_getsymshndx (filter->symtab.data, NULL,
- idx, &sym_mem, NULL);
- ASSERT(sym);
-
- symname = elf_strptr(elf,
- filter->symtab.hdr->sh_link,
- sym->st_name);
- if(!strcmp(symname, symbol->name)) {
- symbol->index = idx;
- break;
- }
- }
- }
-#else
- /* Look up the symbol in the ELF file and associate it with the
- entry in the filter. */
- symbol->index = hash_lookup(elf,
- &filter->hash,
- &filter->symtab,
- symbol->name,
- &symbol->symbol);
-#endif
- symbol->len = line - name - 1;
- ASSERT(symbol->len == strlen(symbol->name));
-
- /* If we didn't find the symbol, then it's not in the library.
- */
-
- if(STN_UNDEF == symbol->index) {
- PRINT("%s: symbol was not found!\n", symbol->name);
- }
- else {
- /* If we found the symbol but it's an undefined symbol, then
- it's not in the library as well. */
- GElf_Sym sym_mem;
- GElf_Sym *sym;
- sym = gelf_getsymshndx (filter->symtab.data, NULL,
- symbol->index, &sym_mem, NULL);
- FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
- /* Make sure the hash lookup worked. */
- ASSERT(!strcmp(elf_strptr(elf,
- filter->symtab.hdr->sh_link,
- sym->st_name),
- symbol->name));
- if (sym->st_shndx == SHN_UNDEF) {
- PRINT("%s: symbol was not found (undefined)!\n", symbol->name);
- }
- else {
- filter->num_symbols++;
- /* Total count includes null terminators */
- filter->total_name_length += symbol->len + 1;
-
- /* Set the flag in the symbols_to_keep[] array. This indicates
- to function copy_elf() that we want to keep the symbol.
- */
- filter->symbols_to_keep[symbol->index] = true;
- INFO("FILTER-SYMBOL: [%s] [%d bytes]\n",
- symbol->name,
- symbol->len);
- }
- }
- }
- }
- } while (NOT_DONE);
-#undef NOT_DONE
-}
-
-void destroy_symfilter(symfilter_t *filter)
-{
- symfilter_list_t *old;
- INFO("Destroying symbol list...\n");
- while ((old = filter->symbols)) {
- filter->symbols = old->next;
- FREE(old);
- }
- munmap(filter->mmap, filter->fsize);
- close(filter->fd);
-}
-
-static int match_hash_table_section(Elf *elf, Elf_Scn *sect, void *data)
-{
- (void)elf; // unused argument
-
- symfilter_t *filter = (symfilter_t *)data;
- Elf32_Shdr *shdr;
-
- ASSERT(filter);
- ASSERT(sect);
- shdr = elf32_getshdr(sect);
-
- /* The section must be marked both as a SHT_HASH, and it's sh_link field
- must contain the index of our symbol table (per ELF-file spec).
- */
- if (shdr->sh_type == SHT_HASH)
- {
- FAILIF(filter->hash.sect != NULL,
- "There is more than one hash table!\n");
- get_section_info(sect, &filter->hash);
- }
-
- return 0; /* keep looking */
-}
-
-static int match_dynsym_section(Elf *elf, Elf_Scn *sect, void *data)
-{
- (void)elf; // unused argument
-
- symfilter_t *filter = (symfilter_t *)data;
- Elf32_Shdr *shdr;
-
- ASSERT(filter);
- ASSERT(sect);
- shdr = elf32_getshdr(sect);
-
- if (shdr->sh_type == SHT_DYNSYM)
- {
- FAILIF(filter->symtab.sect != NULL,
- "There is more than one dynamic symbol table!\n");
- get_section_info(sect, &filter->symtab);
- }
-
- return 0; /* keep looking */
-}
diff --git a/tools/soslim/symfilter.h b/tools/soslim/symfilter.h
deleted file mode 100644
index f73fd50..0000000
--- a/tools/soslim/symfilter.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef SYMFILTER_H
-#define SYMFILTER_H
-
-/* This file describes the interface for parsing the list of symbols. Currently,
- this is just a text file with each symbol on a separate line. We build an
- in-memory linked list of symbols out of this image.
-*/
-
-#include <stdio.h>
-#include <libelf.h>
-#include <gelf.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libebl.h> /* defines bool */
-
-typedef struct symfilter_list_t symfilter_list_t;
-struct symfilter_list_t {
- symfilter_list_t *next;
- const char *name;
- unsigned int len; /* strlen(name) */
- Elf32_Word index;
- GElf_Sym symbol;
-};
-
-typedef struct symfilter_t {
-
- int fd; /* symbol-filter-file descriptor */
- off_t fsize; /* size of file */
- void *mmap; /* symbol-fiter-file memory mapping */
-
- section_info_t symtab;
- section_info_t hash;
- symfilter_list_t *symbols;
-
- /* The total number of symbols in the symfilter. */
- unsigned int num_symbols;
- /* The total number of bytes occupied by the names of the symbols, including
- the terminating null characters.
- */
- unsigned int total_name_length;
-
- bool *symbols_to_keep;
- /* must be the same as the number of symbols in the dynamic table! */
- int num_symbols_to_keep;
-} symfilter_t;
-
-void build_symfilter(const char *name, Elf *elf, symfilter_t *filter, off_t);
-void destroy_symfilter(symfilter_t *);
-
-#endif/*SYMFILTER_H*/