Skip to content

Commit

Permalink
Pass -pie and -no-pie to the linker (#81533)
Browse files Browse the repository at this point in the history
* Pass -pie and -no-pie to the linker

When `PositionIndependentExecutable` is `false`, we need to pass
`-no-pie` to the linker. Otherwise, we need to pass `-pie` to the
linker with `-Wl` because we are not compiling the code at this stage
(only linking the objects).

* Add -pie for non-pie .o (in CentOS 7)
  • Loading branch information
am11 authored Feb 2, 2023
1 parent e2a706e commit 873775b
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Include="-dynamiclib" Condition="'$(TargetOS)' == 'osx' and '$(NativeLib)' == 'Shared'" />
<LinkerArg Include="-shared" Condition="'$(TargetOS)' != 'osx' and '$(NativeLib)' == 'Shared'" />
<!-- binskim warning BA3001 PIE disabled on executable -->
<LinkerArg Include="-pie" Condition="'$(TargetOS)' != 'osx' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' != 'false'" />
<LinkerArg Include="-pie -Wl,-pie" Condition="'$(TargetOS)' != 'osx' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' != 'false'" />
<LinkerArg Include="-Wl,-no-pie" Condition="'$(TargetOS)' != 'osx' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' == 'false'" />
<!-- binskim warning BA3010 The GNU_RELRO segment is missing -->
<LinkerArg Include="-Wl,-z,relro" Condition="'$(TargetOS)' != 'osx'" />
<!-- binskim warning BA3011 The BIND_NOW flag is missing -->
Expand Down

0 comments on commit 873775b

Please sign in to comment.