Build: Merge with the AOSP

Summary:
Will be clean merged on approval

Enable NX protections

Add -Wa,--noexecstack and -Wl,-z,noexecstack as default
flags when compiling host-side applications.  This enables
NX protections, which prevent code from executing on the
stack or heap.  NX protections make exploiting memory
corruption issues more challenging and is an important
security feature.

Change-Id: Iae580abe887e01f9029ec2a4e0fc0aae496724a4

Fix regex for finding symbol data.

The new output of debuggerd removed a space between the #00 and the rest
of the line. The regex is very restrictive, so fixing it to handle the new
output.

Change-Id: I5259ae1e56a351608b330dfd858a2021e6d89358

Add an explicit definition of __ANDROID__=1

Once the aarch64 toolchain is refreshed this will be removed.
Also removed some CFLAG duplications.

Change-Id: I42fd86931263af82042ea696196fb25e948fe9cb

Merge "Add an explicit definition of __ANDROID__=1"

Merge "Fix regex for finding symbol data."

Merge "Enable NX protections"

enable PIE for dynamically linked Linux host executables

Compile all host programs for Android with -fPIE and -pie. This
enables PIE (Position Independent Executables), which helps
protect these applications from exploitation due to memory
management bugs.

Note: PIE *static* executables are not supported at this time. darwin
and windows are also not supported.

Change-Id: I67c1be297711ea23064c349f97ebd02eef3eff09

Merge "enable PIE for dynamically linked Linux host executables"

Enable uapi kernel headers for arm.

Bug: 11559337
Change-Id: Idd251338f707b7c6a08f43a79f9784c57142f43c

Merge "Enable uapi kernel headers for arm."

Revert "Enable uapi kernel headers for arm."

This reverts commit 88c6c533e17f7bc2e1491310b8d679a91b33aaeb.

Change-Id: I3cd84383c6f217bc6e627e16b2d0c7d948f8131d

Merge "Revert "Enable uapi kernel headers for arm.""

Re-enable uapi kernel headers for arm.

Bug: 11559337
Change-Id: Ib914e5f22b10d5a74edc357d42b0dcb223185ab4

Make aarch64 more like arm wrt strict-aliasing.

All thumb code compiles with -fno-strict-aliasing. Let's not make aarch64
porting any more difficult than it needs to be.

Change-Id: I94874df1217b69532c328d7c86c9961631ebde8a

Merge "Make aarch64 more like arm wrt strict-aliasing."

Add DEXPREOPT support for ART

Change-Id: I24d0d7b2a23a769f5d69bd4dc14be22e1475b759

Merge "Re-enable uapi kernel headers for arm."

Merge "Add DEXPREOPT support for ART"

Create the dest dir before copying over files.

Change-Id: I8ad79704558d7a10099e64fc1d032c8ddd3330b9

Merge "Create the dest dir before copying over files."

Simplify the calculation of LOCAL_UNSTRIPPED_PATH

Also this fixes the LOCAL_UNSTRIPPED_PATH if the module is installed to
the vendor dir via LOCAL_PROPRIETARY_MODULE.

Bug: 11289169
Change-Id: Ib07e5761411210963076487fe0e148c259e1e082

Merge "Simplify the calculation of LOCAL_UNSTRIPPED_PATH"

Fix aarch64 and x86-64 AndroidConfig.h.

_LARGEFILE_SOURCE should never be defined with bionic.
_FILE_OFFSET_BITS should be 64 on 64-bit architectures.

Change-Id: I7acf6b39a3af7782d5d7ad00f709593d96fa8522

Merge "Fix aarch64 and x86-64 AndroidConfig.h."

envsetup.sh: cd to toplevel in get_build_var

dumpvar doesn't work right if we're not called from the toplevel;
due to the way the build system works internally, -C does not
suffice. This was already done in get_abs_build_var.

Redundant -C calls removed since we're at the toplevel already.

Change-Id: Iaaa48982547d099186922cc3ddc417a82c85e9a5
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>

Merge "envsetup.sh: cd to toplevel in get_build_var"

Add policy for x86 emulator.

Merge "Add policy for x86 emulator."

Remove a non-existent directory from the include path.

Brings aarch64 in line with the other architectures.

Change-Id: Iba3fd33e34e3b5bc071f55cfe09de9e55a023cf7

Merge "Remove a non-existent directory from the include path."

Allow execmem and ashmem_device execute as required.

bootanim requires execmem.
bootanim and surfaceflinger requires execute to ashmem_device.

Change-Id: I3b4964c5acd31a44ce81672077c70353a375c072
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>

e2fsck missing from emulator

The emulator file system was recently switched to ext4 however, e2fsck was not
added to the emulator build.

Change-Id: I94621c148fa40d6042b5c86a26815d867a417a6c
See: https://code.google.com/p/android/issues/detail?id=64144

Merge "e2fsck missing from emulator"

Merge "Allow execmem and ashmem_device execute as required."

Remove LOCAL_SRC_FILES as precondition of enabling dexpreopt

Because a library or app can be built from mere static libraries,
or generated java files. For example, framework is built from only
static library framework-base but without LOCAL_SRC_FILES.
Also added framework2 to PRODUCT_PACKAGES.
Previously framework2.jar was installed by dependency explicitly
established in frameworks/base/Android.mk. That's not enough for the
.odex file.
This fixed the boot failure reported in bug 12382916.

Bug: 12382916
Change-Id: If1a70261ab2bb7fef77cf7b7b995bdc029be0fc3

Merge "Remove LOCAL_SRC_FILES as precondition of enabling dexpreopt"

Allow clang to build host binaries.

Change-Id: I7e4f9dc6f69a97cfefdfa2ed55c5d7b8ad496da7

Remove libSR_AudioIn from base.mk

This is an obsolete rule that was grandfathered in because
it was a USER module at some point. It's no longer
required, even by builds that use packages/app/VoiceDialer.

Change-Id: Ife9e89bd1b03c0364e27650863a83bad945b8089

PRODUCT_BOOT_JARS as a list of jar names separated by space

This makes it easier for OEMs to extend the PRODUCT_BOOT_JARS in their
product configuration files.

Change-Id: I5feca2f808b1914c275f28c7a4c38cca2ba6851f

Merge "PRODUCT_BOOT_JARS as a list of jar names separated by space"

Merge "Remove libSR_AudioIn from base.mk"

Merge "Allow clang to build host binaries."

Define PRIVATE_TARGET_ variables for only target modules.

Change-Id: I12c54bfffd9acb78a61d1032a087a0edaf3bf12c

Add support for ALTERNATE_JAVAC

Bug: 12476356
Change-Id: Idd013031dc32a560bca76cca295bedcad55982b4

Merge "Define PRIVATE_TARGET_ variables for only target modules."

Merge "Add support for ALTERNATE_JAVAC"

Fix x86_64 build

Issue introduced here:
https://android-review.googlesource.com/#/c/71842/

Change-Id: I8a60641ff07173fcedf259df89aaaa4bc6d6ea3e
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>

Merge "Fix x86_64 build"

Remove obsolete CUSTOM_KERNEL_HEADERS.

Change-Id: Id260dd351b90f065eee56e231d4c341b18c1b27f

Merge "Remove obsolete CUSTOM_KERNEL_HEADERS."

Revert "Fix x86_64 build"

This reverts commit 522b0a633cb7d14aa64583e911e11914d81acf96.

Revert "Allow clang to build host binaries."

This reverts commit e6f65438a45f0e1b519fb3cd2799f44ca87911a7.

Merge branch 'master' into kk-devel-merge

Test Plan: verified here...

Reviewers: randall.rushing, jriordan001, anders3408

Differential Revision: http://review.codefirex.com/D247
LLVM: introduce CLANG (3.5) for Darwin

Summary: DARWIN LOVE!

Test Plan: Test all the things

Reviewers: randall.rushing, raymanfx

Reviewed By: raymanfx

CC: randall.rushing

Differential Revision: http://review.codefirex.com/D280