File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
nativeaot/BuildIntegration
tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,7 @@ The .NET Foundation licenses this file to you under the MIT license.
341
341
<CustomLinkerArg Include =" -exported_symbols_list /dev/null" Condition =" '$(OutputType)' == 'exe' and '$(_IsApplePlatform)' == 'true' and '$(ExportsFile)' == ''" />
342
342
<CustomLinkerArg Include =" -Wl,--version-script=$(ExportsFile)" Condition =" '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(ExportsFile)' != ''" />
343
343
<CustomLinkerArg Include =" -Wl,--export-dynamic" Condition =" '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(ExportsFile)' != ''" />
344
+ <CustomLinkerArg Include =" -Wl,-dead_strip" Condition =" '$(_IsApplePlatform)' == 'true'" />
344
345
<CustomLinkerArg Include =" @(LinkerArg)" />
345
346
</ItemGroup >
346
347
<ItemGroup Condition =" '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true'" >
Original file line number Diff line number Diff line change @@ -475,12 +475,15 @@ private protected override void EmitSymbolTable(
475
475
foreach ( ( string name , SymbolDefinition definition ) in definedSymbols )
476
476
{
477
477
MachSection section = _sections [ definition . SectionIndex ] ;
478
+ // Sections in our object file should not be altered during native linking as the runtime
479
+ // depends on the layout generated during compilation. For this reason we mark all symbols
480
+ // with N_NO_DEAD_STRIP to prevent breaking up sections into subsections during linking.
478
481
sortedDefinedSymbols . Add ( new MachSymbol
479
482
{
480
483
Name = name ,
481
484
Section = section ,
482
485
Value = section . VirtualAddress + ( ulong ) definition . Value ,
483
- Descriptor = 0 ,
486
+ Descriptor = N_NO_DEAD_STRIP ,
484
487
Type = N_SECT | N_EXT ,
485
488
} ) ;
486
489
}
You can’t perform that action at this time.
0 commit comments