Merge changes Id46c03ed,If4730136

* changes:
  Update the build system maintainers doc.
  Remove redundant build flags.
diff --git a/build/cmake/android.toolchain.cmake b/build/cmake/android.toolchain.cmake
index b808a32..4e15453 100644
--- a/build/cmake/android.toolchain.cmake
+++ b/build/cmake/android.toolchain.cmake
@@ -467,19 +467,9 @@
 endif()
 
 # Toolchain and ABI specific flags.
-if(ANDROID_ABI STREQUAL armeabi)
-  list(APPEND ANDROID_COMPILER_FLAGS
-    -march=armv5te
-    -mtune=xscale
-    -msoft-float)
-endif()
 if(ANDROID_ABI STREQUAL armeabi-v7a)
-  list(APPEND ANDROID_COMPILER_FLAGS
-    -march=armv7-a
-    -mfloat-abi=softfp
-    -mfpu=vfpv3-d16)
-  list(APPEND ANDROID_LINKER_FLAGS
-    -Wl,--fix-cortex-a8)
+  list(APPEND ANDROID_COMPILER_FLAGS -mfpu=vfpv3-d16)
+  list(APPEND ANDROID_LINKER_FLAGS -Wl,--fix-cortex-a8)
 endif()
 if(ANDROID_ABI STREQUAL x86 AND ANDROID_PLATFORM_LEVEL LESS 24)
   # http://b.android.com/222239
@@ -505,22 +495,11 @@
 
 # Configuration specific flags.
 
-# x86 and x86_64 use large model pic, whereas everything else uses small model.
-# In the past we've always used -fPIE, but the LLVMgold plugin (for LTO)
-# complains if the models are mismatched.
-list(APPEND ANDROID_PIE_FLAGS -pie)
-if(ANDROID_ABI MATCHES "x86")
-  list(APPEND ANDROID_PIE_FLAGS -fPIE)
-else()
-  list(APPEND ANDROID_PIE_FLAGS -fpie)
-endif()
-
 # PIE is supported on all currently supported Android releases, but it is not
 # supported with static executables, so we still provide ANDROID_PIE as an
 # escape hatch for those.
 if(ANDROID_PIE)
   set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
-  list(APPEND ANDROID_LINKER_FLAGS_EXE ${ANDROID_PIE_FLAGS})
 endif()
 
 if(ANDROID_CPP_FEATURES)
@@ -540,11 +519,9 @@
 endif()
 if(ANDROID_ABI MATCHES "armeabi")
   if(ANDROID_ARM_MODE STREQUAL thumb)
-    list(APPEND ANDROID_COMPILER_FLAGS
-      -mthumb)
+    list(APPEND ANDROID_COMPILER_FLAGS -mthumb)
   elseif(ANDROID_ARM_MODE STREQUAL arm)
-    list(APPEND ANDROID_COMPILER_FLAGS
-      -marm)
+    # Default behavior.
   else()
     message(FATAL_ERROR "Invalid Android ARM mode: ${ANDROID_ARM_MODE}.")
   endif()
diff --git a/build/core/build-binary.mk b/build/core/build-binary.mk
index e3ff570..74d41f6 100644
--- a/build/core/build-binary.mk
+++ b/build/core/build-binary.mk
@@ -234,22 +234,6 @@
   LOCAL_CFLAGS += $(TARGET_FORMAT_STRING_CFLAGS)
 endif
 
-# Enable PIE for dynamic executables.
-ifeq ($(call module-get-class,$(LOCAL_MODULE)),EXECUTABLE)
-    ifeq (,$(filter -static,$(TARGET_LDFLAGS) $(LOCAL_LDFLAGS) $(NDK_APP_LDFLAGS)))
-        # x86 and x86_64 use large model pic, whereas everything else uses small
-        # model. In the past we've always used -fPIE, but the LLVMgold plugin
-        # (for LTO) complains if the models are mismatched.
-        ifneq (,$(filter x86 x86_64,$(TARGET_ARCH_ABI)))
-            LOCAL_CFLAGS += -fPIE
-            LOCAL_LDFLAGS += -fPIE -pie
-        else
-            LOCAL_CFLAGS += -fpie
-            LOCAL_LDFLAGS += -fpie -pie
-        endif
-    endif
-endif
-
 # http://b.android.com/222239
 # http://b.android.com/220159 (internal http://b/31809417)
 # x86 devices have stack alignment issues.
diff --git a/build/core/toolchains/arm-linux-androideabi-clang/setup.mk b/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
index 2c24af1..ea33e59 100644
--- a/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
+++ b/build/core/toolchains/arm-linux-androideabi-clang/setup.mk
@@ -21,8 +21,6 @@
 
 TARGET_CFLAGS := \
     -fpic \
-    -march=armv7-a \
-    -mfloat-abi=softfp \
     -mfpu=vfpv3-d16 \
 
 TARGET_LDFLAGS += \
@@ -31,7 +29,6 @@
 TARGET_CFLAGS.neon := -mfpu=neon
 
 TARGET_arm_release_CFLAGS := \
-    -marm \
     -O2 \
     -DNDEBUG \
 
@@ -41,7 +38,6 @@
     -DNDEBUG \
 
 TARGET_arm_debug_CFLAGS := \
-    -marm \
     -O0 \
     -UNDEBUG \
     -fno-limit-debug-info \
diff --git a/docs/BuildSystemMaintainers.md b/docs/BuildSystemMaintainers.md
index 6c3b66b..c618561 100644
--- a/docs/BuildSystemMaintainers.md
+++ b/docs/BuildSystemMaintainers.md
@@ -52,7 +52,7 @@
 | 32-bit Intel | x86     | x86         | i686-linux-android    |
 | 64-bit Intel | x86_64  | x86_64      | x86_64-linux-android  |
 
-Note: Strictly speaking ARMv7 with NEON is a different ABI from ARMv7 without
+Note: Strictly speaking ARMv7 with [NEON] is a different ABI from ARMv7 without
 NEON, but it is not a *system* ABI. Both NEON and non-NEON ARMv7 code uses the
 ARMv7 system and toolchains.
 
@@ -333,13 +333,28 @@
 but they are not yet. Check back in a future NDK release to see if any can be
 removed from your build system.
 
-TODO: Check if -mfloat-abi=softfp and friends are actually needed for Android
-targets. They ought to be implied, but I need to check.
+32-bit ARM targets should use `-mfpu=vfpv3-d16` when compiling unless using
+[NEON]. This allows the compiler to make use of the FPU.
+
+32-bit ARM targets should use `-Wl,--fix-cortex-a8` when linking. This instructs
+the linker to apply a workaround for an erratum that affects Cortex-A8 CPUs.
+
+C++ builds should use `-stdlib=libc++` when using libc++. This flag is used both
+when compiling and when linking. This allows the compiler to find the correct
+C++ standard headers and libraries.
 
 For x86 targets prior to Android Nougat (API 24), `-mstackrealign` is needed to
 properly align stacks for global constructors. See [Issue 635].
 
+All code must be linked with `-Wl,-z,relro`, which causes relocations to be
+made read-only after relocation is performed.
+
+Android requires [Position-independent executables] beginning with API 21. Clang
+builds PIE executables by default. If invoking the linker directly or not using
+Clang, use `-pie` when linking.
+
 [Issue 635]: https://github.com/android-ndk/ndk/issues/635
+[Position-independent executables]: https://en.wikipedia.org/wiki/Position-independent_code#Position-independent_executables
 
 ## Useful Arguments