diff --git a/android-configure b/android-configure index 5cdfa70bbafba7..5bc46d9ed202ca 100755 --- a/android-configure +++ b/android-configure @@ -15,4 +15,6 @@ export LINK=$TOOLCHAIN/bin/arm-linux-androideabi-g++ ./configure \ --dest-cpu=arm \ - --dest-os=android + --dest-os=android \ + --cflag-pie=true \ + --without-snapshot diff --git a/common.gypi b/common.gypi index 5b8b2c09d6b4a9..e9b15c9639604e 100644 --- a/common.gypi +++ b/common.gypi @@ -68,6 +68,10 @@ 'cflags': [ '-gxcoff' ], 'ldflags': [ '-Wl,-bbigtoc' ], }], + ['cflag_pie=="true"', { + 'cflags': [ '-fPIE' ], + 'ldflags': [ '-fPIE', '-pie' ], + }], ], 'msvs_settings': { 'VCCLCompilerTool': { @@ -101,6 +105,10 @@ ['OS!="mac" and OS!="win"', { 'cflags': [ '-fno-omit-frame-pointer' ], }], + ['cflag_pie=="true"', { + 'cflags': [ '-fPIE' ], + 'ldflags': [ '-fPIE', '-pie' ], + }], ], 'msvs_settings': { 'VCCLCompilerTool': { diff --git a/configure b/configure index 2d767c77e3e819..face6bffda8e67 100755 --- a/configure +++ b/configure @@ -373,6 +373,13 @@ parser.add_option('--enable-static', dest='enable_static', help='build as static library') +parser.add_option('--cflag-pie', + action='store', + choices=('true', 'false'), + default='false', + dest='cflag_pie', + help='add cflags -fPIE') + (options, args) = parser.parse_args() # Expand ~ in the install prefix now, it gets written to multiple files. @@ -666,6 +673,9 @@ def configure_mips(o): def configure_node(o): if options.dest_os == 'android': o['variables']['OS'] = 'android' + + o['variables']['cflag_pie'] = options.cflag_pie + o['variables']['node_prefix'] = options.prefix o['variables']['node_install_npm'] = b(not options.without_npm) o['default_configuration'] = 'Debug' if options.debug else 'Release'