Skip to content

Commit f60d188

Browse files
authored
Improve -static-pie support (#81163)
1 parent d021235 commit f60d188

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The .NET Foundation licenses this file to you under the MIT license.
111111
<LinkerArg Include="-arch $(CrossCompileArch)" Condition="'$(TargetOS)' == 'osx' and '$(CrossCompileArch)' != ''" />
112112
<LinkerArg Include="-g" Condition="$(NativeDebugSymbols) == 'true'" />
113113
<LinkerArg Include="-Wl,--strip-debug" Condition="$(NativeDebugSymbols) != 'true' and '$(TargetOS)' != 'osx'" />
114-
<LinkerArg Include="-Wl,-rpath,'$(IlcRPath)'" />
114+
<LinkerArg Include="-Wl,-rpath,'$(IlcRPath)'" Condition="'$(StaticExecutable)' != 'true'" />
115115
<LinkerArg Include="-Wl,--build-id=sha1" Condition="'$(TargetOS)' != 'osx'" />
116116
<LinkerArg Include="-Wl,--as-needed" Condition="'$(TargetOS)' != 'osx'" />
117117
<LinkerArg Include="-Wl,-e0x0" Condition="'$(NativeLib)' == 'Shared' and '$(TargetOS)' != 'osx'" />
@@ -129,12 +129,12 @@ The .NET Foundation licenses this file to you under the MIT license.
129129
<LinkerArg Include="@(StaticICULibs)" Condition="'$(StaticICULinking)' == 'true'" />
130130
<LinkerArg Include="@(StaticSslLibs)" Condition="'$(StaticOpenSslLinking)' == 'true'" />
131131
<LinkerArg Include="-lm" />
132-
<LinkerArg Include="-static" Condition="'$(StaticExecutable)' == 'true'" />
132+
<LinkerArg Include="-static" Condition="'$(StaticExecutable)' == 'true' and '$(PositionIndependentExecutable)' == 'false'" />
133+
<LinkerArg Include="-static-pie" Condition="'$(StaticExecutable)' == 'true' and '$(PositionIndependentExecutable)' != 'false'" />
133134
<LinkerArg Include="-dynamiclib" Condition="'$(TargetOS)' == 'osx' and '$(NativeLib)' == 'Shared'" />
134135
<LinkerArg Include="-shared" Condition="'$(TargetOS)' != 'osx' and '$(NativeLib)' == 'Shared'" />
135136
<!-- binskim warning BA3001 PIE disabled on executable -->
136137
<LinkerArg Include="-pie" Condition="'$(TargetOS)' != 'osx' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' != 'false'" />
137-
<LinkerArg Include="-static-pie" Condition="'$(StaticExecutable)' == 'true' and '$(PositionIndependentExecutable)' != 'false'" />
138138
<!-- binskim warning BA3010 The GNU_RELRO segment is missing -->
139139
<LinkerArg Include="-Wl,-z,relro" Condition="'$(TargetOS)' != 'osx'" />
140140
<!-- binskim warning BA3011 The BIND_NOW flag is missing -->

src/native/libs/System.Globalization.Native/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ set(NATIVEGLOBALIZATION_SOURCES
6060
)
6161

6262
if (LOCAL_BUILD)
63+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
6364
set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c)
6465
add_definitions(-DLOCAL_BUILD)
6566
add_definitions(-DSTATIC_ICU)

src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set(NATIVECRYPTO_SOURCES
4545
)
4646

4747
if (LOCAL_BUILD)
48+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4849
add_definitions(-DLOCAL_BUILD)
4950
add_definitions(-DPALEXPORT=EXTERN_C)
5051
add_definitions(-DTARGET_UNIX)

0 commit comments

Comments
 (0)